@interactive-inc/docs-client 0.0.16 → 0.0.18

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.js CHANGED
@@ -4160,7 +4160,7 @@ var DocDirectoryReference = class _DocDirectoryReference {
4160
4160
  }
4161
4161
  return refs;
4162
4162
  }
4163
- async file(fileName) {
4163
+ file(fileName) {
4164
4164
  const filePath = this.pathSystem.join(this.relativePath, fileName);
4165
4165
  if (fileName.endsWith(".md")) {
4166
4166
  return new DocFileMdReference({
@@ -4178,7 +4178,7 @@ var DocDirectoryReference = class _DocDirectoryReference {
4178
4178
  config: this.props.config
4179
4179
  });
4180
4180
  }
4181
- async mdFile(fileName) {
4181
+ mdFile(fileName) {
4182
4182
  return new DocFileMdReference({
4183
4183
  path: fileName.endsWith(".md") ? this.pathSystem.join(this.relativePath, fileName) : this.pathSystem.join(this.relativePath, `${fileName}.md`),
4184
4184
  fileSystem: this.fileSystem,
@@ -4248,16 +4248,24 @@ var DocDirectoryReference = class _DocDirectoryReference {
4248
4248
  archiveDirectoryName: this.archiveDirectoryName,
4249
4249
  fileSystem: this.fileSystem,
4250
4250
  pathSystem: this.pathSystem,
4251
- customSchema: {},
4251
+ customSchema: this.customSchema,
4252
4252
  config: this.props.config
4253
4253
  });
4254
4254
  });
4255
4255
  }
4256
- /**
4257
- * Get single subdirectory reference
4258
- */
4259
- directory(directoryName) {
4256
+ directory(directoryName, customSchema) {
4260
4257
  const dirPath = this.pathSystem.join(this.relativePath, directoryName);
4258
+ if (customSchema) {
4259
+ return new _DocDirectoryReference({
4260
+ path: dirPath,
4261
+ indexFileName: this.indexFileName,
4262
+ archiveDirectoryName: this.archiveDirectoryName,
4263
+ fileSystem: this.fileSystem,
4264
+ pathSystem: this.pathSystem,
4265
+ customSchema,
4266
+ config: this.props.config
4267
+ });
4268
+ }
4261
4269
  return new _DocDirectoryReference({
4262
4270
  path: dirPath,
4263
4271
  indexFileName: this.indexFileName,
@@ -4755,10 +4763,15 @@ var DocClient = class {
4755
4763
  * Get file reference
4756
4764
  */
4757
4765
  file(relativePath, customSchema) {
4758
- if (relativePath.endsWith(".md") && customSchema === void 0) {
4759
- return this.mdFile(relativePath);
4760
- }
4761
- if (relativePath.endsWith(".md") && customSchema !== void 0) {
4766
+ const fileName = this.pathSystem.basename(relativePath);
4767
+ if (fileName === this.config.indexFileName) {
4768
+ const dirPath = this.pathSystem.dirname(relativePath);
4769
+ return this.indexFile(dirPath === "." ? "" : dirPath, customSchema);
4770
+ }
4771
+ if (relativePath.endsWith(".md")) {
4772
+ if (customSchema === void 0) {
4773
+ return this.mdFile(relativePath);
4774
+ }
4762
4775
  return this.mdFile(relativePath, customSchema);
4763
4776
  }
4764
4777
  return new DocFileUnknownReference({
@@ -5307,73 +5320,73 @@ var DocFileSystemDebug = class _DocFileSystemDebug extends DocFileSystem {
5307
5320
  }
5308
5321
  };
5309
5322
 
5310
- // lib/schema-builder.ts
5311
- var SchemaBuilder = class _SchemaBuilder {
5323
+ // lib/doc-schema-builder.ts
5324
+ var DocSchemaBuilder = class _DocSchemaBuilder {
5312
5325
  constructor(schema = {}) {
5313
5326
  this.schema = schema;
5314
5327
  }
5315
5328
  text(key, required) {
5316
- return new _SchemaBuilder({
5329
+ return new _DocSchemaBuilder({
5317
5330
  ...this.schema,
5318
5331
  [key]: { type: "text", required }
5319
5332
  });
5320
5333
  }
5321
5334
  number(key, required) {
5322
- return new _SchemaBuilder({
5335
+ return new _DocSchemaBuilder({
5323
5336
  ...this.schema,
5324
5337
  [key]: { type: "number", required }
5325
5338
  });
5326
5339
  }
5327
5340
  boolean(key, required) {
5328
- return new _SchemaBuilder({
5341
+ return new _DocSchemaBuilder({
5329
5342
  ...this.schema,
5330
5343
  [key]: { type: "boolean", required }
5331
5344
  });
5332
5345
  }
5333
5346
  relation(key, required) {
5334
- return new _SchemaBuilder({
5347
+ return new _DocSchemaBuilder({
5335
5348
  ...this.schema,
5336
5349
  [key]: { type: "relation", required }
5337
5350
  });
5338
5351
  }
5339
5352
  multiRelation(key, required) {
5340
- return new _SchemaBuilder({
5353
+ return new _DocSchemaBuilder({
5341
5354
  ...this.schema,
5342
5355
  [key]: { type: "multi-relation", required }
5343
5356
  });
5344
5357
  }
5345
5358
  selectText(key, required) {
5346
- return new _SchemaBuilder({
5359
+ return new _DocSchemaBuilder({
5347
5360
  ...this.schema,
5348
5361
  [key]: { type: "select-text", required }
5349
5362
  });
5350
5363
  }
5351
5364
  selectNumber(key, required) {
5352
- return new _SchemaBuilder({
5365
+ return new _DocSchemaBuilder({
5353
5366
  ...this.schema,
5354
5367
  [key]: { type: "select-number", required }
5355
5368
  });
5356
5369
  }
5357
5370
  multiText(key, required) {
5358
- return new _SchemaBuilder({
5371
+ return new _DocSchemaBuilder({
5359
5372
  ...this.schema,
5360
5373
  [key]: { type: "multi-text", required }
5361
5374
  });
5362
5375
  }
5363
5376
  multiNumber(key, required) {
5364
- return new _SchemaBuilder({
5377
+ return new _DocSchemaBuilder({
5365
5378
  ...this.schema,
5366
5379
  [key]: { type: "multi-number", required }
5367
5380
  });
5368
5381
  }
5369
5382
  multiSelectText(key, required) {
5370
- return new _SchemaBuilder({
5383
+ return new _DocSchemaBuilder({
5371
5384
  ...this.schema,
5372
5385
  [key]: { type: "multi-select-text", required }
5373
5386
  });
5374
5387
  }
5375
5388
  multiSelectNumber(key, required) {
5376
- return new _SchemaBuilder({
5389
+ return new _DocSchemaBuilder({
5377
5390
  ...this.schema,
5378
5391
  [key]: { type: "multi-select-number", required }
5379
5392
  });
@@ -5477,12 +5490,12 @@ export {
5477
5490
  DocFileRelationReference,
5478
5491
  DocFileSystem,
5479
5492
  DocFileSystemDebug,
5493
+ DocFileTreeSystem,
5480
5494
  DocFileUnknownEntity,
5481
5495
  DocFileUnknownReference,
5482
5496
  DocMarkdownSystem,
5483
5497
  DocPathSystem,
5484
- DocFileTreeSystem as FileTreeSystem,
5485
- SchemaBuilder,
5498
+ DocSchemaBuilder,
5486
5499
  assertType,
5487
5500
  defaultTestConfig,
5488
5501
  defineSchema,
package/debug/debug.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { DocClient } from "@/doc-client"
2
2
  import { DocFileSystem } from "@/doc-file-system"
3
- import { SchemaBuilder } from "@/schema-builder"
3
+ import { DocSchemaBuilder } from "@/doc-schema-builder"
4
4
  import { defineSchema, docCustomSchemaField } from "@/utils"
5
5
 
6
6
  const client = new DocClient({
@@ -12,9 +12,9 @@ const pageSchema = defineSchema({
12
12
  features: docCustomSchemaField.multiRelation(true),
13
13
  })
14
14
 
15
- const pagesRef = client.directory("docs-studio/pages", pageSchema)
15
+ const pagesRef = client.directory("docs-studio").directory("pages", pageSchema)
16
16
 
17
- const mdFileRef = await pagesRef.mdFile("document-editor")
17
+ const mdFileRef = pagesRef.file("document-editor.md")
18
18
 
19
19
  const mdFile = await mdFileRef.read()
20
20
 
@@ -44,7 +44,7 @@ const file = await relations[0].read()
44
44
  console.log("relations", file)
45
45
 
46
46
  // Method 3: Using SchemaBuilder
47
- const fooSchema = new SchemaBuilder()
47
+ const fooSchema = new DocSchemaBuilder()
48
48
  .multiRelation("feature", true)
49
49
  .text("priority", false)
50
50
  .build()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interactive-inc/docs-client",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "check": "tsgo --noEmit",