@interactive-inc/docs-client 1.0.20 → 1.1.1

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,334 +1,614 @@
1
+ import { D as DocFileSystemInterface, a as DocPathSystem } from './doc-file-system.interface-C5vpYrOL.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
- 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
- import { Octokit } from '@octokit/rest';
5
4
 
6
5
  /**
7
- * Path operations system
6
+ * Single boolean type schema field
8
7
  */
9
- declare class DocPathSystem {
10
- readonly separator = "/";
11
- /**
12
- * Join paths
13
- */
14
- join(...paths: string[]): string;
15
- /**
16
- * Get filename with extension
17
- */
18
- basename(path: string, ext?: string): string;
19
- /**
20
- * Get directory name
21
- */
22
- dirname(path: string): string;
23
- /**
24
- * Get extension
25
- */
26
- extname(path: string): string;
27
- /**
28
- * Calculate relative path
29
- */
30
- relative(from: string, to: string): string;
31
- /**
32
- * Convert to absolute path
33
- */
34
- resolve(...paths: string[]): string;
35
- /**
36
- * Normalize path
37
- */
38
- normalize(path: string): string;
8
+ declare class DocSchemaFieldBooleanValue<T extends RecordKey> {
9
+ readonly key: T;
10
+ readonly value: DocSchemaFieldBoolean;
11
+ constructor(key: T, value: DocSchemaFieldBoolean);
12
+ get type(): "boolean";
13
+ get required(): boolean;
14
+ get title(): string;
15
+ get description(): string;
16
+ get default(): boolean | null;
17
+ readonly isArray = false;
18
+ readonly isSingle = true;
19
+ readonly isBoolean = true;
20
+ toJson(): DocFileIndexSchemaField;
39
21
  /**
40
- * Check if path is absolute
22
+ * Validate value type
41
23
  */
42
- isAbsolute(path: string): boolean;
24
+ validate(value: unknown): boolean;
25
+ static empty(key: RecordKey): DocSchemaFieldBooleanValue<RecordKey>;
26
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldBooleanValue<RecordKey>;
43
27
  }
44
28
 
45
29
  /**
46
- * Meta
30
+ * Multiple relation type schema field
47
31
  */
48
- declare class DocFileMdMetaValue<T extends DocCustomSchema> {
49
- readonly value: SchemaToValueType<T>;
50
- readonly customSchema: T;
51
- constructor(value: SchemaToValueType<T>, customSchema: T);
52
- get keys(): Array<keyof T>;
53
- /**
54
- * Return a new instance with a single property updated
55
- */
56
- withProperty<K extends keyof T>(key: K, value: BaseFieldValueType<ExtractFieldType<T[K]>>): DocFileMdMetaValue<T>;
57
- schemaField<K extends keyof T>(key: K): T[K];
58
- field<K extends keyof T>(key: K): FieldValueType<ExtractFieldType<T[K]>, ExtractRequired<T[K]>>;
59
- relation(key: keyof T): DocMetaFieldRelation;
60
- multiRelation(key: keyof T): DocMetaFieldMultiRelation;
61
- text(key: keyof T): DocMetaFieldText;
62
- number(key: keyof T): DocMetaFieldNumber;
63
- boolean(key: keyof T): DocMetaFieldBoolean;
64
- multiText(key: keyof T): DocMetaFieldMultiText;
65
- multiNumber(key: keyof T): DocMetaFieldMultiNumber;
66
- hasKey(key: keyof T): boolean;
67
- toJson(): SchemaToValueType<T>;
68
- toYaml(): string;
69
- private validateValue;
70
- private getValueField;
32
+ declare class DocSchemaFieldMultiRelationValue<T extends RecordKey> {
33
+ readonly key: T;
34
+ readonly value: DocSchemaFieldMultiRelation;
35
+ constructor(key: T, value: DocSchemaFieldMultiRelation);
36
+ get type(): "multi-relation";
37
+ get required(): boolean;
38
+ get title(): string;
39
+ get description(): string;
40
+ get default(): string[] | null;
41
+ get path(): string;
42
+ readonly isArray = true;
43
+ readonly isSingle = false;
44
+ readonly isRelation = true;
71
45
  /**
72
- * Generate from Markdown text
46
+ * Validate value
73
47
  */
74
- static fromYamlText<T extends DocCustomSchema>(yamlText: string, customSchema: T): DocFileMdMetaValue<T>;
75
- static empty<T extends DocCustomSchema>(customSchema: T): DocFileMdMetaValue<T>;
48
+ validate(value: unknown): boolean;
49
+ toJson(): DocFileIndexSchemaField;
50
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiRelationValue<T>;
51
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiRelationValue<RecordKey>;
76
52
  }
77
53
 
78
54
  /**
79
- * File: Markdown > Content
55
+ * Multiple select number type schema field
80
56
  */
81
- declare class DocFileMdContentValue<T extends DocCustomSchema> {
82
- readonly value: DocFileMdContent<T>;
83
- private readonly customSchema;
84
- constructor(value: DocFileMdContent<T>, customSchema: T);
85
- /**
86
- * Content body (does not include frontMatter)
87
- */
88
- get body(): string;
89
- /**
90
- * Title
91
- */
57
+ declare class DocSchemaFieldMultiSelectNumberValue<T extends RecordKey> {
58
+ readonly key: T;
59
+ readonly value: DocSchemaFieldMultiSelectNumber;
60
+ constructor(key: T, value: DocSchemaFieldMultiSelectNumber);
61
+ get type(): "multi-select-number";
62
+ get required(): boolean;
92
63
  get title(): string;
93
- /**
94
- * Description
95
- */
96
64
  get description(): string;
65
+ get default(): number[] | null;
66
+ get options(): number[];
67
+ readonly isArray = true;
68
+ readonly isSingle = false;
69
+ readonly isSelect = true;
70
+ readonly isNumberSelect = true;
97
71
  /**
98
- * FrontMatter (uses constructor's Zod schema or argument schema)
99
- */
100
- meta(): DocFileMdMetaValue<T>;
101
- /**
102
- * Update title
103
- */
104
- withTitle(title: string): DocFileMdContentValue<T>;
105
- /**
106
- * Update description
107
- */
108
- withDescription(description: string, defaultTitle?: string): DocFileMdContentValue<T>;
109
- /**
110
- * Update body
111
- */
112
- withBody(body: string): DocFileMdContentValue<T>;
113
- /**
114
- * @deprecated Use `withBody` instead
115
- */
116
- withContent(content: string): DocFileMdContentValue<T>;
117
- /**
118
- * Update FrontMatter
119
- */
120
- withMeta<U extends DocCustomSchema>(meta: DocFileMdMetaValue<U>): DocFileMdContentValue<U>;
121
- withMeta(updater: UpdateFunction<DocFileMdMetaValue<T>>): DocFileMdContentValue<T>;
122
- /**
123
- * Update specific property of FrontMatter
124
- */
125
- withMetaProperty<K extends keyof T>(key: K, value: BaseFieldValueType<ExtractFieldType<T[K]>>): DocFileMdContentValue<T>;
126
- /**
127
- * Generate from Markdown text
128
- */
129
- static fromMarkdown<T extends DocCustomSchema>(markdown: string, customSchema: T): DocFileMdContentValue<T>;
130
- /**
131
- * Generate complete text combining FrontMatter and body
132
- */
133
- toText(): string;
134
- /**
135
- * Generate empty content
136
- */
137
- static empty<T extends DocCustomSchema = DocCustomSchema>(title: string, customSchema: T): DocFileMdContentValue<T>;
138
- /**
139
- * Output in JSON format
72
+ * Validate value
140
73
  */
141
- toJson(): DocFileMdContent<T>;
74
+ validate(value: unknown): boolean;
75
+ toJson(): DocFileIndexSchemaField;
76
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiSelectNumberValue<T>;
77
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiSelectNumberValue<RecordKey>;
142
78
  }
143
79
 
144
80
  /**
145
- * Markdown file entity
81
+ * Multiple select text type schema field
146
82
  */
147
- declare class DocFileMdEntity<T extends DocCustomSchema> {
148
- readonly value: DocFileMd<T>;
149
- private readonly customSchema;
150
- constructor(value: DocFileMd<T>, customSchema: T);
151
- /**
152
- * Content
153
- */
154
- get content(): DocFileMdContentValue<T>;
155
- /**
156
- * Path information
157
- */
158
- get path(): DocFilePath;
83
+ declare class DocSchemaFieldMultiSelectTextValue<T extends RecordKey> {
84
+ readonly key: T;
85
+ readonly value: DocSchemaFieldMultiSelectText;
86
+ constructor(key: T, value: DocSchemaFieldMultiSelectText);
87
+ get type(): "multi-select-text";
88
+ get required(): boolean;
89
+ get title(): string;
90
+ get description(): string;
91
+ get default(): string[] | null;
92
+ get options(): string[];
93
+ readonly isArray = true;
94
+ readonly isSingle = false;
95
+ readonly isSelect = true;
96
+ readonly isTextSelect = true;
159
97
  /**
160
- * Update content
98
+ * Validate value
161
99
  */
162
- withContent(content: DocFileMdContentValue<T>): DocFileMdEntity<T>;
163
- withContent(updater: UpdateFunction<DocFileMdContentValue<T>>): DocFileMdEntity<T>;
100
+ validate(value: unknown): boolean;
101
+ toJson(): DocFileIndexSchemaField;
102
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiSelectTextValue<T>;
103
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiSelectTextValue<RecordKey>;
104
+ }
105
+
106
+ /**
107
+ * Multiple text type schema field
108
+ */
109
+ declare class DocSchemaFieldMultiTextValue<T extends RecordKey> {
110
+ readonly key: T;
111
+ readonly value: DocSchemaFieldMultiText;
112
+ constructor(key: T, value: DocSchemaFieldMultiText);
113
+ get type(): "multi-text";
114
+ get required(): boolean;
115
+ get title(): string;
116
+ get description(): string;
117
+ get default(): string[] | null;
118
+ readonly isArray = true;
119
+ readonly isSingle = false;
120
+ readonly isText = true;
121
+ toJson(): DocFileIndexSchemaField;
164
122
  /**
165
- * Update path
123
+ * Validate value type
166
124
  */
167
- withPath(path: DocFilePath): DocFileMdEntity<T>;
168
- withPath(updater: UpdateFunction<DocFilePath>): DocFileMdEntity<T>;
169
- withMeta(meta: DocFileMdMetaValue<T>): DocFileMdEntity<T>;
170
- withMeta(updater: UpdateFunction<DocFileMdMetaValue<T>>): DocFileMdEntity<T>;
171
- withTitle(title: string): DocFileMdEntity<T>;
172
- withDescription(description: string, defaultTitle?: string): DocFileMdEntity<T>;
125
+ validate(value: unknown): boolean;
126
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiTextValue<T>;
127
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiTextValue<RecordKey>;
128
+ }
129
+
130
+ /**
131
+ * Single number type schema field
132
+ */
133
+ declare class DocSchemaFieldNumberValue<T extends RecordKey> {
134
+ readonly key: T;
135
+ readonly value: DocSchemaFieldNumber;
136
+ constructor(key: T, value: DocSchemaFieldNumber);
137
+ get type(): "number";
138
+ get required(): boolean;
139
+ get title(): string;
140
+ get description(): string;
141
+ get default(): number | null;
142
+ readonly isArray = false;
143
+ readonly isSingle = true;
144
+ readonly isNumber = true;
145
+ toJson(): DocFileIndexSchemaField;
173
146
  /**
174
- * z.infer<typeof zDocFileMd>
147
+ * Validate value type
175
148
  */
176
- toJson(): z.infer<typeof zDocFileMd>;
149
+ validate(value: unknown): boolean;
150
+ static empty(key: RecordKey): DocSchemaFieldNumberValue<RecordKey>;
151
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldNumberValue<RecordKey>;
177
152
  }
178
153
 
179
- type Props$f<T extends DocCustomSchema> = {
180
- path: string;
181
- fileSystem: DocFileSystem;
182
- pathSystem: DocPathSystem;
183
- customSchema: T;
184
- config: DocClientConfig;
185
- };
186
154
  /**
187
- * File reference
155
+ * Single relation type schema field
188
156
  */
189
- declare class DocFileMdReference<T extends DocCustomSchema> {
190
- private readonly props;
191
- private readonly pathSystem;
192
- private readonly customSchema;
193
- constructor(props: Props$f<T>);
194
- get fileSystem(): DocFileSystem;
195
- get basePath(): string;
157
+ declare class DocSchemaFieldRelationValue<T extends RecordKey> {
158
+ readonly key: T;
159
+ readonly value: DocSchemaFieldRelation;
160
+ constructor(key: T, value: DocSchemaFieldRelation);
161
+ get type(): "relation";
162
+ get required(): boolean;
163
+ get title(): string;
164
+ get description(): string;
165
+ get default(): string | null;
196
166
  get path(): string;
197
- get fullPath(): string;
198
- get directoryPath(): string;
199
- get archivedPath(): string;
200
- get name(): string;
201
- get nameWithExtension(): string;
202
- exists(): Promise<boolean>;
203
- read(): Promise<DocFileMdEntity<T> | Error>;
167
+ readonly isArray = false;
168
+ readonly isSingle = true;
169
+ readonly isRelation = true;
170
+ toJson(): DocFileIndexSchemaField;
204
171
  /**
205
- * Read file content
172
+ * Validate value type
206
173
  */
207
- readText(): Promise<Error | string>;
174
+ validate(value: unknown): boolean;
175
+ static empty(key: RecordKey): DocSchemaFieldRelationValue<RecordKey>;
176
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldRelationValue<RecordKey>;
177
+ }
178
+
179
+ /**
180
+ * Single select number type schema field
181
+ */
182
+ declare class DocSchemaFieldSelectNumberValue<T extends RecordKey> {
183
+ readonly key: T;
184
+ readonly value: DocSchemaFieldSelectNumber;
185
+ constructor(key: T, value: DocSchemaFieldSelectNumber);
186
+ get type(): "select-number";
187
+ get required(): boolean;
188
+ get title(): string;
189
+ get description(): string;
190
+ get default(): number | null;
191
+ get options(): number[];
192
+ readonly isArray = false;
193
+ readonly isSingle = true;
194
+ readonly isSelect = true;
195
+ readonly isNumberSelect = true;
208
196
  /**
209
- * Create empty DocFileMdEntity
197
+ * Validate value
210
198
  */
211
- empty(): DocFileMdEntity<T>;
199
+ validate(value: unknown): boolean;
200
+ toJson(): DocFileIndexSchemaField;
201
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldSelectNumberValue<T>;
202
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldSelectNumberValue<RecordKey>;
203
+ }
204
+
205
+ /**
206
+ * Single select text type schema field
207
+ */
208
+ declare class DocSchemaFieldSelectTextValue<T extends RecordKey> {
209
+ readonly key: T;
210
+ readonly value: DocSchemaFieldSelectText;
211
+ constructor(key: T, value: DocSchemaFieldSelectText);
212
+ get type(): "select-text";
213
+ get required(): boolean;
214
+ get title(): string;
215
+ get description(): string;
216
+ get default(): string | null;
217
+ get options(): string[];
218
+ readonly isArray = false;
219
+ readonly isSingle = true;
220
+ readonly isSelect = true;
221
+ readonly isTextSelect = true;
222
+ toJson(): DocFileIndexSchemaField;
212
223
  /**
213
- * Write entity
224
+ * Validate value type
214
225
  */
215
- write(entity: DocFileMdEntity<T>): Promise<Error | null>;
216
- writeText(text: string): Promise<Error | null>;
226
+ validate(value: unknown): boolean;
227
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldSelectTextValue<T>;
228
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldSelectTextValue<RecordKey>;
229
+ }
230
+
231
+ /**
232
+ * Single text type schema field
233
+ */
234
+ declare class DocSchemaFieldTextValue<T extends RecordKey> {
235
+ readonly key: T;
236
+ readonly value: DocSchemaFieldText;
237
+ constructor(key: T, value: DocSchemaFieldText);
238
+ get type(): "text";
239
+ get required(): boolean;
240
+ get title(): string;
241
+ get description(): string;
242
+ get default(): string | null;
243
+ readonly isArray = false;
244
+ readonly isSingle = true;
245
+ readonly isText = true;
246
+ toJson(): DocFileIndexSchemaField;
217
247
  /**
218
- * Create new file with default content
248
+ * Validate value type
219
249
  */
220
- writeDefault(): Promise<Error | null>;
250
+ validate(value: unknown): boolean;
251
+ static empty(key: RecordKey): DocSchemaFieldTextValue<RecordKey>;
252
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldTextValue<RecordKey>;
253
+ }
254
+
255
+ /**
256
+ * Multiple number type schema field
257
+ */
258
+ declare class DocSchemaFieldMultiNumberValue<T extends RecordKey> {
259
+ readonly key: T;
260
+ readonly value: DocSchemaFieldMultiNumber;
261
+ constructor(key: T, value: DocSchemaFieldMultiNumber);
262
+ get type(): "multi-number";
263
+ get required(): boolean;
264
+ get title(): string;
265
+ get description(): string;
266
+ get default(): number[] | null;
267
+ readonly isArray = true;
268
+ readonly isSingle = false;
269
+ readonly isNumber = true;
221
270
  /**
222
- * Delete file
271
+ * Validate value
223
272
  */
224
- delete(): Promise<Error | null>;
273
+ validate(value: unknown): boolean;
274
+ toJson(): DocFileIndexSchemaField;
275
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiNumberValue<T>;
276
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiNumberValue<RecordKey>;
277
+ }
278
+
279
+ /**
280
+ * Type-safe schema value object
281
+ */
282
+ declare class DocFileIndexSchemaValue<T extends DocCustomSchema> {
283
+ readonly value: DocFileIndexSchema<keyof T>;
284
+ readonly customSchema: T;
285
+ constructor(value: DocFileIndexSchema<keyof T>, customSchema: T);
225
286
  /**
226
- * Copy file
287
+ * Get list of field names
288
+ * Automatically type-safe when using Zod schema
227
289
  */
228
- copyTo(destinationPath: string): Promise<Error | null>;
290
+ get fieldNames(): Array<keyof T>;
229
291
  /**
230
- * Move file
292
+ * Get field with specified field name
293
+ * Returns type-safe specific field Value object
231
294
  */
232
- moveTo(destinationPath: string): Promise<Error | null>;
295
+ 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;
296
+ relation<K extends keyof T>(key: K): DocSchemaFieldRelationValue<K>;
297
+ multiRelation<K extends keyof T>(key: K): DocSchemaFieldMultiRelationValue<K>;
298
+ toJson(): DocFileIndexSchema<keyof T>;
233
299
  /**
234
- * Move file to archive and return new reference
300
+ * Create empty schema entity
301
+ * biome-ignore lint/complexity/noBannedTypes: {} as DocCustomSchema
235
302
  */
236
- archive(archiveDirectoryName?: string): Promise<DocFileMdReference<T>>;
303
+ static empty(): DocFileIndexSchemaValue<{}>;
304
+ }
305
+
306
+ /**
307
+ * File: index.md > content > FrontMatter
308
+ */
309
+ declare class DocFileIndexMetaValue<T extends DocCustomSchema> {
310
+ readonly value: DocFileIndexMeta<T>;
311
+ readonly customSchema: T;
312
+ private readonly config;
313
+ private readonly additionalProperties;
314
+ constructor(value: DocFileIndexMeta<T>, customSchema: T, config: DocClientConfig, additionalProperties?: Record<string, unknown>);
237
315
  /**
238
- * Restore file from archive and return new reference
316
+ * Get icon
239
317
  */
240
- restore(archiveDirectoryName?: string): Promise<DocFileMdReference<T>>;
318
+ get icon(): string | null;
241
319
  /**
242
- * Get file size in bytes
320
+ * Get schema
243
321
  */
244
- size(): Promise<number | Error>;
322
+ schema(): DocFileIndexSchemaValue<T>;
245
323
  /**
246
- * Get file last modified time
324
+ * Check if schema is defined
247
325
  */
248
- lastModified(): Promise<Date | Error>;
326
+ get hasSchema(): boolean;
249
327
  /**
250
- * Get file creation time
328
+ * Update icon field
251
329
  */
252
- createdAt(): Promise<Date | Error>;
253
- directory(): DocDirectoryReference<T>;
330
+ withIcon(value: string | null): DocFileIndexMetaValue<T>;
254
331
  /**
255
- * Get relation based on schema
332
+ * Update schema field
256
333
  */
257
- relation<U extends DocCustomSchema = DocCustomSchema>(key: RelationKeys<T>, targetSchema?: U): Promise<DocFileMdReference<U> | Error | null>;
334
+ withSchema(value: DocFileIndexSchema<keyof T>): DocFileIndexMetaValue<T>;
258
335
  /**
259
- * Get index.md in the same directory
336
+ * Return a new instance with an unknown schema
337
+ * Allows accepting Record<string, unknown> schemas from external sources
260
338
  */
261
- directoryIndex(): Promise<DocFileIndexReference<T> | null>;
339
+ withUnknownSchema(draft: Record<string, unknown>): DocFileIndexMetaValue<DocCustomSchema>;
262
340
  /**
263
- * Get multiple relations based on schema
341
+ * Output in JSON format
264
342
  */
265
- relations<U extends DocCustomSchema = DocCustomSchema>(key: MultiRelationKeys<T>, customSchema?: U): Promise<DocFileMdReference<U>[]>;
343
+ toJson(): DocFileIndexMeta<T>;
266
344
  /**
267
- * File: Markdown > FrontMatter
345
+ * Output in YAML format
268
346
  */
269
- readFrontMatter(): Promise<DocFileMdMetaValue<T> | Error>;
347
+ toYaml(): string;
270
348
  /**
271
- * File: Markdown > FrontMatter
349
+ * Generate from Markdown text (can process incomplete data)
272
350
  */
273
- updateFrontMatter<K extends keyof T>(key: K, value: BaseFieldValueType<ExtractFieldType<T[K]>>): Promise<this | Error>;
274
- }
275
-
276
- /**
277
- * Unknown file entity
278
- */
279
- declare class DocFileUnknownEntity {
280
- readonly value: DocFileUnknown;
281
- constructor(value: DocFileUnknown);
351
+ static from<T extends DocCustomSchema>(markdownText: string, customSchema: T, config: DocClientConfig): DocFileIndexMetaValue<T>;
282
352
  /**
283
- * Content
353
+ * Generate directly from data (can process incomplete data)
284
354
  */
285
- get content(): string;
355
+ static fromRecord<T extends DocCustomSchema>(record: Record<string, unknown>, customSchema: T, config: DocClientConfig): DocFileIndexMetaValue<T>;
286
356
  /**
287
- * Path information
357
+ * Generate empty FrontMatter
288
358
  */
289
- get path(): DocFilePath;
359
+ static empty<T extends DocCustomSchema>(customSchema: T, config: DocClientConfig): DocFileIndexMetaValue<T>;
290
360
  /**
291
- * Update content
361
+ * Extract icon
292
362
  */
293
- withContent(content: string): DocFileUnknownEntity;
363
+ private static extractIcon;
294
364
  /**
295
- * Update path
365
+ * Extract schema part
296
366
  */
297
- withPath(path: DocFilePath): DocFileUnknownEntity;
298
- withPath(updater: UpdateFunction<DocFilePath>): DocFileUnknownEntity;
299
- toJson(): z.infer<typeof zDocFileUnknown>;
367
+ private static extractSchema;
368
+ /**
369
+ * Normalize entire schema
370
+ */
371
+ private static normalizeSchema;
372
+ static emptySchema<T extends DocCustomSchema>(customSchema: T): DocFileIndexSchema<keyof T>;
300
373
  }
301
374
 
302
- type Props$e<T extends DocCustomSchema> = {
303
- path: string;
304
- fileSystem: DocFileSystem;
305
- pathSystem: DocPathSystem;
306
- customSchema: T;
307
- config: DocClientConfig;
308
- };
309
375
  /**
310
- * File reference
376
+ * File: index.md > content
311
377
  */
312
- declare class DocFileUnknownReference<T extends DocCustomSchema> {
313
- private readonly props;
314
- private readonly pathSystem;
378
+ declare class DocFileIndexContentValue<T extends DocCustomSchema> {
379
+ readonly value: DocFileIndexContent<T>;
315
380
  private readonly customSchema;
316
- constructor(props: Props$e<T>);
317
- get fileSystem(): DocFileSystem;
318
- get basePath(): string;
319
- get path(): string;
320
- get directoryPath(): string;
321
- get fileFullPath(): string;
322
- directory(): DocDirectoryReference<T>;
323
- read(): Promise<Error | DocFileUnknownEntity>;
381
+ private readonly config;
382
+ constructor(value: DocFileIndexContent<T>, customSchema: T, config: DocClientConfig);
383
+ /**
384
+ * Content body (does not include frontMatter)
385
+ */
386
+ get body(): string;
387
+ /**
388
+ * Title
389
+ */
390
+ get title(): string;
391
+ /**
392
+ * Description
393
+ */
394
+ get description(): string;
395
+ /**
396
+ * FrontMatter
397
+ */
398
+ meta(): DocFileIndexMetaValue<T>;
399
+ /**
400
+ * Update title
401
+ */
402
+ withTitle(title: string): DocFileIndexContentValue<T>;
403
+ /**
404
+ * Update description
405
+ */
406
+ withDescription(description: string, defaultTitle?: string): DocFileIndexContentValue<T>;
407
+ /**
408
+ * Generate from Markdown text
409
+ */
410
+ static fromMarkdown<T extends DocCustomSchema>(markdown: string, customSchema: T, config: DocClientConfig): DocFileIndexContentValue<T>;
411
+ /**
412
+ * Update content
413
+ */
414
+ withBody(body: string): DocFileIndexContentValue<T>;
415
+ /**
416
+ * @deprecated Use `withBody` instead
417
+ */
418
+ withContent(body: string): DocFileIndexContentValue<T>;
419
+ /**
420
+ * Update FrontMatter
421
+ */
422
+ withMeta(meta: DocFileIndexMeta<T>): DocFileIndexContentValue<T>;
423
+ /**
424
+ * Generate default index.md content
425
+ */
426
+ static empty<T extends DocCustomSchema = DocCustomSchema>(directoryName: string, customSchema: T, config: DocClientConfig): DocFileIndexContentValue<T>;
427
+ /**
428
+ * Generate complete text combining FrontMatter and body
429
+ */
430
+ toText(): string;
431
+ /**
432
+ * Output in JSON format
433
+ */
434
+ toJson(): DocFileIndexContent<T>;
435
+ }
436
+
437
+ /**
438
+ * Document directory entity
439
+ */
440
+ declare class DocFileIndexEntity<T extends DocCustomSchema> {
441
+ readonly value: DocFileIndex<T>;
442
+ private readonly customSchema;
443
+ private readonly config;
444
+ constructor(value: DocFileIndex<T>, customSchema: T, config?: DocClientConfig);
445
+ /**
446
+ * Content
447
+ */
448
+ get content(): DocFileIndexContentValue<T>;
449
+ /**
450
+ * Path information
451
+ */
452
+ get path(): DocFilePath;
453
+ /**
454
+ * Update content
455
+ */
456
+ withContent(content: DocFileIndexContentValue<T>): DocFileIndexEntity<T>;
457
+ withContent(updater: UpdateFunction<DocFileIndexContentValue<T>>): DocFileIndexEntity<T>;
458
+ /**
459
+ * Update path
460
+ */
461
+ withPath(path: DocFilePath): DocFileIndexEntity<T>;
462
+ withPath(updater: UpdateFunction<DocFilePath>): DocFileIndexEntity<T>;
463
+ /**
464
+ * z.infer<typeof zDocFileIndex>
465
+ */
466
+ toJson(): DocFileIndexAny;
467
+ }
468
+
469
+ /**
470
+ * Relation file
471
+ */
472
+ declare class DocRelationFileValue {
473
+ private readonly value;
474
+ constructor(value: DocRelationFile);
475
+ /**
476
+ * File path
477
+ */
478
+ get id(): string;
479
+ /**
480
+ * Slug
481
+ */
482
+ get slug(): string;
483
+ /**
484
+ * Display label
485
+ */
486
+ get label(): string;
487
+ /**
488
+ * Convert to JSON format
489
+ */
490
+ toJson(): DocRelationFile;
491
+ /**
492
+ * Extract file name from file path (without extension)
493
+ */
494
+ private static extractFileName;
495
+ /**
496
+ * Create from file path and title
497
+ */
498
+ static from(filePath: string, title: string | null): DocRelationFileValue;
499
+ }
500
+
501
+ /**
502
+ * Manages relation information
503
+ */
504
+ declare class DocRelationValue {
505
+ readonly value: DocRelation;
506
+ constructor(value: DocRelation);
507
+ /**
508
+ * Relation path
509
+ */
510
+ get path(): string;
511
+ /**
512
+ * Get file count
513
+ */
514
+ get fileCount(): number;
515
+ /**
516
+ * Whether it's empty
517
+ */
518
+ get isEmpty(): boolean;
519
+ /**
520
+ * List of related files (value objects)
521
+ */
522
+ files(): DocRelationFileValue[];
523
+ /**
524
+ * Export as JSON format
525
+ */
526
+ toJson(): DocRelation;
527
+ /**
528
+ * Create empty relation entity
529
+ */
530
+ static empty(path: string): DocRelationValue;
531
+ }
532
+
533
+ type Props$8 = {
534
+ filePath: string;
535
+ fileSystem: DocFileSystemInterface;
536
+ pathSystem: DocPathSystem;
537
+ };
538
+ /**
539
+ * Relation file reference
540
+ */
541
+ declare class DocFileRelationReference {
542
+ private readonly props;
543
+ private readonly pathSystem;
544
+ constructor(props: Props$8);
545
+ get fileSystem(): DocFileSystemInterface;
546
+ get basePath(): string;
547
+ /**
548
+ * Relation path
549
+ */
550
+ get path(): string;
551
+ /**
552
+ * Full path
553
+ */
554
+ get fullPath(): string;
555
+ read(): Promise<DocRelationValue | Error | null>;
556
+ /**
557
+ * Read list of relation files
558
+ */
559
+ readFiles(): Promise<DocRelationFileValue[] | Error>;
560
+ /**
561
+ * Read single relation file
562
+ */
563
+ readFile(filePath: string): Promise<DocRelationFileValue | Error | null>;
564
+ /**
565
+ * Check if file exists
566
+ */
567
+ exists(slug: string): Promise<boolean>;
568
+ /**
569
+ * Get list of file names (without extension)
570
+ */
571
+ readSlugs(): Promise<string[] | Error>;
572
+ /**
573
+ * Get file count
574
+ */
575
+ count(): Promise<number | Error>;
576
+ /**
577
+ * Check if empty
578
+ */
579
+ isEmpty(): Promise<boolean | Error>;
580
+ }
581
+
582
+ type Props$7<T extends DocCustomSchema> = {
583
+ customSchema: T;
584
+ path: string;
585
+ fileSystem: DocFileSystemInterface;
586
+ pathSystem: DocPathSystem;
587
+ config: DocClientConfig;
588
+ };
589
+ /**
590
+ * File reference class
591
+ */
592
+ declare class DocFileIndexReference<T extends DocCustomSchema> {
593
+ private readonly props;
594
+ private readonly pathSystem;
595
+ private readonly customSchema;
596
+ constructor(props: Props$7<T>);
597
+ get fileSystem(): DocFileSystemInterface;
598
+ get basePath(): string;
599
+ get filePath(): string;
600
+ get fileFullPath(): string;
601
+ get durectoryPath(): string;
602
+ read(): Promise<DocFileIndexEntity<T> | Error>;
603
+ readSchemaValue(): Promise<DocFileIndexSchema<RecordKey>>;
324
604
  /**
325
605
  * Read file content
326
606
  */
327
607
  readContent(): Promise<Error | string>;
328
608
  /**
329
- * Create empty DocFileUnknownEntity
609
+ * Create empty DocFileIndexEntity
330
610
  */
331
- empty(): DocFileUnknownEntity;
611
+ empty(): DocFileIndexEntity<T>;
332
612
  /**
333
613
  * Write content to file
334
614
  */
@@ -336,11 +616,11 @@ declare class DocFileUnknownReference<T extends DocCustomSchema> {
336
616
  /**
337
617
  * Write entity
338
618
  */
339
- write(entity: DocFileUnknownEntity): Promise<Error | null>;
619
+ write(entity: DocFileIndexEntity<T>): Promise<Error | null>;
340
620
  /**
341
- * Write raw content
621
+ * Create new file with default content
342
622
  */
343
- writeRaw(content: string): Promise<Error | null>;
623
+ writeDefault(): Promise<Error | null>;
344
624
  /**
345
625
  * Delete file
346
626
  */
@@ -349,1196 +629,385 @@ declare class DocFileUnknownReference<T extends DocCustomSchema> {
349
629
  * Check if file exists
350
630
  */
351
631
  exists(): Promise<boolean>;
352
- /**
353
- * Copy file
354
- */
355
- copyTo(destinationPath: string): Promise<Error | null>;
356
- /**
357
- * Move file
358
- */
359
- moveTo(destinationPath: string): Promise<Error | null>;
632
+ relations(): Promise<DocFileRelationReference[] | Error>;
633
+ readRelations(): Promise<DocRelationValue[] | Error>;
360
634
  /**
361
635
  * Get file size in bytes
362
636
  */
363
637
  size(): Promise<number | Error>;
364
638
  /**
365
- * Get file last modified time
639
+ * Get last modified date
366
640
  */
367
641
  lastModified(): Promise<Date | Error>;
368
642
  /**
369
- * Get file creation time
643
+ * Get file creation date
370
644
  */
371
645
  createdAt(): Promise<Date | Error>;
372
646
  /**
373
647
  * Move file to archive and return new reference
374
648
  */
375
- archive(archiveDirectoryName?: string): Promise<DocFileUnknownReference<T>>;
649
+ archive(archiveDirectoryName?: string): Promise<DocFileIndexReference<T>>;
376
650
  /**
377
651
  * Restore file from archive and return new reference
378
652
  */
379
- restore(archiveDirectoryName?: string): Promise<DocFileUnknownReference<T>>;
653
+ restore(archiveDirectoryName?: string): Promise<DocFileIndexReference<T>>;
380
654
  }
381
655
 
382
656
  /**
383
- * Generic updater function type that takes a value and returns the same type
384
- */
385
- type UpdateFunction<T> = (current: T) => T;
386
- /**
387
- * Text field type
657
+ * Meta
388
658
  */
389
- type DocSchemaFieldText = z.infer<typeof zDocSchemaFieldText>;
390
- /**
391
- * Number field type
392
- */
393
- type DocSchemaFieldNumber = z.infer<typeof zDocSchemaFieldNumber>;
394
- /**
395
- * Boolean field type
396
- */
397
- type DocSchemaFieldBoolean = z.infer<typeof zDocSchemaFieldBoolean>;
398
- /**
399
- * Multi-text field type
400
- */
401
- type DocSchemaFieldMultiText = z.infer<typeof zDocSchemaFieldMultiText>;
402
- /**
403
- * Multi-number field type
404
- */
405
- type DocSchemaFieldMultiNumber = z.infer<typeof zDocSchemaFieldMultiNumber>;
406
- /**
407
- * Relation field type
408
- */
409
- type DocSchemaFieldRelation = z.infer<typeof zDocSchemaFieldRelation>;
410
- /**
411
- * Multi-relation field type
412
- */
413
- type DocSchemaFieldMultiRelation = z.infer<typeof zDocSchemaFieldMultiRelation>;
414
- /**
415
- * Select text field type
416
- */
417
- type DocSchemaFieldSelectText = z.infer<typeof zDocSchemaFieldSelectText>;
418
- /**
419
- * Select number field type
420
- */
421
- type DocSchemaFieldSelectNumber = z.infer<typeof zDocSchemaFieldSelectNumber>;
422
- /**
423
- * Multi-select text field type
424
- */
425
- type DocSchemaFieldMultiSelectText = z.infer<typeof zDocSchemaFieldMultiSelectText>;
426
- /**
427
- * Multi-select number field type
428
- */
429
- type DocSchemaFieldMultiSelectNumber = z.infer<typeof zDocSchemaFieldMultiSelectNumber>;
430
- type DocMetaField = z.infer<typeof zDocMetaField>;
431
- type DocMetaFieldText = z.infer<typeof zDocMetaFieldText>;
432
- type DocMetaFieldNumber = z.infer<typeof zDocMetaFieldNumber>;
433
- type DocMetaFieldBoolean = z.infer<typeof zDocMetaFieldBoolean>;
434
- type DocMetaFieldSelectText = z.infer<typeof zDocMetaFieldSelectText>;
435
- type DocMetaFieldSelectNumber = z.infer<typeof zDocMetaFieldSelectNumber>;
436
- type DocMetaFieldRelation = z.infer<typeof zDocMetaFieldRelation>;
437
- type DocMetaFieldMultiText = z.infer<typeof zDocMetaFieldMultiText>;
438
- type DocMetaFieldMultiNumber = z.infer<typeof zDocMetaFieldMultiNumber>;
439
- type DocMetaFieldMultiSelectText = z.infer<typeof zDocMetaFieldMultiSelectText>;
440
- type DocMetaFieldMultiSelectNumber = z.infer<typeof zDocMetaFieldMultiSelectNumber>;
441
- type DocMetaFieldMultiRelation = z.infer<typeof zDocMetaFieldMultiRelation>;
442
- type DocFileMdMeta<T extends RecordKey> = Record<T, DocMetaField>;
443
- type DocFileMdMetaAny = DocFileMdMeta<RecordKey>;
444
- type DocMetaFieldTypeText = z.infer<typeof zDocMetaFieldTypeText>;
445
- type DocMetaFieldTypeNumber = z.infer<typeof zDocMetaFieldTypeNumber>;
446
- type DocMetaFieldTypeBoolean = z.infer<typeof zDocMetaFieldTypeBoolean>;
447
- type DocMetaFieldTypeSelectText = z.infer<typeof zDocMetaFieldTypeSelectText>;
448
- type DocMetaFieldTypeSelectNumber = z.infer<typeof zDocMetaFieldTypeSelectNumber>;
449
- type DocMetaFieldTypeRelation = z.infer<typeof zDocMetaFieldTypeRelation>;
450
- /**
451
- * Schema field type
452
- */
453
- type DocMetaFieldType = z.infer<typeof zDocMetaFieldType>;
454
- type DocCustomSchemaFieldText = {
455
- type: "text";
456
- required: boolean;
457
- };
458
- type DocCustomSchemaFieldNumber = {
459
- type: "number";
460
- required: boolean;
461
- };
462
- type DocCustomSchemaFieldBoolean = {
463
- type: "boolean";
464
- required: boolean;
465
- };
466
- type DocCustomSchemaFieldRelation = {
467
- type: "relation";
468
- required: boolean;
469
- };
470
- type DocCustomSchemaFieldSelectText = {
471
- type: "select-text";
472
- required: boolean;
473
- };
474
- type DocCustomSchemaFieldSelectNumber = {
475
- type: "select-number";
476
- required: boolean;
477
- };
478
- type DocCustomSchemaFieldMultiText = {
479
- type: "multi-text";
480
- required: boolean;
481
- };
482
- type DocCustomSchemaFieldMultiNumber = {
483
- type: "multi-number";
484
- required: boolean;
485
- };
486
- type DocCustomSchemaFieldMultiRelation = {
487
- type: "multi-relation";
488
- required: boolean;
489
- };
490
- type DocCustomSchemaFieldMultiSelectText = {
491
- type: "multi-select-text";
492
- required: boolean;
493
- };
494
- type DocCustomSchemaFieldMultiSelectNumber = {
495
- type: "multi-select-number";
496
- required: boolean;
497
- };
498
- /**
499
- * Schema field type
500
- */
501
- type DocFileIndexSchemaField = z.infer<typeof zDocFileIndexSchemaField>;
502
- /**
503
- * Schema definition type
504
- */
505
- type DocFileIndexSchema<T extends RecordKey = string> = Record<T, DocFileIndexSchemaField>;
506
- /**
507
- * Schema field to override
508
- * ex: { xxx: { type: "text", required: true } }
509
- */
510
- type DocCustomSchemaField = DocCustomSchemaFieldText | DocCustomSchemaFieldNumber | DocCustomSchemaFieldBoolean | DocCustomSchemaFieldRelation | DocCustomSchemaFieldSelectText | DocCustomSchemaFieldSelectNumber | DocCustomSchemaFieldMultiText | DocCustomSchemaFieldMultiNumber | DocCustomSchemaFieldMultiRelation | DocCustomSchemaFieldMultiSelectText | DocCustomSchemaFieldMultiSelectNumber;
511
- /**
512
- * Type literal for field types
513
- */
514
- type DocFieldTypeLiteral = "text" | "number" | "boolean" | "relation" | "multi-text" | "multi-number" | "multi-relation" | "select-text" | "select-number" | "multi-select-text" | "multi-select-number";
515
- /**
516
- * Minimal schema definition type
517
- */
518
- type DocCustomSchema<T extends RecordKey = string> = Record<T, DocCustomSchemaField>;
519
- /**
520
- * Union type for relation fields
521
- */
522
- type DocSchemaRelationFieldUnion = DocSchemaFieldRelation | DocSchemaFieldMultiRelation;
523
- /**
524
- * File node type (for files only)
525
- */
526
- type DocTreeFileNode = {
527
- type: "file";
528
- name: string;
529
- path: string;
530
- icon: string;
531
- title: string;
532
- };
533
- /**
534
- * Directory node type (for directories only)
535
- */
536
- type DocTreeDirectoryNode = {
537
- type: "directory";
538
- name: string;
539
- path: string;
540
- icon: string;
541
- title: string;
542
- children: DocTreeNode[];
543
- };
544
- /**
545
- * Unified tree node type
546
- */
547
- type DocTreeNode = DocTreeFileNode | DocTreeDirectoryNode;
548
- /**
549
- * Index file type
550
- */
551
- type DocFileIndex<T extends DocCustomSchema = DocCustomSchema> = {
552
- type: "index";
553
- path: DocFilePath;
554
- isArchived: boolean;
555
- content: DocFileIndexContent<T>;
556
- };
557
- /**
558
- * Type to check if two types are equal
559
- */
560
- type Equals<T, U> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? true : false;
561
- /**
562
- * Extract relation field keys from schema
563
- */
564
- type RelationKeys<T extends DocCustomSchema> = {
565
- [K in keyof T]: T[K]["type"] extends "relation" ? K : never;
566
- }[keyof T];
567
- /**
568
- * Extract multi-relation field keys from schema
569
- */
570
- type MultiRelationKeys<T extends DocCustomSchema> = {
571
- [K in keyof T]: T[K]["type"] extends "multi-relation" ? K : never;
572
- }[keyof T];
573
- /**
574
- * Markdown file type (excluding index.md)
575
- */
576
- type DocFileMd<T extends DocCustomSchema> = {
577
- type: "markdown";
578
- path: DocFilePath;
579
- isArchived: boolean;
580
- content: DocFileMdContent<T>;
581
- };
582
- /**
583
- * Other file type (non-markdown)
584
- */
585
- type DocFileUnknown = z.infer<typeof zDocFileUnknown>;
586
- /**
587
- * File union type (index.md, regular md, other)
588
- */
589
- type DocFile<T extends DocCustomSchema = DocCustomSchema> = DocFileIndex<T> | DocFileMd<T> | DocFileUnknown;
590
- type DocDirectoryFile<T extends DocCustomSchema = DocCustomSchema> = DocFileMd<T> | DocFileUnknown;
591
- type DocFileIndexAny = z.infer<typeof zDocFileIndex>;
592
- type DocFileMdAny = z.infer<typeof zDocFileMd>;
593
- /**
594
- * DocFile<DocCustomSchema<RecordKey>>
595
- */
596
- type DocFileAny = DocFileIndexAny | DocFileMdAny | DocFileUnknown;
597
- /**
598
- * Directory FrontMatter type
599
- */
600
- type DocFileIndexMeta<T extends DocCustomSchema = DocCustomSchema> = {
601
- type: "index-meta";
602
- icon: string | null;
603
- schema: DocFileIndexSchema<keyof T>;
604
- };
605
- /**
606
- * Relation options type
607
- */
608
- type DocRelationFile = z.infer<typeof zDocRelationFile>;
609
- /**
610
- * Relation information type
611
- */
612
- type DocRelation = z.infer<typeof zDocRelation>;
613
- /**
614
- * Relation field type
615
- */
616
- type DocRelationField = z.infer<typeof zDocRelationField>;
617
- /**
618
- * String literal type utilities for file path detection
619
- */
620
- /**
621
- * Check if path ends with specific extension
622
- */
623
- type EndsWith<T extends string, U extends string> = T extends `${string}${U}` ? true : false;
624
- /**
625
- * Extract filename from path
626
- */
627
- type Basename<T extends string> = T extends `${string}/${infer U}` ? Basename<U> : T;
628
- /**
629
- * Check if filename is index.md
630
- */
631
- type IsIndexMd<T extends string> = Basename<T> extends "index.md" ? true : false;
632
- /**
633
- * Detect file type from path
634
- */
635
- type DetectFileType<T extends string> = IsIndexMd<T> extends true ? "index" : EndsWith<T, ".md"> extends true ? "markdown" : "unknown";
636
- /**
637
- * Map file type to reference class
638
- */
639
- type FileTypeToReference<FileType extends string, Schema extends DocCustomSchema> = FileType extends "index" ? DocFileIndexReference<Schema> : FileType extends "markdown" ? DocFileMdReference<Schema> : DocFileUnknownReference<Schema>;
640
- /**
641
- * Infer reference type from path
642
- */
643
- type InferReference<Path extends string, Schema extends DocCustomSchema> = FileTypeToReference<DetectFileType<Path>, Schema>;
644
- /**
645
- * File path information type
646
- */
647
- type DocFilePath = z.infer<typeof zDocFilePath>;
648
- /**
649
- * Markdown content information type
650
- */
651
- type DocFileMdContent<T extends DocCustomSchema = DocCustomSchema> = {
652
- type: "markdown-content";
653
- body: string;
654
- title: string;
655
- description: string;
656
- meta: SchemaToValueType<T>;
657
- };
658
- /**
659
- * Index file content information type
660
- */
661
- type DocFileIndexContent<T extends DocCustomSchema = DocCustomSchema> = {
662
- type: "markdown-index";
663
- body: string;
664
- title: string;
665
- description: string;
666
- meta: DocFileIndexMeta<T>;
667
- };
668
- /**
669
- * Directory response type (re-export from server package)
670
- */
671
- type DocDirectory<T extends DocCustomSchema> = {
672
- cwd: string;
673
- indexFile: DocFileIndex<T>;
674
- files: DocFile<T>[];
675
- relations: DocRelation[];
676
- };
677
- type RecordKey = PropertyKey;
678
- /**
679
- * DocClient configuration
680
- */
681
- type DocClientConfig = z.infer<typeof zDocClientConfig>;
682
- /**
683
- * Type definitions for DocFileMdMetaValue
684
- */
685
- type ExtractFieldType<T> = T extends {
686
- type: infer Type;
687
- } ? Type : never;
688
- type ExtractRequired<T> = T extends {
689
- required: infer Required;
690
- } ? Required : false;
691
- 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;
692
- type FieldValueType<Type, Required> = Required extends true ? BaseFieldValueType<Type> : BaseFieldValueType<Type> | null;
693
- /**
694
- * Extract required field keys
695
- */
696
- type RequiredKeys<T extends DocCustomSchema> = {
697
- [K in keyof T]: T[K] extends {
698
- required: true;
699
- } ? K : never;
700
- }[keyof T];
701
- /**
702
- * Extract optional field keys
703
- */
704
- type OptionalKeys<T extends DocCustomSchema> = {
705
- [K in keyof T]: T[K] extends {
706
- required: true;
707
- } ? never : K;
708
- }[keyof T];
709
- /**
710
- * Generate expected value type from schema (considering required)
711
- */
712
- type SchemaToValueType<T extends DocCustomSchema> = {
713
- [K in RequiredKeys<T>]: BaseFieldValueType<ExtractFieldType<T[K]>>;
714
- } & {
715
- [K in OptionalKeys<T>]: BaseFieldValueType<ExtractFieldType<T[K]>> | null;
716
- };
717
- /**
718
- * Helper type for type-safe property access
719
- */
720
- type GetValueType<T extends DocCustomSchema, K extends keyof T> = K extends RequiredKeys<T> ? BaseFieldValueType<ExtractFieldType<T[K]>> : BaseFieldValueType<ExtractFieldType<T[K]>> | undefined | null;
721
- type GetIndexFieldType<Schema extends DocFileIndexSchema<RecordKey>, K extends keyof Schema> = Schema[K] extends DocFileIndexSchemaField ? Schema[K] : never;
722
- /**
723
- * Infers DocFileMd type from the result of defineSchema
724
- */
725
- type InferDocFileMd<T> = T extends DocCustomSchema ? DocFileMd<T> : never;
726
- /**
727
- * Read-only file system interface for document operations
728
- */
729
- type DocFileSystemReadType = {
730
- /**
731
- * Read file content at the specified path
732
- */
733
- readFile(relativePath: string): Promise<string | null | Error>;
734
- /**
735
- * Get file name from path
736
- */
737
- readFileName(relativePath: string): string;
738
- /**
739
- * Get file extension from path
740
- */
741
- readFileExtension(relativePath: string): string;
742
- /**
743
- * Get directory path where the file exists
744
- */
745
- readFileDirectory(relativePath: string): string;
746
- /**
747
- * Get list of entries in directory
748
- */
749
- readDirectoryFileNames(relativePath?: string): Promise<string[] | Error>;
750
- /**
751
- * Get list of file paths in directory
752
- */
753
- readDirectoryFilePaths(relativePath: string): Promise<string[] | Error>;
754
- /**
755
- * Check if path is a directory
756
- */
757
- isDirectory(relativePath: string): Promise<boolean>;
758
- /**
759
- * Check if path is a file
760
- */
761
- isFile(relativePath: string): Promise<boolean>;
762
- /**
763
- * Check if file or directory exists
764
- */
765
- exists(relativePath: string): Promise<boolean>;
766
- /**
767
- * Check if directory exists
768
- */
769
- directoryExists(relativePath: string): Promise<boolean>;
770
- /**
771
- * Check if file exists
772
- */
773
- fileExists(relativePath: string): Promise<boolean>;
774
- /**
775
- * Get base path
776
- */
777
- getBasePath(): string;
778
- /**
779
- * Convert relative path to absolute path
780
- */
781
- resolve(relativePath: string): string;
782
- /**
783
- * Get file size in bytes
784
- */
785
- getFileSize(relativePath: string): Promise<number | Error>;
786
- /**
787
- * Get file last modified time
788
- */
789
- getFileModifiedTime(relativePath: string): Promise<Date | Error>;
790
- /**
791
- * Get file creation time
792
- */
793
- getFileCreatedTime(relativePath: string): Promise<Date | Error>;
794
- };
795
- /**
796
- * Write-only file system interface for document operations
797
- */
798
- type DocFileSystemWriteType = {
799
- /**
800
- * Write content to file at the specified path (creates directory if needed)
801
- */
802
- writeFile(relativePath: string, content: string): Promise<Error | null>;
803
- /**
804
- * Delete file at the specified path
805
- */
806
- deleteFile(relativePath: string): Promise<Error | null>;
807
- /**
808
- * Create directory
809
- */
810
- createDirectory(relativePath: string): Promise<Error | null>;
811
- /**
812
- * Create directory if it doesn't exist
813
- */
814
- ensureDirectoryExists(relativePath: string): Promise<Error | null>;
815
- /**
816
- * Copy file
817
- */
818
- copyFile(sourcePath: string, destinationPath: string): Promise<Error | null>;
819
- /**
820
- * Move file
821
- */
822
- moveFile(sourcePath: string, destinationPath: string): Promise<Error | null>;
823
- };
824
-
825
- type Props$d = {
826
- basePath: string;
827
- pathSystem?: DocPathSystem;
828
- reader?: DocFileSystemReadType;
829
- writer?: DocFileSystemWriteType;
830
- };
831
- /**
832
- * File system wrapper with optional dependency injection for read/write operations
833
- */
834
- declare class DocFileSystem {
835
- protected readonly reader: DocFileSystemReadType;
836
- protected readonly writer: DocFileSystemWriteType;
837
- protected readonly basePath: string;
838
- protected readonly pathSystem: DocPathSystem;
839
- constructor(props: Props$d);
840
- /**
841
- * Read file content at the specified path
842
- */
843
- readFile(relativePath: string): Promise<string | null | Error>;
844
- /**
845
- * Write content to file at the specified path (creates directory if needed)
846
- */
847
- writeFile(relativePath: string, content: string): Promise<Error | null>;
848
- /**
849
- * Delete file at the specified path
850
- */
851
- deleteFile(relativePath: string): Promise<Error | null>;
852
- /**
853
- * Get file name from path
854
- */
855
- readFileName(relativePath: string): string;
856
- /**
857
- * Get file extension from path
858
- */
859
- readFileExtension(relativePath: string): string;
860
- /**
861
- * Get directory path where the file exists
862
- */
863
- readFileDirectory(relativePath: string): string;
864
- /**
865
- * Get list of entries in directory
866
- */
867
- readDirectoryFileNames(relativePath?: string): Promise<string[] | Error>;
868
- readDirectoryFilePaths(relativePath: string): Promise<string[] | Error>;
869
- /**
870
- * Check if path is a directory
871
- */
872
- isDirectory(relativePath: string): Promise<boolean>;
873
- /**
874
- * Check if path is a file
875
- */
876
- isFile(relativePath: string): Promise<boolean>;
877
- /**
878
- * Check if file or directory exists
879
- */
880
- exists(relativePath: string): Promise<boolean>;
881
- /**
882
- * Check if directory exists
883
- */
884
- directoryExists(relativePath: string): Promise<boolean>;
885
- /**
886
- * Check if file exists
887
- */
888
- fileExists(relativePath: string): Promise<boolean>;
889
- /**
890
- * Get base path
891
- */
892
- getBasePath(): string;
893
- /**
894
- * Convert relative path to absolute path
895
- */
896
- resolve(relativePath: string): string;
897
- /**
898
- * Create directory
899
- */
900
- createDirectory(relativePath: string): Promise<Error | null>;
901
- /**
902
- * Get file size in bytes
903
- */
904
- getFileSize(relativePath: string): Promise<number | Error>;
905
- /**
906
- * Create directory if it doesn't exist
907
- */
908
- ensureDirectoryExists(relativePath: string): Promise<Error | null>;
909
- /**
910
- * Copy file
911
- */
912
- copyFile(sourcePath: string, destinationPath: string): Promise<Error | null>;
913
- /**
914
- * Move file
915
- */
916
- moveFile(sourcePath: string, destinationPath: string): Promise<Error | null>;
917
- /**
918
- * Get file last modified time
919
- */
920
- getFileModifiedTime(relativePath: string): Promise<Date | Error>;
921
- /**
922
- * Get file creation time
923
- */
924
- getFileCreatedTime(relativePath: string): Promise<Date | Error>;
925
- }
926
-
927
- /**
928
- * Relation file
929
- */
930
- declare class DocRelationFileValue {
931
- private readonly value;
932
- constructor(value: DocRelationFile);
933
- /**
934
- * File path
935
- */
936
- get id(): string;
937
- /**
938
- * Slug
939
- */
940
- get slug(): string;
941
- /**
942
- * Display label
943
- */
944
- get label(): string;
945
- /**
946
- * Convert to JSON format
947
- */
948
- toJson(): DocRelationFile;
949
- /**
950
- * Extract file name from file path (without extension)
951
- */
952
- private static extractFileName;
953
- /**
954
- * Create from file path and title
955
- */
956
- static from(filePath: string, title: string | null): DocRelationFileValue;
957
- }
958
-
959
- /**
960
- * Manages relation information
961
- */
962
- declare class DocRelationValue {
963
- readonly value: DocRelation;
964
- constructor(value: DocRelation);
965
- /**
966
- * Relation path
967
- */
968
- get path(): string;
969
- /**
970
- * Get file count
971
- */
972
- get fileCount(): number;
973
- /**
974
- * Whether it's empty
975
- */
976
- get isEmpty(): boolean;
977
- /**
978
- * List of related files (value objects)
979
- */
980
- files(): DocRelationFileValue[];
981
- /**
982
- * Export as JSON format
983
- */
984
- toJson(): DocRelation;
985
- /**
986
- * Create empty relation entity
987
- */
988
- static empty(path: string): DocRelationValue;
989
- }
990
-
991
- type Props$c = {
992
- filePath: string;
993
- fileSystem: DocFileSystem;
994
- pathSystem: DocPathSystem;
995
- };
996
- /**
997
- * Relation file reference
998
- */
999
- declare class DocFileRelationReference {
1000
- private readonly props;
1001
- private readonly pathSystem;
1002
- constructor(props: Props$c);
1003
- get fileSystem(): DocFileSystem;
1004
- get basePath(): string;
1005
- /**
1006
- * Relation path
1007
- */
1008
- get path(): string;
1009
- /**
1010
- * Full path
1011
- */
1012
- get fullPath(): string;
1013
- read(): Promise<DocRelationValue | Error | null>;
1014
- /**
1015
- * Read list of relation files
1016
- */
1017
- readFiles(): Promise<DocRelationFileValue[] | Error>;
1018
- /**
1019
- * Read single relation file
1020
- */
1021
- readFile(filePath: string): Promise<DocRelationFileValue | Error | null>;
1022
- /**
1023
- * Check if file exists
1024
- */
1025
- exists(slug: string): Promise<boolean>;
1026
- /**
1027
- * Get list of file names (without extension)
1028
- */
1029
- readSlugs(): Promise<string[] | Error>;
1030
- /**
1031
- * Get file count
1032
- */
1033
- count(): Promise<number | Error>;
1034
- /**
1035
- * Check if empty
1036
- */
1037
- isEmpty(): Promise<boolean | Error>;
1038
- }
1039
-
1040
- /**
1041
- * Single boolean type schema field
1042
- */
1043
- declare class DocSchemaFieldBooleanValue<T extends RecordKey> {
1044
- readonly key: T;
1045
- readonly value: DocSchemaFieldBoolean;
1046
- constructor(key: T, value: DocSchemaFieldBoolean);
1047
- get type(): "boolean";
1048
- get required(): boolean;
1049
- get title(): string;
1050
- get description(): string;
1051
- get default(): boolean | null;
1052
- readonly isArray = false;
1053
- readonly isSingle = true;
1054
- readonly isBoolean = true;
1055
- toJson(): DocFileIndexSchemaField;
1056
- /**
1057
- * Validate value type
1058
- */
1059
- validate(value: unknown): boolean;
1060
- static empty(key: RecordKey): DocSchemaFieldBooleanValue<RecordKey>;
1061
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldBooleanValue<RecordKey>;
1062
- }
1063
-
1064
- /**
1065
- * Multiple relation type schema field
1066
- */
1067
- declare class DocSchemaFieldMultiRelationValue<T extends RecordKey> {
1068
- readonly key: T;
1069
- readonly value: DocSchemaFieldMultiRelation;
1070
- constructor(key: T, value: DocSchemaFieldMultiRelation);
1071
- get type(): "multi-relation";
1072
- get required(): boolean;
1073
- get title(): string;
1074
- get description(): string;
1075
- get default(): string[] | null;
1076
- get path(): string;
1077
- readonly isArray = true;
1078
- readonly isSingle = false;
1079
- readonly isRelation = true;
1080
- /**
1081
- * Validate value
1082
- */
1083
- validate(value: unknown): boolean;
1084
- toJson(): DocFileIndexSchemaField;
1085
- static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiRelationValue<T>;
1086
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiRelationValue<RecordKey>;
1087
- }
1088
-
1089
- /**
1090
- * Multiple select number type schema field
1091
- */
1092
- declare class DocSchemaFieldMultiSelectNumberValue<T extends RecordKey> {
1093
- readonly key: T;
1094
- readonly value: DocSchemaFieldMultiSelectNumber;
1095
- constructor(key: T, value: DocSchemaFieldMultiSelectNumber);
1096
- get type(): "multi-select-number";
1097
- get required(): boolean;
1098
- get title(): string;
1099
- get description(): string;
1100
- get default(): number[] | null;
1101
- get options(): number[];
1102
- readonly isArray = true;
1103
- readonly isSingle = false;
1104
- readonly isSelect = true;
1105
- readonly isNumberSelect = true;
1106
- /**
1107
- * Validate value
1108
- */
1109
- validate(value: unknown): boolean;
1110
- toJson(): DocFileIndexSchemaField;
1111
- static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiSelectNumberValue<T>;
1112
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiSelectNumberValue<RecordKey>;
1113
- }
1114
-
1115
- /**
1116
- * Multiple select text type schema field
1117
- */
1118
- declare class DocSchemaFieldMultiSelectTextValue<T extends RecordKey> {
1119
- readonly key: T;
1120
- readonly value: DocSchemaFieldMultiSelectText;
1121
- constructor(key: T, value: DocSchemaFieldMultiSelectText);
1122
- get type(): "multi-select-text";
1123
- get required(): boolean;
1124
- get title(): string;
1125
- get description(): string;
1126
- get default(): string[] | null;
1127
- get options(): string[];
1128
- readonly isArray = true;
1129
- readonly isSingle = false;
1130
- readonly isSelect = true;
1131
- readonly isTextSelect = true;
1132
- /**
1133
- * Validate value
1134
- */
1135
- validate(value: unknown): boolean;
1136
- toJson(): DocFileIndexSchemaField;
1137
- static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiSelectTextValue<T>;
1138
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiSelectTextValue<RecordKey>;
1139
- }
1140
-
1141
- /**
1142
- * Multiple text type schema field
1143
- */
1144
- declare class DocSchemaFieldMultiTextValue<T extends RecordKey> {
1145
- readonly key: T;
1146
- readonly value: DocSchemaFieldMultiText;
1147
- constructor(key: T, value: DocSchemaFieldMultiText);
1148
- get type(): "multi-text";
1149
- get required(): boolean;
1150
- get title(): string;
1151
- get description(): string;
1152
- get default(): string[] | null;
1153
- readonly isArray = true;
1154
- readonly isSingle = false;
1155
- readonly isText = true;
1156
- toJson(): DocFileIndexSchemaField;
1157
- /**
1158
- * Validate value type
1159
- */
1160
- validate(value: unknown): boolean;
1161
- static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiTextValue<T>;
1162
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiTextValue<RecordKey>;
1163
- }
1164
-
1165
- /**
1166
- * Single number type schema field
1167
- */
1168
- declare class DocSchemaFieldNumberValue<T extends RecordKey> {
1169
- readonly key: T;
1170
- readonly value: DocSchemaFieldNumber;
1171
- constructor(key: T, value: DocSchemaFieldNumber);
1172
- get type(): "number";
1173
- get required(): boolean;
1174
- get title(): string;
1175
- get description(): string;
1176
- get default(): number | null;
1177
- readonly isArray = false;
1178
- readonly isSingle = true;
1179
- readonly isNumber = true;
1180
- toJson(): DocFileIndexSchemaField;
1181
- /**
1182
- * Validate value type
1183
- */
1184
- validate(value: unknown): boolean;
1185
- static empty(key: RecordKey): DocSchemaFieldNumberValue<RecordKey>;
1186
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldNumberValue<RecordKey>;
1187
- }
1188
-
1189
- /**
1190
- * Single relation type schema field
1191
- */
1192
- declare class DocSchemaFieldRelationValue<T extends RecordKey> {
1193
- readonly key: T;
1194
- readonly value: DocSchemaFieldRelation;
1195
- constructor(key: T, value: DocSchemaFieldRelation);
1196
- get type(): "relation";
1197
- get required(): boolean;
1198
- get title(): string;
1199
- get description(): string;
1200
- get default(): string | null;
1201
- get path(): string;
1202
- readonly isArray = false;
1203
- readonly isSingle = true;
1204
- readonly isRelation = true;
1205
- toJson(): DocFileIndexSchemaField;
1206
- /**
1207
- * Validate value type
1208
- */
1209
- validate(value: unknown): boolean;
1210
- static empty(key: RecordKey): DocSchemaFieldRelationValue<RecordKey>;
1211
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldRelationValue<RecordKey>;
1212
- }
1213
-
1214
- /**
1215
- * Single select number type schema field
1216
- */
1217
- declare class DocSchemaFieldSelectNumberValue<T extends RecordKey> {
1218
- readonly key: T;
1219
- readonly value: DocSchemaFieldSelectNumber;
1220
- constructor(key: T, value: DocSchemaFieldSelectNumber);
1221
- get type(): "select-number";
1222
- get required(): boolean;
1223
- get title(): string;
1224
- get description(): string;
1225
- get default(): number | null;
1226
- get options(): number[];
1227
- readonly isArray = false;
1228
- readonly isSingle = true;
1229
- readonly isSelect = true;
1230
- readonly isNumberSelect = true;
659
+ declare class DocFileMdMetaValue<T extends DocCustomSchema> {
660
+ readonly value: SchemaToValueType<T>;
661
+ readonly customSchema: T;
662
+ constructor(value: SchemaToValueType<T>, customSchema: T);
663
+ get keys(): Array<keyof T>;
1231
664
  /**
1232
- * Validate value
665
+ * Return a new instance with a single property updated
1233
666
  */
1234
- validate(value: unknown): boolean;
1235
- toJson(): DocFileIndexSchemaField;
1236
- static empty<T extends RecordKey>(key: T): DocSchemaFieldSelectNumberValue<T>;
1237
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldSelectNumberValue<RecordKey>;
1238
- }
1239
-
1240
- /**
1241
- * Single select text type schema field
1242
- */
1243
- declare class DocSchemaFieldSelectTextValue<T extends RecordKey> {
1244
- readonly key: T;
1245
- readonly value: DocSchemaFieldSelectText;
1246
- constructor(key: T, value: DocSchemaFieldSelectText);
1247
- get type(): "select-text";
1248
- get required(): boolean;
1249
- get title(): string;
1250
- get description(): string;
1251
- get default(): string | null;
1252
- get options(): string[];
1253
- readonly isArray = false;
1254
- readonly isSingle = true;
1255
- readonly isSelect = true;
1256
- readonly isTextSelect = true;
1257
- toJson(): DocFileIndexSchemaField;
667
+ withProperty<K extends keyof T>(key: K, value: BaseFieldValueType<ExtractFieldType<T[K]>>): DocFileMdMetaValue<T>;
668
+ schemaField<K extends keyof T>(key: K): T[K];
669
+ field<K extends keyof T>(key: K): FieldValueType<ExtractFieldType<T[K]>, ExtractRequired<T[K]>>;
670
+ relation(key: keyof T): DocMetaFieldRelation;
671
+ multiRelation(key: keyof T): DocMetaFieldMultiRelation;
672
+ text(key: keyof T): DocMetaFieldText;
673
+ number(key: keyof T): DocMetaFieldNumber;
674
+ boolean(key: keyof T): DocMetaFieldBoolean;
675
+ multiText(key: keyof T): DocMetaFieldMultiText;
676
+ multiNumber(key: keyof T): DocMetaFieldMultiNumber;
677
+ hasKey(key: keyof T): boolean;
678
+ toJson(): SchemaToValueType<T>;
679
+ toYaml(): string;
680
+ private validateValue;
681
+ private getValueField;
1258
682
  /**
1259
- * Validate value type
683
+ * Generate from Markdown text
1260
684
  */
1261
- validate(value: unknown): boolean;
1262
- static empty<T extends RecordKey>(key: T): DocSchemaFieldSelectTextValue<T>;
1263
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldSelectTextValue<RecordKey>;
685
+ static fromYamlText<T extends DocCustomSchema>(yamlText: string, customSchema: T): DocFileMdMetaValue<T>;
686
+ static empty<T extends DocCustomSchema>(customSchema: T): DocFileMdMetaValue<T>;
1264
687
  }
1265
688
 
1266
689
  /**
1267
- * Single text type schema field
690
+ * File: Markdown > Content
1268
691
  */
1269
- declare class DocSchemaFieldTextValue<T extends RecordKey> {
1270
- readonly key: T;
1271
- readonly value: DocSchemaFieldText;
1272
- constructor(key: T, value: DocSchemaFieldText);
1273
- get type(): "text";
1274
- get required(): boolean;
1275
- get title(): string;
1276
- get description(): string;
1277
- get default(): string | null;
1278
- readonly isArray = false;
1279
- readonly isSingle = true;
1280
- readonly isText = true;
1281
- toJson(): DocFileIndexSchemaField;
692
+ declare class DocFileMdContentValue<T extends DocCustomSchema> {
693
+ readonly value: DocFileMdContent<T>;
694
+ private readonly customSchema;
695
+ constructor(value: DocFileMdContent<T>, customSchema: T);
1282
696
  /**
1283
- * Validate value type
697
+ * Content body (does not include frontMatter)
698
+ */
699
+ get body(): string;
700
+ /**
701
+ * Title
1284
702
  */
1285
- validate(value: unknown): boolean;
1286
- static empty(key: RecordKey): DocSchemaFieldTextValue<RecordKey>;
1287
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldTextValue<RecordKey>;
1288
- }
1289
-
1290
- /**
1291
- * Multiple number type schema field
1292
- */
1293
- declare class DocSchemaFieldMultiNumberValue<T extends RecordKey> {
1294
- readonly key: T;
1295
- readonly value: DocSchemaFieldMultiNumber;
1296
- constructor(key: T, value: DocSchemaFieldMultiNumber);
1297
- get type(): "multi-number";
1298
- get required(): boolean;
1299
703
  get title(): string;
704
+ /**
705
+ * Description
706
+ */
1300
707
  get description(): string;
1301
- get default(): number[] | null;
1302
- readonly isArray = true;
1303
- readonly isSingle = false;
1304
- readonly isNumber = true;
1305
708
  /**
1306
- * Validate value
709
+ * FrontMatter (uses constructor's Zod schema or argument schema)
1307
710
  */
1308
- validate(value: unknown): boolean;
1309
- toJson(): DocFileIndexSchemaField;
1310
- static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiNumberValue<T>;
1311
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiNumberValue<RecordKey>;
1312
- }
1313
-
1314
- /**
1315
- * Type-safe schema value object
1316
- */
1317
- declare class DocFileIndexSchemaValue<T extends DocCustomSchema> {
1318
- readonly value: DocFileIndexSchema<keyof T>;
1319
- readonly customSchema: T;
1320
- constructor(value: DocFileIndexSchema<keyof T>, customSchema: T);
711
+ meta(): DocFileMdMetaValue<T>;
1321
712
  /**
1322
- * Get list of field names
1323
- * Automatically type-safe when using Zod schema
713
+ * Update title
1324
714
  */
1325
- get fieldNames(): Array<keyof T>;
715
+ withTitle(title: string): DocFileMdContentValue<T>;
1326
716
  /**
1327
- * Get field with specified field name
1328
- * Returns type-safe specific field Value object
717
+ * Update description
1329
718
  */
1330
- 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;
1331
- relation<K extends keyof T>(key: K): DocSchemaFieldRelationValue<K>;
1332
- multiRelation<K extends keyof T>(key: K): DocSchemaFieldMultiRelationValue<K>;
1333
- toJson(): DocFileIndexSchema<keyof T>;
719
+ withDescription(description: string, defaultTitle?: string): DocFileMdContentValue<T>;
1334
720
  /**
1335
- * Create empty schema entity
1336
- * biome-ignore lint/complexity/noBannedTypes: {} as DocCustomSchema
721
+ * Update body
1337
722
  */
1338
- static empty(): DocFileIndexSchemaValue<{}>;
1339
- }
1340
-
1341
- /**
1342
- * File: index.md > content > FrontMatter
1343
- */
1344
- declare class DocFileIndexMetaValue<T extends DocCustomSchema> {
1345
- readonly value: DocFileIndexMeta<T>;
1346
- readonly customSchema: T;
1347
- private readonly config;
1348
- private readonly additionalProperties;
1349
- constructor(value: DocFileIndexMeta<T>, customSchema: T, config: DocClientConfig, additionalProperties?: Record<string, unknown>);
723
+ withBody(body: string): DocFileMdContentValue<T>;
1350
724
  /**
1351
- * Get icon
725
+ * @deprecated Use `withBody` instead
1352
726
  */
1353
- get icon(): string | null;
727
+ withContent(content: string): DocFileMdContentValue<T>;
1354
728
  /**
1355
- * Get schema
729
+ * Update FrontMatter
1356
730
  */
1357
- schema(): DocFileIndexSchemaValue<T>;
731
+ withMeta<U extends DocCustomSchema>(meta: DocFileMdMetaValue<U>): DocFileMdContentValue<U>;
732
+ withMeta(updater: UpdateFunction<DocFileMdMetaValue<T>>): DocFileMdContentValue<T>;
1358
733
  /**
1359
- * Check if schema is defined
734
+ * Update specific property of FrontMatter
1360
735
  */
1361
- get hasSchema(): boolean;
736
+ withMetaProperty<K extends keyof T>(key: K, value: BaseFieldValueType<ExtractFieldType<T[K]>>): DocFileMdContentValue<T>;
1362
737
  /**
1363
- * Update icon field
738
+ * Generate from Markdown text
1364
739
  */
1365
- withIcon(value: string | null): DocFileIndexMetaValue<T>;
740
+ static fromMarkdown<T extends DocCustomSchema>(markdown: string, customSchema: T): DocFileMdContentValue<T>;
1366
741
  /**
1367
- * Update schema field
742
+ * Generate complete text combining FrontMatter and body
1368
743
  */
1369
- withSchema(value: DocFileIndexSchema<keyof T>): DocFileIndexMetaValue<T>;
744
+ toText(): string;
1370
745
  /**
1371
- * Return a new instance with an unknown schema
1372
- * Allows accepting Record<string, unknown> schemas from external sources
746
+ * Generate empty content
1373
747
  */
1374
- withUnknownSchema(draft: Record<string, unknown>): DocFileIndexMetaValue<DocCustomSchema>;
748
+ static empty<T extends DocCustomSchema = DocCustomSchema>(title: string, customSchema: T): DocFileMdContentValue<T>;
1375
749
  /**
1376
750
  * Output in JSON format
1377
751
  */
1378
- toJson(): DocFileIndexMeta<T>;
752
+ toJson(): DocFileMdContent<T>;
753
+ }
754
+
755
+ /**
756
+ * Markdown file entity
757
+ */
758
+ declare class DocFileMdEntity<T extends DocCustomSchema> {
759
+ readonly value: DocFileMd<T>;
760
+ private readonly customSchema;
761
+ constructor(value: DocFileMd<T>, customSchema: T);
1379
762
  /**
1380
- * Output in YAML format
763
+ * Content
1381
764
  */
1382
- toYaml(): string;
765
+ content(): DocFileMdContentValue<T>;
1383
766
  /**
1384
- * Generate from Markdown text (can process incomplete data)
767
+ * Path information
1385
768
  */
1386
- static from<T extends DocCustomSchema>(markdownText: string, customSchema: T, config: DocClientConfig): DocFileIndexMetaValue<T>;
769
+ get path(): DocFilePath;
1387
770
  /**
1388
- * Generate directly from data (can process incomplete data)
771
+ * Update content
1389
772
  */
1390
- static fromRecord<T extends DocCustomSchema>(record: Record<string, unknown>, customSchema: T, config: DocClientConfig): DocFileIndexMetaValue<T>;
773
+ withContent(content: DocFileMdContentValue<T>): DocFileMdEntity<T>;
774
+ withContent(updater: UpdateFunction<DocFileMdContentValue<T>>): DocFileMdEntity<T>;
1391
775
  /**
1392
- * Generate empty FrontMatter
776
+ * Update path
1393
777
  */
1394
- static empty<T extends DocCustomSchema>(customSchema: T, config: DocClientConfig): DocFileIndexMetaValue<T>;
778
+ withPath(path: DocFilePath): DocFileMdEntity<T>;
779
+ withPath(updater: UpdateFunction<DocFilePath>): DocFileMdEntity<T>;
780
+ withMeta(meta: DocFileMdMetaValue<T>): DocFileMdEntity<T>;
781
+ withMeta(updater: UpdateFunction<DocFileMdMetaValue<T>>): DocFileMdEntity<T>;
782
+ withTitle(title: string): DocFileMdEntity<T>;
783
+ withDescription(description: string, defaultTitle?: string): DocFileMdEntity<T>;
1395
784
  /**
1396
- * Extract icon
785
+ * z.infer<typeof zDocFileMd>
1397
786
  */
1398
- private static extractIcon;
787
+ toJson(): z.infer<typeof zDocFileMd>;
788
+ }
789
+
790
+ /**
791
+ * Unknown file entity
792
+ */
793
+ declare class DocFileUnknownEntity {
794
+ readonly value: DocFileUnknown;
795
+ constructor(value: DocFileUnknown);
1399
796
  /**
1400
- * Extract schema part
797
+ * Content
1401
798
  */
1402
- private static extractSchema;
799
+ get content(): string;
1403
800
  /**
1404
- * Normalize entire schema
801
+ * Path information
1405
802
  */
1406
- private static normalizeSchema;
1407
- static emptySchema<T extends DocCustomSchema>(customSchema: T): DocFileIndexSchema<keyof T>;
803
+ get path(): DocFilePath;
804
+ /**
805
+ * Update content
806
+ */
807
+ withContent(content: string): DocFileUnknownEntity;
808
+ /**
809
+ * Update path
810
+ */
811
+ withPath(path: DocFilePath): DocFileUnknownEntity;
812
+ withPath(updater: UpdateFunction<DocFilePath>): DocFileUnknownEntity;
813
+ toJson(): z.infer<typeof zDocFileUnknown>;
1408
814
  }
1409
815
 
816
+ type DocFileEntity<T extends DocCustomSchema> = DocFileMdEntity<T> | DocFileIndexEntity<T> | DocFileUnknownEntity;
817
+ type DocFileDirectoryEntity<T extends DocCustomSchema> = DocFileMdEntity<T> | DocFileUnknownEntity;
818
+
819
+ type Props$6<T extends DocCustomSchema> = {
820
+ path: string;
821
+ fileSystem: DocFileSystemInterface;
822
+ pathSystem: DocPathSystem;
823
+ customSchema: T;
824
+ config: DocClientConfig;
825
+ };
1410
826
  /**
1411
- * File: index.md > content
827
+ * File reference
1412
828
  */
1413
- declare class DocFileIndexContentValue<T extends DocCustomSchema> {
1414
- readonly value: DocFileIndexContent<T>;
829
+ declare class DocFileUnknownReference<T extends DocCustomSchema> {
830
+ private readonly props;
831
+ private readonly pathSystem;
1415
832
  private readonly customSchema;
1416
- private readonly config;
1417
- constructor(value: DocFileIndexContent<T>, customSchema: T, config: DocClientConfig);
833
+ constructor(props: Props$6<T>);
834
+ get fileSystem(): DocFileSystemInterface;
835
+ get basePath(): string;
836
+ get path(): string;
837
+ get directoryPath(): string;
838
+ get fileFullPath(): string;
839
+ directory(): DocDirectoryReference<T>;
840
+ read(): Promise<Error | DocFileUnknownEntity>;
1418
841
  /**
1419
- * Content body (does not include frontMatter)
842
+ * Read file content
1420
843
  */
1421
- get body(): string;
844
+ readContent(): Promise<Error | string>;
1422
845
  /**
1423
- * Title
846
+ * Create empty DocFileUnknownEntity
1424
847
  */
1425
- get title(): string;
848
+ empty(): DocFileUnknownEntity;
1426
849
  /**
1427
- * Description
850
+ * Write content to file
1428
851
  */
1429
- get description(): string;
852
+ writeContent(content: string): Promise<Error | null>;
1430
853
  /**
1431
- * FrontMatter
854
+ * Write entity
1432
855
  */
1433
- meta(): DocFileIndexMetaValue<T>;
856
+ write(entity: DocFileUnknownEntity): Promise<Error | null>;
1434
857
  /**
1435
- * Update title
858
+ * Write raw content
1436
859
  */
1437
- withTitle(title: string): DocFileIndexContentValue<T>;
860
+ writeRaw(content: string): Promise<Error | null>;
1438
861
  /**
1439
- * Update description
862
+ * Delete file
1440
863
  */
1441
- withDescription(description: string, defaultTitle?: string): DocFileIndexContentValue<T>;
864
+ delete(): Promise<Error | null>;
1442
865
  /**
1443
- * Generate from Markdown text
866
+ * Check if file exists
1444
867
  */
1445
- static fromMarkdown<T extends DocCustomSchema>(markdown: string, customSchema: T, config: DocClientConfig): DocFileIndexContentValue<T>;
868
+ exists(): Promise<boolean>;
1446
869
  /**
1447
- * Update content
870
+ * Copy file
1448
871
  */
1449
- withBody(body: string): DocFileIndexContentValue<T>;
872
+ copyTo(destinationPath: string): Promise<Error | null>;
1450
873
  /**
1451
- * @deprecated Use `withBody` instead
874
+ * Move file
1452
875
  */
1453
- withContent(body: string): DocFileIndexContentValue<T>;
876
+ moveTo(destinationPath: string): Promise<Error | null>;
1454
877
  /**
1455
- * Update FrontMatter
878
+ * Get file size in bytes
1456
879
  */
1457
- withMeta(meta: DocFileIndexMeta<T>): DocFileIndexContentValue<T>;
880
+ size(): Promise<number | Error>;
1458
881
  /**
1459
- * Generate default index.md content
882
+ * Get file last modified time
883
+ */
884
+ lastModified(): Promise<Date | Error>;
885
+ /**
886
+ * Get file creation time
1460
887
  */
1461
- static empty<T extends DocCustomSchema = DocCustomSchema>(directoryName: string, customSchema: T, config: DocClientConfig): DocFileIndexContentValue<T>;
888
+ createdAt(): Promise<Date | Error>;
1462
889
  /**
1463
- * Generate complete text combining FrontMatter and body
890
+ * Move file to archive and return new reference
1464
891
  */
1465
- toText(): string;
892
+ archive(archiveDirectoryName?: string): Promise<DocFileUnknownReference<T>>;
1466
893
  /**
1467
- * Output in JSON format
894
+ * Restore file from archive and return new reference
1468
895
  */
1469
- toJson(): DocFileIndexContent<T>;
896
+ restore(archiveDirectoryName?: string): Promise<DocFileUnknownReference<T>>;
1470
897
  }
1471
898
 
899
+ type DocFileDirectoryReference<T extends DocCustomSchema> = DocFileMdReference<T> | DocFileUnknownReference<T>;
900
+
901
+ type Props$5<T extends DocCustomSchema> = {
902
+ customSchema: T;
903
+ path: string;
904
+ indexFileName: string;
905
+ archiveDirectoryName: string;
906
+ fileSystem: DocFileSystemInterface;
907
+ pathSystem: DocPathSystem;
908
+ config: DocClientConfig;
909
+ };
1472
910
  /**
1473
- * Document directory entity
911
+ * Directory reference
1474
912
  */
1475
- declare class DocFileIndexEntity<T extends DocCustomSchema> {
1476
- readonly value: DocFileIndex<T>;
913
+ declare class DocDirectoryReference<T extends DocCustomSchema> {
914
+ private readonly props;
915
+ private readonly pathSystem;
1477
916
  private readonly customSchema;
1478
- private readonly config;
1479
- constructor(value: DocFileIndex<T>, customSchema: T, config?: DocClientConfig);
917
+ constructor(props: Props$5<T>);
918
+ get fileSystem(): DocFileSystemInterface;
919
+ get basePath(): string;
920
+ get config(): DocClientConfig;
921
+ get path(): string;
1480
922
  /**
1481
- * Content
923
+ * @deprecated
1482
924
  */
1483
- get content(): DocFileIndexContentValue<T>;
925
+ get relativePath(): string;
926
+ get fullPath(): string;
1484
927
  /**
1485
- * Path information
928
+ * @deprecated
1486
929
  */
1487
- get path(): DocFilePath;
930
+ get absolutePath(): string;
931
+ get indexFileName(): string;
932
+ get indexFilePath(): string;
933
+ get archiveDirectoryName(): string;
934
+ get name(): string;
935
+ fileNames(): Promise<string[] | Error>;
936
+ archivedFileNames(): Promise<string[] | Error>;
937
+ filesGenerator(): AsyncGenerator<DocFileDirectoryReference<T>, void, unknown>;
938
+ mdFilesGenerator(): AsyncGenerator<DocFileMdReference<T> | Error, void, unknown>;
939
+ files(): Promise<DocFileDirectoryReference<T>[]>;
940
+ mdFiles(): Promise<DocFileMdReference<T>[]>;
941
+ file<FileName extends string>(fileName: FileName): InferReference<FileName, T>;
942
+ mdFile(fileName: string): DocFileMdReference<T>;
943
+ readFiles(): Promise<DocFileDirectoryEntity<T>[]>;
944
+ readMdFiles(): Promise<DocFileMdEntity<T>[]>;
945
+ readUnknownFiles(): Promise<DocFileUnknownEntity[]>;
1488
946
  /**
1489
- * Update content
947
+ * Get list of subdirectory names
1490
948
  */
1491
- withContent(content: DocFileIndexContentValue<T>): DocFileIndexEntity<T>;
1492
- withContent(updater: UpdateFunction<DocFileIndexContentValue<T>>): DocFileIndexEntity<T>;
949
+ directoryNames(): Promise<string[]>;
1493
950
  /**
1494
- * Update path
951
+ * Get subdirectory references
1495
952
  */
1496
- withPath(path: DocFilePath): DocFileIndexEntity<T>;
1497
- withPath(updater: UpdateFunction<DocFilePath>): DocFileIndexEntity<T>;
953
+ directories(): Promise<DocDirectoryReference<T>[]>;
1498
954
  /**
1499
- * z.infer<typeof zDocFileIndex>
955
+ * Get single subdirectory reference
1500
956
  */
1501
- toJson(): DocFileIndexAny;
957
+ directory(directoryName: string): DocDirectoryReference<T>;
958
+ directory<S extends DocCustomSchema>(directoryName: string, customSchema: S): DocDirectoryReference<S>;
959
+ indexFile(): DocFileIndexReference<T>;
960
+ readIndexFile(): Promise<DocFileIndexEntity<T> | Error>;
961
+ writeFile(entity: DocFileIndexEntity<T> | DocFileMdEntity<T> | DocFileUnknownEntity): Promise<Error | null>;
962
+ exists(): Promise<boolean>;
963
+ /**
964
+ * Create new Markdown file
965
+ */
966
+ createMdFile(fileName?: string): Promise<DocFileMdReference<T>>;
967
+ /**
968
+ * Generate unique filename
969
+ */
970
+ private uniqueFileName;
1502
971
  }
1503
972
 
1504
- type Props$b<T extends DocCustomSchema> = {
1505
- customSchema: T;
973
+ type Props$4<T extends DocCustomSchema> = {
1506
974
  path: string;
1507
- fileSystem: DocFileSystem;
975
+ fileSystem: DocFileSystemInterface;
1508
976
  pathSystem: DocPathSystem;
977
+ customSchema: T;
1509
978
  config: DocClientConfig;
1510
979
  };
1511
980
  /**
1512
- * File reference class
981
+ * File reference
1513
982
  */
1514
- declare class DocFileIndexReference<T extends DocCustomSchema> {
983
+ declare class DocFileMdReference<T extends DocCustomSchema> {
1515
984
  private readonly props;
1516
985
  private readonly pathSystem;
1517
986
  private readonly customSchema;
1518
- constructor(props: Props$b<T>);
1519
- get fileSystem(): DocFileSystem;
987
+ constructor(props: Props$4<T>);
988
+ get fileSystem(): DocFileSystemInterface;
1520
989
  get basePath(): string;
1521
- get filePath(): string;
1522
- get fileFullPath(): string;
1523
- get durectoryPath(): string;
1524
- read(): Promise<DocFileIndexEntity<T> | Error>;
1525
- readSchemaValue(): Promise<DocFileIndexSchema<RecordKey>>;
990
+ get path(): string;
991
+ get fullPath(): string;
992
+ get directoryPath(): string;
993
+ get archivedPath(): string;
994
+ get name(): string;
995
+ get nameWithExtension(): string;
996
+ exists(): Promise<boolean>;
997
+ read(): Promise<DocFileMdEntity<T> | Error>;
1526
998
  /**
1527
999
  * Read file content
1528
1000
  */
1529
- readContent(): Promise<Error | string>;
1530
- /**
1531
- * Create empty DocFileIndexEntity
1532
- */
1533
- empty(): DocFileIndexEntity<T>;
1001
+ readText(): Promise<Error | string>;
1534
1002
  /**
1535
- * Write content to file
1003
+ * Create empty DocFileMdEntity
1536
1004
  */
1537
- writeContent(content: string): Promise<Error | null>;
1005
+ empty(): DocFileMdEntity<T>;
1538
1006
  /**
1539
1007
  * Write entity
1540
1008
  */
1541
- write(entity: DocFileIndexEntity<T>): Promise<Error | null>;
1009
+ write(entity: DocFileMdEntity<T>): Promise<Error | null>;
1010
+ writeText(text: string): Promise<Error | null>;
1542
1011
  /**
1543
1012
  * Create new file with default content
1544
1013
  */
@@ -1548,884 +1017,585 @@ declare class DocFileIndexReference<T extends DocCustomSchema> {
1548
1017
  */
1549
1018
  delete(): Promise<Error | null>;
1550
1019
  /**
1551
- * Check if file exists
1020
+ * Copy file
1552
1021
  */
1553
- exists(): Promise<boolean>;
1554
- relations(): Promise<DocFileRelationReference[] | Error>;
1555
- readRelations(): Promise<DocRelationValue[] | Error>;
1022
+ copyTo(destinationPath: string): Promise<Error | null>;
1023
+ /**
1024
+ * Move file
1025
+ */
1026
+ moveTo(destinationPath: string): Promise<Error | null>;
1027
+ /**
1028
+ * Move file to archive and return new reference
1029
+ */
1030
+ archive(archiveDirectoryName?: string): Promise<DocFileMdReference<T>>;
1031
+ /**
1032
+ * Restore file from archive and return new reference
1033
+ */
1034
+ restore(archiveDirectoryName?: string): Promise<DocFileMdReference<T>>;
1556
1035
  /**
1557
1036
  * Get file size in bytes
1558
1037
  */
1559
1038
  size(): Promise<number | Error>;
1560
1039
  /**
1561
- * Get last modified date
1040
+ * Get file last modified time
1562
1041
  */
1563
1042
  lastModified(): Promise<Date | Error>;
1564
1043
  /**
1565
- * Get file creation date
1044
+ * Get file creation time
1566
1045
  */
1567
1046
  createdAt(): Promise<Date | Error>;
1047
+ directory(): DocDirectoryReference<T>;
1568
1048
  /**
1569
- * Move file to archive and return new reference
1049
+ * Get relation based on schema
1570
1050
  */
1571
- archive(archiveDirectoryName?: string): Promise<DocFileIndexReference<T>>;
1051
+ relation<U extends DocCustomSchema = DocCustomSchema>(key: RelationKeys<T>, targetSchema?: U): Promise<DocFileMdReference<U> | Error | null>;
1572
1052
  /**
1573
- * Restore file from archive and return new reference
1053
+ * Get index.md in the same directory
1574
1054
  */
1575
- restore(archiveDirectoryName?: string): Promise<DocFileIndexReference<T>>;
1055
+ directoryIndex(): Promise<DocFileIndexReference<T> | null>;
1056
+ /**
1057
+ * Get multiple relations based on schema
1058
+ */
1059
+ relations<U extends DocCustomSchema = DocCustomSchema>(key: MultiRelationKeys<T>, customSchema?: U): Promise<DocFileMdReference<U>[]>;
1060
+ /**
1061
+ * File: Markdown > FrontMatter
1062
+ */
1063
+ readFrontMatter(): Promise<DocFileMdMetaValue<T> | Error>;
1064
+ /**
1065
+ * File: Markdown > FrontMatter
1066
+ */
1067
+ updateFrontMatter<K extends keyof T>(key: K, value: BaseFieldValueType<ExtractFieldType<T[K]>>): Promise<this | Error>;
1576
1068
  }
1577
1069
 
1578
- type DocFileDirectoryReference<T extends DocCustomSchema> = DocFileMdReference<T> | DocFileUnknownReference<T>;
1579
-
1580
- type DocFileEntity<T extends DocCustomSchema> = DocFileMdEntity<T> | DocFileIndexEntity<T> | DocFileUnknownEntity;
1581
- type DocFileDirectoryEntity<T extends DocCustomSchema> = DocFileMdEntity<T> | DocFileUnknownEntity;
1582
-
1583
- type Props$a<T extends DocCustomSchema> = {
1584
- customSchema: T;
1585
- path: string;
1586
- indexFileName: string;
1587
- archiveDirectoryName: string;
1588
- fileSystem: DocFileSystem;
1589
- pathSystem: DocPathSystem;
1590
- config: DocClientConfig;
1070
+ /**
1071
+ * Generic updater function type that takes a value and returns the same type
1072
+ */
1073
+ type UpdateFunction<T> = (current: T) => T;
1074
+ /**
1075
+ * Text field type
1076
+ */
1077
+ type DocSchemaFieldText = z.infer<typeof zDocSchemaFieldText>;
1078
+ /**
1079
+ * Number field type
1080
+ */
1081
+ type DocSchemaFieldNumber = z.infer<typeof zDocSchemaFieldNumber>;
1082
+ /**
1083
+ * Boolean field type
1084
+ */
1085
+ type DocSchemaFieldBoolean = z.infer<typeof zDocSchemaFieldBoolean>;
1086
+ /**
1087
+ * Multi-text field type
1088
+ */
1089
+ type DocSchemaFieldMultiText = z.infer<typeof zDocSchemaFieldMultiText>;
1090
+ /**
1091
+ * Multi-number field type
1092
+ */
1093
+ type DocSchemaFieldMultiNumber = z.infer<typeof zDocSchemaFieldMultiNumber>;
1094
+ /**
1095
+ * Relation field type
1096
+ */
1097
+ type DocSchemaFieldRelation = z.infer<typeof zDocSchemaFieldRelation>;
1098
+ /**
1099
+ * Multi-relation field type
1100
+ */
1101
+ type DocSchemaFieldMultiRelation = z.infer<typeof zDocSchemaFieldMultiRelation>;
1102
+ /**
1103
+ * Select text field type
1104
+ */
1105
+ type DocSchemaFieldSelectText = z.infer<typeof zDocSchemaFieldSelectText>;
1106
+ /**
1107
+ * Select number field type
1108
+ */
1109
+ type DocSchemaFieldSelectNumber = z.infer<typeof zDocSchemaFieldSelectNumber>;
1110
+ /**
1111
+ * Multi-select text field type
1112
+ */
1113
+ type DocSchemaFieldMultiSelectText = z.infer<typeof zDocSchemaFieldMultiSelectText>;
1114
+ /**
1115
+ * Multi-select number field type
1116
+ */
1117
+ type DocSchemaFieldMultiSelectNumber = z.infer<typeof zDocSchemaFieldMultiSelectNumber>;
1118
+ type DocMetaField = z.infer<typeof zDocMetaField>;
1119
+ type DocMetaFieldText = z.infer<typeof zDocMetaFieldText>;
1120
+ type DocMetaFieldNumber = z.infer<typeof zDocMetaFieldNumber>;
1121
+ type DocMetaFieldBoolean = z.infer<typeof zDocMetaFieldBoolean>;
1122
+ type DocMetaFieldSelectText = z.infer<typeof zDocMetaFieldSelectText>;
1123
+ type DocMetaFieldSelectNumber = z.infer<typeof zDocMetaFieldSelectNumber>;
1124
+ type DocMetaFieldRelation = z.infer<typeof zDocMetaFieldRelation>;
1125
+ type DocMetaFieldMultiText = z.infer<typeof zDocMetaFieldMultiText>;
1126
+ type DocMetaFieldMultiNumber = z.infer<typeof zDocMetaFieldMultiNumber>;
1127
+ type DocMetaFieldMultiSelectText = z.infer<typeof zDocMetaFieldMultiSelectText>;
1128
+ type DocMetaFieldMultiSelectNumber = z.infer<typeof zDocMetaFieldMultiSelectNumber>;
1129
+ type DocMetaFieldMultiRelation = z.infer<typeof zDocMetaFieldMultiRelation>;
1130
+ type DocFileMdMeta<T extends RecordKey> = Record<T, DocMetaField>;
1131
+ type DocFileMdMetaAny = DocFileMdMeta<RecordKey>;
1132
+ type DocMetaFieldTypeText = z.infer<typeof zDocMetaFieldTypeText>;
1133
+ type DocMetaFieldTypeNumber = z.infer<typeof zDocMetaFieldTypeNumber>;
1134
+ type DocMetaFieldTypeBoolean = z.infer<typeof zDocMetaFieldTypeBoolean>;
1135
+ type DocMetaFieldTypeSelectText = z.infer<typeof zDocMetaFieldTypeSelectText>;
1136
+ type DocMetaFieldTypeSelectNumber = z.infer<typeof zDocMetaFieldTypeSelectNumber>;
1137
+ type DocMetaFieldTypeRelation = z.infer<typeof zDocMetaFieldTypeRelation>;
1138
+ /**
1139
+ * Schema field type
1140
+ */
1141
+ type DocMetaFieldType = z.infer<typeof zDocMetaFieldType>;
1142
+ type DocCustomSchemaFieldText = {
1143
+ type: "text";
1144
+ required: boolean;
1145
+ };
1146
+ type DocCustomSchemaFieldNumber = {
1147
+ type: "number";
1148
+ required: boolean;
1149
+ };
1150
+ type DocCustomSchemaFieldBoolean = {
1151
+ type: "boolean";
1152
+ required: boolean;
1153
+ };
1154
+ type DocCustomSchemaFieldRelation = {
1155
+ type: "relation";
1156
+ required: boolean;
1157
+ };
1158
+ type DocCustomSchemaFieldSelectText = {
1159
+ type: "select-text";
1160
+ required: boolean;
1161
+ };
1162
+ type DocCustomSchemaFieldSelectNumber = {
1163
+ type: "select-number";
1164
+ required: boolean;
1165
+ };
1166
+ type DocCustomSchemaFieldMultiText = {
1167
+ type: "multi-text";
1168
+ required: boolean;
1169
+ };
1170
+ type DocCustomSchemaFieldMultiNumber = {
1171
+ type: "multi-number";
1172
+ required: boolean;
1173
+ };
1174
+ type DocCustomSchemaFieldMultiRelation = {
1175
+ type: "multi-relation";
1176
+ required: boolean;
1177
+ };
1178
+ type DocCustomSchemaFieldMultiSelectText = {
1179
+ type: "multi-select-text";
1180
+ required: boolean;
1181
+ };
1182
+ type DocCustomSchemaFieldMultiSelectNumber = {
1183
+ type: "multi-select-number";
1184
+ required: boolean;
1591
1185
  };
1592
1186
  /**
1593
- * Directory reference
1187
+ * Schema field type
1594
1188
  */
1595
- declare class DocDirectoryReference<T extends DocCustomSchema> {
1596
- private readonly props;
1597
- private readonly pathSystem;
1598
- private readonly customSchema;
1599
- constructor(props: Props$a<T>);
1600
- get fileSystem(): DocFileSystem;
1601
- get basePath(): string;
1602
- get config(): DocClientConfig;
1603
- get path(): string;
1604
- /**
1605
- * @deprecated
1606
- */
1607
- get relativePath(): string;
1608
- get fullPath(): string;
1609
- /**
1610
- * @deprecated
1611
- */
1612
- get absolutePath(): string;
1613
- get indexFileName(): string;
1614
- get indexFilePath(): string;
1615
- get archiveDirectoryName(): string;
1616
- get name(): string;
1617
- fileNames(): Promise<string[] | Error>;
1618
- archivedFileNames(): Promise<string[] | Error>;
1619
- filesGenerator(): AsyncGenerator<DocFileDirectoryReference<T>, void, unknown>;
1620
- mdFilesGenerator(): AsyncGenerator<DocFileMdReference<T> | Error, void, unknown>;
1621
- files(): Promise<DocFileDirectoryReference<T>[]>;
1622
- mdFiles(): Promise<DocFileMdReference<T>[]>;
1623
- file<FileName extends string>(fileName: FileName): InferReference<FileName, T>;
1624
- mdFile(fileName: string): DocFileMdReference<T>;
1625
- readFiles(): Promise<DocFileDirectoryEntity<T>[]>;
1626
- readMdFiles(): Promise<DocFileMdEntity<T>[]>;
1627
- readUnknownFiles(): Promise<DocFileUnknownEntity[]>;
1628
- /**
1629
- * Get list of subdirectory names
1630
- */
1631
- directoryNames(): Promise<string[]>;
1632
- /**
1633
- * Get subdirectory references
1634
- */
1635
- directories(): Promise<DocDirectoryReference<T>[]>;
1636
- /**
1637
- * Get single subdirectory reference
1638
- */
1639
- directory(directoryName: string): DocDirectoryReference<T>;
1640
- directory<S extends DocCustomSchema>(directoryName: string, customSchema: S): DocDirectoryReference<S>;
1641
- indexFile(): DocFileIndexReference<T>;
1642
- readIndexFile(): Promise<DocFileIndexEntity<T> | Error>;
1643
- writeFile(entity: DocFileIndexEntity<T> | DocFileMdEntity<T> | DocFileUnknownEntity): Promise<Error | null>;
1644
- exists(): Promise<boolean>;
1645
- /**
1646
- * Create new Markdown file
1647
- */
1648
- createMdFile(fileName?: string): Promise<DocFileMdReference<T>>;
1649
- /**
1650
- * Generate unique filename
1651
- */
1652
- private uniqueFileName;
1653
- }
1654
-
1655
- declare const DOC_NODE_TYPE_DIRECTORY: "directory";
1656
-
1657
- type Props$9 = {
1189
+ type DocFileIndexSchemaField = z.infer<typeof zDocFileIndexSchemaField>;
1190
+ /**
1191
+ * Schema definition type
1192
+ */
1193
+ type DocFileIndexSchema<T extends RecordKey = string> = Record<T, DocFileIndexSchemaField>;
1194
+ /**
1195
+ * Schema field to override
1196
+ * ex: { xxx: { type: "text", required: true } }
1197
+ */
1198
+ type DocCustomSchemaField = DocCustomSchemaFieldText | DocCustomSchemaFieldNumber | DocCustomSchemaFieldBoolean | DocCustomSchemaFieldRelation | DocCustomSchemaFieldSelectText | DocCustomSchemaFieldSelectNumber | DocCustomSchemaFieldMultiText | DocCustomSchemaFieldMultiNumber | DocCustomSchemaFieldMultiRelation | DocCustomSchemaFieldMultiSelectText | DocCustomSchemaFieldMultiSelectNumber;
1199
+ /**
1200
+ * Type literal for field types
1201
+ */
1202
+ type DocFieldTypeLiteral = "text" | "number" | "boolean" | "relation" | "multi-text" | "multi-number" | "multi-relation" | "select-text" | "select-number" | "multi-select-text" | "multi-select-number";
1203
+ /**
1204
+ * Minimal schema definition type
1205
+ */
1206
+ type DocCustomSchema<T extends RecordKey = string> = Record<T, DocCustomSchemaField>;
1207
+ /**
1208
+ * Union type for relation fields
1209
+ */
1210
+ type DocSchemaRelationFieldUnion = DocSchemaFieldRelation | DocSchemaFieldMultiRelation;
1211
+ /**
1212
+ * File node type (for files only)
1213
+ */
1214
+ type DocTreeFileNode = {
1215
+ type: "file";
1658
1216
  name: string;
1659
1217
  path: string;
1660
1218
  icon: string;
1661
1219
  title: string;
1662
1220
  };
1663
1221
  /**
1664
- * Tree file node value object
1222
+ * Directory node type (for directories only)
1665
1223
  */
1666
- declare class DocTreeFileNodeValue {
1667
- private readonly props;
1668
- constructor(props: Props$9);
1669
- get name(): string;
1670
- get path(): string;
1671
- get icon(): string;
1672
- get title(): string;
1673
- get type(): "file";
1674
- /**
1675
- * Convert to plain object
1676
- */
1677
- toJson(): DocTreeFileNode;
1678
- /**
1679
- * Create from properties
1680
- */
1681
- static from(props: Props$9): DocTreeFileNodeValue;
1682
- /**
1683
- * Create from JSON object
1684
- */
1685
- static fromJson(json: unknown): DocTreeFileNodeValue;
1686
- }
1687
-
1688
- type DocTreeNodeValue = DocTreeFileNodeValue | DocTreeDirectoryNodeValue;
1689
-
1690
- type Props$8 = {
1224
+ type DocTreeDirectoryNode = {
1225
+ type: "directory";
1691
1226
  name: string;
1692
1227
  path: string;
1693
1228
  icon: string;
1694
1229
  title: string;
1695
- children: DocTreeNodeValue[];
1230
+ children: DocTreeNode[];
1696
1231
  };
1697
1232
  /**
1698
- * Tree directory node value object
1233
+ * Unified tree node type
1699
1234
  */
1700
- declare class DocTreeDirectoryNodeValue {
1701
- private readonly props;
1702
- constructor(props: Props$8);
1703
- get name(): string;
1704
- get path(): string;
1705
- get icon(): string;
1706
- get title(): string;
1707
- get children(): DocTreeNodeValue[];
1708
- get type(): typeof DOC_NODE_TYPE_DIRECTORY;
1709
- /**
1710
- * Convert to plain object
1711
- */
1712
- toJson(): DocTreeDirectoryNode;
1713
- /**
1714
- * Create from properties
1715
- */
1716
- static from(props: Props$8): DocTreeDirectoryNodeValue;
1717
- /**
1718
- * Create from JSON object
1719
- */
1720
- static fromJson(json: unknown): DocTreeDirectoryNodeValue;
1721
- }
1722
-
1723
- type Props$7 = {
1724
- fileSystem: DocFileSystem;
1725
- pathSystem: DocPathSystem;
1726
- indexFileName: string;
1727
- archiveDirectoryName: string;
1728
- config: DocClientConfig;
1235
+ type DocTreeNode = DocTreeFileNode | DocTreeDirectoryNode;
1236
+ /**
1237
+ * Index file type
1238
+ */
1239
+ type DocFileIndex<T extends DocCustomSchema = DocCustomSchema> = {
1240
+ type: "index";
1241
+ path: DocFilePath;
1242
+ isArchived: boolean;
1243
+ content: DocFileIndexContent<T>;
1244
+ };
1245
+ /**
1246
+ * Type to check if two types are equal
1247
+ */
1248
+ type Equals<T, U> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? true : false;
1249
+ /**
1250
+ * Extract relation field keys from schema
1251
+ */
1252
+ type RelationKeys<T extends DocCustomSchema> = {
1253
+ [K in keyof T]: T[K]["type"] extends "relation" ? K : never;
1254
+ }[keyof T];
1255
+ /**
1256
+ * Extract multi-relation field keys from schema
1257
+ */
1258
+ type MultiRelationKeys<T extends DocCustomSchema> = {
1259
+ [K in keyof T]: T[K]["type"] extends "multi-relation" ? K : never;
1260
+ }[keyof T];
1261
+ /**
1262
+ * Markdown file type (excluding index.md)
1263
+ */
1264
+ type DocFileMd<T extends DocCustomSchema> = {
1265
+ type: "markdown";
1266
+ path: DocFilePath;
1267
+ isArchived: boolean;
1268
+ content: DocFileMdContent<T>;
1269
+ };
1270
+ /**
1271
+ * Other file type (non-markdown)
1272
+ */
1273
+ type DocFileUnknown = z.infer<typeof zDocFileUnknown>;
1274
+ /**
1275
+ * File union type (index.md, regular md, other)
1276
+ */
1277
+ type DocFile<T extends DocCustomSchema = DocCustomSchema> = DocFileIndex<T> | DocFileMd<T> | DocFileUnknown;
1278
+ type DocDirectoryFile<T extends DocCustomSchema = DocCustomSchema> = DocFileMd<T> | DocFileUnknown;
1279
+ type DocFileIndexAny = z.infer<typeof zDocFileIndex>;
1280
+ type DocFileMdAny = z.infer<typeof zDocFileMd>;
1281
+ /**
1282
+ * DocFile<DocCustomSchema<RecordKey>>
1283
+ */
1284
+ type DocFileAny = DocFileIndexAny | DocFileMdAny | DocFileUnknown;
1285
+ /**
1286
+ * Directory FrontMatter type
1287
+ */
1288
+ type DocFileIndexMeta<T extends DocCustomSchema = DocCustomSchema> = {
1289
+ type: "index-meta";
1290
+ icon: string | null;
1291
+ schema: DocFileIndexSchema<keyof T>;
1729
1292
  };
1730
1293
  /**
1731
- * File tree building system
1294
+ * Relation options type
1295
+ */
1296
+ type DocRelationFile = z.infer<typeof zDocRelationFile>;
1297
+ /**
1298
+ * Relation information type
1299
+ */
1300
+ type DocRelation = z.infer<typeof zDocRelation>;
1301
+ /**
1302
+ * Relation field type
1303
+ */
1304
+ type DocRelationField = z.infer<typeof zDocRelationField>;
1305
+ /**
1306
+ * String literal type utilities for file path detection
1307
+ */
1308
+ /**
1309
+ * Check if path ends with specific extension
1310
+ */
1311
+ type EndsWith<T extends string, U extends string> = T extends `${string}${U}` ? true : false;
1312
+ /**
1313
+ * Extract filename from path
1314
+ */
1315
+ type Basename<T extends string> = T extends `${string}/${infer U}` ? Basename<U> : T;
1316
+ /**
1317
+ * Check if filename is index.md
1318
+ */
1319
+ type IsIndexMd<T extends string> = Basename<T> extends "index.md" ? true : false;
1320
+ /**
1321
+ * Detect file type from path
1732
1322
  */
1733
- declare class DocFileTreeSystem {
1734
- private readonly props;
1735
- private readonly config;
1736
- constructor(props: Props$7);
1737
- /**
1738
- * Build file tree recursively
1739
- */
1740
- buildFileTree(directoryPath?: string): Promise<DocTreeNodeValue[] | Error>;
1741
- /**
1742
- * Create file node
1743
- */
1744
- private createFileNode;
1745
- /**
1746
- * Create directory node
1747
- */
1748
- private createDirectoryNode;
1749
- /**
1750
- * Create index file reference
1751
- */
1752
- private createIndexFileReference;
1753
- /**
1754
- * Create MD file reference
1755
- */
1756
- private createMdFileReference;
1757
- /**
1758
- * Build directory tree recursively (directories only)
1759
- */
1760
- buildDirectoryTree(directoryPath?: string): Promise<DocTreeDirectoryNodeValue[] | Error>;
1761
- /**
1762
- * Create directory node for directory tree
1763
- */
1764
- private createDirectoryNodeForTree;
1765
- }
1766
-
1323
+ type DetectFileType<T extends string> = IsIndexMd<T> extends true ? "index" : EndsWith<T, ".md"> extends true ? "markdown" : "unknown";
1767
1324
  /**
1768
- * Markdown parsing and processing system
1325
+ * Map file type to reference class
1769
1326
  */
1770
- declare class DocMarkdownSystem {
1771
- private readonly frontMatterSeparator;
1772
- constructor();
1773
- /**
1774
- * Detect FrontMatter separator line
1775
- */
1776
- private detectFrontMatterSeparator;
1777
- /**
1778
- * Extract FrontMatter
1779
- */
1780
- extractFrontMatter(text: string): string | null;
1781
- /**
1782
- * Extract body without FrontMatter (includes title and description)
1783
- */
1784
- extractBody(text: string): string;
1785
- /**
1786
- * Extract title
1787
- */
1788
- extractTitle(text: string): string | null;
1789
- /**
1790
- * Extract description (first paragraph after title)
1791
- */
1792
- extractDescription(text: string): string | null;
1793
- /**
1794
- * Update title in body (returns body only, without FrontMatter)
1795
- */
1796
- updateTitle(text: string, newTitle: string): string;
1797
- /**
1798
- * Update description in body (returns body only, without FrontMatter)
1799
- */
1800
- updateDescription(text: string, newDescription: string, defaultTitle: string): string;
1801
- /**
1802
- * Skip empty lines
1803
- */
1804
- private skipEmptyLines;
1805
- /**
1806
- * Generate Markdown text (title + description + body)
1807
- */
1808
- static from(title: string, description: string, body: string): string;
1809
- }
1810
-
1811
- type Props$6 = {
1812
- fileSystem: DocFileSystem;
1813
- pathSystem?: DocPathSystem;
1814
- markdownSystem?: DocMarkdownSystem;
1815
- fileTreeSystem?: DocFileTreeSystem;
1816
- /**
1817
- * Configuration
1818
- */
1819
- config?: DocClientConfig;
1820
- };
1821
- declare class DocClient {
1822
- readonly fileSystem: DocFileSystem;
1823
- readonly pathSystem: DocPathSystem;
1824
- readonly markdownSystem: DocMarkdownSystem;
1825
- readonly fileTreeSystem: DocFileTreeSystem;
1826
- readonly config: DocClientConfig;
1827
- constructor(props: Props$6);
1828
- basePath(): string;
1829
- file<Path extends string>(relativePath: Path): InferReference<Path, DocCustomSchema>;
1830
- file<Path extends string, T extends DocCustomSchema>(relativePath: Path, customSchema: T): InferReference<Path, T>;
1831
- mdFile(relativePath: string): DocFileMdReference<DocCustomSchema>;
1832
- mdFile<T extends DocCustomSchema>(relativePath: string, customSchema: T): DocFileMdReference<T>;
1833
- indexFile(relativePath: string): DocFileIndexReference<DocCustomSchema>;
1834
- indexFile<T extends DocCustomSchema>(relativePath: string, customSchema: T): DocFileIndexReference<T>;
1835
- directory(relativePath: string): DocDirectoryReference<DocCustomSchema>;
1836
- directory<T extends DocCustomSchema>(relativePath: string, customSchema: T): DocDirectoryReference<T>;
1837
- fileTree(directoryPath?: string): Promise<DocTreeNode[]>;
1838
- directoryTree(directoryPath?: string): Promise<DocTreeDirectoryNode[]>;
1839
- }
1840
-
1841
- declare const zJsonDocumentData$2: z.ZodRecord<z.ZodString, z.ZodString>;
1842
- type JsonDocumentData$2 = z.infer<typeof zJsonDocumentData$2>;
1843
- type JsonProps = {
1844
- data?: JsonDocumentData$2 | unknown;
1845
- basePath?: string;
1846
- pathSystem?: DocPathSystem;
1847
- onDataChange?: (data: JsonDocumentData$2) => void;
1327
+ type FileTypeToReference<FileType extends string, Schema extends DocCustomSchema> = FileType extends "index" ? DocFileIndexReference<Schema> : FileType extends "markdown" ? DocFileMdReference<Schema> : DocFileUnknownReference<Schema>;
1328
+ /**
1329
+ * Infer reference type from path
1330
+ */
1331
+ type InferReference<Path extends string, Schema extends DocCustomSchema> = FileTypeToReference<DetectFileType<Path>, Schema>;
1332
+ /**
1333
+ * File path information type
1334
+ */
1335
+ type DocFilePath = z.infer<typeof zDocFilePath>;
1336
+ /**
1337
+ * Markdown content information type
1338
+ */
1339
+ type DocFileMdContent<T extends DocCustomSchema = DocCustomSchema> = {
1340
+ type: "markdown-content";
1341
+ body: string;
1342
+ title: string;
1343
+ description: string;
1344
+ meta: SchemaToValueType<T>;
1848
1345
  };
1849
1346
  /**
1850
- * JSON-based file system with separate read/write components
1347
+ * Index file content information type
1851
1348
  */
1852
- declare class DocFileSystemJson extends DocFileSystem {
1853
- private readonly jsonReader;
1854
- private readonly jsonWriter;
1855
- constructor(props?: JsonProps);
1856
- /**
1857
- * Get the current JSON data
1858
- */
1859
- getData(): JsonDocumentData$2;
1860
- /**
1861
- * Update the entire JSON data
1862
- */
1863
- setData(data: JsonDocumentData$2 | unknown): Error | null;
1864
- /**
1865
- * Clear all data
1866
- */
1867
- clear(): void;
1868
- /**
1869
- * Get all file paths in the JSON data
1870
- */
1871
- getAllFilePaths(): string[];
1872
- /**
1873
- * Get the raw JSON data (read-only copy)
1874
- */
1875
- getRawData(): JsonDocumentData$2;
1876
- /**
1877
- * Create from docs-to-json format
1878
- */
1879
- static fromDocsToJson(data: Record<string, string> | unknown, options?: Omit<JsonProps, "data">): DocFileSystemJson;
1880
- /**
1881
- * Export to docs-to-json format
1882
- */
1883
- toDocsToJson(): Record<string, string>;
1884
- }
1885
-
1886
- declare const zJsonDocumentData$1: z.ZodRecord<z.ZodString, z.ZodString>;
1887
- type JsonDocumentData$1 = z.infer<typeof zJsonDocumentData$1>;
1888
- type Props$5 = {
1889
- data: JsonDocumentData$1 | unknown;
1890
- basePath?: string;
1891
- pathSystem?: DocPathSystem;
1349
+ type DocFileIndexContent<T extends DocCustomSchema = DocCustomSchema> = {
1350
+ type: "markdown-index";
1351
+ body: string;
1352
+ title: string;
1353
+ description: string;
1354
+ meta: DocFileIndexMeta<T>;
1892
1355
  };
1893
1356
  /**
1894
- * JSON-based read-only file system implementation
1357
+ * Directory response type (re-export from server package)
1895
1358
  */
1896
- declare class DocFileSystemJsonRead implements DocFileSystemReadType {
1897
- private readonly data;
1898
- private readonly basePath;
1899
- private readonly pathSystem;
1900
- constructor(props: Props$5);
1901
- /**
1902
- * Read file content from JSON data
1903
- */
1904
- readFile(relativePath: string): Promise<string | null | Error>;
1905
- /**
1906
- * Get file name from path
1907
- */
1908
- readFileName(relativePath: string): string;
1909
- /**
1910
- * Get file extension from path
1911
- */
1912
- readFileExtension(relativePath: string): string;
1913
- /**
1914
- * Get directory path where the file exists
1915
- */
1916
- readFileDirectory(relativePath: string): string;
1917
- /**
1918
- * Get list of file names in directory
1919
- */
1920
- readDirectoryFileNames(relativePath?: string): Promise<string[] | Error>;
1921
- /**
1922
- * Get list of file paths in directory
1923
- */
1924
- readDirectoryFilePaths(relativePath: string): Promise<string[] | Error>;
1925
- /**
1926
- * Check if path is a directory
1927
- */
1928
- isDirectory(relativePath: string): Promise<boolean>;
1929
- /**
1930
- * Check if path is a file
1931
- */
1932
- isFile(relativePath: string): Promise<boolean>;
1933
- /**
1934
- * Check if file or directory exists
1935
- */
1936
- exists(relativePath: string): Promise<boolean>;
1937
- /**
1938
- * Check if directory exists
1939
- */
1940
- directoryExists(relativePath: string): Promise<boolean>;
1941
- /**
1942
- * Check if file exists
1943
- */
1944
- fileExists(relativePath: string): Promise<boolean>;
1945
- /**
1946
- * Get base path
1947
- */
1948
- getBasePath(): string;
1949
- /**
1950
- * Convert relative path to absolute path
1951
- */
1952
- resolve(relativePath: string): string;
1953
- /**
1954
- * Get file size in bytes
1955
- */
1956
- getFileSize(relativePath: string): Promise<number | Error>;
1957
- /**
1958
- * Get file last modified time (not available for JSON data)
1959
- */
1960
- getFileModifiedTime(_relativePath: string): Promise<Date | Error>;
1961
- /**
1962
- * Get file creation time (not available for JSON data)
1963
- */
1964
- getFileCreatedTime(_relativePath: string): Promise<Date | Error>;
1965
- /**
1966
- * Get all file paths in the JSON data
1967
- */
1968
- getAllFilePaths(): string[];
1969
- /**
1970
- * Get the raw JSON data
1971
- */
1972
- getRawData(): JsonDocumentData$1;
1973
- /**
1974
- * Normalize path by removing leading/trailing slashes
1975
- */
1976
- private normalizePath;
1977
- /**
1978
- * Check if a file path is within a directory
1979
- */
1980
- private isFileInDirectory;
1981
- /**
1982
- * Get the relative part of a file path from a directory
1983
- */
1984
- private getRelativePartFromDirectory;
1985
- }
1986
-
1987
- declare const zJsonDocumentData: z.ZodRecord<z.ZodString, z.ZodString>;
1988
- type JsonDocumentData = z.infer<typeof zJsonDocumentData>;
1989
- type Props$4 = {
1990
- data?: JsonDocumentData | unknown;
1991
- basePath?: string;
1992
- pathSystem?: DocPathSystem;
1993
- reader?: DocFileSystemReadType;
1994
- onDataChange?: (data: JsonDocumentData) => void;
1359
+ type DocDirectory<T extends DocCustomSchema> = {
1360
+ cwd: string;
1361
+ indexFile: DocFileIndex<T>;
1362
+ files: DocFile<T>[];
1363
+ relations: DocRelation[];
1995
1364
  };
1365
+ type RecordKey = PropertyKey;
1996
1366
  /**
1997
- * JSON-based write-only file system implementation
1367
+ * DocClient configuration
1998
1368
  */
1999
- declare class DocFileSystemJsonWrite implements DocFileSystemWriteType {
2000
- private data;
2001
- private readonly basePath;
2002
- private readonly pathSystem;
2003
- private readonly reader?;
2004
- private readonly onDataChange?;
2005
- constructor(props?: Props$4);
2006
- /**
2007
- * Write content to JSON data
2008
- */
2009
- writeFile(relativePath: string, content: string): Promise<Error | null>;
2010
- /**
2011
- * Delete file from JSON data
2012
- */
2013
- deleteFile(relativePath: string): Promise<Error | null>;
2014
- /**
2015
- * Create directory (creates a placeholder entry)
2016
- */
2017
- createDirectory(relativePath: string): Promise<Error | null>;
2018
- /**
2019
- * Create directory if it doesn't exist
2020
- */
2021
- ensureDirectoryExists(relativePath: string): Promise<Error | null>;
2022
- /**
2023
- * Copy file within JSON data
2024
- */
2025
- copyFile(sourcePath: string, destinationPath: string): Promise<Error | null>;
2026
- /**
2027
- * Move file within JSON data
2028
- */
2029
- moveFile(sourcePath: string, destinationPath: string): Promise<Error | null>;
2030
- /**
2031
- * Get the current JSON data
2032
- */
2033
- getData(): JsonDocumentData;
2034
- /**
2035
- * Update the entire JSON data
2036
- */
2037
- setData(data: JsonDocumentData | unknown): Error | null;
2038
- /**
2039
- * Clear all data
2040
- */
2041
- clear(): void;
2042
- /**
2043
- * Get all file paths in the JSON data
2044
- */
2045
- getAllFilePaths(): string[];
2046
- /**
2047
- * Normalize path by removing leading/trailing slashes
2048
- */
2049
- private normalizePath;
2050
- /**
2051
- * Check if directory exists in data
2052
- */
2053
- private directoryExistsInData;
2054
- /**
2055
- * Notify data change callback
2056
- */
2057
- private notifyDataChange;
2058
- }
2059
-
1369
+ type DocClientConfig = z.infer<typeof zDocClientConfig>;
1370
+ /**
1371
+ * Type definitions for DocFileMdMetaValue
1372
+ */
1373
+ type ExtractFieldType<T> = T extends {
1374
+ type: infer Type;
1375
+ } ? Type : never;
1376
+ type ExtractRequired<T> = T extends {
1377
+ required: infer Required;
1378
+ } ? Required : false;
1379
+ 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;
1380
+ type FieldValueType<Type, Required> = Required extends true ? BaseFieldValueType<Type> : BaseFieldValueType<Type> | null;
1381
+ /**
1382
+ * Extract required field keys
1383
+ */
1384
+ type RequiredKeys<T extends DocCustomSchema> = {
1385
+ [K in keyof T]: T[K] extends {
1386
+ required: true;
1387
+ } ? K : never;
1388
+ }[keyof T];
1389
+ /**
1390
+ * Extract optional field keys
1391
+ */
1392
+ type OptionalKeys<T extends DocCustomSchema> = {
1393
+ [K in keyof T]: T[K] extends {
1394
+ required: true;
1395
+ } ? never : K;
1396
+ }[keyof T];
2060
1397
  /**
2061
- * In-memory file system for testing
1398
+ * Generate expected value type from schema (considering required)
2062
1399
  */
2063
- declare class DocFileSystemMock extends DocFileSystem {
2064
- private files;
2065
- private readonly _pathSystem;
2066
- private readonly _basePath;
2067
- constructor(props: {
2068
- basePath: string;
2069
- pathSystem: DocPathSystem;
2070
- skipDefaultFiles?: boolean;
2071
- });
2072
- /**
2073
- * PathSystem accessor (for testing)
2074
- */
2075
- getPathSystem(): DocPathSystem;
2076
- /**
2077
- * Normalize path using basePath
2078
- */
2079
- private normalizePath;
2080
- /**
2081
- * Create instance (mock data is automatically loaded)
2082
- */
2083
- static create(basePath?: string): DocFileSystemMock;
2084
- /**
2085
- * Factory method for testing
2086
- */
2087
- static createWithFiles(props: {
2088
- basePath?: string;
2089
- fileContents?: Record<string, string>;
2090
- }): DocFileSystemMock;
2091
- readFile(filePath: string): Promise<string | null | Error>;
2092
- writeFile(filePath: string, content: string): Promise<Error | null>;
2093
- deleteFile(filePath: string): Promise<Error | null>;
2094
- exists(filePath: string): Promise<boolean>;
2095
- copyFile(source: string, destination: string): Promise<Error | null>;
2096
- moveFile(source: string, destination: string): Promise<Error | null>;
2097
- readDirectory(directoryPath: string): Promise<string[]>;
2098
- readDirectoryRecursive(directoryPath: string): Promise<string[]>;
2099
- readDirectoryFilePaths(directoryPath: string): Promise<string[] | Error>;
2100
- createDirectory(_directoryPath: string): Promise<Error | null>;
2101
- deleteDirectory(directoryPath: string): Promise<void>;
2102
- getFileSize(filePath: string): Promise<number | Error>;
2103
- getFileModifiedTime(filePath: string): Promise<Date | Error>;
2104
- getFileCreatedTime(filePath: string): Promise<Date | Error>;
2105
- isDirectory(relativePath: string): Promise<boolean>;
2106
- isFile(relativePath: string): Promise<boolean>;
2107
- /**
2108
- * Get list of entries in directory
2109
- */
2110
- readDirectoryFileNames(directoryPath?: string): Promise<string[] | Error>;
2111
- /**
2112
- * Check if directory exists
2113
- */
2114
- directoryExists(relativePath: string): Promise<boolean>;
2115
- /**
2116
- * Check if file exists
2117
- */
2118
- fileExists(relativePath: string): Promise<boolean>;
2119
- /**
2120
- * Create directory if it doesn't exist
2121
- */
2122
- ensureDirectoryExists(_relativePath: string): Promise<Error | null>;
2123
- /**
2124
- * Clear all files
2125
- */
2126
- clear(): void;
2127
- /**
2128
- * Check file existence (for testing)
2129
- */
2130
- hasFile(filePath: string): boolean;
2131
- /**
2132
- * Get file content (sync version, for testing)
2133
- */
2134
- getFileContent(filePath: string): string | undefined;
2135
- /**
2136
- * Get all file paths (for testing)
2137
- */
2138
- getAllFilePaths(): string[];
2139
- /**
2140
- * Get file count (for testing)
2141
- */
2142
- getFileCount(): number;
2143
- /**
2144
- * Setup test data
2145
- */
2146
- setupTestFiles(files: Record<string, string>): void;
2147
- }
2148
-
2149
- type GitHubProps = {
2150
- owner: string;
2151
- repo: string;
2152
- basePath: string;
2153
- branch?: string;
2154
- token: string;
2155
- pathSystem?: DocPathSystem;
1400
+ type SchemaToValueType<T extends DocCustomSchema> = {
1401
+ [K in RequiredKeys<T>]: BaseFieldValueType<ExtractFieldType<T[K]>>;
1402
+ } & {
1403
+ [K in OptionalKeys<T>]: BaseFieldValueType<ExtractFieldType<T[K]>> | null;
2156
1404
  };
2157
1405
  /**
2158
- * GitHub repository file system using Octokit with separate read/write components
1406
+ * Helper type for type-safe property access
2159
1407
  */
2160
- declare class DocFileSystemOctokit extends DocFileSystem {
2161
- private readonly owner;
2162
- private readonly repo;
2163
- private readonly branch;
2164
- constructor(props: GitHubProps);
2165
- /**
2166
- * Get repository information
2167
- */
2168
- getRepositoryInfo(): {
2169
- owner: string;
2170
- repo: string;
2171
- branch: string;
2172
- };
2173
- }
1408
+ type GetValueType<T extends DocCustomSchema, K extends keyof T> = K extends RequiredKeys<T> ? BaseFieldValueType<ExtractFieldType<T[K]>> : BaseFieldValueType<ExtractFieldType<T[K]>> | undefined | null;
1409
+ type GetIndexFieldType<Schema extends DocFileIndexSchema<RecordKey>, K extends keyof Schema> = Schema[K] extends DocFileIndexSchemaField ? Schema[K] : never;
1410
+ /**
1411
+ * Infers DocFileMd type from the result of defineSchema
1412
+ */
1413
+ type InferDocFileMd<T> = T extends DocCustomSchema ? DocFileMd<T> : never;
1414
+
1415
+ declare const DOC_NODE_TYPE_DIRECTORY: "directory";
2174
1416
 
2175
1417
  type Props$3 = {
2176
- owner: string;
2177
- repo: string;
2178
- basePath: string;
2179
- branch?: string;
2180
- token: string;
2181
- pathSystem?: DocPathSystem;
2182
- };
2183
- type FileCache = {
2184
- sha: string;
2185
- content: string;
2186
- size: number;
2187
- modifiedTime?: string;
1418
+ name: string;
1419
+ path: string;
1420
+ icon: string;
1421
+ title: string;
2188
1422
  };
2189
1423
  /**
2190
- * GitHub repository read-only file system using Octokit
1424
+ * Tree file node value object
2191
1425
  */
2192
- declare class DocFileSystemOctokitRead implements DocFileSystemReadType {
2193
- protected readonly octokit: Octokit;
2194
- protected readonly owner: string;
2195
- protected readonly repo: string;
2196
- protected readonly branch: string;
2197
- protected readonly pathSystem: DocPathSystem;
2198
- protected readonly basePath: string;
2199
- protected fileCache: Map<string, FileCache>;
1426
+ declare class DocTreeFileNodeValue {
1427
+ private readonly props;
2200
1428
  constructor(props: Props$3);
1429
+ get name(): string;
1430
+ get path(): string;
1431
+ get icon(): string;
1432
+ get title(): string;
1433
+ get type(): "file";
2201
1434
  /**
2202
- * Read file content from GitHub repository
2203
- */
2204
- readFile(relativePath: string): Promise<string | null | Error>;
2205
- /**
2206
- * Get file name from path
2207
- */
2208
- readFileName(relativePath: string): string;
2209
- /**
2210
- * Get file extension from path
2211
- */
2212
- readFileExtension(relativePath: string): string;
2213
- /**
2214
- * Get directory path where the file exists
2215
- */
2216
- readFileDirectory(relativePath: string): string;
2217
- /**
2218
- * Get list of file names in directory
2219
- */
2220
- readDirectoryFileNames(relativePath?: string): Promise<string[] | Error>;
2221
- /**
2222
- * Get list of file paths in directory
2223
- */
2224
- readDirectoryFilePaths(relativePath: string): Promise<string[] | Error>;
2225
- /**
2226
- * Check if path is a directory
2227
- */
2228
- isDirectory(relativePath: string): Promise<boolean>;
2229
- /**
2230
- * Check if path is a file
2231
- */
2232
- isFile(relativePath: string): Promise<boolean>;
2233
- /**
2234
- * Check if file or directory exists
2235
- */
2236
- exists(relativePath: string): Promise<boolean>;
2237
- /**
2238
- * Check if directory exists
2239
- */
2240
- directoryExists(relativePath: string): Promise<boolean>;
2241
- /**
2242
- * Check if file exists
2243
- */
2244
- fileExists(relativePath: string): Promise<boolean>;
2245
- /**
2246
- * Get base path
2247
- */
2248
- getBasePath(): string;
2249
- /**
2250
- * Convert relative path to absolute path
2251
- */
2252
- resolve(relativePath: string): string;
2253
- /**
2254
- * Get file size in bytes
2255
- */
2256
- getFileSize(relativePath: string): Promise<number | Error>;
2257
- /**
2258
- * Get file last modified time
1435
+ * Convert to plain object
2259
1436
  */
2260
- getFileModifiedTime(relativePath: string): Promise<Date | Error>;
1437
+ toJson(): DocTreeFileNode;
2261
1438
  /**
2262
- * Get file creation time (first commit)
1439
+ * Create from properties
2263
1440
  */
2264
- getFileCreatedTime(relativePath: string): Promise<Date | Error>;
1441
+ static from(props: Props$3): DocTreeFileNodeValue;
2265
1442
  /**
2266
- * Get cached SHA for a file
1443
+ * Create from JSON object
2267
1444
  */
2268
- getCachedSha(relativePath: string): string | undefined;
1445
+ static fromJson(json: unknown): DocTreeFileNodeValue;
2269
1446
  }
2270
1447
 
1448
+ type DocTreeNodeValue = DocTreeFileNodeValue | DocTreeDirectoryNodeValue;
1449
+
2271
1450
  type Props$2 = {
2272
- owner: string;
2273
- repo: string;
2274
- basePath: string;
2275
- branch?: string;
2276
- token: string;
2277
- pathSystem?: DocPathSystem;
2278
- reader?: DocFileSystemReadType;
1451
+ name: string;
1452
+ path: string;
1453
+ icon: string;
1454
+ title: string;
1455
+ children: DocTreeNodeValue[];
2279
1456
  };
2280
1457
  /**
2281
- * GitHub repository write-only file system using Octokit
1458
+ * Tree directory node value object
2282
1459
  */
2283
- declare class DocFileSystemOctokitWrite implements DocFileSystemWriteType {
2284
- private readonly octokit;
2285
- private readonly owner;
2286
- private readonly repo;
2287
- private readonly basePath;
2288
- private readonly branch;
2289
- private readonly pathSystem;
2290
- private readonly reader?;
1460
+ declare class DocTreeDirectoryNodeValue {
1461
+ private readonly props;
2291
1462
  constructor(props: Props$2);
1463
+ get name(): string;
1464
+ get path(): string;
1465
+ get icon(): string;
1466
+ get title(): string;
1467
+ get children(): DocTreeNodeValue[];
1468
+ get type(): typeof DOC_NODE_TYPE_DIRECTORY;
2292
1469
  /**
2293
- * Write content to file in GitHub repository
2294
- */
2295
- writeFile(relativePath: string, content: string): Promise<Error | null>;
2296
- /**
2297
- * Delete file from GitHub repository
2298
- */
2299
- deleteFile(relativePath: string): Promise<Error | null>;
2300
- /**
2301
- * Create directory by creating a .gitkeep file
2302
- */
2303
- createDirectory(relativePath: string): Promise<Error | null>;
2304
- /**
2305
- * Create directory if it doesn't exist
1470
+ * Convert to plain object
2306
1471
  */
2307
- ensureDirectoryExists(relativePath: string): Promise<Error | null>;
1472
+ toJson(): DocTreeDirectoryNode;
2308
1473
  /**
2309
- * Copy file to new location
1474
+ * Create from properties
2310
1475
  */
2311
- copyFile(sourcePath: string, destinationPath: string): Promise<Error | null>;
1476
+ static from(props: Props$2): DocTreeDirectoryNodeValue;
2312
1477
  /**
2313
- * Move file to new location
1478
+ * Create from JSON object
2314
1479
  */
2315
- moveFile(sourcePath: string, destinationPath: string): Promise<Error | null>;
1480
+ static fromJson(json: unknown): DocTreeDirectoryNodeValue;
2316
1481
  }
2317
1482
 
2318
1483
  type Props$1 = {
2319
- basePath: string;
2320
- pathSystem?: DocPathSystem;
1484
+ fileSystem: DocFileSystemInterface;
1485
+ pathSystem: DocPathSystem;
1486
+ indexFileName: string;
1487
+ archiveDirectoryName: string;
1488
+ config: DocClientConfig;
2321
1489
  };
2322
1490
  /**
2323
- * Read-only file system implementation
1491
+ * File tree building system
2324
1492
  */
2325
- declare class DocFileSystemRead implements DocFileSystemReadType {
2326
- protected readonly basePath: string;
2327
- protected readonly pathSystem: DocPathSystem;
1493
+ declare class DocFileTreeSystem {
1494
+ private readonly props;
1495
+ private readonly config;
2328
1496
  constructor(props: Props$1);
2329
1497
  /**
2330
- * Read file content at the specified path
1498
+ * Build file tree recursively
1499
+ */
1500
+ buildFileTree(directoryPath?: string): Promise<DocTreeNodeValue[] | Error>;
1501
+ /**
1502
+ * Create file node
2331
1503
  */
2332
- readFile(relativePath: string): Promise<string | null | Error>;
1504
+ private createFileNode;
2333
1505
  /**
2334
- * Get file name from path
1506
+ * Create directory node
2335
1507
  */
2336
- readFileName(relativePath: string): string;
1508
+ private createDirectoryNode;
2337
1509
  /**
2338
- * Get file extension from path
1510
+ * Create index file reference
2339
1511
  */
2340
- readFileExtension(relativePath: string): string;
1512
+ private createIndexFileReference;
2341
1513
  /**
2342
- * Get directory path where the file exists
1514
+ * Create MD file reference
2343
1515
  */
2344
- readFileDirectory(relativePath: string): string;
1516
+ private createMdFileReference;
2345
1517
  /**
2346
- * Get list of entries in directory
1518
+ * Build directory tree recursively (directories only)
2347
1519
  */
2348
- readDirectoryFileNames(relativePath?: string): Promise<string[] | Error>;
2349
- readDirectoryFilePaths(relativePath: string): Promise<string[] | Error>;
1520
+ buildDirectoryTree(directoryPath?: string): Promise<DocTreeDirectoryNodeValue[] | Error>;
2350
1521
  /**
2351
- * Check if path is a directory
1522
+ * Create directory node for directory tree
2352
1523
  */
2353
- isDirectory(relativePath: string): Promise<boolean>;
1524
+ private createDirectoryNodeForTree;
1525
+ }
1526
+
1527
+ /**
1528
+ * Markdown parsing and processing system
1529
+ */
1530
+ declare class DocMarkdownSystem {
1531
+ private readonly frontMatterSeparator;
1532
+ constructor();
2354
1533
  /**
2355
- * Check if path is a file
1534
+ * Detect FrontMatter separator line
2356
1535
  */
2357
- isFile(relativePath: string): Promise<boolean>;
1536
+ private detectFrontMatterSeparator;
2358
1537
  /**
2359
- * Check if file or directory exists
1538
+ * Extract FrontMatter
2360
1539
  */
2361
- exists(relativePath: string): Promise<boolean>;
1540
+ extractFrontMatter(text: string): string | null;
2362
1541
  /**
2363
- * Check if directory exists
1542
+ * Extract body without FrontMatter (includes title and description)
2364
1543
  */
2365
- directoryExists(relativePath: string): Promise<boolean>;
1544
+ extractBody(text: string): string;
2366
1545
  /**
2367
- * Check if file exists
1546
+ * Extract title
2368
1547
  */
2369
- fileExists(relativePath: string): Promise<boolean>;
1548
+ extractTitle(text: string): string | null;
2370
1549
  /**
2371
- * Get base path
1550
+ * Extract description (first paragraph after title)
2372
1551
  */
2373
- getBasePath(): string;
1552
+ extractDescription(text: string): string | null;
2374
1553
  /**
2375
- * Convert relative path to absolute path
1554
+ * Update title in body (returns body only, without FrontMatter)
2376
1555
  */
2377
- resolve(relativePath: string): string;
1556
+ updateTitle(text: string, newTitle: string): string;
2378
1557
  /**
2379
- * Get file size in bytes
1558
+ * Update description in body (returns body only, without FrontMatter)
2380
1559
  */
2381
- getFileSize(relativePath: string): Promise<number | Error>;
1560
+ updateDescription(text: string, newDescription: string, defaultTitle: string): string;
2382
1561
  /**
2383
- * Get file last modified time
1562
+ * Skip empty lines
2384
1563
  */
2385
- getFileModifiedTime(relativePath: string): Promise<Date | Error>;
1564
+ private skipEmptyLines;
2386
1565
  /**
2387
- * Get file creation time
1566
+ * Generate Markdown text (title + description + body)
2388
1567
  */
2389
- getFileCreatedTime(relativePath: string): Promise<Date | Error>;
1568
+ static from(title: string, description: string, body: string): string;
2390
1569
  }
2391
1570
 
2392
1571
  type Props = {
2393
- basePath: string;
1572
+ fileSystem: DocFileSystemInterface;
2394
1573
  pathSystem?: DocPathSystem;
2395
- reader?: DocFileSystemReadType;
2396
- };
2397
- /**
2398
- * Write-only file system implementation
2399
- */
2400
- declare class DocFileSystemWrite implements DocFileSystemWriteType {
2401
- protected readonly basePath: string;
2402
- protected readonly pathSystem: DocPathSystem;
2403
- private readonly reader?;
2404
- constructor(props: Props);
2405
- /**
2406
- * Write content to file at the specified path (creates directory if needed)
2407
- */
2408
- writeFile(relativePath: string, content: string): Promise<Error | null>;
2409
- /**
2410
- * Delete file at the specified path
2411
- */
2412
- deleteFile(relativePath: string): Promise<Error | null>;
2413
- /**
2414
- * Create directory
2415
- */
2416
- createDirectory(relativePath: string): Promise<Error | null>;
2417
- /**
2418
- * Create directory if it doesn't exist
2419
- */
2420
- ensureDirectoryExists(relativePath: string): Promise<Error | null>;
2421
- /**
2422
- * Copy file
2423
- */
2424
- copyFile(sourcePath: string, destinationPath: string): Promise<Error | null>;
1574
+ markdownSystem?: DocMarkdownSystem;
1575
+ fileTreeSystem?: DocFileTreeSystem;
2425
1576
  /**
2426
- * Move file
1577
+ * Configuration
2427
1578
  */
2428
- moveFile(sourcePath: string, destinationPath: string): Promise<Error | null>;
1579
+ config?: DocClientConfig;
1580
+ };
1581
+ declare class DocClient {
1582
+ readonly fileSystem: DocFileSystemInterface;
1583
+ readonly pathSystem: DocPathSystem;
1584
+ readonly markdownSystem: DocMarkdownSystem;
1585
+ readonly fileTreeSystem: DocFileTreeSystem;
1586
+ readonly config: DocClientConfig;
1587
+ constructor(props: Props);
1588
+ basePath(): string;
1589
+ file<Path extends string>(relativePath: Path): InferReference<Path, DocCustomSchema>;
1590
+ file<Path extends string, T extends DocCustomSchema>(relativePath: Path, customSchema: T): InferReference<Path, T>;
1591
+ mdFile(relativePath: string): DocFileMdReference<DocCustomSchema>;
1592
+ mdFile<T extends DocCustomSchema>(relativePath: string, customSchema: T): DocFileMdReference<T>;
1593
+ indexFile(relativePath: string): DocFileIndexReference<DocCustomSchema>;
1594
+ indexFile<T extends DocCustomSchema>(relativePath: string, customSchema: T): DocFileIndexReference<T>;
1595
+ directory(relativePath: string): DocDirectoryReference<DocCustomSchema>;
1596
+ directory<T extends DocCustomSchema>(relativePath: string, customSchema: T): DocDirectoryReference<T>;
1597
+ fileTree(directoryPath?: string): Promise<DocTreeNode[]>;
1598
+ directoryTree(directoryPath?: string): Promise<DocTreeDirectoryNode[]>;
2429
1599
  }
2430
1600
 
2431
1601
  /**
@@ -2449,67 +1619,6 @@ declare class DocPathSystemMock extends DocPathSystem {
2449
1619
  static createWithSeparator(separator: string): DocPathSystemMock;
2450
1620
  }
2451
1621
 
2452
- /**
2453
- * Schema builder
2454
- * Build schemas in a chain style
2455
- *
2456
- * @example
2457
- * const schema = new SchemaBuilder()
2458
- * .text("title", true)
2459
- * .multiRelation("features", true)
2460
- * .selectText("priority", false)
2461
- * .build()
2462
- */
2463
- declare class DocSchemaBuilder<T extends DocCustomSchema> {
2464
- private schema;
2465
- constructor(schema?: T);
2466
- text<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
2467
- type: "text";
2468
- required: boolean;
2469
- }>>;
2470
- number<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
2471
- type: "number";
2472
- required: boolean;
2473
- }>>;
2474
- boolean<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
2475
- type: "boolean";
2476
- required: boolean;
2477
- }>>;
2478
- relation<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
2479
- type: "relation";
2480
- required: boolean;
2481
- }>>;
2482
- multiRelation<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
2483
- type: "multi-relation";
2484
- required: boolean;
2485
- }>>;
2486
- selectText<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
2487
- type: "select-text";
2488
- required: boolean;
2489
- }>>;
2490
- selectNumber<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
2491
- type: "select-number";
2492
- required: boolean;
2493
- }>>;
2494
- multiText<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
2495
- type: "multi-text";
2496
- required: boolean;
2497
- }>>;
2498
- multiNumber<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
2499
- type: "multi-number";
2500
- required: boolean;
2501
- }>>;
2502
- multiSelectText<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
2503
- type: "multi-select-text";
2504
- required: boolean;
2505
- }>>;
2506
- multiSelectNumber<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
2507
- type: "multi-select-number";
2508
- required: boolean;
2509
- }>>;
2510
- build(): T;
2511
- }
2512
-
2513
1622
  /**
2514
1623
  * Function that only performs type checking (does nothing at runtime)
2515
1624
  */
@@ -2561,13 +1670,19 @@ declare const docCustomSchemaField: {
2561
1670
  type: "boolean";
2562
1671
  required: boolean;
2563
1672
  };
2564
- readonly relation: (required: boolean) => {
1673
+ readonly relation: (required: boolean, path: string) => {
2565
1674
  type: "relation";
2566
1675
  required: boolean;
1676
+ title: null;
1677
+ description: null;
1678
+ path: string;
2567
1679
  };
2568
- readonly multiRelation: (required: boolean) => {
1680
+ readonly multiRelation: (required: boolean, path: string) => {
2569
1681
  type: "multi-relation";
2570
1682
  required: boolean;
1683
+ title: null;
1684
+ description: null;
1685
+ path: string;
2571
1686
  };
2572
1687
  readonly selectText: (required: boolean) => {
2573
1688
  type: "select-text";
@@ -2788,4 +1903,4 @@ declare class DocRelationFieldValue {
2788
1903
  }): DocRelationFieldValue;
2789
1904
  }
2790
1905
 
2791
- 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, DocFileSystemJson, DocFileSystemJsonRead, DocFileSystemJsonWrite, DocFileSystemMock, DocFileSystemOctokit, DocFileSystemOctokitRead, DocFileSystemOctokitWrite, DocFileSystemRead, type DocFileSystemReadType, DocFileSystemWrite, type DocFileSystemWriteType, 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 };
1906
+ 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 };