@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.js
CHANGED
|
@@ -1273,8 +1273,8 @@ var DocFileMdMetaValue = class _DocFileMdMetaValue {
|
|
|
1273
1273
|
* Return a new instance with an unknown schema
|
|
1274
1274
|
* Allows accepting Record<string, unknown> schemas from external sources
|
|
1275
1275
|
*/
|
|
1276
|
-
withUnknownSchema(
|
|
1277
|
-
const typedSchema =
|
|
1276
|
+
withUnknownSchema(draft) {
|
|
1277
|
+
const typedSchema = draft;
|
|
1278
1278
|
const newValue = {};
|
|
1279
1279
|
for (const key in typedSchema) {
|
|
1280
1280
|
if (key in this.value) {
|
|
@@ -2876,8 +2876,8 @@ var DocFileIndexMetaValue = class _DocFileIndexMetaValue {
|
|
|
2876
2876
|
* Return a new instance with an unknown schema
|
|
2877
2877
|
* Allows accepting Record<string, unknown> schemas from external sources
|
|
2878
2878
|
*/
|
|
2879
|
-
withUnknownSchema(
|
|
2880
|
-
const typedSchema =
|
|
2879
|
+
withUnknownSchema(draft) {
|
|
2880
|
+
const typedSchema = draft;
|
|
2881
2881
|
return new _DocFileIndexMetaValue(
|
|
2882
2882
|
{
|
|
2883
2883
|
type: "index-meta",
|
|
@@ -4160,7 +4160,7 @@ var DocDirectoryReference = class _DocDirectoryReference {
|
|
|
4160
4160
|
}
|
|
4161
4161
|
return refs;
|
|
4162
4162
|
}
|
|
4163
|
-
|
|
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
|
-
|
|
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,7 +4248,7 @@ 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
|
});
|
|
@@ -4755,10 +4755,15 @@ var DocClient = class {
|
|
|
4755
4755
|
* Get file reference
|
|
4756
4756
|
*/
|
|
4757
4757
|
file(relativePath, customSchema) {
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4758
|
+
const fileName = this.pathSystem.basename(relativePath);
|
|
4759
|
+
if (fileName === this.config.indexFileName) {
|
|
4760
|
+
const dirPath = this.pathSystem.dirname(relativePath);
|
|
4761
|
+
return this.indexFile(dirPath === "." ? "" : dirPath, customSchema);
|
|
4762
|
+
}
|
|
4763
|
+
if (relativePath.endsWith(".md")) {
|
|
4764
|
+
if (customSchema === void 0) {
|
|
4765
|
+
return this.mdFile(relativePath);
|
|
4766
|
+
}
|
|
4762
4767
|
return this.mdFile(relativePath, customSchema);
|
|
4763
4768
|
}
|
|
4764
4769
|
return new DocFileUnknownReference({
|
|
@@ -5307,73 +5312,73 @@ var DocFileSystemDebug = class _DocFileSystemDebug extends DocFileSystem {
|
|
|
5307
5312
|
}
|
|
5308
5313
|
};
|
|
5309
5314
|
|
|
5310
|
-
// lib/schema-builder.ts
|
|
5311
|
-
var
|
|
5315
|
+
// lib/doc-schema-builder.ts
|
|
5316
|
+
var DocSchemaBuilder = class _DocSchemaBuilder {
|
|
5312
5317
|
constructor(schema = {}) {
|
|
5313
5318
|
this.schema = schema;
|
|
5314
5319
|
}
|
|
5315
5320
|
text(key, required) {
|
|
5316
|
-
return new
|
|
5321
|
+
return new _DocSchemaBuilder({
|
|
5317
5322
|
...this.schema,
|
|
5318
5323
|
[key]: { type: "text", required }
|
|
5319
5324
|
});
|
|
5320
5325
|
}
|
|
5321
5326
|
number(key, required) {
|
|
5322
|
-
return new
|
|
5327
|
+
return new _DocSchemaBuilder({
|
|
5323
5328
|
...this.schema,
|
|
5324
5329
|
[key]: { type: "number", required }
|
|
5325
5330
|
});
|
|
5326
5331
|
}
|
|
5327
5332
|
boolean(key, required) {
|
|
5328
|
-
return new
|
|
5333
|
+
return new _DocSchemaBuilder({
|
|
5329
5334
|
...this.schema,
|
|
5330
5335
|
[key]: { type: "boolean", required }
|
|
5331
5336
|
});
|
|
5332
5337
|
}
|
|
5333
5338
|
relation(key, required) {
|
|
5334
|
-
return new
|
|
5339
|
+
return new _DocSchemaBuilder({
|
|
5335
5340
|
...this.schema,
|
|
5336
5341
|
[key]: { type: "relation", required }
|
|
5337
5342
|
});
|
|
5338
5343
|
}
|
|
5339
5344
|
multiRelation(key, required) {
|
|
5340
|
-
return new
|
|
5345
|
+
return new _DocSchemaBuilder({
|
|
5341
5346
|
...this.schema,
|
|
5342
5347
|
[key]: { type: "multi-relation", required }
|
|
5343
5348
|
});
|
|
5344
5349
|
}
|
|
5345
5350
|
selectText(key, required) {
|
|
5346
|
-
return new
|
|
5351
|
+
return new _DocSchemaBuilder({
|
|
5347
5352
|
...this.schema,
|
|
5348
5353
|
[key]: { type: "select-text", required }
|
|
5349
5354
|
});
|
|
5350
5355
|
}
|
|
5351
5356
|
selectNumber(key, required) {
|
|
5352
|
-
return new
|
|
5357
|
+
return new _DocSchemaBuilder({
|
|
5353
5358
|
...this.schema,
|
|
5354
5359
|
[key]: { type: "select-number", required }
|
|
5355
5360
|
});
|
|
5356
5361
|
}
|
|
5357
5362
|
multiText(key, required) {
|
|
5358
|
-
return new
|
|
5363
|
+
return new _DocSchemaBuilder({
|
|
5359
5364
|
...this.schema,
|
|
5360
5365
|
[key]: { type: "multi-text", required }
|
|
5361
5366
|
});
|
|
5362
5367
|
}
|
|
5363
5368
|
multiNumber(key, required) {
|
|
5364
|
-
return new
|
|
5369
|
+
return new _DocSchemaBuilder({
|
|
5365
5370
|
...this.schema,
|
|
5366
5371
|
[key]: { type: "multi-number", required }
|
|
5367
5372
|
});
|
|
5368
5373
|
}
|
|
5369
5374
|
multiSelectText(key, required) {
|
|
5370
|
-
return new
|
|
5375
|
+
return new _DocSchemaBuilder({
|
|
5371
5376
|
...this.schema,
|
|
5372
5377
|
[key]: { type: "multi-select-text", required }
|
|
5373
5378
|
});
|
|
5374
5379
|
}
|
|
5375
5380
|
multiSelectNumber(key, required) {
|
|
5376
|
-
return new
|
|
5381
|
+
return new _DocSchemaBuilder({
|
|
5377
5382
|
...this.schema,
|
|
5378
5383
|
[key]: { type: "multi-select-number", required }
|
|
5379
5384
|
});
|
|
@@ -5477,12 +5482,12 @@ export {
|
|
|
5477
5482
|
DocFileRelationReference,
|
|
5478
5483
|
DocFileSystem,
|
|
5479
5484
|
DocFileSystemDebug,
|
|
5485
|
+
DocFileTreeSystem,
|
|
5480
5486
|
DocFileUnknownEntity,
|
|
5481
5487
|
DocFileUnknownReference,
|
|
5482
5488
|
DocMarkdownSystem,
|
|
5483
5489
|
DocPathSystem,
|
|
5484
|
-
|
|
5485
|
-
SchemaBuilder,
|
|
5490
|
+
DocSchemaBuilder,
|
|
5486
5491
|
assertType,
|
|
5487
5492
|
defaultTestConfig,
|
|
5488
5493
|
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 {
|
|
3
|
+
import { DocSchemaBuilder } from "@/doc-schema-builder"
|
|
4
4
|
import { defineSchema, docCustomSchemaField } from "@/utils"
|
|
5
5
|
|
|
6
6
|
const client = new DocClient({
|
|
@@ -14,7 +14,7 @@ const pageSchema = defineSchema({
|
|
|
14
14
|
|
|
15
15
|
const pagesRef = client.directory("docs-studio/pages", pageSchema)
|
|
16
16
|
|
|
17
|
-
const mdFileRef =
|
|
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
|
|
47
|
+
const fooSchema = new DocSchemaBuilder()
|
|
48
48
|
.multiRelation("feature", true)
|
|
49
49
|
.text("priority", false)
|
|
50
50
|
.build()
|