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