@interactive-inc/docs-client 1.0.4 → 1.0.8
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 +582 -409
- package/build/index.js +564 -207
- package/build/models.d.ts +277 -3753
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -1233,24 +1233,6 @@ var DocFileMdMetaValue = class _DocFileMdMetaValue {
|
|
|
1233
1233
|
this.validateValue(value, customSchema);
|
|
1234
1234
|
Object.freeze(this);
|
|
1235
1235
|
}
|
|
1236
|
-
validateValue(value, schema) {
|
|
1237
|
-
const keys = Object.keys(schema);
|
|
1238
|
-
for (const key of keys) {
|
|
1239
|
-
const schemaField = schema[key];
|
|
1240
|
-
const fieldValue = this.getValueField(value, key);
|
|
1241
|
-
if (schemaField.required && fieldValue === void 0) {
|
|
1242
|
-
throw new Error(`Required field "${key}" is missing`);
|
|
1243
|
-
}
|
|
1244
|
-
if (fieldValue !== void 0) {
|
|
1245
|
-
const factory = new DocMetaFieldFactory();
|
|
1246
|
-
factory.fromType(key, schemaField.type, fieldValue);
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1250
|
-
getValueField(value, key) {
|
|
1251
|
-
const record = value;
|
|
1252
|
-
return record[key];
|
|
1253
|
-
}
|
|
1254
1236
|
get keys() {
|
|
1255
1237
|
return Object.keys(this.value);
|
|
1256
1238
|
}
|
|
@@ -1269,24 +1251,6 @@ var DocFileMdMetaValue = class _DocFileMdMetaValue {
|
|
|
1269
1251
|
this.customSchema
|
|
1270
1252
|
);
|
|
1271
1253
|
}
|
|
1272
|
-
/**
|
|
1273
|
-
* Return a new instance with an unknown schema
|
|
1274
|
-
* Allows accepting Record<string, unknown> schemas from external sources
|
|
1275
|
-
*/
|
|
1276
|
-
withUnknownSchema(draft) {
|
|
1277
|
-
const typedSchema = draft;
|
|
1278
|
-
const newValue = {};
|
|
1279
|
-
for (const key in typedSchema) {
|
|
1280
|
-
if (key in this.value) {
|
|
1281
|
-
const unknownValue = this.value;
|
|
1282
|
-
newValue[key] = unknownValue[key];
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
return new _DocFileMdMetaValue(
|
|
1286
|
-
newValue,
|
|
1287
|
-
typedSchema
|
|
1288
|
-
);
|
|
1289
|
-
}
|
|
1290
1254
|
schemaField(key) {
|
|
1291
1255
|
const field = this.customSchema[key];
|
|
1292
1256
|
if (field === void 0) {
|
|
@@ -1367,6 +1331,33 @@ var DocFileMdMetaValue = class _DocFileMdMetaValue {
|
|
|
1367
1331
|
}
|
|
1368
1332
|
return true;
|
|
1369
1333
|
}
|
|
1334
|
+
toJson() {
|
|
1335
|
+
return this.value;
|
|
1336
|
+
}
|
|
1337
|
+
toYaml() {
|
|
1338
|
+
return stringify(this.value).trim();
|
|
1339
|
+
}
|
|
1340
|
+
validateValue(value, schema) {
|
|
1341
|
+
if (Object.keys(schema).length === 0) {
|
|
1342
|
+
return;
|
|
1343
|
+
}
|
|
1344
|
+
const keys = Object.keys(schema);
|
|
1345
|
+
for (const key of keys) {
|
|
1346
|
+
const schemaField = schema[key];
|
|
1347
|
+
const fieldValue = this.getValueField(value, key);
|
|
1348
|
+
if (schemaField.required && fieldValue === void 0) {
|
|
1349
|
+
throw new Error(`Required field "${key}" is missing`);
|
|
1350
|
+
}
|
|
1351
|
+
if (fieldValue !== void 0) {
|
|
1352
|
+
const factory = new DocMetaFieldFactory();
|
|
1353
|
+
factory.fromType(key, schemaField.type, fieldValue);
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
getValueField(value, key) {
|
|
1358
|
+
const record = value;
|
|
1359
|
+
return record[key];
|
|
1360
|
+
}
|
|
1370
1361
|
/**
|
|
1371
1362
|
* Generate from Markdown text
|
|
1372
1363
|
*/
|
|
@@ -1381,7 +1372,7 @@ var DocFileMdMetaValue = class _DocFileMdMetaValue {
|
|
|
1381
1372
|
}).parse(yamlRecord);
|
|
1382
1373
|
const schemaFieldKeys = Object.keys(customSchema);
|
|
1383
1374
|
const factory = new DocCustomSchemaFieldFactory();
|
|
1384
|
-
const validatedRecord = {};
|
|
1375
|
+
const validatedRecord = { ...record };
|
|
1385
1376
|
for (const key of schemaFieldKeys) {
|
|
1386
1377
|
const schemaField = customSchema[key];
|
|
1387
1378
|
const customSchemaField = factory.fromType(key, schemaField);
|
|
@@ -1408,12 +1399,6 @@ var DocFileMdMetaValue = class _DocFileMdMetaValue {
|
|
|
1408
1399
|
}
|
|
1409
1400
|
return new _DocFileMdMetaValue(record, customSchema);
|
|
1410
1401
|
}
|
|
1411
|
-
toJson() {
|
|
1412
|
-
return this.value;
|
|
1413
|
-
}
|
|
1414
|
-
toYaml() {
|
|
1415
|
-
return stringify(this.value).trim();
|
|
1416
|
-
}
|
|
1417
1402
|
};
|
|
1418
1403
|
|
|
1419
1404
|
// lib/values/doc-file-md-content-value.ts
|
|
@@ -1714,6 +1699,12 @@ var DocFilePathValue = class _DocFilePathValue {
|
|
|
1714
1699
|
get isArchived() {
|
|
1715
1700
|
return this.path.includes("/.archive/");
|
|
1716
1701
|
}
|
|
1702
|
+
/**
|
|
1703
|
+
* Export as JSON format
|
|
1704
|
+
*/
|
|
1705
|
+
toJson() {
|
|
1706
|
+
return this.value;
|
|
1707
|
+
}
|
|
1717
1708
|
/**
|
|
1718
1709
|
* Create instance from relative path (DI support)
|
|
1719
1710
|
*/
|
|
@@ -1735,12 +1726,6 @@ var DocFilePathValue = class _DocFilePathValue {
|
|
|
1735
1726
|
pathSystem
|
|
1736
1727
|
);
|
|
1737
1728
|
}
|
|
1738
|
-
/**
|
|
1739
|
-
* Export as JSON format
|
|
1740
|
-
*/
|
|
1741
|
-
toJson() {
|
|
1742
|
-
return this.value;
|
|
1743
|
-
}
|
|
1744
1729
|
};
|
|
1745
1730
|
|
|
1746
1731
|
// lib/values/doc-relation-file-value.ts
|
|
@@ -1770,16 +1755,10 @@ var DocRelationFileValue = class _DocRelationFileValue {
|
|
|
1770
1755
|
return this.value.label || this.value.name;
|
|
1771
1756
|
}
|
|
1772
1757
|
/**
|
|
1773
|
-
*
|
|
1758
|
+
* Convert to JSON format
|
|
1774
1759
|
*/
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
return new _DocRelationFileValue({
|
|
1778
|
-
name: fileName,
|
|
1779
|
-
label: title || fileName,
|
|
1780
|
-
value: null,
|
|
1781
|
-
path: null
|
|
1782
|
-
});
|
|
1760
|
+
toJson() {
|
|
1761
|
+
return { ...this.value };
|
|
1783
1762
|
}
|
|
1784
1763
|
/**
|
|
1785
1764
|
* Extract file name from file path (without extension)
|
|
@@ -1788,10 +1767,16 @@ var DocRelationFileValue = class _DocRelationFileValue {
|
|
|
1788
1767
|
return filePath.split("/").pop()?.replace(".md", "") || filePath;
|
|
1789
1768
|
}
|
|
1790
1769
|
/**
|
|
1791
|
-
*
|
|
1770
|
+
* Create from file path and title
|
|
1792
1771
|
*/
|
|
1793
|
-
|
|
1794
|
-
|
|
1772
|
+
static from(filePath, title) {
|
|
1773
|
+
const fileName = _DocRelationFileValue.extractFileName(filePath);
|
|
1774
|
+
return new _DocRelationFileValue({
|
|
1775
|
+
name: fileName,
|
|
1776
|
+
label: title || fileName,
|
|
1777
|
+
value: null,
|
|
1778
|
+
path: null
|
|
1779
|
+
});
|
|
1795
1780
|
}
|
|
1796
1781
|
};
|
|
1797
1782
|
|
|
@@ -1809,32 +1794,23 @@ var DocRelationValue = class _DocRelationValue {
|
|
|
1809
1794
|
get path() {
|
|
1810
1795
|
return this.value.path;
|
|
1811
1796
|
}
|
|
1812
|
-
/**
|
|
1813
|
-
* List of related files (value objects)
|
|
1814
|
-
*/
|
|
1815
|
-
get files() {
|
|
1816
|
-
return this.value.files.map((file) => new DocRelationFileValue(file));
|
|
1817
|
-
}
|
|
1818
1797
|
/**
|
|
1819
1798
|
* Get file count
|
|
1820
1799
|
*/
|
|
1821
1800
|
get fileCount() {
|
|
1822
|
-
return this.files.length;
|
|
1801
|
+
return this.files().length;
|
|
1823
1802
|
}
|
|
1824
1803
|
/**
|
|
1825
1804
|
* Whether it's empty
|
|
1826
1805
|
*/
|
|
1827
1806
|
get isEmpty() {
|
|
1828
|
-
return this.files.length === 0;
|
|
1807
|
+
return this.files().length === 0;
|
|
1829
1808
|
}
|
|
1830
1809
|
/**
|
|
1831
|
-
*
|
|
1810
|
+
* List of related files (value objects)
|
|
1832
1811
|
*/
|
|
1833
|
-
|
|
1834
|
-
return new
|
|
1835
|
-
path,
|
|
1836
|
-
files: []
|
|
1837
|
-
});
|
|
1812
|
+
files() {
|
|
1813
|
+
return this.value.files.map((file) => new DocRelationFileValue(file));
|
|
1838
1814
|
}
|
|
1839
1815
|
/**
|
|
1840
1816
|
* Export as JSON format
|
|
@@ -1842,9 +1818,18 @@ var DocRelationValue = class _DocRelationValue {
|
|
|
1842
1818
|
toJson() {
|
|
1843
1819
|
return {
|
|
1844
1820
|
path: this.path,
|
|
1845
|
-
files: this.files.map((file) => file.toJson())
|
|
1821
|
+
files: this.files().map((file) => file.toJson())
|
|
1846
1822
|
};
|
|
1847
1823
|
}
|
|
1824
|
+
/**
|
|
1825
|
+
* Create empty relation entity
|
|
1826
|
+
*/
|
|
1827
|
+
static empty(path) {
|
|
1828
|
+
return new _DocRelationValue({
|
|
1829
|
+
path,
|
|
1830
|
+
files: []
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1848
1833
|
};
|
|
1849
1834
|
|
|
1850
1835
|
// lib/doc-file-relation-reference.ts
|
|
@@ -1985,6 +1970,10 @@ import { stringify as stringify3 } from "yaml";
|
|
|
1985
1970
|
// lib/values/doc-file-index-meta-value.ts
|
|
1986
1971
|
import { parse as parse2, stringify as stringify2 } from "yaml";
|
|
1987
1972
|
|
|
1973
|
+
// lib/constants.ts
|
|
1974
|
+
var INDEX_META = "index-meta";
|
|
1975
|
+
var DOC_NODE_TYPE_DIRECTORY = "directory";
|
|
1976
|
+
|
|
1988
1977
|
// lib/values/doc-schema-field/doc-schema-field-boolean-value.ts
|
|
1989
1978
|
var DocSchemaFieldBooleanValue = class _DocSchemaFieldBooleanValue {
|
|
1990
1979
|
constructor(key, value) {
|
|
@@ -2028,11 +2017,11 @@ var DocSchemaFieldBooleanValue = class _DocSchemaFieldBooleanValue {
|
|
|
2028
2017
|
default: null
|
|
2029
2018
|
});
|
|
2030
2019
|
}
|
|
2031
|
-
static
|
|
2020
|
+
static from(key, record) {
|
|
2032
2021
|
const value = record;
|
|
2033
2022
|
return new _DocSchemaFieldBooleanValue(key, {
|
|
2034
2023
|
type: value.type,
|
|
2035
|
-
required: value.required,
|
|
2024
|
+
required: value.required ?? false,
|
|
2036
2025
|
title: value.title ?? null,
|
|
2037
2026
|
description: value.description ?? null,
|
|
2038
2027
|
default: value.default ?? null
|
|
@@ -2087,11 +2076,11 @@ var DocSchemaFieldMultiNumberValue = class _DocSchemaFieldMultiNumberValue {
|
|
|
2087
2076
|
default: null
|
|
2088
2077
|
});
|
|
2089
2078
|
}
|
|
2090
|
-
static
|
|
2079
|
+
static from(key, record) {
|
|
2091
2080
|
const value = record;
|
|
2092
2081
|
return new _DocSchemaFieldMultiNumberValue(key, {
|
|
2093
2082
|
type: value.type,
|
|
2094
|
-
required: value.required,
|
|
2083
|
+
required: value.required ?? false,
|
|
2095
2084
|
title: value.title ?? null,
|
|
2096
2085
|
description: value.description ?? null,
|
|
2097
2086
|
default: value.default ?? null
|
|
@@ -2150,11 +2139,11 @@ var DocSchemaFieldMultiRelationValue = class _DocSchemaFieldMultiRelationValue {
|
|
|
2150
2139
|
path: ""
|
|
2151
2140
|
});
|
|
2152
2141
|
}
|
|
2153
|
-
static
|
|
2142
|
+
static from(key, record) {
|
|
2154
2143
|
const value = record;
|
|
2155
2144
|
return new _DocSchemaFieldMultiRelationValue(key, {
|
|
2156
2145
|
type: value.type,
|
|
2157
|
-
required: value.required,
|
|
2146
|
+
required: value.required ?? false,
|
|
2158
2147
|
title: value.title ?? null,
|
|
2159
2148
|
description: value.description ?? null,
|
|
2160
2149
|
default: value.default ?? null,
|
|
@@ -2216,11 +2205,11 @@ var DocSchemaFieldMultiSelectNumberValue = class _DocSchemaFieldMultiSelectNumbe
|
|
|
2216
2205
|
options: []
|
|
2217
2206
|
});
|
|
2218
2207
|
}
|
|
2219
|
-
static
|
|
2208
|
+
static from(key, record) {
|
|
2220
2209
|
const value = record;
|
|
2221
2210
|
return new _DocSchemaFieldMultiSelectNumberValue(key, {
|
|
2222
2211
|
type: value.type,
|
|
2223
|
-
required: value.required,
|
|
2212
|
+
required: value.required ?? false,
|
|
2224
2213
|
title: value.title ?? null,
|
|
2225
2214
|
description: value.description ?? null,
|
|
2226
2215
|
default: value.default ?? null,
|
|
@@ -2282,11 +2271,11 @@ var DocSchemaFieldMultiSelectTextValue = class _DocSchemaFieldMultiSelectTextVal
|
|
|
2282
2271
|
options: []
|
|
2283
2272
|
});
|
|
2284
2273
|
}
|
|
2285
|
-
static
|
|
2274
|
+
static from(key, record) {
|
|
2286
2275
|
const value = record;
|
|
2287
2276
|
return new _DocSchemaFieldMultiSelectTextValue(key, {
|
|
2288
2277
|
type: value.type,
|
|
2289
|
-
required: value.required,
|
|
2278
|
+
required: value.required ?? false,
|
|
2290
2279
|
title: value.title ?? null,
|
|
2291
2280
|
description: value.description ?? null,
|
|
2292
2281
|
default: value.default ?? null,
|
|
@@ -2342,11 +2331,11 @@ var DocSchemaFieldMultiTextValue = class _DocSchemaFieldMultiTextValue {
|
|
|
2342
2331
|
default: null
|
|
2343
2332
|
});
|
|
2344
2333
|
}
|
|
2345
|
-
static
|
|
2334
|
+
static from(key, record) {
|
|
2346
2335
|
const value = record;
|
|
2347
2336
|
return new _DocSchemaFieldMultiTextValue(key, {
|
|
2348
2337
|
type: value.type,
|
|
2349
|
-
required: value.required,
|
|
2338
|
+
required: value.required ?? false,
|
|
2350
2339
|
title: value.title ?? null,
|
|
2351
2340
|
description: value.description ?? null,
|
|
2352
2341
|
default: value.default ?? null
|
|
@@ -2397,11 +2386,11 @@ var DocSchemaFieldNumberValue = class _DocSchemaFieldNumberValue {
|
|
|
2397
2386
|
default: null
|
|
2398
2387
|
});
|
|
2399
2388
|
}
|
|
2400
|
-
static
|
|
2389
|
+
static from(key, record) {
|
|
2401
2390
|
const value = record;
|
|
2402
2391
|
return new _DocSchemaFieldNumberValue(key, {
|
|
2403
2392
|
type: value.type,
|
|
2404
|
-
required: value.required,
|
|
2393
|
+
required: value.required ?? false,
|
|
2405
2394
|
title: value.title ?? null,
|
|
2406
2395
|
description: value.description ?? null,
|
|
2407
2396
|
default: value.default ?? null
|
|
@@ -2456,11 +2445,11 @@ var DocSchemaFieldRelationValue = class _DocSchemaFieldRelationValue {
|
|
|
2456
2445
|
path: ""
|
|
2457
2446
|
});
|
|
2458
2447
|
}
|
|
2459
|
-
static
|
|
2448
|
+
static from(key, record) {
|
|
2460
2449
|
const value = record;
|
|
2461
2450
|
return new _DocSchemaFieldRelationValue(key, {
|
|
2462
2451
|
type: value.type,
|
|
2463
|
-
required: value.required,
|
|
2452
|
+
required: value.required ?? false,
|
|
2464
2453
|
title: value.title ?? null,
|
|
2465
2454
|
description: value.description ?? null,
|
|
2466
2455
|
default: value.default ?? null,
|
|
@@ -2519,11 +2508,11 @@ var DocSchemaFieldSelectNumberValue = class _DocSchemaFieldSelectNumberValue {
|
|
|
2519
2508
|
options: []
|
|
2520
2509
|
});
|
|
2521
2510
|
}
|
|
2522
|
-
static
|
|
2511
|
+
static from(key, record) {
|
|
2523
2512
|
const value = record;
|
|
2524
2513
|
return new _DocSchemaFieldSelectNumberValue(key, {
|
|
2525
2514
|
type: value.type,
|
|
2526
|
-
required: value.required,
|
|
2515
|
+
required: value.required ?? false,
|
|
2527
2516
|
title: value.title ?? null,
|
|
2528
2517
|
description: value.description ?? null,
|
|
2529
2518
|
default: value.default ?? null,
|
|
@@ -2584,11 +2573,11 @@ var DocSchemaFieldSelectTextValue = class _DocSchemaFieldSelectTextValue {
|
|
|
2584
2573
|
options: []
|
|
2585
2574
|
});
|
|
2586
2575
|
}
|
|
2587
|
-
static
|
|
2576
|
+
static from(key, record) {
|
|
2588
2577
|
const value = record;
|
|
2589
2578
|
return new _DocSchemaFieldSelectTextValue(key, {
|
|
2590
2579
|
type: value.type,
|
|
2591
|
-
required: value.required,
|
|
2580
|
+
required: value.required ?? false,
|
|
2592
2581
|
title: value.title ?? null,
|
|
2593
2582
|
description: value.description ?? null,
|
|
2594
2583
|
default: value.default ?? null,
|
|
@@ -2640,11 +2629,11 @@ var DocSchemaFieldTextValue = class _DocSchemaFieldTextValue {
|
|
|
2640
2629
|
default: null
|
|
2641
2630
|
});
|
|
2642
2631
|
}
|
|
2643
|
-
static
|
|
2632
|
+
static from(key, record) {
|
|
2644
2633
|
const value = record;
|
|
2645
2634
|
return new _DocSchemaFieldTextValue(key, {
|
|
2646
2635
|
type: value.type,
|
|
2647
|
-
required: value.required,
|
|
2636
|
+
required: value.required ?? false,
|
|
2648
2637
|
title: value.title ?? null,
|
|
2649
2638
|
description: value.description ?? null,
|
|
2650
2639
|
default: value.default ?? null
|
|
@@ -2690,41 +2679,41 @@ var DocFileIndexSchemaFieldFactory = class {
|
|
|
2690
2679
|
}
|
|
2691
2680
|
throw new Error(`Unknown field type: ${type}`);
|
|
2692
2681
|
}
|
|
2693
|
-
|
|
2682
|
+
from(key, record) {
|
|
2694
2683
|
const value = record;
|
|
2695
2684
|
const type = value.type;
|
|
2696
2685
|
if (type === "text") {
|
|
2697
|
-
return DocSchemaFieldTextValue.
|
|
2686
|
+
return DocSchemaFieldTextValue.from(key, record);
|
|
2698
2687
|
}
|
|
2699
2688
|
if (type === "number") {
|
|
2700
|
-
return DocSchemaFieldNumberValue.
|
|
2689
|
+
return DocSchemaFieldNumberValue.from(key, record);
|
|
2701
2690
|
}
|
|
2702
2691
|
if (type === "boolean") {
|
|
2703
|
-
return DocSchemaFieldBooleanValue.
|
|
2692
|
+
return DocSchemaFieldBooleanValue.from(key, record);
|
|
2704
2693
|
}
|
|
2705
2694
|
if (type === "select-text") {
|
|
2706
|
-
return DocSchemaFieldSelectTextValue.
|
|
2695
|
+
return DocSchemaFieldSelectTextValue.from(key, record);
|
|
2707
2696
|
}
|
|
2708
2697
|
if (type === "select-number") {
|
|
2709
|
-
return DocSchemaFieldSelectNumberValue.
|
|
2698
|
+
return DocSchemaFieldSelectNumberValue.from(key, record);
|
|
2710
2699
|
}
|
|
2711
2700
|
if (type === "relation") {
|
|
2712
|
-
return DocSchemaFieldRelationValue.
|
|
2701
|
+
return DocSchemaFieldRelationValue.from(key, record);
|
|
2713
2702
|
}
|
|
2714
2703
|
if (type === "multi-text") {
|
|
2715
|
-
return DocSchemaFieldMultiTextValue.
|
|
2704
|
+
return DocSchemaFieldMultiTextValue.from(key, record);
|
|
2716
2705
|
}
|
|
2717
2706
|
if (type === "multi-number") {
|
|
2718
|
-
return DocSchemaFieldMultiNumberValue.
|
|
2707
|
+
return DocSchemaFieldMultiNumberValue.from(key, record);
|
|
2719
2708
|
}
|
|
2720
2709
|
if (type === "multi-select-text") {
|
|
2721
|
-
return DocSchemaFieldMultiSelectTextValue.
|
|
2710
|
+
return DocSchemaFieldMultiSelectTextValue.from(key, record);
|
|
2722
2711
|
}
|
|
2723
2712
|
if (type === "multi-select-number") {
|
|
2724
|
-
return DocSchemaFieldMultiSelectNumberValue.
|
|
2713
|
+
return DocSchemaFieldMultiSelectNumberValue.from(key, record);
|
|
2725
2714
|
}
|
|
2726
2715
|
if (type === "multi-relation") {
|
|
2727
|
-
return DocSchemaFieldMultiRelationValue.
|
|
2716
|
+
return DocSchemaFieldMultiRelationValue.from(key, record);
|
|
2728
2717
|
}
|
|
2729
2718
|
throw new Error(`Unknown field type: ${type}`);
|
|
2730
2719
|
}
|
|
@@ -2755,35 +2744,40 @@ var DocFileIndexSchemaValue = class _DocFileIndexSchemaValue {
|
|
|
2755
2744
|
if (!fieldValue) {
|
|
2756
2745
|
throw new Error(`Field "${key}" not found in schema`);
|
|
2757
2746
|
}
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2747
|
+
if (fieldValue.type === "text") {
|
|
2748
|
+
return new DocSchemaFieldTextValue(key, fieldValue);
|
|
2749
|
+
}
|
|
2750
|
+
if (fieldValue.type === "number") {
|
|
2751
|
+
return new DocSchemaFieldNumberValue(key, fieldValue);
|
|
2752
|
+
}
|
|
2753
|
+
if (fieldValue.type === "boolean") {
|
|
2754
|
+
return new DocSchemaFieldBooleanValue(key, fieldValue);
|
|
2755
|
+
}
|
|
2756
|
+
if (fieldValue.type === "relation") {
|
|
2757
|
+
return new DocSchemaFieldRelationValue(key, fieldValue);
|
|
2758
|
+
}
|
|
2759
|
+
if (fieldValue.type === "select-text") {
|
|
2760
|
+
return new DocSchemaFieldSelectTextValue(key, fieldValue);
|
|
2761
|
+
}
|
|
2762
|
+
if (fieldValue.type === "select-number") {
|
|
2763
|
+
return new DocSchemaFieldSelectNumberValue(key, fieldValue);
|
|
2764
|
+
}
|
|
2765
|
+
if (fieldValue.type === "multi-text") {
|
|
2766
|
+
return new DocSchemaFieldMultiTextValue(key, fieldValue);
|
|
2767
|
+
}
|
|
2768
|
+
if (fieldValue.type === "multi-number") {
|
|
2769
|
+
return new DocSchemaFieldMultiNumberValue(key, fieldValue);
|
|
2770
|
+
}
|
|
2771
|
+
if (fieldValue.type === "multi-relation") {
|
|
2772
|
+
return new DocSchemaFieldMultiRelationValue(key, fieldValue);
|
|
2773
|
+
}
|
|
2774
|
+
if (fieldValue.type === "multi-select-text") {
|
|
2775
|
+
return new DocSchemaFieldMultiSelectTextValue(key, fieldValue);
|
|
2786
2776
|
}
|
|
2777
|
+
if (fieldValue.type === "multi-select-number") {
|
|
2778
|
+
return new DocSchemaFieldMultiSelectNumberValue(key, fieldValue);
|
|
2779
|
+
}
|
|
2780
|
+
throw new Error("Unknown field type");
|
|
2787
2781
|
}
|
|
2788
2782
|
relation(key) {
|
|
2789
2783
|
const fieldValue = this.value[key];
|
|
@@ -2805,24 +2799,6 @@ var DocFileIndexSchemaValue = class _DocFileIndexSchemaValue {
|
|
|
2805
2799
|
}
|
|
2806
2800
|
return new DocSchemaFieldMultiRelationValue(key, fieldValue);
|
|
2807
2801
|
}
|
|
2808
|
-
/**
|
|
2809
|
-
* Get all fields
|
|
2810
|
-
* Note: For type safety, it's recommended to use field() method individually
|
|
2811
|
-
*/
|
|
2812
|
-
get fields() {
|
|
2813
|
-
return this.fieldNames.map((name) => {
|
|
2814
|
-
const value = this.value[name];
|
|
2815
|
-
if (value === void 0) {
|
|
2816
|
-
throw new Error(`Field "${name}" does not exist in schema.`);
|
|
2817
|
-
}
|
|
2818
|
-
return this.value[name];
|
|
2819
|
-
});
|
|
2820
|
-
}
|
|
2821
|
-
get relationFields() {
|
|
2822
|
-
return this.fields.filter((t) => {
|
|
2823
|
-
return t instanceof DocSchemaFieldRelationValue || t instanceof DocSchemaFieldMultiRelationValue;
|
|
2824
|
-
});
|
|
2825
|
-
}
|
|
2826
2802
|
toJson() {
|
|
2827
2803
|
return this.value;
|
|
2828
2804
|
}
|
|
@@ -2841,14 +2817,10 @@ var DocFileIndexMetaValue = class _DocFileIndexMetaValue {
|
|
|
2841
2817
|
this.value = value;
|
|
2842
2818
|
this.customSchema = customSchema;
|
|
2843
2819
|
this.config = config;
|
|
2844
|
-
zDocFileIndexMeta.parse(value);
|
|
2845
2820
|
this.additionalProperties = additionalProperties;
|
|
2821
|
+
zDocFileIndexMeta.parse(value);
|
|
2846
2822
|
Object.freeze(this);
|
|
2847
2823
|
}
|
|
2848
|
-
/**
|
|
2849
|
-
* Additional properties to include in the meta data
|
|
2850
|
-
*/
|
|
2851
|
-
additionalProperties;
|
|
2852
2824
|
/**
|
|
2853
2825
|
* Get icon
|
|
2854
2826
|
*/
|
|
@@ -2871,9 +2843,8 @@ var DocFileIndexMetaValue = class _DocFileIndexMetaValue {
|
|
|
2871
2843
|
* Update icon field
|
|
2872
2844
|
*/
|
|
2873
2845
|
withIcon(value) {
|
|
2874
|
-
const currentData = this.toJson();
|
|
2875
2846
|
return new _DocFileIndexMetaValue(
|
|
2876
|
-
{ ...
|
|
2847
|
+
{ ...this.value, icon: value },
|
|
2877
2848
|
this.customSchema,
|
|
2878
2849
|
this.config,
|
|
2879
2850
|
this.additionalProperties
|
|
@@ -2884,10 +2855,7 @@ var DocFileIndexMetaValue = class _DocFileIndexMetaValue {
|
|
|
2884
2855
|
*/
|
|
2885
2856
|
withSchema(value) {
|
|
2886
2857
|
return new _DocFileIndexMetaValue(
|
|
2887
|
-
{
|
|
2888
|
-
...this.value,
|
|
2889
|
-
schema: value
|
|
2890
|
-
},
|
|
2858
|
+
{ ...this.value, schema: value },
|
|
2891
2859
|
this.customSchema,
|
|
2892
2860
|
this.config,
|
|
2893
2861
|
this.additionalProperties
|
|
@@ -2901,7 +2869,7 @@ var DocFileIndexMetaValue = class _DocFileIndexMetaValue {
|
|
|
2901
2869
|
const typedSchema = draft;
|
|
2902
2870
|
return new _DocFileIndexMetaValue(
|
|
2903
2871
|
{
|
|
2904
|
-
type:
|
|
2872
|
+
type: INDEX_META,
|
|
2905
2873
|
icon: this.value.icon,
|
|
2906
2874
|
schema: typedSchema
|
|
2907
2875
|
},
|
|
@@ -3013,13 +2981,32 @@ var DocFileIndexMetaValue = class _DocFileIndexMetaValue {
|
|
|
3013
2981
|
* Normalize entire schema
|
|
3014
2982
|
*/
|
|
3015
2983
|
static normalizeSchema(schema, customSchema) {
|
|
2984
|
+
const factory = new DocFileIndexSchemaFieldFactory();
|
|
2985
|
+
if (Object.keys(customSchema).length === 0) {
|
|
2986
|
+
const dynamicRecord = {};
|
|
2987
|
+
for (const key of Object.keys(schema)) {
|
|
2988
|
+
const schemaValue = schema[key];
|
|
2989
|
+
if (schemaValue !== void 0 && schemaValue !== null) {
|
|
2990
|
+
const field = factory.from(key, schemaValue);
|
|
2991
|
+
const normalizedValue = {
|
|
2992
|
+
...field.value,
|
|
2993
|
+
required: field.value.required ?? false
|
|
2994
|
+
};
|
|
2995
|
+
dynamicRecord[key] = normalizedValue;
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
return dynamicRecord;
|
|
2999
|
+
}
|
|
3016
3000
|
const record = {};
|
|
3017
3001
|
const customSchemaKeys = Object.keys(customSchema);
|
|
3018
|
-
const factory = new DocFileIndexSchemaFieldFactory();
|
|
3019
3002
|
for (const key of customSchemaKeys) {
|
|
3020
3003
|
const schemaValue = schema[key];
|
|
3021
|
-
const field = factory.
|
|
3022
|
-
|
|
3004
|
+
const field = factory.from(key, schemaValue);
|
|
3005
|
+
const normalizedValue = {
|
|
3006
|
+
...field.value,
|
|
3007
|
+
required: field.value.required ?? false
|
|
3008
|
+
};
|
|
3009
|
+
record[key] = normalizedValue;
|
|
3023
3010
|
}
|
|
3024
3011
|
return record;
|
|
3025
3012
|
}
|
|
@@ -3030,7 +3017,11 @@ var DocFileIndexMetaValue = class _DocFileIndexMetaValue {
|
|
|
3030
3017
|
for (const key of customSchemaKeys) {
|
|
3031
3018
|
const field = customSchema[key];
|
|
3032
3019
|
const customSchemaField = factory.empty(key, field.type);
|
|
3033
|
-
|
|
3020
|
+
const normalizedValue = {
|
|
3021
|
+
...customSchemaField.value,
|
|
3022
|
+
required: customSchemaField.value.required ?? false
|
|
3023
|
+
};
|
|
3024
|
+
record[key] = normalizedValue;
|
|
3034
3025
|
}
|
|
3035
3026
|
return record;
|
|
3036
3027
|
}
|
|
@@ -3205,7 +3196,12 @@ ${this.toMarkdownText()}`;
|
|
|
3205
3196
|
* Output in JSON format
|
|
3206
3197
|
*/
|
|
3207
3198
|
toJson() {
|
|
3208
|
-
|
|
3199
|
+
const metaValue = this.meta();
|
|
3200
|
+
const metaJson = metaValue.toJson();
|
|
3201
|
+
return {
|
|
3202
|
+
...this.value,
|
|
3203
|
+
meta: metaJson
|
|
3204
|
+
};
|
|
3209
3205
|
}
|
|
3210
3206
|
};
|
|
3211
3207
|
|
|
@@ -3340,6 +3336,13 @@ var DocFileIndexReference = class _DocFileIndexReference {
|
|
|
3340
3336
|
this.customSchema
|
|
3341
3337
|
);
|
|
3342
3338
|
}
|
|
3339
|
+
async readSchemaValue() {
|
|
3340
|
+
const indexFile = await this.read();
|
|
3341
|
+
if (indexFile instanceof Error) {
|
|
3342
|
+
return {};
|
|
3343
|
+
}
|
|
3344
|
+
return indexFile.content.meta().schema().value;
|
|
3345
|
+
}
|
|
3343
3346
|
/**
|
|
3344
3347
|
* Read file content
|
|
3345
3348
|
*/
|
|
@@ -4169,10 +4172,7 @@ var DocDirectoryReference = class _DocDirectoryReference {
|
|
|
4169
4172
|
}
|
|
4170
4173
|
async *filesGenerator() {
|
|
4171
4174
|
const fileNames = await this.fileNames();
|
|
4172
|
-
if (fileNames instanceof Error)
|
|
4173
|
-
yield fileNames;
|
|
4174
|
-
return;
|
|
4175
|
-
}
|
|
4175
|
+
if (fileNames instanceof Error) return;
|
|
4176
4176
|
for (const fileName of fileNames) {
|
|
4177
4177
|
if (fileName === "index.md") continue;
|
|
4178
4178
|
if (fileName.endsWith(".md")) {
|
|
@@ -4193,10 +4193,7 @@ var DocDirectoryReference = class _DocDirectoryReference {
|
|
|
4193
4193
|
});
|
|
4194
4194
|
}
|
|
4195
4195
|
const archivedFileNames = await this.archivedFileNames();
|
|
4196
|
-
if (archivedFileNames instanceof Error)
|
|
4197
|
-
yield archivedFileNames;
|
|
4198
|
-
return;
|
|
4199
|
-
}
|
|
4196
|
+
if (archivedFileNames instanceof Error) return;
|
|
4200
4197
|
for (const fileName of archivedFileNames) {
|
|
4201
4198
|
if (fileName === this.indexFileName) continue;
|
|
4202
4199
|
if (fileName.endsWith(".md")) {
|
|
@@ -4240,9 +4237,7 @@ var DocDirectoryReference = class _DocDirectoryReference {
|
|
|
4240
4237
|
async files() {
|
|
4241
4238
|
const files = [];
|
|
4242
4239
|
for await (const ref of this.filesGenerator()) {
|
|
4243
|
-
if (ref instanceof Error)
|
|
4244
|
-
return ref;
|
|
4245
|
-
}
|
|
4240
|
+
if (ref instanceof Error) continue;
|
|
4246
4241
|
files.push(ref);
|
|
4247
4242
|
}
|
|
4248
4243
|
return files;
|
|
@@ -4250,9 +4245,7 @@ var DocDirectoryReference = class _DocDirectoryReference {
|
|
|
4250
4245
|
async mdFiles() {
|
|
4251
4246
|
const refs = [];
|
|
4252
4247
|
for await (const file of this.mdFilesGenerator()) {
|
|
4253
|
-
if (file instanceof Error)
|
|
4254
|
-
return file;
|
|
4255
|
-
}
|
|
4248
|
+
if (file instanceof Error) continue;
|
|
4256
4249
|
refs.push(file);
|
|
4257
4250
|
}
|
|
4258
4251
|
return refs;
|
|
@@ -4287,9 +4280,6 @@ var DocDirectoryReference = class _DocDirectoryReference {
|
|
|
4287
4280
|
async readFiles() {
|
|
4288
4281
|
const entities = [];
|
|
4289
4282
|
for await (const file of this.filesGenerator()) {
|
|
4290
|
-
if (file instanceof Error) {
|
|
4291
|
-
return file;
|
|
4292
|
-
}
|
|
4293
4283
|
const entity = await file.read();
|
|
4294
4284
|
if (entity instanceof Error) continue;
|
|
4295
4285
|
entities.push(entity);
|
|
@@ -4299,9 +4289,6 @@ var DocDirectoryReference = class _DocDirectoryReference {
|
|
|
4299
4289
|
async readMdFiles() {
|
|
4300
4290
|
const entities = [];
|
|
4301
4291
|
for await (const file of this.filesGenerator()) {
|
|
4302
|
-
if (file instanceof Error) {
|
|
4303
|
-
return file;
|
|
4304
|
-
}
|
|
4305
4292
|
const entity = await file.read();
|
|
4306
4293
|
if (entity instanceof Error) continue;
|
|
4307
4294
|
if (entity instanceof DocFileUnknownEntity) continue;
|
|
@@ -4312,9 +4299,6 @@ var DocDirectoryReference = class _DocDirectoryReference {
|
|
|
4312
4299
|
async readUnknownFiles() {
|
|
4313
4300
|
const entities = [];
|
|
4314
4301
|
for await (const file of this.filesGenerator()) {
|
|
4315
|
-
if (file instanceof Error) {
|
|
4316
|
-
return file;
|
|
4317
|
-
}
|
|
4318
4302
|
const entity = await file.read();
|
|
4319
4303
|
if (entity instanceof Error) continue;
|
|
4320
4304
|
if (entity instanceof DocFileMdEntity) continue;
|
|
@@ -4330,7 +4314,7 @@ var DocDirectoryReference = class _DocDirectoryReference {
|
|
|
4330
4314
|
this.relativePath
|
|
4331
4315
|
);
|
|
4332
4316
|
if (allFileNames instanceof Error) {
|
|
4333
|
-
return
|
|
4317
|
+
return [];
|
|
4334
4318
|
}
|
|
4335
4319
|
const directoryNames = [];
|
|
4336
4320
|
for (const fileName of allFileNames) {
|
|
@@ -4350,7 +4334,7 @@ var DocDirectoryReference = class _DocDirectoryReference {
|
|
|
4350
4334
|
async directories() {
|
|
4351
4335
|
const directoryNames = await this.directoryNames();
|
|
4352
4336
|
if (directoryNames instanceof Error) {
|
|
4353
|
-
return
|
|
4337
|
+
return [];
|
|
4354
4338
|
}
|
|
4355
4339
|
return directoryNames.map((dirName) => {
|
|
4356
4340
|
const dirPath = this.pathSystem.join(this.relativePath, dirName);
|
|
@@ -4427,13 +4411,6 @@ var DocDirectoryReference = class _DocDirectoryReference {
|
|
|
4427
4411
|
async exists() {
|
|
4428
4412
|
return await this.fileSystem.exists(this.relativePath);
|
|
4429
4413
|
}
|
|
4430
|
-
/**
|
|
4431
|
-
* Generate unique filename
|
|
4432
|
-
*/
|
|
4433
|
-
uniqueFileName(prefix = "document") {
|
|
4434
|
-
const [uuid] = crypto.randomUUID().split("-");
|
|
4435
|
-
return `${prefix}-${uuid}.md`;
|
|
4436
|
-
}
|
|
4437
4414
|
/**
|
|
4438
4415
|
* Create new Markdown file
|
|
4439
4416
|
*/
|
|
@@ -4454,6 +4431,13 @@ var DocDirectoryReference = class _DocDirectoryReference {
|
|
|
4454
4431
|
}
|
|
4455
4432
|
return fileRef;
|
|
4456
4433
|
}
|
|
4434
|
+
/**
|
|
4435
|
+
* Generate unique filename
|
|
4436
|
+
*/
|
|
4437
|
+
uniqueFileName(prefix = "document") {
|
|
4438
|
+
const [uuid] = crypto.randomUUID().split("-");
|
|
4439
|
+
return `${prefix}-${uuid}.md`;
|
|
4440
|
+
}
|
|
4457
4441
|
};
|
|
4458
4442
|
|
|
4459
4443
|
// lib/values/doc-tree-file-node-value.ts
|
|
@@ -4533,7 +4517,7 @@ var DocTreeDirectoryNodeValue = class _DocTreeDirectoryNodeValue {
|
|
|
4533
4517
|
return this.props.children;
|
|
4534
4518
|
}
|
|
4535
4519
|
get type() {
|
|
4536
|
-
return
|
|
4520
|
+
return DOC_NODE_TYPE_DIRECTORY;
|
|
4537
4521
|
}
|
|
4538
4522
|
/**
|
|
4539
4523
|
* Convert to plain object
|
|
@@ -4542,7 +4526,7 @@ var DocTreeDirectoryNodeValue = class _DocTreeDirectoryNodeValue {
|
|
|
4542
4526
|
return {
|
|
4543
4527
|
name: this.name,
|
|
4544
4528
|
path: this.path,
|
|
4545
|
-
type:
|
|
4529
|
+
type: DOC_NODE_TYPE_DIRECTORY,
|
|
4546
4530
|
icon: this.icon,
|
|
4547
4531
|
title: this.title,
|
|
4548
4532
|
children: this.children.map((child) => child.toJson())
|
|
@@ -5886,13 +5870,381 @@ var docCustomSchemaField = {
|
|
|
5886
5870
|
};
|
|
5887
5871
|
}
|
|
5888
5872
|
};
|
|
5873
|
+
|
|
5874
|
+
// lib/values/doc-custom-schema-field-value.ts
|
|
5875
|
+
var DocCustomSchemaFieldValue = class {
|
|
5876
|
+
constructor(value) {
|
|
5877
|
+
this.value = value;
|
|
5878
|
+
zDocCustomSchemaField.parse(value);
|
|
5879
|
+
Object.freeze(this);
|
|
5880
|
+
}
|
|
5881
|
+
validate(value) {
|
|
5882
|
+
if (this.value.type === "text") {
|
|
5883
|
+
try {
|
|
5884
|
+
return zDocMetaFieldText.parse(value);
|
|
5885
|
+
} catch {
|
|
5886
|
+
if (this.value.required) {
|
|
5887
|
+
return DocMetaFieldTextValue.defaultValue();
|
|
5888
|
+
}
|
|
5889
|
+
return null;
|
|
5890
|
+
}
|
|
5891
|
+
}
|
|
5892
|
+
if (this.value.type === "number") {
|
|
5893
|
+
try {
|
|
5894
|
+
return zDocMetaFieldNumber.parse(value);
|
|
5895
|
+
} catch {
|
|
5896
|
+
if (this.value.required) {
|
|
5897
|
+
return DocMetaFieldNumberValue.defaultValue();
|
|
5898
|
+
}
|
|
5899
|
+
return null;
|
|
5900
|
+
}
|
|
5901
|
+
}
|
|
5902
|
+
if (this.value.type === "boolean") {
|
|
5903
|
+
try {
|
|
5904
|
+
return zDocMetaFieldBoolean.parse(value);
|
|
5905
|
+
} catch {
|
|
5906
|
+
if (this.value.required) {
|
|
5907
|
+
return DocMetaFieldBooleanValue.defaultValue();
|
|
5908
|
+
}
|
|
5909
|
+
return null;
|
|
5910
|
+
}
|
|
5911
|
+
}
|
|
5912
|
+
if (this.value.type === "select-text") {
|
|
5913
|
+
try {
|
|
5914
|
+
return zDocMetaFieldSelectText.parse(value);
|
|
5915
|
+
} catch {
|
|
5916
|
+
if (this.value.required) {
|
|
5917
|
+
return DocMetaFieldSelectTextValue.defaultValue();
|
|
5918
|
+
}
|
|
5919
|
+
return null;
|
|
5920
|
+
}
|
|
5921
|
+
}
|
|
5922
|
+
if (this.value.type === "select-number") {
|
|
5923
|
+
try {
|
|
5924
|
+
return zDocMetaFieldSelectNumber.parse(value);
|
|
5925
|
+
} catch {
|
|
5926
|
+
if (this.value.required) {
|
|
5927
|
+
return DocMetaFieldSelectNumberValue.defaultValue();
|
|
5928
|
+
}
|
|
5929
|
+
return null;
|
|
5930
|
+
}
|
|
5931
|
+
}
|
|
5932
|
+
if (this.value.type === "relation") {
|
|
5933
|
+
try {
|
|
5934
|
+
return zDocMetaFieldRelation.parse(value);
|
|
5935
|
+
} catch {
|
|
5936
|
+
if (this.value.required) {
|
|
5937
|
+
return DocMetaFieldRelationValue.defaultValue();
|
|
5938
|
+
}
|
|
5939
|
+
return null;
|
|
5940
|
+
}
|
|
5941
|
+
}
|
|
5942
|
+
if (this.value.type === "multi-text") {
|
|
5943
|
+
try {
|
|
5944
|
+
return zDocMetaFieldMultiText.parse(value);
|
|
5945
|
+
} catch {
|
|
5946
|
+
if (this.value.required) {
|
|
5947
|
+
return DocMetaFieldMultiTextValue.defaultValue();
|
|
5948
|
+
}
|
|
5949
|
+
return null;
|
|
5950
|
+
}
|
|
5951
|
+
}
|
|
5952
|
+
if (this.value.type === "multi-number") {
|
|
5953
|
+
try {
|
|
5954
|
+
return zDocMetaFieldMultiNumber.parse(value);
|
|
5955
|
+
} catch {
|
|
5956
|
+
if (this.value.required) {
|
|
5957
|
+
return DocMetaFieldMultiNumberValue.defaultValue();
|
|
5958
|
+
}
|
|
5959
|
+
return null;
|
|
5960
|
+
}
|
|
5961
|
+
}
|
|
5962
|
+
if (this.value.type === "multi-select-text") {
|
|
5963
|
+
try {
|
|
5964
|
+
return zDocMetaFieldMultiSelectText.parse(value);
|
|
5965
|
+
} catch {
|
|
5966
|
+
if (this.value.required) {
|
|
5967
|
+
return DocMetaFieldMultiSelectTextValue.defaultValue();
|
|
5968
|
+
}
|
|
5969
|
+
return null;
|
|
5970
|
+
}
|
|
5971
|
+
}
|
|
5972
|
+
if (this.value.type === "multi-select-number") {
|
|
5973
|
+
try {
|
|
5974
|
+
return zDocMetaFieldMultiSelectNumber.parse(value);
|
|
5975
|
+
} catch {
|
|
5976
|
+
if (this.value.required) {
|
|
5977
|
+
return DocMetaFieldMultiSelectNumberValue.defaultValue();
|
|
5978
|
+
}
|
|
5979
|
+
return null;
|
|
5980
|
+
}
|
|
5981
|
+
}
|
|
5982
|
+
if (this.value.type === "multi-relation") {
|
|
5983
|
+
try {
|
|
5984
|
+
return zDocMetaFieldMultiRelation.parse(value);
|
|
5985
|
+
} catch {
|
|
5986
|
+
if (this.value.required) {
|
|
5987
|
+
return DocMetaFieldMultiRelationValue.defaultValue();
|
|
5988
|
+
}
|
|
5989
|
+
return null;
|
|
5990
|
+
}
|
|
5991
|
+
}
|
|
5992
|
+
throw new Error("Unknown field type");
|
|
5993
|
+
}
|
|
5994
|
+
};
|
|
5995
|
+
|
|
5996
|
+
// lib/values/doc-directory-path-value.ts
|
|
5997
|
+
var DocDirectoryPathValue = class _DocDirectoryPathValue {
|
|
5998
|
+
constructor(value, pathSystem) {
|
|
5999
|
+
this.value = value;
|
|
6000
|
+
this.pathSystem = pathSystem;
|
|
6001
|
+
Object.freeze(this);
|
|
6002
|
+
}
|
|
6003
|
+
/**
|
|
6004
|
+
* Relative directory path
|
|
6005
|
+
*/
|
|
6006
|
+
get path() {
|
|
6007
|
+
return this.value.path;
|
|
6008
|
+
}
|
|
6009
|
+
/**
|
|
6010
|
+
* Directory name
|
|
6011
|
+
*/
|
|
6012
|
+
get name() {
|
|
6013
|
+
return this.value.name;
|
|
6014
|
+
}
|
|
6015
|
+
/**
|
|
6016
|
+
* Get parent directory path
|
|
6017
|
+
*/
|
|
6018
|
+
get parent() {
|
|
6019
|
+
if (this.path === "." || this.path === "") {
|
|
6020
|
+
return null;
|
|
6021
|
+
}
|
|
6022
|
+
const parentPath = this.pathSystem.dirname(this.path);
|
|
6023
|
+
const parentName = parentPath === "." ? "" : this.pathSystem.basename(parentPath);
|
|
6024
|
+
return new _DocDirectoryPathValue(
|
|
6025
|
+
{
|
|
6026
|
+
path: parentPath,
|
|
6027
|
+
name: parentName,
|
|
6028
|
+
fullPath: this.pathSystem.dirname(this.fullPath)
|
|
6029
|
+
},
|
|
6030
|
+
this.pathSystem
|
|
6031
|
+
);
|
|
6032
|
+
}
|
|
6033
|
+
/**
|
|
6034
|
+
* Parent directory path
|
|
6035
|
+
*/
|
|
6036
|
+
get parentPath() {
|
|
6037
|
+
return this.pathSystem.dirname(this.path);
|
|
6038
|
+
}
|
|
6039
|
+
/**
|
|
6040
|
+
* Depth (number of directory levels)
|
|
6041
|
+
*/
|
|
6042
|
+
get depth() {
|
|
6043
|
+
if (this.path === "." || this.path === "") {
|
|
6044
|
+
return 0;
|
|
6045
|
+
}
|
|
6046
|
+
return this.path.split(this.pathSystem.separator).filter(Boolean).length;
|
|
6047
|
+
}
|
|
6048
|
+
/**
|
|
6049
|
+
* Path segments (array of directories)
|
|
6050
|
+
*/
|
|
6051
|
+
get segments() {
|
|
6052
|
+
return this.path.split(this.pathSystem.separator).filter(Boolean);
|
|
6053
|
+
}
|
|
6054
|
+
/**
|
|
6055
|
+
* Relative path from root (without leading slash)
|
|
6056
|
+
*/
|
|
6057
|
+
get normalizedPath() {
|
|
6058
|
+
return this.path.replace(/^\/+/, "");
|
|
6059
|
+
}
|
|
6060
|
+
/**
|
|
6061
|
+
* Whether this is an archive directory (directory name is "_")
|
|
6062
|
+
*/
|
|
6063
|
+
get isArchived() {
|
|
6064
|
+
return this.name === "_";
|
|
6065
|
+
}
|
|
6066
|
+
/**
|
|
6067
|
+
* Whether this is a hidden directory
|
|
6068
|
+
*/
|
|
6069
|
+
get isHidden() {
|
|
6070
|
+
return this.name.startsWith(".");
|
|
6071
|
+
}
|
|
6072
|
+
/**
|
|
6073
|
+
* Whether this is the root directory
|
|
6074
|
+
*/
|
|
6075
|
+
get isRoot() {
|
|
6076
|
+
return this.path === "." || this.path === "";
|
|
6077
|
+
}
|
|
6078
|
+
/**
|
|
6079
|
+
* Absolute path
|
|
6080
|
+
*/
|
|
6081
|
+
get fullPath() {
|
|
6082
|
+
return this.value.fullPath;
|
|
6083
|
+
}
|
|
6084
|
+
/**
|
|
6085
|
+
* Get index file path
|
|
6086
|
+
*/
|
|
6087
|
+
get indexFile() {
|
|
6088
|
+
return DocFilePathValue.fromPathWithSystem(
|
|
6089
|
+
this.pathSystem.join(this.path, "index.md"),
|
|
6090
|
+
this.pathSystem,
|
|
6091
|
+
this.pathSystem.dirname(this.fullPath)
|
|
6092
|
+
);
|
|
6093
|
+
}
|
|
6094
|
+
/**
|
|
6095
|
+
* Create file path
|
|
6096
|
+
*/
|
|
6097
|
+
file(fileName) {
|
|
6098
|
+
return DocFilePathValue.fromPathWithSystem(
|
|
6099
|
+
this.pathSystem.join(this.path, fileName),
|
|
6100
|
+
this.pathSystem,
|
|
6101
|
+
this.pathSystem.dirname(this.fullPath)
|
|
6102
|
+
);
|
|
6103
|
+
}
|
|
6104
|
+
/**
|
|
6105
|
+
* Create subdirectory path
|
|
6106
|
+
*/
|
|
6107
|
+
subdirectory(dirName) {
|
|
6108
|
+
const subPath = this.pathSystem.join(this.path, dirName);
|
|
6109
|
+
return new _DocDirectoryPathValue(
|
|
6110
|
+
{
|
|
6111
|
+
path: subPath,
|
|
6112
|
+
name: dirName,
|
|
6113
|
+
fullPath: this.pathSystem.join(this.fullPath, dirName)
|
|
6114
|
+
},
|
|
6115
|
+
this.pathSystem
|
|
6116
|
+
);
|
|
6117
|
+
}
|
|
6118
|
+
/**
|
|
6119
|
+
* Create instance from relative path (DI support)
|
|
6120
|
+
*/
|
|
6121
|
+
static fromPathWithSystem(dirPath, basePath, pathSystem) {
|
|
6122
|
+
const name = dirPath === "." ? "" : pathSystem.basename(dirPath);
|
|
6123
|
+
const fullPath = dirPath === "." ? basePath : pathSystem.join(basePath, dirPath);
|
|
6124
|
+
return new _DocDirectoryPathValue(
|
|
6125
|
+
{
|
|
6126
|
+
path: dirPath,
|
|
6127
|
+
name,
|
|
6128
|
+
fullPath
|
|
6129
|
+
},
|
|
6130
|
+
pathSystem
|
|
6131
|
+
);
|
|
6132
|
+
}
|
|
6133
|
+
/**
|
|
6134
|
+
* Export as JSON format
|
|
6135
|
+
*/
|
|
6136
|
+
toJson() {
|
|
6137
|
+
return this.value;
|
|
6138
|
+
}
|
|
6139
|
+
/**
|
|
6140
|
+
* Check if paths are equal
|
|
6141
|
+
*/
|
|
6142
|
+
equals(other) {
|
|
6143
|
+
return this.path === other.path;
|
|
6144
|
+
}
|
|
6145
|
+
/**
|
|
6146
|
+
* Check if specified directory is a descendant of this directory
|
|
6147
|
+
*/
|
|
6148
|
+
contains(other) {
|
|
6149
|
+
const relative = this.pathSystem.relative(this.path, other.path);
|
|
6150
|
+
return !relative.startsWith("..") && relative !== "";
|
|
6151
|
+
}
|
|
6152
|
+
};
|
|
6153
|
+
|
|
6154
|
+
// lib/values/doc-relation-field-value.ts
|
|
6155
|
+
var DocRelationFieldValue = class _DocRelationFieldValue {
|
|
6156
|
+
constructor(value) {
|
|
6157
|
+
this.value = value;
|
|
6158
|
+
zDocRelationField.parse(value);
|
|
6159
|
+
Object.freeze(this);
|
|
6160
|
+
}
|
|
6161
|
+
/**
|
|
6162
|
+
* Get field name
|
|
6163
|
+
*/
|
|
6164
|
+
get fieldName() {
|
|
6165
|
+
return this.value.fieldName;
|
|
6166
|
+
}
|
|
6167
|
+
/**
|
|
6168
|
+
* Get relation target path
|
|
6169
|
+
*/
|
|
6170
|
+
get relationPath() {
|
|
6171
|
+
return this.value.filePath;
|
|
6172
|
+
}
|
|
6173
|
+
/**
|
|
6174
|
+
* Get whether it's an array type
|
|
6175
|
+
*/
|
|
6176
|
+
get isArray() {
|
|
6177
|
+
return this.value.isArray;
|
|
6178
|
+
}
|
|
6179
|
+
/**
|
|
6180
|
+
* Check if it's a single relation
|
|
6181
|
+
*/
|
|
6182
|
+
get isSingle() {
|
|
6183
|
+
return !this.value.isArray;
|
|
6184
|
+
}
|
|
6185
|
+
/**
|
|
6186
|
+
* Check if it's a multiple relation
|
|
6187
|
+
*/
|
|
6188
|
+
get isMultiple() {
|
|
6189
|
+
return this.value.isArray;
|
|
6190
|
+
}
|
|
6191
|
+
/**
|
|
6192
|
+
* Get target directory name
|
|
6193
|
+
*/
|
|
6194
|
+
get targetDirectoryName() {
|
|
6195
|
+
const parts = this.value.filePath.split("/");
|
|
6196
|
+
return parts[parts.length - 1] || "";
|
|
6197
|
+
}
|
|
6198
|
+
/**
|
|
6199
|
+
* Generate full relation path
|
|
6200
|
+
*/
|
|
6201
|
+
fullPath(basePath) {
|
|
6202
|
+
if (this.value.filePath.startsWith("/")) {
|
|
6203
|
+
return this.value.filePath;
|
|
6204
|
+
}
|
|
6205
|
+
return `${basePath}/${this.value.filePath}`;
|
|
6206
|
+
}
|
|
6207
|
+
/**
|
|
6208
|
+
* Check equality
|
|
6209
|
+
*/
|
|
6210
|
+
equals(other) {
|
|
6211
|
+
return this.fieldName === other.fieldName && this.relationPath === other.relationPath && this.isArray === other.isArray;
|
|
6212
|
+
}
|
|
6213
|
+
/**
|
|
6214
|
+
* Convert to JSON format
|
|
6215
|
+
*/
|
|
6216
|
+
toJson() {
|
|
6217
|
+
return { ...this.value };
|
|
6218
|
+
}
|
|
6219
|
+
/**
|
|
6220
|
+
* Create from data
|
|
6221
|
+
*/
|
|
6222
|
+
static from(data) {
|
|
6223
|
+
const validated = zDocRelationField.parse(data);
|
|
6224
|
+
return new _DocRelationFieldValue(validated);
|
|
6225
|
+
}
|
|
6226
|
+
/**
|
|
6227
|
+
* Create from properties
|
|
6228
|
+
*/
|
|
6229
|
+
static fromProps(props) {
|
|
6230
|
+
return new _DocRelationFieldValue(props);
|
|
6231
|
+
}
|
|
6232
|
+
};
|
|
5889
6233
|
export {
|
|
5890
6234
|
DocClient,
|
|
6235
|
+
DocCustomSchemaFieldValue,
|
|
6236
|
+
DocDirectoryPathValue,
|
|
5891
6237
|
DocDirectoryReference,
|
|
6238
|
+
DocFileIndexContentValue,
|
|
5892
6239
|
DocFileIndexEntity,
|
|
6240
|
+
DocFileIndexMetaValue,
|
|
5893
6241
|
DocFileIndexReference,
|
|
6242
|
+
DocFileIndexSchemaValue,
|
|
6243
|
+
DocFileMdContentValue,
|
|
5894
6244
|
DocFileMdEntity,
|
|
6245
|
+
DocFileMdMetaValue,
|
|
5895
6246
|
DocFileMdReference,
|
|
6247
|
+
DocFilePathValue,
|
|
5896
6248
|
DocFileRelationReference,
|
|
5897
6249
|
DocFileSystem,
|
|
5898
6250
|
DocFileSystemMock,
|
|
@@ -5902,7 +6254,12 @@ export {
|
|
|
5902
6254
|
DocMarkdownSystem,
|
|
5903
6255
|
DocPathSystem,
|
|
5904
6256
|
DocPathSystemMock,
|
|
6257
|
+
DocRelationFieldValue,
|
|
6258
|
+
DocRelationFileValue,
|
|
6259
|
+
DocRelationValue,
|
|
5905
6260
|
DocSchemaBuilder,
|
|
6261
|
+
DocTreeDirectoryNodeValue,
|
|
6262
|
+
DocTreeFileNodeValue,
|
|
5906
6263
|
assertType,
|
|
5907
6264
|
defaultTestConfig,
|
|
5908
6265
|
defineSchema,
|