@interactive-inc/docs-client 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.d.ts CHANGED
@@ -1715,7 +1715,7 @@ declare class DocClient {
1715
1715
  /**
1716
1716
  * In-memory file system for testing
1717
1717
  */
1718
- declare class DocFileSystemDebug extends DocFileSystem {
1718
+ declare class DocFileSystemMock extends DocFileSystem {
1719
1719
  private files;
1720
1720
  private readonly _pathSystem;
1721
1721
  constructor(props: {
@@ -1726,13 +1726,17 @@ declare class DocFileSystemDebug extends DocFileSystem {
1726
1726
  * PathSystem accessor (for testing)
1727
1727
  */
1728
1728
  getPathSystem(): DocPathSystem;
1729
+ /**
1730
+ * Create instance (mock data is automatically loaded)
1731
+ */
1732
+ static create(basePath?: string): DocFileSystemMock;
1729
1733
  /**
1730
1734
  * Factory method for testing
1731
1735
  */
1732
1736
  static createWithFiles(props: {
1733
1737
  basePath?: string;
1734
1738
  fileContents?: Record<string, string>;
1735
- }): DocFileSystemDebug;
1739
+ }): DocFileSystemMock;
1736
1740
  readFile(filePath: string): Promise<string | null>;
1737
1741
  writeFile(filePath: string, content: string): Promise<void>;
1738
1742
  deleteFile(filePath: string): Promise<Error | null>;
@@ -1791,6 +1795,27 @@ declare class DocFileSystemDebug extends DocFileSystem {
1791
1795
  setupTestFiles(files: Record<string, string>): void;
1792
1796
  }
1793
1797
 
1798
+ /**
1799
+ * Mock path system for testing
1800
+ */
1801
+ declare class DocPathSystemMock extends DocPathSystem {
1802
+ private readonly _separator;
1803
+ constructor(separator?: string);
1804
+ join(...paths: string[]): string;
1805
+ basename(path: string, ext?: string): string;
1806
+ dirname(path: string): string;
1807
+ extname(path: string): string;
1808
+ relative(from: string, to: string): string;
1809
+ resolve(...paths: string[]): string;
1810
+ normalize(path: string): string;
1811
+ isAbsolute(path: string): boolean;
1812
+ get sep(): string;
1813
+ /**
1814
+ * Set custom separator for testing
1815
+ */
1816
+ static createWithSeparator(separator: string): DocPathSystemMock;
1817
+ }
1818
+
1794
1819
  /**
1795
1820
  * Schema builder
1796
1821
  * Build schemas in a chain style
@@ -1939,4 +1964,4 @@ declare const docCustomSchemaField: {
1939
1964
  };
1940
1965
  };
1941
1966
 
1942
- 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 };
1967
+ 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, DocFileSystemMock, 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, DocPathSystemMock, 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 };
package/build/index.js CHANGED
@@ -5062,13 +5062,46 @@ var DocFileSystem = class {
5062
5062
  }
5063
5063
  };
5064
5064
 
5065
- // lib/doc-file-system-debug.ts
5066
- var DocFileSystemDebug = class _DocFileSystemDebug extends DocFileSystem {
5065
+ // lib/doc-file-system-mock.ts
5066
+ var mockDirectoryData = {
5067
+ "docs/index.md": `---
5068
+ icon: \u{1F4DA}
5069
+ ---
5070
+
5071
+ # Documentation
5072
+
5073
+ Welcome to the documentation!`,
5074
+ "docs/guide/index.md": `---
5075
+ icon: \u{1F4D6}
5076
+ ---
5077
+
5078
+ # Guide
5079
+
5080
+ This is a guide.`,
5081
+ "docs/guide/getting-started.md": `# Getting Started
5082
+
5083
+ Let's get started!`,
5084
+ "docs/guide/advanced.md": `# Advanced
5085
+
5086
+ Advanced topics here.`,
5087
+ "docs/api/index.md": `---
5088
+ icon: \u{1F527}
5089
+ ---
5090
+
5091
+ # API
5092
+
5093
+ API documentation.`,
5094
+ "docs/api/reference.md": `# API Reference
5095
+
5096
+ Complete API reference.`
5097
+ };
5098
+ var DocFileSystemMock = class _DocFileSystemMock extends DocFileSystem {
5067
5099
  files = /* @__PURE__ */ new Map();
5068
5100
  _pathSystem;
5069
5101
  constructor(props) {
5070
5102
  super(props);
5071
5103
  this._pathSystem = props.pathSystem;
5104
+ this.setupTestFiles(mockDirectoryData);
5072
5105
  Object.freeze(this);
5073
5106
  }
5074
5107
  /**
@@ -5077,13 +5110,20 @@ var DocFileSystemDebug = class _DocFileSystemDebug extends DocFileSystem {
5077
5110
  getPathSystem() {
5078
5111
  return this._pathSystem;
5079
5112
  }
5113
+ /**
5114
+ * Create instance (mock data is automatically loaded)
5115
+ */
5116
+ static create(basePath = "/test") {
5117
+ const pathSystem = new DocPathSystem();
5118
+ return new _DocFileSystemMock({ basePath, pathSystem });
5119
+ }
5080
5120
  /**
5081
5121
  * Factory method for testing
5082
5122
  */
5083
5123
  static createWithFiles(props) {
5084
5124
  const pathSystem = new DocPathSystem();
5085
5125
  const basePath = props.basePath ?? "/test";
5086
- const fileSystem = new _DocFileSystemDebug({ basePath, pathSystem });
5126
+ const fileSystem = new _DocFileSystemMock({ basePath, pathSystem });
5087
5127
  if (props.fileContents) {
5088
5128
  const now = /* @__PURE__ */ new Date();
5089
5129
  for (const [path, content] of Object.entries(props.fileContents)) {
@@ -5243,7 +5283,7 @@ var DocFileSystemDebug = class _DocFileSystemDebug extends DocFileSystem {
5243
5283
  * Get list of entries in directory
5244
5284
  */
5245
5285
  async readDirectoryFileNames(directoryPath = "") {
5246
- const normalizedDir = directoryPath === "" ? "docs" : directoryPath.startsWith("docs/") ? directoryPath : `docs/${directoryPath}`;
5286
+ const normalizedDir = directoryPath === "" ? "docs" : directoryPath === "docs" ? "docs" : directoryPath.startsWith("docs/") ? directoryPath : `docs/${directoryPath}`;
5247
5287
  const dirPath = normalizedDir.endsWith("/") ? normalizedDir : `${normalizedDir}/`;
5248
5288
  const entries = /* @__PURE__ */ new Set();
5249
5289
  for (const path of this.files.keys()) {
@@ -5320,6 +5360,109 @@ var DocFileSystemDebug = class _DocFileSystemDebug extends DocFileSystem {
5320
5360
  }
5321
5361
  };
5322
5362
 
5363
+ // lib/doc-path-system-mock.ts
5364
+ var DocPathSystemMock = class _DocPathSystemMock extends DocPathSystem {
5365
+ _separator;
5366
+ constructor(separator = "/") {
5367
+ super();
5368
+ this._separator = separator;
5369
+ Object.freeze(this);
5370
+ }
5371
+ join(...paths) {
5372
+ return paths.filter((path) => path !== "").join(this._separator).replace(new RegExp(`${this._separator}+`, "g"), this._separator);
5373
+ }
5374
+ basename(path, ext) {
5375
+ const normalizedPath = path.replace(/\\/g, "/");
5376
+ const lastSlashIndex = normalizedPath.lastIndexOf("/");
5377
+ let base = lastSlashIndex === -1 ? normalizedPath : normalizedPath.slice(lastSlashIndex + 1);
5378
+ if (ext && base.endsWith(ext)) {
5379
+ base = base.slice(0, -ext.length);
5380
+ }
5381
+ return base;
5382
+ }
5383
+ dirname(path) {
5384
+ const normalizedPath = path.replace(/\\/g, "/");
5385
+ const lastSlashIndex = normalizedPath.lastIndexOf("/");
5386
+ if (lastSlashIndex === -1) {
5387
+ return ".";
5388
+ }
5389
+ if (lastSlashIndex === 0) {
5390
+ return "/";
5391
+ }
5392
+ return normalizedPath.slice(0, lastSlashIndex);
5393
+ }
5394
+ extname(path) {
5395
+ const base = this.basename(path);
5396
+ const lastDotIndex = base.lastIndexOf(".");
5397
+ if (lastDotIndex === -1 || lastDotIndex === 0) {
5398
+ return "";
5399
+ }
5400
+ return base.slice(lastDotIndex);
5401
+ }
5402
+ relative(from, to) {
5403
+ const fromParts = from.split("/").filter(Boolean);
5404
+ const toParts = to.split("/").filter(Boolean);
5405
+ let commonLength = 0;
5406
+ for (let i = 0; i < Math.min(fromParts.length, toParts.length); i++) {
5407
+ if (fromParts[i] === toParts[i]) {
5408
+ commonLength++;
5409
+ } else {
5410
+ break;
5411
+ }
5412
+ }
5413
+ const upLevels = fromParts.length - commonLength;
5414
+ const downParts = toParts.slice(commonLength);
5415
+ const result = Array(upLevels).fill("..").concat(downParts);
5416
+ return result.length === 0 ? "." : result.join("/");
5417
+ }
5418
+ resolve(...paths) {
5419
+ let resolved = "";
5420
+ let isAbsolute = false;
5421
+ for (let i = paths.length - 1; i >= 0 && !isAbsolute; i--) {
5422
+ const path = paths[i];
5423
+ if (path) {
5424
+ resolved = path + (resolved ? `/${resolved}` : "");
5425
+ isAbsolute = path.startsWith("/");
5426
+ }
5427
+ }
5428
+ if (!isAbsolute) {
5429
+ resolved = `/mock-cwd/${resolved}`;
5430
+ }
5431
+ return this.normalize(resolved);
5432
+ }
5433
+ normalize(path) {
5434
+ if (!path) return ".";
5435
+ const isAbsolute = path.startsWith("/");
5436
+ const parts = path.split("/").filter(Boolean);
5437
+ const normalizedParts = [];
5438
+ for (const part of parts) {
5439
+ if (part === "..") {
5440
+ if (normalizedParts.length > 0 && normalizedParts[normalizedParts.length - 1] !== "..") {
5441
+ normalizedParts.pop();
5442
+ } else if (!isAbsolute) {
5443
+ normalizedParts.push("..");
5444
+ }
5445
+ } else if (part !== ".") {
5446
+ normalizedParts.push(part);
5447
+ }
5448
+ }
5449
+ const result = (isAbsolute ? "/" : "") + normalizedParts.join("/");
5450
+ return result || (isAbsolute ? "/" : ".");
5451
+ }
5452
+ isAbsolute(path) {
5453
+ return path.startsWith("/");
5454
+ }
5455
+ get sep() {
5456
+ return this._separator;
5457
+ }
5458
+ /**
5459
+ * Set custom separator for testing
5460
+ */
5461
+ static createWithSeparator(separator) {
5462
+ return new _DocPathSystemMock(separator);
5463
+ }
5464
+ };
5465
+
5323
5466
  // lib/doc-schema-builder.ts
5324
5467
  var DocSchemaBuilder = class _DocSchemaBuilder {
5325
5468
  constructor(schema = {}) {
@@ -5489,12 +5632,13 @@ export {
5489
5632
  DocFileMdReference,
5490
5633
  DocFileRelationReference,
5491
5634
  DocFileSystem,
5492
- DocFileSystemDebug,
5635
+ DocFileSystemMock,
5493
5636
  DocFileTreeSystem,
5494
5637
  DocFileUnknownEntity,
5495
5638
  DocFileUnknownReference,
5496
5639
  DocMarkdownSystem,
5497
5640
  DocPathSystem,
5641
+ DocPathSystemMock,
5498
5642
  DocSchemaBuilder,
5499
5643
  assertType,
5500
5644
  defaultTestConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interactive-inc/docs-client",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "check": "tsgo --noEmit",
@@ -8,7 +8,9 @@
8
8
  "deploy": "bun run build && npm publish"
9
9
  },
10
10
  "dependencies": {
11
- "yaml": "^2.0.0",
11
+ "yaml": "^2.0.0"
12
+ },
13
+ "peerDependencies": {
12
14
  "zod": "^4.0.0"
13
15
  },
14
16
  "publishConfig": {