@interactive-inc/docs-client 1.0.20 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.d.ts CHANGED
@@ -1,334 +1,615 @@
1
+ import { D as DocFileSystem, a as DocPathSystem } from './doc-file-system-BQAOBIO-.js';
1
2
  import { z } from 'zod';
2
3
  import { zDocFileMd, zDocFileUnknown, zDocClientConfig, zDocFilePath, zDocFileIndexSchemaField, zDocSchemaFieldText, zDocSchemaFieldNumber, zDocSchemaFieldBoolean, zDocSchemaFieldRelation, zDocSchemaFieldSelectText, zDocSchemaFieldSelectNumber, zDocSchemaFieldMultiText, zDocSchemaFieldMultiNumber, zDocSchemaFieldMultiRelation, zDocSchemaFieldMultiSelectText, zDocSchemaFieldMultiSelectNumber, zDocFileIndex, zDocRelation, zDocRelationFile, zDocMetaFieldRelation, zDocMetaFieldMultiRelation, zDocMetaFieldText, zDocMetaFieldNumber, zDocMetaFieldBoolean, zDocMetaFieldMultiText, zDocMetaFieldMultiNumber, zDocRelationField, zDocMetaField, zDocMetaFieldSelectText, zDocMetaFieldSelectNumber, zDocMetaFieldMultiSelectText, zDocMetaFieldMultiSelectNumber, zDocMetaFieldTypeText, zDocMetaFieldTypeNumber, zDocMetaFieldTypeBoolean, zDocMetaFieldTypeSelectText, zDocMetaFieldTypeSelectNumber, zDocMetaFieldTypeRelation, zDocMetaFieldType } from './models.js';
3
4
  export { zDocCustomSchema, zDocCustomSchemaField, zDocCustomSchemaFieldBoolean, zDocCustomSchemaFieldMultiNumber, zDocCustomSchemaFieldMultiRelation, zDocCustomSchemaFieldMultiSelectNumber, zDocCustomSchemaFieldMultiSelectText, zDocCustomSchemaFieldMultiText, zDocCustomSchemaFieldNumber, zDocCustomSchemaFieldRelation, zDocCustomSchemaFieldSelectNumber, zDocCustomSchemaFieldSelectText, zDocCustomSchemaFieldText, zDocFile, zDocFileDirectory, zDocFileIndexContent, zDocFileIndexMeta, zDocFileIndexMetaInput, zDocFileIndexSchema, zDocFileIndexSchemaInput, zDocFileMdContent, zDocFileMdContentInput, zDocFileMdInput, zDocFileMdMeta, zDocFileMdMetaInput, zDocMetaFieldTypeMultiNumber, zDocMetaFieldTypeMultiRelation, zDocMetaFieldTypeMultiSelectNumber, zDocMetaFieldTypeMultiSelectText, zDocMetaFieldTypeMultiText, zDocTreeDirectoryNode, zDocTreeFileNode, zDocTreeNode } from './models.js';
4
- import { Octokit } from '@octokit/rest';
5
5
 
6
6
  /**
7
- * Path operations system
7
+ * Single boolean type schema field
8
8
  */
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;
9
+ declare class DocSchemaFieldBooleanValue<T extends RecordKey> {
10
+ readonly key: T;
11
+ readonly value: DocSchemaFieldBoolean;
12
+ constructor(key: T, value: DocSchemaFieldBoolean);
13
+ get type(): "boolean";
14
+ get required(): boolean;
15
+ get title(): string;
16
+ get description(): string;
17
+ get default(): boolean | null;
18
+ readonly isArray = false;
19
+ readonly isSingle = true;
20
+ readonly isBoolean = true;
21
+ toJson(): DocFileIndexSchemaField;
39
22
  /**
40
- * Check if path is absolute
23
+ * Validate value type
41
24
  */
42
- isAbsolute(path: string): boolean;
25
+ validate(value: unknown): boolean;
26
+ static empty(key: RecordKey): DocSchemaFieldBooleanValue<RecordKey>;
27
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldBooleanValue<RecordKey>;
43
28
  }
44
29
 
45
30
  /**
46
- * Meta
31
+ * Multiple relation type schema field
47
32
  */
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;
33
+ declare class DocSchemaFieldMultiRelationValue<T extends RecordKey> {
34
+ readonly key: T;
35
+ readonly value: DocSchemaFieldMultiRelation;
36
+ constructor(key: T, value: DocSchemaFieldMultiRelation);
37
+ get type(): "multi-relation";
38
+ get required(): boolean;
39
+ get title(): string;
40
+ get description(): string;
41
+ get default(): string[] | null;
42
+ get path(): string;
43
+ readonly isArray = true;
44
+ readonly isSingle = false;
45
+ readonly isRelation = true;
71
46
  /**
72
- * Generate from Markdown text
47
+ * Validate value
73
48
  */
74
- static fromYamlText<T extends DocCustomSchema>(yamlText: string, customSchema: T): DocFileMdMetaValue<T>;
75
- static empty<T extends DocCustomSchema>(customSchema: T): DocFileMdMetaValue<T>;
49
+ validate(value: unknown): boolean;
50
+ toJson(): DocFileIndexSchemaField;
51
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiRelationValue<T>;
52
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiRelationValue<RecordKey>;
76
53
  }
77
54
 
78
55
  /**
79
- * File: Markdown > Content
56
+ * Multiple select number type schema field
80
57
  */
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
- */
58
+ declare class DocSchemaFieldMultiSelectNumberValue<T extends RecordKey> {
59
+ readonly key: T;
60
+ readonly value: DocSchemaFieldMultiSelectNumber;
61
+ constructor(key: T, value: DocSchemaFieldMultiSelectNumber);
62
+ get type(): "multi-select-number";
63
+ get required(): boolean;
92
64
  get title(): string;
93
- /**
94
- * Description
95
- */
96
65
  get description(): string;
66
+ get default(): number[] | null;
67
+ get options(): number[];
68
+ readonly isArray = true;
69
+ readonly isSingle = false;
70
+ readonly isSelect = true;
71
+ readonly isNumberSelect = true;
97
72
  /**
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
73
+ * Validate value
140
74
  */
141
- toJson(): DocFileMdContent<T>;
75
+ validate(value: unknown): boolean;
76
+ toJson(): DocFileIndexSchemaField;
77
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiSelectNumberValue<T>;
78
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiSelectNumberValue<RecordKey>;
142
79
  }
143
80
 
144
81
  /**
145
- * Markdown file entity
82
+ * Multiple select text type schema field
146
83
  */
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;
84
+ declare class DocSchemaFieldMultiSelectTextValue<T extends RecordKey> {
85
+ readonly key: T;
86
+ readonly value: DocSchemaFieldMultiSelectText;
87
+ constructor(key: T, value: DocSchemaFieldMultiSelectText);
88
+ get type(): "multi-select-text";
89
+ get required(): boolean;
90
+ get title(): string;
91
+ get description(): string;
92
+ get default(): string[] | null;
93
+ get options(): string[];
94
+ readonly isArray = true;
95
+ readonly isSingle = false;
96
+ readonly isSelect = true;
97
+ readonly isTextSelect = true;
159
98
  /**
160
- * Update content
99
+ * Validate value
161
100
  */
162
- withContent(content: DocFileMdContentValue<T>): DocFileMdEntity<T>;
163
- withContent(updater: UpdateFunction<DocFileMdContentValue<T>>): DocFileMdEntity<T>;
101
+ validate(value: unknown): boolean;
102
+ toJson(): DocFileIndexSchemaField;
103
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiSelectTextValue<T>;
104
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiSelectTextValue<RecordKey>;
105
+ }
106
+
107
+ /**
108
+ * Multiple text type schema field
109
+ */
110
+ declare class DocSchemaFieldMultiTextValue<T extends RecordKey> {
111
+ readonly key: T;
112
+ readonly value: DocSchemaFieldMultiText;
113
+ constructor(key: T, value: DocSchemaFieldMultiText);
114
+ get type(): "multi-text";
115
+ get required(): boolean;
116
+ get title(): string;
117
+ get description(): string;
118
+ get default(): string[] | null;
119
+ readonly isArray = true;
120
+ readonly isSingle = false;
121
+ readonly isText = true;
122
+ toJson(): DocFileIndexSchemaField;
164
123
  /**
165
- * Update path
124
+ * Validate value type
166
125
  */
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>;
126
+ validate(value: unknown): boolean;
127
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiTextValue<T>;
128
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiTextValue<RecordKey>;
129
+ }
130
+
131
+ /**
132
+ * Single number type schema field
133
+ */
134
+ declare class DocSchemaFieldNumberValue<T extends RecordKey> {
135
+ readonly key: T;
136
+ readonly value: DocSchemaFieldNumber;
137
+ constructor(key: T, value: DocSchemaFieldNumber);
138
+ get type(): "number";
139
+ get required(): boolean;
140
+ get title(): string;
141
+ get description(): string;
142
+ get default(): number | null;
143
+ readonly isArray = false;
144
+ readonly isSingle = true;
145
+ readonly isNumber = true;
146
+ toJson(): DocFileIndexSchemaField;
173
147
  /**
174
- * z.infer<typeof zDocFileMd>
148
+ * Validate value type
175
149
  */
176
- toJson(): z.infer<typeof zDocFileMd>;
150
+ validate(value: unknown): boolean;
151
+ static empty(key: RecordKey): DocSchemaFieldNumberValue<RecordKey>;
152
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldNumberValue<RecordKey>;
177
153
  }
178
154
 
179
- type Props$f<T extends DocCustomSchema> = {
180
- path: string;
181
- fileSystem: DocFileSystem;
182
- pathSystem: DocPathSystem;
183
- customSchema: T;
184
- config: DocClientConfig;
185
- };
186
155
  /**
187
- * File reference
156
+ * Single relation type schema field
188
157
  */
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;
158
+ declare class DocSchemaFieldRelationValue<T extends RecordKey> {
159
+ readonly key: T;
160
+ readonly value: DocSchemaFieldRelation;
161
+ constructor(key: T, value: DocSchemaFieldRelation);
162
+ get type(): "relation";
163
+ get required(): boolean;
164
+ get title(): string;
165
+ get description(): string;
166
+ get default(): string | null;
196
167
  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>;
168
+ readonly isArray = false;
169
+ readonly isSingle = true;
170
+ readonly isRelation = true;
171
+ toJson(): DocFileIndexSchemaField;
204
172
  /**
205
- * Read file content
173
+ * Validate value type
206
174
  */
207
- readText(): Promise<Error | string>;
175
+ validate(value: unknown): boolean;
176
+ static empty(key: RecordKey): DocSchemaFieldRelationValue<RecordKey>;
177
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldRelationValue<RecordKey>;
178
+ }
179
+
180
+ /**
181
+ * Single select number type schema field
182
+ */
183
+ declare class DocSchemaFieldSelectNumberValue<T extends RecordKey> {
184
+ readonly key: T;
185
+ readonly value: DocSchemaFieldSelectNumber;
186
+ constructor(key: T, value: DocSchemaFieldSelectNumber);
187
+ get type(): "select-number";
188
+ get required(): boolean;
189
+ get title(): string;
190
+ get description(): string;
191
+ get default(): number | null;
192
+ get options(): number[];
193
+ readonly isArray = false;
194
+ readonly isSingle = true;
195
+ readonly isSelect = true;
196
+ readonly isNumberSelect = true;
208
197
  /**
209
- * Create empty DocFileMdEntity
198
+ * Validate value
210
199
  */
211
- empty(): DocFileMdEntity<T>;
200
+ validate(value: unknown): boolean;
201
+ toJson(): DocFileIndexSchemaField;
202
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldSelectNumberValue<T>;
203
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldSelectNumberValue<RecordKey>;
204
+ }
205
+
206
+ /**
207
+ * Single select text type schema field
208
+ */
209
+ declare class DocSchemaFieldSelectTextValue<T extends RecordKey> {
210
+ readonly key: T;
211
+ readonly value: DocSchemaFieldSelectText;
212
+ constructor(key: T, value: DocSchemaFieldSelectText);
213
+ get type(): "select-text";
214
+ get required(): boolean;
215
+ get title(): string;
216
+ get description(): string;
217
+ get default(): string | null;
218
+ get options(): string[];
219
+ readonly isArray = false;
220
+ readonly isSingle = true;
221
+ readonly isSelect = true;
222
+ readonly isTextSelect = true;
223
+ toJson(): DocFileIndexSchemaField;
212
224
  /**
213
- * Write entity
225
+ * Validate value type
214
226
  */
215
- write(entity: DocFileMdEntity<T>): Promise<Error | null>;
216
- writeText(text: string): Promise<Error | null>;
227
+ validate(value: unknown): boolean;
228
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldSelectTextValue<T>;
229
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldSelectTextValue<RecordKey>;
230
+ }
231
+
232
+ /**
233
+ * Single text type schema field
234
+ */
235
+ declare class DocSchemaFieldTextValue<T extends RecordKey> {
236
+ readonly key: T;
237
+ readonly value: DocSchemaFieldText;
238
+ constructor(key: T, value: DocSchemaFieldText);
239
+ get type(): "text";
240
+ get required(): boolean;
241
+ get title(): string;
242
+ get description(): string;
243
+ get default(): string | null;
244
+ readonly isArray = false;
245
+ readonly isSingle = true;
246
+ readonly isText = true;
247
+ toJson(): DocFileIndexSchemaField;
217
248
  /**
218
- * Create new file with default content
249
+ * Validate value type
219
250
  */
220
- writeDefault(): Promise<Error | null>;
251
+ validate(value: unknown): boolean;
252
+ static empty(key: RecordKey): DocSchemaFieldTextValue<RecordKey>;
253
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldTextValue<RecordKey>;
254
+ }
255
+
256
+ /**
257
+ * Multiple number type schema field
258
+ */
259
+ declare class DocSchemaFieldMultiNumberValue<T extends RecordKey> {
260
+ readonly key: T;
261
+ readonly value: DocSchemaFieldMultiNumber;
262
+ constructor(key: T, value: DocSchemaFieldMultiNumber);
263
+ get type(): "multi-number";
264
+ get required(): boolean;
265
+ get title(): string;
266
+ get description(): string;
267
+ get default(): number[] | null;
268
+ readonly isArray = true;
269
+ readonly isSingle = false;
270
+ readonly isNumber = true;
221
271
  /**
222
- * Delete file
272
+ * Validate value
223
273
  */
224
- delete(): Promise<Error | null>;
274
+ validate(value: unknown): boolean;
275
+ toJson(): DocFileIndexSchemaField;
276
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiNumberValue<T>;
277
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiNumberValue<RecordKey>;
278
+ }
279
+
280
+ /**
281
+ * Type-safe schema value object
282
+ */
283
+ declare class DocFileIndexSchemaValue<T extends DocCustomSchema> {
284
+ readonly value: DocFileIndexSchema<keyof T>;
285
+ readonly customSchema: T;
286
+ constructor(value: DocFileIndexSchema<keyof T>, customSchema: T);
225
287
  /**
226
- * Copy file
288
+ * Get list of field names
289
+ * Automatically type-safe when using Zod schema
227
290
  */
228
- copyTo(destinationPath: string): Promise<Error | null>;
291
+ get fieldNames(): Array<keyof T>;
229
292
  /**
230
- * Move file
293
+ * Get field with specified field name
294
+ * Returns type-safe specific field Value object
231
295
  */
232
- moveTo(destinationPath: string): Promise<Error | null>;
296
+ field<K extends keyof T>(key: K): T[K]["type"] extends infer Type ? Type extends "text" ? DocSchemaFieldTextValue<K> : Type extends "number" ? DocSchemaFieldNumberValue<K> : Type extends "boolean" ? DocSchemaFieldBooleanValue<K> : Type extends "relation" ? DocSchemaFieldRelationValue<K> : Type extends "select-text" ? DocSchemaFieldSelectTextValue<K> : Type extends "select-number" ? DocSchemaFieldSelectNumberValue<K> : Type extends "multi-text" ? DocSchemaFieldMultiTextValue<K> : Type extends "multi-number" ? DocSchemaFieldMultiNumberValue<K> : Type extends "multi-relation" ? DocSchemaFieldMultiRelationValue<K> : Type extends "multi-select-text" ? DocSchemaFieldMultiSelectTextValue<K> : Type extends "multi-select-number" ? DocSchemaFieldMultiSelectNumberValue<K> : never : never;
297
+ relation<K extends keyof T>(key: K): DocSchemaFieldRelationValue<K>;
298
+ multiRelation<K extends keyof T>(key: K): DocSchemaFieldMultiRelationValue<K>;
299
+ toJson(): DocFileIndexSchema<keyof T>;
233
300
  /**
234
- * Move file to archive and return new reference
301
+ * Create empty schema entity
302
+ * biome-ignore lint/complexity/noBannedTypes: {} as DocCustomSchema
235
303
  */
236
- archive(archiveDirectoryName?: string): Promise<DocFileMdReference<T>>;
304
+ static empty(): DocFileIndexSchemaValue<{}>;
305
+ }
306
+
307
+ /**
308
+ * File: index.md > content > FrontMatter
309
+ */
310
+ declare class DocFileIndexMetaValue<T extends DocCustomSchema> {
311
+ readonly value: DocFileIndexMeta<T>;
312
+ readonly customSchema: T;
313
+ private readonly config;
314
+ private readonly additionalProperties;
315
+ constructor(value: DocFileIndexMeta<T>, customSchema: T, config: DocClientConfig, additionalProperties?: Record<string, unknown>);
237
316
  /**
238
- * Restore file from archive and return new reference
317
+ * Get icon
239
318
  */
240
- restore(archiveDirectoryName?: string): Promise<DocFileMdReference<T>>;
319
+ get icon(): string | null;
241
320
  /**
242
- * Get file size in bytes
321
+ * Get schema
243
322
  */
244
- size(): Promise<number | Error>;
323
+ schema(): DocFileIndexSchemaValue<T>;
245
324
  /**
246
- * Get file last modified time
325
+ * Check if schema is defined
247
326
  */
248
- lastModified(): Promise<Date | Error>;
327
+ get hasSchema(): boolean;
249
328
  /**
250
- * Get file creation time
329
+ * Update icon field
251
330
  */
252
- createdAt(): Promise<Date | Error>;
253
- directory(): DocDirectoryReference<T>;
331
+ withIcon(value: string | null): DocFileIndexMetaValue<T>;
254
332
  /**
255
- * Get relation based on schema
333
+ * Update schema field
256
334
  */
257
- relation<U extends DocCustomSchema = DocCustomSchema>(key: RelationKeys<T>, targetSchema?: U): Promise<DocFileMdReference<U> | Error | null>;
335
+ withSchema(value: DocFileIndexSchema<keyof T>): DocFileIndexMetaValue<T>;
258
336
  /**
259
- * Get index.md in the same directory
337
+ * Return a new instance with an unknown schema
338
+ * Allows accepting Record<string, unknown> schemas from external sources
260
339
  */
261
- directoryIndex(): Promise<DocFileIndexReference<T> | null>;
340
+ withUnknownSchema(draft: Record<string, unknown>): DocFileIndexMetaValue<DocCustomSchema>;
262
341
  /**
263
- * Get multiple relations based on schema
342
+ * Output in JSON format
264
343
  */
265
- relations<U extends DocCustomSchema = DocCustomSchema>(key: MultiRelationKeys<T>, customSchema?: U): Promise<DocFileMdReference<U>[]>;
344
+ toJson(): DocFileIndexMeta<T>;
266
345
  /**
267
- * File: Markdown > FrontMatter
346
+ * Output in YAML format
268
347
  */
269
- readFrontMatter(): Promise<DocFileMdMetaValue<T> | Error>;
348
+ toYaml(): string;
270
349
  /**
271
- * File: Markdown > FrontMatter
350
+ * Generate from Markdown text (can process incomplete data)
272
351
  */
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);
352
+ static from<T extends DocCustomSchema>(markdownText: string, customSchema: T, config: DocClientConfig): DocFileIndexMetaValue<T>;
282
353
  /**
283
- * Content
354
+ * Generate directly from data (can process incomplete data)
284
355
  */
285
- get content(): string;
356
+ static fromRecord<T extends DocCustomSchema>(record: Record<string, unknown>, customSchema: T, config: DocClientConfig): DocFileIndexMetaValue<T>;
286
357
  /**
287
- * Path information
358
+ * Generate empty FrontMatter
288
359
  */
289
- get path(): DocFilePath;
360
+ static empty<T extends DocCustomSchema>(customSchema: T, config: DocClientConfig): DocFileIndexMetaValue<T>;
290
361
  /**
291
- * Update content
362
+ * Extract icon
292
363
  */
293
- withContent(content: string): DocFileUnknownEntity;
364
+ private static extractIcon;
294
365
  /**
295
- * Update path
366
+ * Extract schema part
296
367
  */
297
- withPath(path: DocFilePath): DocFileUnknownEntity;
298
- withPath(updater: UpdateFunction<DocFilePath>): DocFileUnknownEntity;
299
- toJson(): z.infer<typeof zDocFileUnknown>;
368
+ private static extractSchema;
369
+ /**
370
+ * Normalize entire schema
371
+ */
372
+ private static normalizeSchema;
373
+ static emptySchema<T extends DocCustomSchema>(customSchema: T): DocFileIndexSchema<keyof T>;
300
374
  }
301
375
 
302
- type Props$e<T extends DocCustomSchema> = {
303
- path: string;
304
- fileSystem: DocFileSystem;
305
- pathSystem: DocPathSystem;
306
- customSchema: T;
307
- config: DocClientConfig;
308
- };
309
376
  /**
310
- * File reference
377
+ * File: index.md > content
311
378
  */
312
- declare class DocFileUnknownReference<T extends DocCustomSchema> {
313
- private readonly props;
314
- private readonly pathSystem;
379
+ declare class DocFileIndexContentValue<T extends DocCustomSchema> {
380
+ readonly value: DocFileIndexContent<T>;
315
381
  private readonly customSchema;
316
- constructor(props: Props$e<T>);
317
- get fileSystem(): DocFileSystem;
382
+ private readonly config;
383
+ constructor(value: DocFileIndexContent<T>, customSchema: T, config: DocClientConfig);
384
+ /**
385
+ * Content body (does not include frontMatter)
386
+ */
387
+ get body(): string;
388
+ /**
389
+ * Title
390
+ */
391
+ get title(): string;
392
+ /**
393
+ * Description
394
+ */
395
+ get description(): string;
396
+ /**
397
+ * FrontMatter
398
+ */
399
+ meta(): DocFileIndexMetaValue<T>;
400
+ /**
401
+ * Update title
402
+ */
403
+ withTitle(title: string): DocFileIndexContentValue<T>;
404
+ /**
405
+ * Update description
406
+ */
407
+ withDescription(description: string, defaultTitle?: string): DocFileIndexContentValue<T>;
408
+ /**
409
+ * Generate from Markdown text
410
+ */
411
+ static fromMarkdown<T extends DocCustomSchema>(markdown: string, customSchema: T, config: DocClientConfig): DocFileIndexContentValue<T>;
412
+ /**
413
+ * Update content
414
+ */
415
+ withBody(body: string): DocFileIndexContentValue<T>;
416
+ /**
417
+ * @deprecated Use `withBody` instead
418
+ */
419
+ withContent(body: string): DocFileIndexContentValue<T>;
420
+ /**
421
+ * Update FrontMatter
422
+ */
423
+ withMeta(meta: DocFileIndexMeta<T>): DocFileIndexContentValue<T>;
424
+ /**
425
+ * Generate default index.md content
426
+ */
427
+ static empty<T extends DocCustomSchema = DocCustomSchema>(directoryName: string, customSchema: T, config: DocClientConfig): DocFileIndexContentValue<T>;
428
+ /**
429
+ * Generate complete text combining FrontMatter and body
430
+ */
431
+ toText(): string;
432
+ /**
433
+ * Output in JSON format
434
+ */
435
+ toJson(): DocFileIndexContent<T>;
436
+ }
437
+
438
+ /**
439
+ * Document directory entity
440
+ */
441
+ declare class DocFileIndexEntity<T extends DocCustomSchema> {
442
+ readonly value: DocFileIndex<T>;
443
+ private readonly customSchema;
444
+ private readonly config;
445
+ constructor(value: DocFileIndex<T>, customSchema: T, config?: DocClientConfig);
446
+ /**
447
+ * Content
448
+ */
449
+ get content(): DocFileIndexContentValue<T>;
450
+ /**
451
+ * Path information
452
+ */
453
+ get path(): DocFilePath;
454
+ /**
455
+ * Update content
456
+ */
457
+ withContent(content: DocFileIndexContentValue<T>): DocFileIndexEntity<T>;
458
+ withContent(updater: UpdateFunction<DocFileIndexContentValue<T>>): DocFileIndexEntity<T>;
459
+ /**
460
+ * Update path
461
+ */
462
+ withPath(path: DocFilePath): DocFileIndexEntity<T>;
463
+ withPath(updater: UpdateFunction<DocFilePath>): DocFileIndexEntity<T>;
464
+ /**
465
+ * z.infer<typeof zDocFileIndex>
466
+ */
467
+ toJson(): DocFileIndexAny;
468
+ }
469
+
470
+ /**
471
+ * Relation file
472
+ */
473
+ declare class DocRelationFileValue {
474
+ private readonly value;
475
+ constructor(value: DocRelationFile);
476
+ /**
477
+ * File path
478
+ */
479
+ get id(): string;
480
+ /**
481
+ * Slug
482
+ */
483
+ get slug(): string;
484
+ /**
485
+ * Display label
486
+ */
487
+ get label(): string;
488
+ /**
489
+ * Convert to JSON format
490
+ */
491
+ toJson(): DocRelationFile;
492
+ /**
493
+ * Extract file name from file path (without extension)
494
+ */
495
+ private static extractFileName;
496
+ /**
497
+ * Create from file path and title
498
+ */
499
+ static from(filePath: string, title: string | null): DocRelationFileValue;
500
+ }
501
+
502
+ /**
503
+ * Manages relation information
504
+ */
505
+ declare class DocRelationValue {
506
+ readonly value: DocRelation;
507
+ constructor(value: DocRelation);
508
+ /**
509
+ * Relation path
510
+ */
511
+ get path(): string;
512
+ /**
513
+ * Get file count
514
+ */
515
+ get fileCount(): number;
516
+ /**
517
+ * Whether it's empty
518
+ */
519
+ get isEmpty(): boolean;
520
+ /**
521
+ * List of related files (value objects)
522
+ */
523
+ files(): DocRelationFileValue[];
524
+ /**
525
+ * Export as JSON format
526
+ */
527
+ toJson(): DocRelation;
528
+ /**
529
+ * Create empty relation entity
530
+ */
531
+ static empty(path: string): DocRelationValue;
532
+ }
533
+
534
+ type Props$8 = {
535
+ filePath: string;
536
+ fileSystem: DocFileSystem;
537
+ pathSystem: DocPathSystem;
538
+ };
539
+ /**
540
+ * Relation file reference
541
+ */
542
+ declare class DocFileRelationReference {
543
+ private readonly props;
544
+ private readonly pathSystem;
545
+ constructor(props: Props$8);
546
+ get fileSystem(): DocFileSystem;
318
547
  get basePath(): string;
548
+ /**
549
+ * Relation path
550
+ */
319
551
  get path(): string;
320
- get directoryPath(): string;
552
+ /**
553
+ * Full path
554
+ */
555
+ get fullPath(): string;
556
+ read(): Promise<DocRelationValue | Error | null>;
557
+ /**
558
+ * Read list of relation files
559
+ */
560
+ readFiles(): Promise<DocRelationFileValue[] | Error>;
561
+ /**
562
+ * Read single relation file
563
+ */
564
+ readFile(filePath: string): Promise<DocRelationFileValue | Error | null>;
565
+ /**
566
+ * Check if file exists
567
+ */
568
+ exists(slug: string): Promise<boolean>;
569
+ /**
570
+ * Get list of file names (without extension)
571
+ */
572
+ readSlugs(): Promise<string[] | Error>;
573
+ /**
574
+ * Get file count
575
+ */
576
+ count(): Promise<number | Error>;
577
+ /**
578
+ * Check if empty
579
+ */
580
+ isEmpty(): Promise<boolean | Error>;
581
+ }
582
+
583
+ type Props$7<T extends DocCustomSchema> = {
584
+ customSchema: T;
585
+ path: string;
586
+ fileSystem: DocFileSystem;
587
+ pathSystem: DocPathSystem;
588
+ config: DocClientConfig;
589
+ };
590
+ /**
591
+ * File reference class
592
+ */
593
+ declare class DocFileIndexReference<T extends DocCustomSchema> {
594
+ private readonly props;
595
+ private readonly pathSystem;
596
+ private readonly customSchema;
597
+ constructor(props: Props$7<T>);
598
+ get fileSystem(): DocFileSystem;
599
+ get basePath(): string;
600
+ get filePath(): string;
321
601
  get fileFullPath(): string;
322
- directory(): DocDirectoryReference<T>;
323
- read(): Promise<Error | DocFileUnknownEntity>;
602
+ get durectoryPath(): string;
603
+ read(): Promise<DocFileIndexEntity<T> | Error>;
604
+ readSchemaValue(): Promise<DocFileIndexSchema<RecordKey>>;
324
605
  /**
325
606
  * Read file content
326
607
  */
327
608
  readContent(): Promise<Error | string>;
328
609
  /**
329
- * Create empty DocFileUnknownEntity
610
+ * Create empty DocFileIndexEntity
330
611
  */
331
- empty(): DocFileUnknownEntity;
612
+ empty(): DocFileIndexEntity<T>;
332
613
  /**
333
614
  * Write content to file
334
615
  */
@@ -336,11 +617,11 @@ declare class DocFileUnknownReference<T extends DocCustomSchema> {
336
617
  /**
337
618
  * Write entity
338
619
  */
339
- write(entity: DocFileUnknownEntity): Promise<Error | null>;
620
+ write(entity: DocFileIndexEntity<T>): Promise<Error | null>;
340
621
  /**
341
- * Write raw content
622
+ * Create new file with default content
342
623
  */
343
- writeRaw(content: string): Promise<Error | null>;
624
+ writeDefault(): Promise<Error | null>;
344
625
  /**
345
626
  * Delete file
346
627
  */
@@ -349,1196 +630,385 @@ declare class DocFileUnknownReference<T extends DocCustomSchema> {
349
630
  * Check if file exists
350
631
  */
351
632
  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>;
633
+ relations(): Promise<DocFileRelationReference[] | Error>;
634
+ readRelations(): Promise<DocRelationValue[] | Error>;
360
635
  /**
361
636
  * Get file size in bytes
362
637
  */
363
638
  size(): Promise<number | Error>;
364
639
  /**
365
- * Get file last modified time
640
+ * Get last modified date
366
641
  */
367
642
  lastModified(): Promise<Date | Error>;
368
643
  /**
369
- * Get file creation time
644
+ * Get file creation date
370
645
  */
371
646
  createdAt(): Promise<Date | Error>;
372
647
  /**
373
648
  * Move file to archive and return new reference
374
649
  */
375
- archive(archiveDirectoryName?: string): Promise<DocFileUnknownReference<T>>;
650
+ archive(archiveDirectoryName?: string): Promise<DocFileIndexReference<T>>;
376
651
  /**
377
652
  * Restore file from archive and return new reference
378
653
  */
379
- restore(archiveDirectoryName?: string): Promise<DocFileUnknownReference<T>>;
654
+ restore(archiveDirectoryName?: string): Promise<DocFileIndexReference<T>>;
380
655
  }
381
656
 
382
657
  /**
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
658
+ * Meta
388
659
  */
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;
1231
- /**
1232
- * Validate value
1233
- */
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;
660
+ declare class DocFileMdMetaValue<T extends DocCustomSchema> {
661
+ readonly value: SchemaToValueType<T>;
662
+ readonly customSchema: T;
663
+ constructor(value: SchemaToValueType<T>, customSchema: T);
664
+ get keys(): Array<keyof T>;
1258
665
  /**
1259
- * Validate value type
666
+ * Return a new instance with a single property updated
1260
667
  */
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>;
1264
- }
1265
-
1266
- /**
1267
- * Single text type schema field
1268
- */
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;
668
+ withProperty<K extends keyof T>(key: K, value: BaseFieldValueType<ExtractFieldType<T[K]>>): DocFileMdMetaValue<T>;
669
+ schemaField<K extends keyof T>(key: K): T[K];
670
+ field<K extends keyof T>(key: K): FieldValueType<ExtractFieldType<T[K]>, ExtractRequired<T[K]>>;
671
+ relation(key: keyof T): DocMetaFieldRelation;
672
+ multiRelation(key: keyof T): DocMetaFieldMultiRelation;
673
+ text(key: keyof T): DocMetaFieldText;
674
+ number(key: keyof T): DocMetaFieldNumber;
675
+ boolean(key: keyof T): DocMetaFieldBoolean;
676
+ multiText(key: keyof T): DocMetaFieldMultiText;
677
+ multiNumber(key: keyof T): DocMetaFieldMultiNumber;
678
+ hasKey(key: keyof T): boolean;
679
+ toJson(): SchemaToValueType<T>;
680
+ toYaml(): string;
681
+ private validateValue;
682
+ private getValueField;
1282
683
  /**
1283
- * Validate value type
684
+ * Generate from Markdown text
1284
685
  */
1285
- validate(value: unknown): boolean;
1286
- static empty(key: RecordKey): DocSchemaFieldTextValue<RecordKey>;
1287
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldTextValue<RecordKey>;
686
+ static fromYamlText<T extends DocCustomSchema>(yamlText: string, customSchema: T): DocFileMdMetaValue<T>;
687
+ static empty<T extends DocCustomSchema>(customSchema: T): DocFileMdMetaValue<T>;
1288
688
  }
1289
689
 
1290
690
  /**
1291
- * Multiple number type schema field
691
+ * File: Markdown > Content
1292
692
  */
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;
693
+ declare class DocFileMdContentValue<T extends DocCustomSchema> {
694
+ readonly value: DocFileMdContent<T>;
695
+ private readonly customSchema;
696
+ constructor(value: DocFileMdContent<T>, customSchema: T);
697
+ /**
698
+ * Content body (does not include frontMatter)
699
+ */
700
+ get body(): string;
701
+ /**
702
+ * Title
703
+ */
1299
704
  get title(): string;
705
+ /**
706
+ * Description
707
+ */
1300
708
  get description(): string;
1301
- get default(): number[] | null;
1302
- readonly isArray = true;
1303
- readonly isSingle = false;
1304
- readonly isNumber = true;
1305
709
  /**
1306
- * Validate value
710
+ * FrontMatter (uses constructor's Zod schema or argument schema)
1307
711
  */
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);
712
+ meta(): DocFileMdMetaValue<T>;
1321
713
  /**
1322
- * Get list of field names
1323
- * Automatically type-safe when using Zod schema
714
+ * Update title
1324
715
  */
1325
- get fieldNames(): Array<keyof T>;
716
+ withTitle(title: string): DocFileMdContentValue<T>;
1326
717
  /**
1327
- * Get field with specified field name
1328
- * Returns type-safe specific field Value object
718
+ * Update description
1329
719
  */
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>;
720
+ withDescription(description: string, defaultTitle?: string): DocFileMdContentValue<T>;
1334
721
  /**
1335
- * Create empty schema entity
1336
- * biome-ignore lint/complexity/noBannedTypes: {} as DocCustomSchema
722
+ * Update body
1337
723
  */
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>);
724
+ withBody(body: string): DocFileMdContentValue<T>;
1350
725
  /**
1351
- * Get icon
726
+ * @deprecated Use `withBody` instead
1352
727
  */
1353
- get icon(): string | null;
728
+ withContent(content: string): DocFileMdContentValue<T>;
1354
729
  /**
1355
- * Get schema
730
+ * Update FrontMatter
1356
731
  */
1357
- schema(): DocFileIndexSchemaValue<T>;
732
+ withMeta<U extends DocCustomSchema>(meta: DocFileMdMetaValue<U>): DocFileMdContentValue<U>;
733
+ withMeta(updater: UpdateFunction<DocFileMdMetaValue<T>>): DocFileMdContentValue<T>;
1358
734
  /**
1359
- * Check if schema is defined
735
+ * Update specific property of FrontMatter
1360
736
  */
1361
- get hasSchema(): boolean;
737
+ withMetaProperty<K extends keyof T>(key: K, value: BaseFieldValueType<ExtractFieldType<T[K]>>): DocFileMdContentValue<T>;
1362
738
  /**
1363
- * Update icon field
739
+ * Generate from Markdown text
1364
740
  */
1365
- withIcon(value: string | null): DocFileIndexMetaValue<T>;
741
+ static fromMarkdown<T extends DocCustomSchema>(markdown: string, customSchema: T): DocFileMdContentValue<T>;
1366
742
  /**
1367
- * Update schema field
743
+ * Generate complete text combining FrontMatter and body
1368
744
  */
1369
- withSchema(value: DocFileIndexSchema<keyof T>): DocFileIndexMetaValue<T>;
745
+ toText(): string;
1370
746
  /**
1371
- * Return a new instance with an unknown schema
1372
- * Allows accepting Record<string, unknown> schemas from external sources
747
+ * Generate empty content
1373
748
  */
1374
- withUnknownSchema(draft: Record<string, unknown>): DocFileIndexMetaValue<DocCustomSchema>;
749
+ static empty<T extends DocCustomSchema = DocCustomSchema>(title: string, customSchema: T): DocFileMdContentValue<T>;
1375
750
  /**
1376
751
  * Output in JSON format
1377
752
  */
1378
- toJson(): DocFileIndexMeta<T>;
753
+ toJson(): DocFileMdContent<T>;
754
+ }
755
+
756
+ /**
757
+ * Markdown file entity
758
+ */
759
+ declare class DocFileMdEntity<T extends DocCustomSchema> {
760
+ readonly value: DocFileMd<T>;
761
+ private readonly customSchema;
762
+ constructor(value: DocFileMd<T>, customSchema: T);
1379
763
  /**
1380
- * Output in YAML format
764
+ * Content
1381
765
  */
1382
- toYaml(): string;
766
+ content(): DocFileMdContentValue<T>;
1383
767
  /**
1384
- * Generate from Markdown text (can process incomplete data)
768
+ * Path information
1385
769
  */
1386
- static from<T extends DocCustomSchema>(markdownText: string, customSchema: T, config: DocClientConfig): DocFileIndexMetaValue<T>;
770
+ get path(): DocFilePath;
1387
771
  /**
1388
- * Generate directly from data (can process incomplete data)
772
+ * Update content
1389
773
  */
1390
- static fromRecord<T extends DocCustomSchema>(record: Record<string, unknown>, customSchema: T, config: DocClientConfig): DocFileIndexMetaValue<T>;
774
+ withContent(content: DocFileMdContentValue<T>): DocFileMdEntity<T>;
775
+ withContent(updater: UpdateFunction<DocFileMdContentValue<T>>): DocFileMdEntity<T>;
1391
776
  /**
1392
- * Generate empty FrontMatter
777
+ * Update path
1393
778
  */
1394
- static empty<T extends DocCustomSchema>(customSchema: T, config: DocClientConfig): DocFileIndexMetaValue<T>;
779
+ withPath(path: DocFilePath): DocFileMdEntity<T>;
780
+ withPath(updater: UpdateFunction<DocFilePath>): DocFileMdEntity<T>;
781
+ withMeta(meta: DocFileMdMetaValue<T>): DocFileMdEntity<T>;
782
+ withMeta(updater: UpdateFunction<DocFileMdMetaValue<T>>): DocFileMdEntity<T>;
783
+ withTitle(title: string): DocFileMdEntity<T>;
784
+ withDescription(description: string, defaultTitle?: string): DocFileMdEntity<T>;
1395
785
  /**
1396
- * Extract icon
786
+ * z.infer<typeof zDocFileMd>
1397
787
  */
1398
- private static extractIcon;
788
+ toJson(): z.infer<typeof zDocFileMd>;
789
+ }
790
+
791
+ /**
792
+ * Unknown file entity
793
+ */
794
+ declare class DocFileUnknownEntity {
795
+ readonly value: DocFileUnknown;
796
+ constructor(value: DocFileUnknown);
1399
797
  /**
1400
- * Extract schema part
798
+ * Content
1401
799
  */
1402
- private static extractSchema;
800
+ get content(): string;
1403
801
  /**
1404
- * Normalize entire schema
802
+ * Path information
1405
803
  */
1406
- private static normalizeSchema;
1407
- static emptySchema<T extends DocCustomSchema>(customSchema: T): DocFileIndexSchema<keyof T>;
804
+ get path(): DocFilePath;
805
+ /**
806
+ * Update content
807
+ */
808
+ withContent(content: string): DocFileUnknownEntity;
809
+ /**
810
+ * Update path
811
+ */
812
+ withPath(path: DocFilePath): DocFileUnknownEntity;
813
+ withPath(updater: UpdateFunction<DocFilePath>): DocFileUnknownEntity;
814
+ toJson(): z.infer<typeof zDocFileUnknown>;
1408
815
  }
1409
816
 
817
+ type DocFileEntity<T extends DocCustomSchema> = DocFileMdEntity<T> | DocFileIndexEntity<T> | DocFileUnknownEntity;
818
+ type DocFileDirectoryEntity<T extends DocCustomSchema> = DocFileMdEntity<T> | DocFileUnknownEntity;
819
+
820
+ type Props$6<T extends DocCustomSchema> = {
821
+ path: string;
822
+ fileSystem: DocFileSystem;
823
+ pathSystem: DocPathSystem;
824
+ customSchema: T;
825
+ config: DocClientConfig;
826
+ };
1410
827
  /**
1411
- * File: index.md > content
828
+ * File reference
1412
829
  */
1413
- declare class DocFileIndexContentValue<T extends DocCustomSchema> {
1414
- readonly value: DocFileIndexContent<T>;
830
+ declare class DocFileUnknownReference<T extends DocCustomSchema> {
831
+ private readonly props;
832
+ private readonly pathSystem;
1415
833
  private readonly customSchema;
1416
- private readonly config;
1417
- constructor(value: DocFileIndexContent<T>, customSchema: T, config: DocClientConfig);
834
+ constructor(props: Props$6<T>);
835
+ get fileSystem(): DocFileSystem;
836
+ get basePath(): string;
837
+ get path(): string;
838
+ get directoryPath(): string;
839
+ get fileFullPath(): string;
840
+ directory(): DocDirectoryReference<T>;
841
+ read(): Promise<Error | DocFileUnknownEntity>;
1418
842
  /**
1419
- * Content body (does not include frontMatter)
843
+ * Read file content
1420
844
  */
1421
- get body(): string;
845
+ readContent(): Promise<Error | string>;
1422
846
  /**
1423
- * Title
847
+ * Create empty DocFileUnknownEntity
1424
848
  */
1425
- get title(): string;
849
+ empty(): DocFileUnknownEntity;
1426
850
  /**
1427
- * Description
851
+ * Write content to file
1428
852
  */
1429
- get description(): string;
853
+ writeContent(content: string): Promise<Error | null>;
1430
854
  /**
1431
- * FrontMatter
855
+ * Write entity
1432
856
  */
1433
- meta(): DocFileIndexMetaValue<T>;
857
+ write(entity: DocFileUnknownEntity): Promise<Error | null>;
1434
858
  /**
1435
- * Update title
859
+ * Write raw content
1436
860
  */
1437
- withTitle(title: string): DocFileIndexContentValue<T>;
861
+ writeRaw(content: string): Promise<Error | null>;
1438
862
  /**
1439
- * Update description
863
+ * Delete file
1440
864
  */
1441
- withDescription(description: string, defaultTitle?: string): DocFileIndexContentValue<T>;
865
+ delete(): Promise<Error | null>;
1442
866
  /**
1443
- * Generate from Markdown text
867
+ * Check if file exists
1444
868
  */
1445
- static fromMarkdown<T extends DocCustomSchema>(markdown: string, customSchema: T, config: DocClientConfig): DocFileIndexContentValue<T>;
869
+ exists(): Promise<boolean>;
1446
870
  /**
1447
- * Update content
871
+ * Copy file
1448
872
  */
1449
- withBody(body: string): DocFileIndexContentValue<T>;
873
+ copyTo(destinationPath: string): Promise<Error | null>;
1450
874
  /**
1451
- * @deprecated Use `withBody` instead
875
+ * Move file
1452
876
  */
1453
- withContent(body: string): DocFileIndexContentValue<T>;
877
+ moveTo(destinationPath: string): Promise<Error | null>;
1454
878
  /**
1455
- * Update FrontMatter
879
+ * Get file size in bytes
1456
880
  */
1457
- withMeta(meta: DocFileIndexMeta<T>): DocFileIndexContentValue<T>;
881
+ size(): Promise<number | Error>;
1458
882
  /**
1459
- * Generate default index.md content
883
+ * Get file last modified time
1460
884
  */
1461
- static empty<T extends DocCustomSchema = DocCustomSchema>(directoryName: string, customSchema: T, config: DocClientConfig): DocFileIndexContentValue<T>;
885
+ lastModified(): Promise<Date | Error>;
1462
886
  /**
1463
- * Generate complete text combining FrontMatter and body
887
+ * Get file creation time
1464
888
  */
1465
- toText(): string;
889
+ createdAt(): Promise<Date | Error>;
1466
890
  /**
1467
- * Output in JSON format
891
+ * Move file to archive and return new reference
1468
892
  */
1469
- toJson(): DocFileIndexContent<T>;
893
+ archive(archiveDirectoryName?: string): Promise<DocFileUnknownReference<T>>;
894
+ /**
895
+ * Restore file from archive and return new reference
896
+ */
897
+ restore(archiveDirectoryName?: string): Promise<DocFileUnknownReference<T>>;
1470
898
  }
1471
899
 
900
+ type DocFileDirectoryReference<T extends DocCustomSchema> = DocFileMdReference<T> | DocFileUnknownReference<T>;
901
+
902
+ type Props$5<T extends DocCustomSchema> = {
903
+ customSchema: T;
904
+ path: string;
905
+ indexFileName: string;
906
+ archiveDirectoryName: string;
907
+ fileSystem: DocFileSystem;
908
+ pathSystem: DocPathSystem;
909
+ config: DocClientConfig;
910
+ };
1472
911
  /**
1473
- * Document directory entity
912
+ * Directory reference
1474
913
  */
1475
- declare class DocFileIndexEntity<T extends DocCustomSchema> {
1476
- readonly value: DocFileIndex<T>;
914
+ declare class DocDirectoryReference<T extends DocCustomSchema> {
915
+ private readonly props;
916
+ private readonly pathSystem;
1477
917
  private readonly customSchema;
1478
- private readonly config;
1479
- constructor(value: DocFileIndex<T>, customSchema: T, config?: DocClientConfig);
918
+ constructor(props: Props$5<T>);
919
+ get fileSystem(): DocFileSystem;
920
+ get basePath(): string;
921
+ get config(): DocClientConfig;
922
+ get path(): string;
1480
923
  /**
1481
- * Content
924
+ * @deprecated
1482
925
  */
1483
- get content(): DocFileIndexContentValue<T>;
926
+ get relativePath(): string;
927
+ get fullPath(): string;
1484
928
  /**
1485
- * Path information
929
+ * @deprecated
1486
930
  */
1487
- get path(): DocFilePath;
931
+ get absolutePath(): string;
932
+ get indexFileName(): string;
933
+ get indexFilePath(): string;
934
+ get archiveDirectoryName(): string;
935
+ get name(): string;
936
+ fileNames(): Promise<string[] | Error>;
937
+ archivedFileNames(): Promise<string[] | Error>;
938
+ filesGenerator(): AsyncGenerator<DocFileDirectoryReference<T>, void, unknown>;
939
+ mdFilesGenerator(): AsyncGenerator<DocFileMdReference<T> | Error, void, unknown>;
940
+ files(): Promise<DocFileDirectoryReference<T>[]>;
941
+ mdFiles(): Promise<DocFileMdReference<T>[]>;
942
+ file<FileName extends string>(fileName: FileName): InferReference<FileName, T>;
943
+ mdFile(fileName: string): DocFileMdReference<T>;
944
+ readFiles(): Promise<DocFileDirectoryEntity<T>[]>;
945
+ readMdFiles(): Promise<DocFileMdEntity<T>[]>;
946
+ readUnknownFiles(): Promise<DocFileUnknownEntity[]>;
1488
947
  /**
1489
- * Update content
948
+ * Get list of subdirectory names
1490
949
  */
1491
- withContent(content: DocFileIndexContentValue<T>): DocFileIndexEntity<T>;
1492
- withContent(updater: UpdateFunction<DocFileIndexContentValue<T>>): DocFileIndexEntity<T>;
950
+ directoryNames(): Promise<string[]>;
1493
951
  /**
1494
- * Update path
952
+ * Get subdirectory references
1495
953
  */
1496
- withPath(path: DocFilePath): DocFileIndexEntity<T>;
1497
- withPath(updater: UpdateFunction<DocFilePath>): DocFileIndexEntity<T>;
954
+ directories(): Promise<DocDirectoryReference<T>[]>;
1498
955
  /**
1499
- * z.infer<typeof zDocFileIndex>
956
+ * Get single subdirectory reference
1500
957
  */
1501
- toJson(): DocFileIndexAny;
958
+ directory(directoryName: string): DocDirectoryReference<T>;
959
+ directory<S extends DocCustomSchema>(directoryName: string, customSchema: S): DocDirectoryReference<S>;
960
+ indexFile(): DocFileIndexReference<T>;
961
+ readIndexFile(): Promise<DocFileIndexEntity<T> | Error>;
962
+ writeFile(entity: DocFileIndexEntity<T> | DocFileMdEntity<T> | DocFileUnknownEntity): Promise<Error | null>;
963
+ exists(): Promise<boolean>;
964
+ /**
965
+ * Create new Markdown file
966
+ */
967
+ createMdFile(fileName?: string): Promise<DocFileMdReference<T>>;
968
+ /**
969
+ * Generate unique filename
970
+ */
971
+ private uniqueFileName;
1502
972
  }
1503
973
 
1504
- type Props$b<T extends DocCustomSchema> = {
1505
- customSchema: T;
974
+ type Props$4<T extends DocCustomSchema> = {
1506
975
  path: string;
1507
976
  fileSystem: DocFileSystem;
1508
977
  pathSystem: DocPathSystem;
978
+ customSchema: T;
1509
979
  config: DocClientConfig;
1510
980
  };
1511
981
  /**
1512
- * File reference class
982
+ * File reference
1513
983
  */
1514
- declare class DocFileIndexReference<T extends DocCustomSchema> {
984
+ declare class DocFileMdReference<T extends DocCustomSchema> {
1515
985
  private readonly props;
1516
986
  private readonly pathSystem;
1517
987
  private readonly customSchema;
1518
- constructor(props: Props$b<T>);
988
+ constructor(props: Props$4<T>);
1519
989
  get fileSystem(): DocFileSystem;
1520
990
  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>>;
991
+ get path(): string;
992
+ get fullPath(): string;
993
+ get directoryPath(): string;
994
+ get archivedPath(): string;
995
+ get name(): string;
996
+ get nameWithExtension(): string;
997
+ exists(): Promise<boolean>;
998
+ read(): Promise<DocFileMdEntity<T> | Error>;
1526
999
  /**
1527
1000
  * Read file content
1528
1001
  */
1529
- readContent(): Promise<Error | string>;
1530
- /**
1531
- * Create empty DocFileIndexEntity
1532
- */
1533
- empty(): DocFileIndexEntity<T>;
1002
+ readText(): Promise<Error | string>;
1534
1003
  /**
1535
- * Write content to file
1004
+ * Create empty DocFileMdEntity
1536
1005
  */
1537
- writeContent(content: string): Promise<Error | null>;
1006
+ empty(): DocFileMdEntity<T>;
1538
1007
  /**
1539
1008
  * Write entity
1540
1009
  */
1541
- write(entity: DocFileIndexEntity<T>): Promise<Error | null>;
1010
+ write(entity: DocFileMdEntity<T>): Promise<Error | null>;
1011
+ writeText(text: string): Promise<Error | null>;
1542
1012
  /**
1543
1013
  * Create new file with default content
1544
1014
  */
@@ -1548,884 +1018,585 @@ declare class DocFileIndexReference<T extends DocCustomSchema> {
1548
1018
  */
1549
1019
  delete(): Promise<Error | null>;
1550
1020
  /**
1551
- * Check if file exists
1021
+ * Copy file
1552
1022
  */
1553
- exists(): Promise<boolean>;
1554
- relations(): Promise<DocFileRelationReference[] | Error>;
1555
- readRelations(): Promise<DocRelationValue[] | Error>;
1023
+ copyTo(destinationPath: string): Promise<Error | null>;
1024
+ /**
1025
+ * Move file
1026
+ */
1027
+ moveTo(destinationPath: string): Promise<Error | null>;
1028
+ /**
1029
+ * Move file to archive and return new reference
1030
+ */
1031
+ archive(archiveDirectoryName?: string): Promise<DocFileMdReference<T>>;
1032
+ /**
1033
+ * Restore file from archive and return new reference
1034
+ */
1035
+ restore(archiveDirectoryName?: string): Promise<DocFileMdReference<T>>;
1556
1036
  /**
1557
1037
  * Get file size in bytes
1558
1038
  */
1559
1039
  size(): Promise<number | Error>;
1560
1040
  /**
1561
- * Get last modified date
1041
+ * Get file last modified time
1562
1042
  */
1563
1043
  lastModified(): Promise<Date | Error>;
1564
1044
  /**
1565
- * Get file creation date
1045
+ * Get file creation time
1566
1046
  */
1567
1047
  createdAt(): Promise<Date | Error>;
1048
+ directory(): DocDirectoryReference<T>;
1568
1049
  /**
1569
- * Move file to archive and return new reference
1050
+ * Get relation based on schema
1570
1051
  */
1571
- archive(archiveDirectoryName?: string): Promise<DocFileIndexReference<T>>;
1052
+ relation<U extends DocCustomSchema = DocCustomSchema>(key: RelationKeys<T>, targetSchema?: U): Promise<DocFileMdReference<U> | Error | null>;
1572
1053
  /**
1573
- * Restore file from archive and return new reference
1054
+ * Get index.md in the same directory
1574
1055
  */
1575
- restore(archiveDirectoryName?: string): Promise<DocFileIndexReference<T>>;
1056
+ directoryIndex(): Promise<DocFileIndexReference<T> | null>;
1057
+ /**
1058
+ * Get multiple relations based on schema
1059
+ */
1060
+ relations<U extends DocCustomSchema = DocCustomSchema>(key: MultiRelationKeys<T>, customSchema?: U): Promise<DocFileMdReference<U>[]>;
1061
+ /**
1062
+ * File: Markdown > FrontMatter
1063
+ */
1064
+ readFrontMatter(): Promise<DocFileMdMetaValue<T> | Error>;
1065
+ /**
1066
+ * File: Markdown > FrontMatter
1067
+ */
1068
+ updateFrontMatter<K extends keyof T>(key: K, value: BaseFieldValueType<ExtractFieldType<T[K]>>): Promise<this | Error>;
1576
1069
  }
1577
1070
 
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;
1071
+ /**
1072
+ * Generic updater function type that takes a value and returns the same type
1073
+ */
1074
+ type UpdateFunction<T> = (current: T) => T;
1075
+ /**
1076
+ * Text field type
1077
+ */
1078
+ type DocSchemaFieldText = z.infer<typeof zDocSchemaFieldText>;
1079
+ /**
1080
+ * Number field type
1081
+ */
1082
+ type DocSchemaFieldNumber = z.infer<typeof zDocSchemaFieldNumber>;
1083
+ /**
1084
+ * Boolean field type
1085
+ */
1086
+ type DocSchemaFieldBoolean = z.infer<typeof zDocSchemaFieldBoolean>;
1087
+ /**
1088
+ * Multi-text field type
1089
+ */
1090
+ type DocSchemaFieldMultiText = z.infer<typeof zDocSchemaFieldMultiText>;
1091
+ /**
1092
+ * Multi-number field type
1093
+ */
1094
+ type DocSchemaFieldMultiNumber = z.infer<typeof zDocSchemaFieldMultiNumber>;
1095
+ /**
1096
+ * Relation field type
1097
+ */
1098
+ type DocSchemaFieldRelation = z.infer<typeof zDocSchemaFieldRelation>;
1099
+ /**
1100
+ * Multi-relation field type
1101
+ */
1102
+ type DocSchemaFieldMultiRelation = z.infer<typeof zDocSchemaFieldMultiRelation>;
1103
+ /**
1104
+ * Select text field type
1105
+ */
1106
+ type DocSchemaFieldSelectText = z.infer<typeof zDocSchemaFieldSelectText>;
1107
+ /**
1108
+ * Select number field type
1109
+ */
1110
+ type DocSchemaFieldSelectNumber = z.infer<typeof zDocSchemaFieldSelectNumber>;
1111
+ /**
1112
+ * Multi-select text field type
1113
+ */
1114
+ type DocSchemaFieldMultiSelectText = z.infer<typeof zDocSchemaFieldMultiSelectText>;
1115
+ /**
1116
+ * Multi-select number field type
1117
+ */
1118
+ type DocSchemaFieldMultiSelectNumber = z.infer<typeof zDocSchemaFieldMultiSelectNumber>;
1119
+ type DocMetaField = z.infer<typeof zDocMetaField>;
1120
+ type DocMetaFieldText = z.infer<typeof zDocMetaFieldText>;
1121
+ type DocMetaFieldNumber = z.infer<typeof zDocMetaFieldNumber>;
1122
+ type DocMetaFieldBoolean = z.infer<typeof zDocMetaFieldBoolean>;
1123
+ type DocMetaFieldSelectText = z.infer<typeof zDocMetaFieldSelectText>;
1124
+ type DocMetaFieldSelectNumber = z.infer<typeof zDocMetaFieldSelectNumber>;
1125
+ type DocMetaFieldRelation = z.infer<typeof zDocMetaFieldRelation>;
1126
+ type DocMetaFieldMultiText = z.infer<typeof zDocMetaFieldMultiText>;
1127
+ type DocMetaFieldMultiNumber = z.infer<typeof zDocMetaFieldMultiNumber>;
1128
+ type DocMetaFieldMultiSelectText = z.infer<typeof zDocMetaFieldMultiSelectText>;
1129
+ type DocMetaFieldMultiSelectNumber = z.infer<typeof zDocMetaFieldMultiSelectNumber>;
1130
+ type DocMetaFieldMultiRelation = z.infer<typeof zDocMetaFieldMultiRelation>;
1131
+ type DocFileMdMeta<T extends RecordKey> = Record<T, DocMetaField>;
1132
+ type DocFileMdMetaAny = DocFileMdMeta<RecordKey>;
1133
+ type DocMetaFieldTypeText = z.infer<typeof zDocMetaFieldTypeText>;
1134
+ type DocMetaFieldTypeNumber = z.infer<typeof zDocMetaFieldTypeNumber>;
1135
+ type DocMetaFieldTypeBoolean = z.infer<typeof zDocMetaFieldTypeBoolean>;
1136
+ type DocMetaFieldTypeSelectText = z.infer<typeof zDocMetaFieldTypeSelectText>;
1137
+ type DocMetaFieldTypeSelectNumber = z.infer<typeof zDocMetaFieldTypeSelectNumber>;
1138
+ type DocMetaFieldTypeRelation = z.infer<typeof zDocMetaFieldTypeRelation>;
1139
+ /**
1140
+ * Schema field type
1141
+ */
1142
+ type DocMetaFieldType = z.infer<typeof zDocMetaFieldType>;
1143
+ type DocCustomSchemaFieldText = {
1144
+ type: "text";
1145
+ required: boolean;
1146
+ };
1147
+ type DocCustomSchemaFieldNumber = {
1148
+ type: "number";
1149
+ required: boolean;
1150
+ };
1151
+ type DocCustomSchemaFieldBoolean = {
1152
+ type: "boolean";
1153
+ required: boolean;
1154
+ };
1155
+ type DocCustomSchemaFieldRelation = {
1156
+ type: "relation";
1157
+ required: boolean;
1158
+ };
1159
+ type DocCustomSchemaFieldSelectText = {
1160
+ type: "select-text";
1161
+ required: boolean;
1162
+ };
1163
+ type DocCustomSchemaFieldSelectNumber = {
1164
+ type: "select-number";
1165
+ required: boolean;
1166
+ };
1167
+ type DocCustomSchemaFieldMultiText = {
1168
+ type: "multi-text";
1169
+ required: boolean;
1170
+ };
1171
+ type DocCustomSchemaFieldMultiNumber = {
1172
+ type: "multi-number";
1173
+ required: boolean;
1174
+ };
1175
+ type DocCustomSchemaFieldMultiRelation = {
1176
+ type: "multi-relation";
1177
+ required: boolean;
1178
+ };
1179
+ type DocCustomSchemaFieldMultiSelectText = {
1180
+ type: "multi-select-text";
1181
+ required: boolean;
1182
+ };
1183
+ type DocCustomSchemaFieldMultiSelectNumber = {
1184
+ type: "multi-select-number";
1185
+ required: boolean;
1591
1186
  };
1592
1187
  /**
1593
- * Directory reference
1188
+ * Schema field type
1594
1189
  */
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 = {
1190
+ type DocFileIndexSchemaField = z.infer<typeof zDocFileIndexSchemaField>;
1191
+ /**
1192
+ * Schema definition type
1193
+ */
1194
+ type DocFileIndexSchema<T extends RecordKey = string> = Record<T, DocFileIndexSchemaField>;
1195
+ /**
1196
+ * Schema field to override
1197
+ * ex: { xxx: { type: "text", required: true } }
1198
+ */
1199
+ type DocCustomSchemaField = DocCustomSchemaFieldText | DocCustomSchemaFieldNumber | DocCustomSchemaFieldBoolean | DocCustomSchemaFieldRelation | DocCustomSchemaFieldSelectText | DocCustomSchemaFieldSelectNumber | DocCustomSchemaFieldMultiText | DocCustomSchemaFieldMultiNumber | DocCustomSchemaFieldMultiRelation | DocCustomSchemaFieldMultiSelectText | DocCustomSchemaFieldMultiSelectNumber;
1200
+ /**
1201
+ * Type literal for field types
1202
+ */
1203
+ type DocFieldTypeLiteral = "text" | "number" | "boolean" | "relation" | "multi-text" | "multi-number" | "multi-relation" | "select-text" | "select-number" | "multi-select-text" | "multi-select-number";
1204
+ /**
1205
+ * Minimal schema definition type
1206
+ */
1207
+ type DocCustomSchema<T extends RecordKey = string> = Record<T, DocCustomSchemaField>;
1208
+ /**
1209
+ * Union type for relation fields
1210
+ */
1211
+ type DocSchemaRelationFieldUnion = DocSchemaFieldRelation | DocSchemaFieldMultiRelation;
1212
+ /**
1213
+ * File node type (for files only)
1214
+ */
1215
+ type DocTreeFileNode = {
1216
+ type: "file";
1658
1217
  name: string;
1659
1218
  path: string;
1660
1219
  icon: string;
1661
1220
  title: string;
1662
1221
  };
1663
1222
  /**
1664
- * Tree file node value object
1223
+ * Directory node type (for directories only)
1665
1224
  */
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 = {
1225
+ type DocTreeDirectoryNode = {
1226
+ type: "directory";
1691
1227
  name: string;
1692
1228
  path: string;
1693
1229
  icon: string;
1694
1230
  title: string;
1695
- children: DocTreeNodeValue[];
1231
+ children: DocTreeNode[];
1696
1232
  };
1697
1233
  /**
1698
- * Tree directory node value object
1234
+ * Unified tree node type
1699
1235
  */
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;
1236
+ type DocTreeNode = DocTreeFileNode | DocTreeDirectoryNode;
1237
+ /**
1238
+ * Index file type
1239
+ */
1240
+ type DocFileIndex<T extends DocCustomSchema = DocCustomSchema> = {
1241
+ type: "index";
1242
+ path: DocFilePath;
1243
+ isArchived: boolean;
1244
+ content: DocFileIndexContent<T>;
1245
+ };
1246
+ /**
1247
+ * Type to check if two types are equal
1248
+ */
1249
+ type Equals<T, U> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? true : false;
1250
+ /**
1251
+ * Extract relation field keys from schema
1252
+ */
1253
+ type RelationKeys<T extends DocCustomSchema> = {
1254
+ [K in keyof T]: T[K]["type"] extends "relation" ? K : never;
1255
+ }[keyof T];
1256
+ /**
1257
+ * Extract multi-relation field keys from schema
1258
+ */
1259
+ type MultiRelationKeys<T extends DocCustomSchema> = {
1260
+ [K in keyof T]: T[K]["type"] extends "multi-relation" ? K : never;
1261
+ }[keyof T];
1262
+ /**
1263
+ * Markdown file type (excluding index.md)
1264
+ */
1265
+ type DocFileMd<T extends DocCustomSchema> = {
1266
+ type: "markdown";
1267
+ path: DocFilePath;
1268
+ isArchived: boolean;
1269
+ content: DocFileMdContent<T>;
1270
+ };
1271
+ /**
1272
+ * Other file type (non-markdown)
1273
+ */
1274
+ type DocFileUnknown = z.infer<typeof zDocFileUnknown>;
1275
+ /**
1276
+ * File union type (index.md, regular md, other)
1277
+ */
1278
+ type DocFile<T extends DocCustomSchema = DocCustomSchema> = DocFileIndex<T> | DocFileMd<T> | DocFileUnknown;
1279
+ type DocDirectoryFile<T extends DocCustomSchema = DocCustomSchema> = DocFileMd<T> | DocFileUnknown;
1280
+ type DocFileIndexAny = z.infer<typeof zDocFileIndex>;
1281
+ type DocFileMdAny = z.infer<typeof zDocFileMd>;
1282
+ /**
1283
+ * DocFile<DocCustomSchema<RecordKey>>
1284
+ */
1285
+ type DocFileAny = DocFileIndexAny | DocFileMdAny | DocFileUnknown;
1286
+ /**
1287
+ * Directory FrontMatter type
1288
+ */
1289
+ type DocFileIndexMeta<T extends DocCustomSchema = DocCustomSchema> = {
1290
+ type: "index-meta";
1291
+ icon: string | null;
1292
+ schema: DocFileIndexSchema<keyof T>;
1729
1293
  };
1730
1294
  /**
1731
- * File tree building system
1295
+ * Relation options type
1296
+ */
1297
+ type DocRelationFile = z.infer<typeof zDocRelationFile>;
1298
+ /**
1299
+ * Relation information type
1300
+ */
1301
+ type DocRelation = z.infer<typeof zDocRelation>;
1302
+ /**
1303
+ * Relation field type
1304
+ */
1305
+ type DocRelationField = z.infer<typeof zDocRelationField>;
1306
+ /**
1307
+ * String literal type utilities for file path detection
1308
+ */
1309
+ /**
1310
+ * Check if path ends with specific extension
1311
+ */
1312
+ type EndsWith<T extends string, U extends string> = T extends `${string}${U}` ? true : false;
1313
+ /**
1314
+ * Extract filename from path
1315
+ */
1316
+ type Basename<T extends string> = T extends `${string}/${infer U}` ? Basename<U> : T;
1317
+ /**
1318
+ * Check if filename is index.md
1319
+ */
1320
+ type IsIndexMd<T extends string> = Basename<T> extends "index.md" ? true : false;
1321
+ /**
1322
+ * Detect file type from path
1323
+ */
1324
+ type DetectFileType<T extends string> = IsIndexMd<T> extends true ? "index" : EndsWith<T, ".md"> extends true ? "markdown" : "unknown";
1325
+ /**
1326
+ * Map file type to reference class
1732
1327
  */
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
-
1328
+ type FileTypeToReference<FileType extends string, Schema extends DocCustomSchema> = FileType extends "index" ? DocFileIndexReference<Schema> : FileType extends "markdown" ? DocFileMdReference<Schema> : DocFileUnknownReference<Schema>;
1767
1329
  /**
1768
- * Markdown parsing and processing system
1330
+ * Infer reference type from path
1769
1331
  */
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;
1332
+ type InferReference<Path extends string, Schema extends DocCustomSchema> = FileTypeToReference<DetectFileType<Path>, Schema>;
1333
+ /**
1334
+ * File path information type
1335
+ */
1336
+ type DocFilePath = z.infer<typeof zDocFilePath>;
1337
+ /**
1338
+ * Markdown content information type
1339
+ */
1340
+ type DocFileMdContent<T extends DocCustomSchema = DocCustomSchema> = {
1341
+ type: "markdown-content";
1342
+ body: string;
1343
+ title: string;
1344
+ description: string;
1345
+ meta: SchemaToValueType<T>;
1848
1346
  };
1849
1347
  /**
1850
- * JSON-based file system with separate read/write components
1348
+ * Index file content information type
1851
1349
  */
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;
1350
+ type DocFileIndexContent<T extends DocCustomSchema = DocCustomSchema> = {
1351
+ type: "markdown-index";
1352
+ body: string;
1353
+ title: string;
1354
+ description: string;
1355
+ meta: DocFileIndexMeta<T>;
1892
1356
  };
1893
1357
  /**
1894
- * JSON-based read-only file system implementation
1358
+ * Directory response type (re-export from server package)
1895
1359
  */
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;
1360
+ type DocDirectory<T extends DocCustomSchema> = {
1361
+ cwd: string;
1362
+ indexFile: DocFileIndex<T>;
1363
+ files: DocFile<T>[];
1364
+ relations: DocRelation[];
1995
1365
  };
1366
+ type RecordKey = PropertyKey;
1996
1367
  /**
1997
- * JSON-based write-only file system implementation
1368
+ * DocClient configuration
1998
1369
  */
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
-
1370
+ type DocClientConfig = z.infer<typeof zDocClientConfig>;
1371
+ /**
1372
+ * Type definitions for DocFileMdMetaValue
1373
+ */
1374
+ type ExtractFieldType<T> = T extends {
1375
+ type: infer Type;
1376
+ } ? Type : never;
1377
+ type ExtractRequired<T> = T extends {
1378
+ required: infer Required;
1379
+ } ? Required : false;
1380
+ type BaseFieldValueType<Type> = Type extends "text" ? string : Type extends "number" ? number : Type extends "boolean" ? boolean : Type extends "multi-text" ? string[] : Type extends "multi-number" ? number[] : Type extends "multi-boolean" ? boolean[] : Type extends "relation" ? string : Type extends "multi-relation" ? string[] : Type extends "select-text" ? string : Type extends "select-number" ? number : Type extends "multi-select-text" ? string[] : Type extends "multi-select-number" ? number[] : never;
1381
+ type FieldValueType<Type, Required> = Required extends true ? BaseFieldValueType<Type> : BaseFieldValueType<Type> | null;
1382
+ /**
1383
+ * Extract required field keys
1384
+ */
1385
+ type RequiredKeys<T extends DocCustomSchema> = {
1386
+ [K in keyof T]: T[K] extends {
1387
+ required: true;
1388
+ } ? K : never;
1389
+ }[keyof T];
1390
+ /**
1391
+ * Extract optional field keys
1392
+ */
1393
+ type OptionalKeys<T extends DocCustomSchema> = {
1394
+ [K in keyof T]: T[K] extends {
1395
+ required: true;
1396
+ } ? never : K;
1397
+ }[keyof T];
2060
1398
  /**
2061
- * In-memory file system for testing
1399
+ * Generate expected value type from schema (considering required)
2062
1400
  */
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;
1401
+ type SchemaToValueType<T extends DocCustomSchema> = {
1402
+ [K in RequiredKeys<T>]: BaseFieldValueType<ExtractFieldType<T[K]>>;
1403
+ } & {
1404
+ [K in OptionalKeys<T>]: BaseFieldValueType<ExtractFieldType<T[K]>> | null;
2156
1405
  };
2157
1406
  /**
2158
- * GitHub repository file system using Octokit with separate read/write components
1407
+ * Helper type for type-safe property access
2159
1408
  */
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
- }
1409
+ type GetValueType<T extends DocCustomSchema, K extends keyof T> = K extends RequiredKeys<T> ? BaseFieldValueType<ExtractFieldType<T[K]>> : BaseFieldValueType<ExtractFieldType<T[K]>> | undefined | null;
1410
+ type GetIndexFieldType<Schema extends DocFileIndexSchema<RecordKey>, K extends keyof Schema> = Schema[K] extends DocFileIndexSchemaField ? Schema[K] : never;
1411
+ /**
1412
+ * Infers DocFileMd type from the result of defineSchema
1413
+ */
1414
+ type InferDocFileMd<T> = T extends DocCustomSchema ? DocFileMd<T> : never;
1415
+
1416
+ declare const DOC_NODE_TYPE_DIRECTORY: "directory";
2174
1417
 
2175
1418
  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;
1419
+ name: string;
1420
+ path: string;
1421
+ icon: string;
1422
+ title: string;
2188
1423
  };
2189
1424
  /**
2190
- * GitHub repository read-only file system using Octokit
1425
+ * Tree file node value object
2191
1426
  */
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>;
1427
+ declare class DocTreeFileNodeValue {
1428
+ private readonly props;
2200
1429
  constructor(props: Props$3);
1430
+ get name(): string;
1431
+ get path(): string;
1432
+ get icon(): string;
1433
+ get title(): string;
1434
+ get type(): "file";
2201
1435
  /**
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
1436
+ * Convert to plain object
2259
1437
  */
2260
- getFileModifiedTime(relativePath: string): Promise<Date | Error>;
1438
+ toJson(): DocTreeFileNode;
2261
1439
  /**
2262
- * Get file creation time (first commit)
1440
+ * Create from properties
2263
1441
  */
2264
- getFileCreatedTime(relativePath: string): Promise<Date | Error>;
1442
+ static from(props: Props$3): DocTreeFileNodeValue;
2265
1443
  /**
2266
- * Get cached SHA for a file
1444
+ * Create from JSON object
2267
1445
  */
2268
- getCachedSha(relativePath: string): string | undefined;
1446
+ static fromJson(json: unknown): DocTreeFileNodeValue;
2269
1447
  }
2270
1448
 
1449
+ type DocTreeNodeValue = DocTreeFileNodeValue | DocTreeDirectoryNodeValue;
1450
+
2271
1451
  type Props$2 = {
2272
- owner: string;
2273
- repo: string;
2274
- basePath: string;
2275
- branch?: string;
2276
- token: string;
2277
- pathSystem?: DocPathSystem;
2278
- reader?: DocFileSystemReadType;
1452
+ name: string;
1453
+ path: string;
1454
+ icon: string;
1455
+ title: string;
1456
+ children: DocTreeNodeValue[];
2279
1457
  };
2280
1458
  /**
2281
- * GitHub repository write-only file system using Octokit
1459
+ * Tree directory node value object
2282
1460
  */
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?;
1461
+ declare class DocTreeDirectoryNodeValue {
1462
+ private readonly props;
2291
1463
  constructor(props: Props$2);
1464
+ get name(): string;
1465
+ get path(): string;
1466
+ get icon(): string;
1467
+ get title(): string;
1468
+ get children(): DocTreeNodeValue[];
1469
+ get type(): typeof DOC_NODE_TYPE_DIRECTORY;
2292
1470
  /**
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
1471
+ * Convert to plain object
2306
1472
  */
2307
- ensureDirectoryExists(relativePath: string): Promise<Error | null>;
1473
+ toJson(): DocTreeDirectoryNode;
2308
1474
  /**
2309
- * Copy file to new location
1475
+ * Create from properties
2310
1476
  */
2311
- copyFile(sourcePath: string, destinationPath: string): Promise<Error | null>;
1477
+ static from(props: Props$2): DocTreeDirectoryNodeValue;
2312
1478
  /**
2313
- * Move file to new location
1479
+ * Create from JSON object
2314
1480
  */
2315
- moveFile(sourcePath: string, destinationPath: string): Promise<Error | null>;
1481
+ static fromJson(json: unknown): DocTreeDirectoryNodeValue;
2316
1482
  }
2317
1483
 
2318
1484
  type Props$1 = {
2319
- basePath: string;
2320
- pathSystem?: DocPathSystem;
1485
+ fileSystem: DocFileSystem;
1486
+ pathSystem: DocPathSystem;
1487
+ indexFileName: string;
1488
+ archiveDirectoryName: string;
1489
+ config: DocClientConfig;
2321
1490
  };
2322
1491
  /**
2323
- * Read-only file system implementation
1492
+ * File tree building system
2324
1493
  */
2325
- declare class DocFileSystemRead implements DocFileSystemReadType {
2326
- protected readonly basePath: string;
2327
- protected readonly pathSystem: DocPathSystem;
1494
+ declare class DocFileTreeSystem {
1495
+ private readonly props;
1496
+ private readonly config;
2328
1497
  constructor(props: Props$1);
2329
1498
  /**
2330
- * Read file content at the specified path
1499
+ * Build file tree recursively
1500
+ */
1501
+ buildFileTree(directoryPath?: string): Promise<DocTreeNodeValue[] | Error>;
1502
+ /**
1503
+ * Create file node
2331
1504
  */
2332
- readFile(relativePath: string): Promise<string | null | Error>;
1505
+ private createFileNode;
2333
1506
  /**
2334
- * Get file name from path
1507
+ * Create directory node
2335
1508
  */
2336
- readFileName(relativePath: string): string;
1509
+ private createDirectoryNode;
2337
1510
  /**
2338
- * Get file extension from path
1511
+ * Create index file reference
2339
1512
  */
2340
- readFileExtension(relativePath: string): string;
1513
+ private createIndexFileReference;
2341
1514
  /**
2342
- * Get directory path where the file exists
1515
+ * Create MD file reference
2343
1516
  */
2344
- readFileDirectory(relativePath: string): string;
1517
+ private createMdFileReference;
2345
1518
  /**
2346
- * Get list of entries in directory
1519
+ * Build directory tree recursively (directories only)
2347
1520
  */
2348
- readDirectoryFileNames(relativePath?: string): Promise<string[] | Error>;
2349
- readDirectoryFilePaths(relativePath: string): Promise<string[] | Error>;
1521
+ buildDirectoryTree(directoryPath?: string): Promise<DocTreeDirectoryNodeValue[] | Error>;
2350
1522
  /**
2351
- * Check if path is a directory
1523
+ * Create directory node for directory tree
2352
1524
  */
2353
- isDirectory(relativePath: string): Promise<boolean>;
1525
+ private createDirectoryNodeForTree;
1526
+ }
1527
+
1528
+ /**
1529
+ * Markdown parsing and processing system
1530
+ */
1531
+ declare class DocMarkdownSystem {
1532
+ private readonly frontMatterSeparator;
1533
+ constructor();
2354
1534
  /**
2355
- * Check if path is a file
1535
+ * Detect FrontMatter separator line
2356
1536
  */
2357
- isFile(relativePath: string): Promise<boolean>;
1537
+ private detectFrontMatterSeparator;
2358
1538
  /**
2359
- * Check if file or directory exists
1539
+ * Extract FrontMatter
2360
1540
  */
2361
- exists(relativePath: string): Promise<boolean>;
1541
+ extractFrontMatter(text: string): string | null;
2362
1542
  /**
2363
- * Check if directory exists
1543
+ * Extract body without FrontMatter (includes title and description)
2364
1544
  */
2365
- directoryExists(relativePath: string): Promise<boolean>;
1545
+ extractBody(text: string): string;
2366
1546
  /**
2367
- * Check if file exists
1547
+ * Extract title
2368
1548
  */
2369
- fileExists(relativePath: string): Promise<boolean>;
1549
+ extractTitle(text: string): string | null;
2370
1550
  /**
2371
- * Get base path
1551
+ * Extract description (first paragraph after title)
2372
1552
  */
2373
- getBasePath(): string;
1553
+ extractDescription(text: string): string | null;
2374
1554
  /**
2375
- * Convert relative path to absolute path
1555
+ * Update title in body (returns body only, without FrontMatter)
2376
1556
  */
2377
- resolve(relativePath: string): string;
1557
+ updateTitle(text: string, newTitle: string): string;
2378
1558
  /**
2379
- * Get file size in bytes
1559
+ * Update description in body (returns body only, without FrontMatter)
2380
1560
  */
2381
- getFileSize(relativePath: string): Promise<number | Error>;
1561
+ updateDescription(text: string, newDescription: string, defaultTitle: string): string;
2382
1562
  /**
2383
- * Get file last modified time
1563
+ * Skip empty lines
2384
1564
  */
2385
- getFileModifiedTime(relativePath: string): Promise<Date | Error>;
1565
+ private skipEmptyLines;
2386
1566
  /**
2387
- * Get file creation time
1567
+ * Generate Markdown text (title + description + body)
2388
1568
  */
2389
- getFileCreatedTime(relativePath: string): Promise<Date | Error>;
1569
+ static from(title: string, description: string, body: string): string;
2390
1570
  }
2391
1571
 
2392
1572
  type Props = {
2393
- basePath: string;
1573
+ fileSystem: DocFileSystem;
2394
1574
  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>;
1575
+ markdownSystem?: DocMarkdownSystem;
1576
+ fileTreeSystem?: DocFileTreeSystem;
2425
1577
  /**
2426
- * Move file
1578
+ * Configuration
2427
1579
  */
2428
- moveFile(sourcePath: string, destinationPath: string): Promise<Error | null>;
1580
+ config?: DocClientConfig;
1581
+ };
1582
+ declare class DocClient {
1583
+ readonly fileSystem: DocFileSystem;
1584
+ readonly pathSystem: DocPathSystem;
1585
+ readonly markdownSystem: DocMarkdownSystem;
1586
+ readonly fileTreeSystem: DocFileTreeSystem;
1587
+ readonly config: DocClientConfig;
1588
+ constructor(props: Props);
1589
+ basePath(): string;
1590
+ file<Path extends string>(relativePath: Path): InferReference<Path, DocCustomSchema>;
1591
+ file<Path extends string, T extends DocCustomSchema>(relativePath: Path, customSchema: T): InferReference<Path, T>;
1592
+ mdFile(relativePath: string): DocFileMdReference<DocCustomSchema>;
1593
+ mdFile<T extends DocCustomSchema>(relativePath: string, customSchema: T): DocFileMdReference<T>;
1594
+ indexFile(relativePath: string): DocFileIndexReference<DocCustomSchema>;
1595
+ indexFile<T extends DocCustomSchema>(relativePath: string, customSchema: T): DocFileIndexReference<T>;
1596
+ directory(relativePath: string): DocDirectoryReference<DocCustomSchema>;
1597
+ directory<T extends DocCustomSchema>(relativePath: string, customSchema: T): DocDirectoryReference<T>;
1598
+ fileTree(directoryPath?: string): Promise<DocTreeNode[]>;
1599
+ directoryTree(directoryPath?: string): Promise<DocTreeDirectoryNode[]>;
2429
1600
  }
2430
1601
 
2431
1602
  /**
@@ -2449,67 +1620,6 @@ declare class DocPathSystemMock extends DocPathSystem {
2449
1620
  static createWithSeparator(separator: string): DocPathSystemMock;
2450
1621
  }
2451
1622
 
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
1623
  /**
2514
1624
  * Function that only performs type checking (does nothing at runtime)
2515
1625
  */
@@ -2788,4 +1898,4 @@ declare class DocRelationFieldValue {
2788
1898
  }): DocRelationFieldValue;
2789
1899
  }
2790
1900
 
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 };
1901
+ export { type BaseFieldValueType, type DetectFileType, DocClient, type DocClientConfig, type DocCustomSchema, type DocCustomSchemaField, type DocCustomSchemaFieldBoolean, type DocCustomSchemaFieldMultiNumber, type DocCustomSchemaFieldMultiRelation, type DocCustomSchemaFieldMultiSelectNumber, type DocCustomSchemaFieldMultiSelectText, type DocCustomSchemaFieldMultiText, type DocCustomSchemaFieldNumber, type DocCustomSchemaFieldRelation, type DocCustomSchemaFieldSelectNumber, type DocCustomSchemaFieldSelectText, type DocCustomSchemaFieldText, DocCustomSchemaFieldValue, type DocDirectory, type DocDirectoryFile, DocDirectoryPathValue, DocDirectoryReference, type DocFieldTypeLiteral, type DocFile, type DocFileAny, type DocFileEntity, type DocFileIndex, type DocFileIndexAny, type DocFileIndexContent, DocFileIndexContentValue, DocFileIndexEntity, type DocFileIndexMeta, DocFileIndexMetaValue, DocFileIndexReference, type DocFileIndexSchema, type DocFileIndexSchemaField, DocFileIndexSchemaValue, type DocFileMd, type DocFileMdAny, type DocFileMdContent, DocFileMdContentValue, DocFileMdEntity, type DocFileMdMeta, type DocFileMdMetaAny, DocFileMdMetaValue, DocFileMdReference, type DocFilePath, DocFilePathValue, DocFileRelationReference, DocFileTreeSystem, type DocFileUnknown, DocFileUnknownEntity, DocFileUnknownReference, DocMarkdownSystem, type DocMetaField, type DocMetaFieldBoolean, type DocMetaFieldMultiNumber, type DocMetaFieldMultiRelation, type DocMetaFieldMultiSelectNumber, type DocMetaFieldMultiSelectText, type DocMetaFieldMultiText, type DocMetaFieldNumber, type DocMetaFieldRelation, type DocMetaFieldSelectNumber, type DocMetaFieldSelectText, type DocMetaFieldText, type DocMetaFieldType, type DocMetaFieldTypeBoolean, type DocMetaFieldTypeNumber, type DocMetaFieldTypeRelation, type DocMetaFieldTypeSelectNumber, type DocMetaFieldTypeSelectText, type DocMetaFieldTypeText, DocPathSystem, DocPathSystemMock, type DocRelation, type DocRelationField, DocRelationFieldValue, type DocRelationFile, DocRelationFileValue, DocRelationValue, type DocSchemaFieldBoolean, type DocSchemaFieldMultiNumber, type DocSchemaFieldMultiRelation, type DocSchemaFieldMultiSelectNumber, type DocSchemaFieldMultiSelectText, type DocSchemaFieldMultiText, type DocSchemaFieldNumber, type DocSchemaFieldRelation, type DocSchemaFieldSelectNumber, type DocSchemaFieldSelectText, type DocSchemaFieldText, type DocSchemaRelationFieldUnion, type DocTreeDirectoryNode, DocTreeDirectoryNodeValue, type DocTreeFileNode, DocTreeFileNodeValue, type DocTreeNode, type DocTreeNodeValue, type Equals, type ExtractFieldType, type ExtractRequired, type FieldValueType, type GetIndexFieldType, type GetValueType, type InferDocFileMd, type InferReference, type MultiRelationKeys, type OptionalKeys, type RecordKey, type RelationKeys, type RequiredKeys, type SchemaToValueType, type UpdateFunction, assertType, defaultTestConfig, defineSchema, docCustomSchemaField, expectType, zDocClientConfig, zDocFileIndex, zDocFileIndexSchemaField, zDocFileMd, zDocFilePath, zDocFileUnknown, zDocMetaField, zDocMetaFieldBoolean, zDocMetaFieldMultiNumber, zDocMetaFieldMultiRelation, zDocMetaFieldMultiSelectNumber, zDocMetaFieldMultiSelectText, zDocMetaFieldMultiText, zDocMetaFieldNumber, zDocMetaFieldRelation, zDocMetaFieldSelectNumber, zDocMetaFieldSelectText, zDocMetaFieldText, zDocMetaFieldType, zDocMetaFieldTypeBoolean, zDocMetaFieldTypeNumber, zDocMetaFieldTypeRelation, zDocMetaFieldTypeSelectNumber, zDocMetaFieldTypeSelectText, zDocMetaFieldTypeText, zDocRelation, zDocRelationField, zDocRelationFile, zDocSchemaFieldBoolean, zDocSchemaFieldMultiNumber, zDocSchemaFieldMultiRelation, zDocSchemaFieldMultiSelectNumber, zDocSchemaFieldMultiSelectText, zDocSchemaFieldMultiText, zDocSchemaFieldNumber, zDocSchemaFieldRelation, zDocSchemaFieldSelectNumber, zDocSchemaFieldSelectText, zDocSchemaFieldText };