@interactive-inc/docs-client 1.1.1 → 1.1.2
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/file-system-json.d.ts +0 -2
- package/build/file-system-json.js +0 -3
- package/build/index.d.ts +2 -16
- package/build/index.js +45 -82
- package/package.json +3 -3
|
@@ -152,7 +152,6 @@ declare const zJsonDocumentData: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
|
152
152
|
type JsonDocumentData = z.infer<typeof zJsonDocumentData>;
|
|
153
153
|
type Props = {
|
|
154
154
|
data?: JsonDocumentData | unknown;
|
|
155
|
-
basePath?: string;
|
|
156
155
|
pathSystem?: DocPathSystem;
|
|
157
156
|
reader?: DocFileSystemReadInterface;
|
|
158
157
|
onDataChange?: (data: JsonDocumentData) => void;
|
|
@@ -162,7 +161,6 @@ type Props = {
|
|
|
162
161
|
*/
|
|
163
162
|
declare class DocFileSystemJsonWrite implements DocFileSystemWriteInterface {
|
|
164
163
|
private data;
|
|
165
|
-
private readonly basePath;
|
|
166
164
|
private readonly pathSystem;
|
|
167
165
|
private readonly reader?;
|
|
168
166
|
private readonly onDataChange?;
|
|
@@ -495,7 +495,6 @@ function parseJsonDocumentData2(data) {
|
|
|
495
495
|
}
|
|
496
496
|
var DocFileSystemJsonWrite = class {
|
|
497
497
|
data;
|
|
498
|
-
basePath;
|
|
499
498
|
pathSystem;
|
|
500
499
|
reader;
|
|
501
500
|
onDataChange;
|
|
@@ -509,7 +508,6 @@ var DocFileSystemJsonWrite = class {
|
|
|
509
508
|
} else {
|
|
510
509
|
this.data = {};
|
|
511
510
|
}
|
|
512
|
-
this.basePath = props.basePath ?? "docs";
|
|
513
511
|
this.pathSystem = props.pathSystem ?? new DocPathSystem();
|
|
514
512
|
this.reader = props.reader;
|
|
515
513
|
this.onDataChange = props.onDataChange;
|
|
@@ -700,7 +698,6 @@ var DocFileSystemJson = class _DocFileSystemJson extends DocFileSystem {
|
|
|
700
698
|
});
|
|
701
699
|
const writer = new DocFileSystemJsonWrite({
|
|
702
700
|
data: props.data,
|
|
703
|
-
basePath: props.basePath,
|
|
704
701
|
pathSystem: props.pathSystem,
|
|
705
702
|
reader,
|
|
706
703
|
onDataChange: props.onDataChange
|
package/build/index.d.ts
CHANGED
|
@@ -357,19 +357,9 @@ declare class DocFileIndexMetaValue<T extends DocCustomSchema> {
|
|
|
357
357
|
* Generate empty FrontMatter
|
|
358
358
|
*/
|
|
359
359
|
static empty<T extends DocCustomSchema>(customSchema: T, config: DocClientConfig): DocFileIndexMetaValue<T>;
|
|
360
|
-
|
|
361
|
-
* Extract icon
|
|
362
|
-
*/
|
|
360
|
+
static emptySchema<T extends DocCustomSchema>(customSchema: T): DocFileIndexSchema<keyof T>;
|
|
363
361
|
private static extractIcon;
|
|
364
|
-
/**
|
|
365
|
-
* Extract schema part
|
|
366
|
-
*/
|
|
367
362
|
private static extractSchema;
|
|
368
|
-
/**
|
|
369
|
-
* Normalize entire schema
|
|
370
|
-
*/
|
|
371
|
-
private static normalizeSchema;
|
|
372
|
-
static emptySchema<T extends DocCustomSchema>(customSchema: T): DocFileIndexSchema<keyof T>;
|
|
373
363
|
}
|
|
374
364
|
|
|
375
365
|
/**
|
|
@@ -488,14 +478,11 @@ declare class DocRelationFileValue {
|
|
|
488
478
|
* Convert to JSON format
|
|
489
479
|
*/
|
|
490
480
|
toJson(): DocRelationFile;
|
|
491
|
-
/**
|
|
492
|
-
* Extract file name from file path (without extension)
|
|
493
|
-
*/
|
|
494
|
-
private static extractFileName;
|
|
495
481
|
/**
|
|
496
482
|
* Create from file path and title
|
|
497
483
|
*/
|
|
498
484
|
static from(filePath: string, title: string | null): DocRelationFileValue;
|
|
485
|
+
private static extractFileName;
|
|
499
486
|
}
|
|
500
487
|
|
|
501
488
|
/**
|
|
@@ -677,7 +664,6 @@ declare class DocFileMdMetaValue<T extends DocCustomSchema> {
|
|
|
677
664
|
hasKey(key: keyof T): boolean;
|
|
678
665
|
toJson(): SchemaToValueType<T>;
|
|
679
666
|
toYaml(): string;
|
|
680
|
-
private validateValue;
|
|
681
667
|
private getValueField;
|
|
682
668
|
/**
|
|
683
669
|
* Generate from Markdown text
|
package/build/index.js
CHANGED
|
@@ -1450,64 +1450,6 @@ var DocFileIndexMetaValue = class _DocFileIndexMetaValue {
|
|
|
1450
1450
|
{}
|
|
1451
1451
|
);
|
|
1452
1452
|
}
|
|
1453
|
-
/**
|
|
1454
|
-
* Extract icon
|
|
1455
|
-
*/
|
|
1456
|
-
static extractIcon(data, config) {
|
|
1457
|
-
if ("icon" in data && typeof data.icon === "string") {
|
|
1458
|
-
return data.icon;
|
|
1459
|
-
}
|
|
1460
|
-
return config.defaultIndexIcon;
|
|
1461
|
-
}
|
|
1462
|
-
/**
|
|
1463
|
-
* Extract schema part
|
|
1464
|
-
*/
|
|
1465
|
-
static extractSchema(record, customSchema) {
|
|
1466
|
-
const hasSchema = "schema" in record;
|
|
1467
|
-
if (hasSchema === false) {
|
|
1468
|
-
return _DocFileIndexMetaValue.emptySchema(customSchema);
|
|
1469
|
-
}
|
|
1470
|
-
if (typeof record.schema !== "object" || record.schema === null) {
|
|
1471
|
-
return _DocFileIndexMetaValue.emptySchema(customSchema);
|
|
1472
|
-
}
|
|
1473
|
-
return _DocFileIndexMetaValue.normalizeSchema(
|
|
1474
|
-
record.schema,
|
|
1475
|
-
customSchema
|
|
1476
|
-
);
|
|
1477
|
-
}
|
|
1478
|
-
/**
|
|
1479
|
-
* Normalize entire schema
|
|
1480
|
-
*/
|
|
1481
|
-
static normalizeSchema(schema, customSchema) {
|
|
1482
|
-
const factory = new DocFileIndexSchemaFieldFactory();
|
|
1483
|
-
if (Object.keys(customSchema).length === 0) {
|
|
1484
|
-
const dynamicRecord = {};
|
|
1485
|
-
for (const key of Object.keys(schema)) {
|
|
1486
|
-
const schemaValue = schema[key];
|
|
1487
|
-
if (schemaValue !== void 0 && schemaValue !== null) {
|
|
1488
|
-
const field = factory.from(key, schemaValue);
|
|
1489
|
-
const normalizedValue = {
|
|
1490
|
-
...field.value,
|
|
1491
|
-
required: field.value.required ?? false
|
|
1492
|
-
};
|
|
1493
|
-
dynamicRecord[key] = normalizedValue;
|
|
1494
|
-
}
|
|
1495
|
-
}
|
|
1496
|
-
return dynamicRecord;
|
|
1497
|
-
}
|
|
1498
|
-
const record = {};
|
|
1499
|
-
const customSchemaKeys = Object.keys(customSchema);
|
|
1500
|
-
for (const key of customSchemaKeys) {
|
|
1501
|
-
const schemaValue = schema[key];
|
|
1502
|
-
const field = factory.from(key, schemaValue);
|
|
1503
|
-
const normalizedValue = {
|
|
1504
|
-
...field.value,
|
|
1505
|
-
required: field.value.required ?? false
|
|
1506
|
-
};
|
|
1507
|
-
record[key] = normalizedValue;
|
|
1508
|
-
}
|
|
1509
|
-
return record;
|
|
1510
|
-
}
|
|
1511
1453
|
static emptySchema(customSchema) {
|
|
1512
1454
|
const record = {};
|
|
1513
1455
|
const customSchemaKeys = Object.keys(customSchema);
|
|
@@ -1523,6 +1465,32 @@ var DocFileIndexMetaValue = class _DocFileIndexMetaValue {
|
|
|
1523
1465
|
}
|
|
1524
1466
|
return record;
|
|
1525
1467
|
}
|
|
1468
|
+
// biome-ignore lint/correctness/noUnusedPrivateClassMembers: Used in fromRecord static method
|
|
1469
|
+
static extractIcon(record, config) {
|
|
1470
|
+
if (typeof record.icon === "string") {
|
|
1471
|
+
return record.icon;
|
|
1472
|
+
}
|
|
1473
|
+
return config.defaultIndexIcon;
|
|
1474
|
+
}
|
|
1475
|
+
// biome-ignore lint/correctness/noUnusedPrivateClassMembers: Used in fromRecord static method
|
|
1476
|
+
static extractSchema(record, customSchema) {
|
|
1477
|
+
if (typeof record.schema === "object" && record.schema !== null && !Array.isArray(record.schema)) {
|
|
1478
|
+
const rawSchema = record.schema;
|
|
1479
|
+
const normalizedSchema = {};
|
|
1480
|
+
for (const key in rawSchema) {
|
|
1481
|
+
const field = rawSchema[key];
|
|
1482
|
+
normalizedSchema[key] = {
|
|
1483
|
+
...field,
|
|
1484
|
+
required: field.required ?? false,
|
|
1485
|
+
title: field.title ?? null,
|
|
1486
|
+
description: field.description ?? null,
|
|
1487
|
+
default: field.default ?? null
|
|
1488
|
+
};
|
|
1489
|
+
}
|
|
1490
|
+
return normalizedSchema;
|
|
1491
|
+
}
|
|
1492
|
+
return _DocFileIndexMetaValue.emptySchema(customSchema);
|
|
1493
|
+
}
|
|
1526
1494
|
};
|
|
1527
1495
|
|
|
1528
1496
|
// lib/values/doc-file-index-content-value.ts
|
|
@@ -2596,7 +2564,12 @@ var DocFileMdMetaValue = class _DocFileMdMetaValue {
|
|
|
2596
2564
|
constructor(value, customSchema) {
|
|
2597
2565
|
this.value = value;
|
|
2598
2566
|
this.customSchema = customSchema;
|
|
2599
|
-
|
|
2567
|
+
for (const key in customSchema) {
|
|
2568
|
+
const field = customSchema[key];
|
|
2569
|
+
if (field.required && !(key in value)) {
|
|
2570
|
+
throw new Error(`Required field "${key}" is missing`);
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2600
2573
|
Object.freeze(this);
|
|
2601
2574
|
}
|
|
2602
2575
|
get keys() {
|
|
@@ -2698,23 +2671,6 @@ var DocFileMdMetaValue = class _DocFileMdMetaValue {
|
|
|
2698
2671
|
toYaml() {
|
|
2699
2672
|
return stringify(this.value).trim();
|
|
2700
2673
|
}
|
|
2701
|
-
validateValue(value, schema) {
|
|
2702
|
-
if (Object.keys(schema).length === 0) {
|
|
2703
|
-
return;
|
|
2704
|
-
}
|
|
2705
|
-
const keys = Object.keys(schema);
|
|
2706
|
-
for (const key of keys) {
|
|
2707
|
-
const schemaField = schema[key];
|
|
2708
|
-
const fieldValue = this.getValueField(value, key);
|
|
2709
|
-
if (schemaField.required && fieldValue === void 0) {
|
|
2710
|
-
throw new Error(`Required field "${key}" is missing`);
|
|
2711
|
-
}
|
|
2712
|
-
if (fieldValue !== void 0) {
|
|
2713
|
-
const factory = new DocMetaFieldFactory();
|
|
2714
|
-
factory.fromType(key, schemaField.type, fieldValue);
|
|
2715
|
-
}
|
|
2716
|
-
}
|
|
2717
|
-
}
|
|
2718
2674
|
getValueField(value, key) {
|
|
2719
2675
|
const record = value;
|
|
2720
2676
|
return record[key];
|
|
@@ -3072,12 +3028,6 @@ var DocRelationFileValue = class _DocRelationFileValue {
|
|
|
3072
3028
|
toJson() {
|
|
3073
3029
|
return { ...this.value };
|
|
3074
3030
|
}
|
|
3075
|
-
/**
|
|
3076
|
-
* Extract file name from file path (without extension)
|
|
3077
|
-
*/
|
|
3078
|
-
static extractFileName(filePath) {
|
|
3079
|
-
return filePath.split("/").pop()?.replace(".md", "") || filePath;
|
|
3080
|
-
}
|
|
3081
3031
|
/**
|
|
3082
3032
|
* Create from file path and title
|
|
3083
3033
|
*/
|
|
@@ -3090,6 +3040,19 @@ var DocRelationFileValue = class _DocRelationFileValue {
|
|
|
3090
3040
|
path: null
|
|
3091
3041
|
});
|
|
3092
3042
|
}
|
|
3043
|
+
// biome-ignore lint/correctness/noUnusedPrivateClassMembers: Used in from static method
|
|
3044
|
+
static extractFileName(filePath) {
|
|
3045
|
+
if (!filePath) {
|
|
3046
|
+
return filePath;
|
|
3047
|
+
}
|
|
3048
|
+
const lastSlash = filePath.lastIndexOf("/");
|
|
3049
|
+
const fileNameWithExt = lastSlash >= 0 ? filePath.slice(lastSlash + 1) : filePath;
|
|
3050
|
+
const lastDot = fileNameWithExt.lastIndexOf(".");
|
|
3051
|
+
if (lastDot > 0) {
|
|
3052
|
+
return fileNameWithExt.slice(0, lastDot);
|
|
3053
|
+
}
|
|
3054
|
+
return fileNameWithExt;
|
|
3055
|
+
}
|
|
3093
3056
|
};
|
|
3094
3057
|
|
|
3095
3058
|
// lib/values/doc-relation-value.ts
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interactive-inc/docs-client",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"check": "tsgo --noEmit",
|
|
7
7
|
"build": "tsup",
|
|
8
|
-
"deploy": "bun
|
|
8
|
+
"deploy": "bun publish"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@octokit/rest": "^22.0.0",
|
|
12
|
-
"yaml": "^2.
|
|
12
|
+
"yaml": "^2.8.1"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"zod": "^4.0.0"
|