@interactive-inc/docs-client 0.0.18 → 1.0.0
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/package.json +3 -3
- package/debug/debug.ts +0 -62
- package/tsup.config.ts +0 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interactive-inc/docs-client",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"check": "tsgo --noEmit",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"deploy": "bun run build && npm publish"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"yaml": "^2.
|
|
12
|
-
"zod": "^4.0.
|
|
11
|
+
"yaml": "^2.0.0",
|
|
12
|
+
"zod": "^4.0.0"
|
|
13
13
|
},
|
|
14
14
|
"publishConfig": {
|
|
15
15
|
"access": "public"
|
package/debug/debug.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { DocClient } from "@/doc-client"
|
|
2
|
-
import { DocFileSystem } from "@/doc-file-system"
|
|
3
|
-
import { DocSchemaBuilder } from "@/doc-schema-builder"
|
|
4
|
-
import { defineSchema, docCustomSchemaField } from "@/utils"
|
|
5
|
-
|
|
6
|
-
const client = new DocClient({
|
|
7
|
-
fileSystem: new DocFileSystem({ basePath: "../../docs" }),
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
// Method 1: Using defineSchema (recommended)
|
|
11
|
-
const pageSchema = defineSchema({
|
|
12
|
-
features: docCustomSchemaField.multiRelation(true),
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
const pagesRef = client.directory("docs-studio").directory("pages", pageSchema)
|
|
16
|
-
|
|
17
|
-
const mdFileRef = pagesRef.file("document-editor.md")
|
|
18
|
-
|
|
19
|
-
const mdFile = await mdFileRef.read()
|
|
20
|
-
|
|
21
|
-
if (mdFile instanceof Error) {
|
|
22
|
-
throw mdFile
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const _features = mdFile.content.meta().field("features")
|
|
26
|
-
|
|
27
|
-
mdFile.withContent(
|
|
28
|
-
mdFile.content.withMetaProperty("features", [
|
|
29
|
-
"edit-document-content",
|
|
30
|
-
"delete-document",
|
|
31
|
-
"foo",
|
|
32
|
-
]),
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
// Method 2: Using field helpers
|
|
36
|
-
const featureSchema = defineSchema({
|
|
37
|
-
"is-done": docCustomSchemaField.boolean(true),
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
const relations = await mdFileRef.relations("features", featureSchema)
|
|
41
|
-
|
|
42
|
-
const file = await relations[0].read()
|
|
43
|
-
|
|
44
|
-
console.log("relations", file)
|
|
45
|
-
|
|
46
|
-
// Method 3: Using SchemaBuilder
|
|
47
|
-
const fooSchema = new DocSchemaBuilder()
|
|
48
|
-
.multiRelation("feature", true)
|
|
49
|
-
.text("priority", false)
|
|
50
|
-
.build()
|
|
51
|
-
|
|
52
|
-
const fooRef = client.directory("docs-studio/files", fooSchema)
|
|
53
|
-
|
|
54
|
-
const aaa = await fooRef.mdFile("a")
|
|
55
|
-
|
|
56
|
-
const fooFile = await aaa.read()
|
|
57
|
-
|
|
58
|
-
if (fooFile instanceof Error) {
|
|
59
|
-
throw fooFile
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
fooFile.content.meta().field("feature")
|