@jxsuite/parser 0.35.1 → 1.1.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 CHANGED
@@ -1,25 +1,32 @@
1
1
  {
2
2
  "name": "@jxsuite/parser",
3
- "version": "0.35.1",
3
+ "version": "1.1.0",
4
4
  "description": "Jx markdown parser and external class integration",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/jxsuite/jx.git",
9
- "directory": "packages/parser"
9
+ "directory": "extensions/parser"
10
10
  },
11
11
  "files": [
12
12
  "src/",
13
- "dist"
13
+ "dist",
14
+ "jx-extension.json",
15
+ "schemas/"
14
16
  ],
15
17
  "type": "module",
16
18
  "exports": {
17
19
  ".": "./src/md.ts",
18
20
  "./content": "./src/content.ts",
21
+ "./content-loader": "./src/content-loader.ts",
19
22
  "./markdown": "./src/markdown.ts",
20
23
  "./md-html": "./src/md-html.ts",
21
24
  "./csv": "./src/csv.ts",
22
25
  "./serialize": "./src/serialize.ts",
26
+ "./jx-extension.json": "./jx-extension.json",
27
+ "./schemas/project.fragment.schema.json": "./schemas/project.fragment.schema.json",
28
+ "./schemas/document.fragment.schema.json": "./schemas/document.fragment.schema.json",
29
+ "./Content.class.json": "./src/Content.class.json",
23
30
  "./ContentCollection.class.json": "./src/ContentCollection.class.json",
24
31
  "./ContentEntry.class.json": "./src/ContentEntry.class.json",
25
32
  "./MarkdownCollection.class.json": "./src/MarkdownCollection.class.json",
@@ -33,28 +40,23 @@
33
40
  "provenance": true
34
41
  },
35
42
  "scripts": {
36
- "prepare": "bun build src/content.ts src/markdown.ts src/csv.ts src/serialize.ts --outdir=dist --format=esm --target=node",
43
+ "prepare": "bun build src/content.ts src/content-loader.ts src/markdown.ts src/csv.ts src/serialize.ts --outdir=dist --format=esm --target=node",
37
44
  "build": "bun run prepare",
38
- "build:metafile": "bun build src/content.ts src/markdown.ts src/csv.ts src/serialize.ts --outdir=dist --format=esm --target=node --metafile=metafile.json",
45
+ "build:metafile": "bun build src/content.ts src/content-loader.ts src/markdown.ts src/csv.ts src/serialize.ts --outdir=dist --format=esm --target=node --metafile=metafile.json",
39
46
  "test": "bun test --isolate",
40
47
  "test:coverage": "bun test --isolate --coverage",
41
48
  "upgrade": "bunx npm-check-updates -u && bun install"
42
49
  },
43
50
  "dependencies": {
44
- "@jxsuite/schema": "^0.35.0",
51
+ "@jxsuite/markup": "^0.3.0",
52
+ "@jxsuite/schema": "^1.1.0",
45
53
  "glob": "^13.0.6",
46
- "hast-util-from-html": "^2.0.3",
47
- "hast-util-whitespace": "^3.0.0",
48
54
  "mdast-util-to-string": "^4.0.0",
49
- "property-information": "^7.2.0",
50
- "rehype-sanitize": "^6.0.0",
51
- "rehype-stringify": "^10.0.1",
52
55
  "remark-directive": "^4.0.0",
53
56
  "remark-frontmatter": "^5.0.0",
54
57
  "remark-gfm": "^4.0.1",
55
58
  "remark-parse": "^11.0.0",
56
59
  "remark-parse-frontmatter": "^1.0.3",
57
- "remark-rehype": "^11.1.2",
58
60
  "remark-stringify": "^11.0.0",
59
61
  "unified": "^11.0.5",
60
62
  "unist-util-visit": "^5.1.0",
@@ -62,8 +64,9 @@
62
64
  },
63
65
  "devDependencies": {
64
66
  "@happy-dom/global-registrator": "^20.10.6",
65
- "@jxsuite/runtime": "^0.34.2",
66
- "@types/hast": "^3.0.4",
67
- "@types/mdast": "^4.0.4"
68
- }
67
+ "@jxsuite/runtime": "^1.1.0",
68
+ "@types/mdast": "^4.0.4",
69
+ "ajv": "^8.20.0"
70
+ },
71
+ "jx": "./jx-extension.json"
69
72
  }
@@ -0,0 +1,27 @@
1
+ {
2
+ "$id": "https://jxsuite.com/schema/ext/parser/document/v1",
3
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4
+ "title": "Parser document fragment",
5
+ "description": "Document-schema fragment contributed by @jxsuite/parser: the content-type `$paths` source shape unioned into the document paths resource.",
6
+ "$defs": {
7
+ "ContentPathsSource": {
8
+ "description": "Content-type $paths source: expands a dynamic route from the entries of a loaded content type.",
9
+ "type": "object",
10
+ "properties": {
11
+ "contentType": {
12
+ "description": "Name of the content type (a key of the project.json `content` section).",
13
+ "type": "string"
14
+ },
15
+ "param": {
16
+ "description": "Route parameter to fill from each entry (default \"slug\").",
17
+ "type": "string"
18
+ },
19
+ "field": {
20
+ "description": "Entry field providing the parameter value; \"id\" (the default) uses the entry id.",
21
+ "type": "string"
22
+ }
23
+ },
24
+ "required": ["contentType"]
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,59 @@
1
+ {
2
+ "$id": "https://jxsuite.com/schema/ext/parser/project/v1",
3
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4
+ "title": "Parser project fragment",
5
+ "description": "Project-schema fragment contributed by @jxsuite/parser: the `content` section declaring file-based content collections.",
6
+ "type": "object",
7
+ "properties": {
8
+ "content": {
9
+ "description": "File-based content collections. Each key names a content type; entries are loaded from the named source through the format registry.",
10
+ "type": "object",
11
+ "additionalProperties": {
12
+ "description": "Content type definition. Defines the source directory, frontmatter schema, and element dependencies.",
13
+ "type": "object",
14
+ "properties": {
15
+ "$elements": {
16
+ "description": "Custom elements available in markdown directives for this content type.",
17
+ "type": "array",
18
+ "items": {
19
+ "oneOf": [
20
+ {
21
+ "type": "object",
22
+ "properties": { "$ref": { "type": "string" } },
23
+ "required": ["$ref"]
24
+ },
25
+ { "type": "string" }
26
+ ]
27
+ }
28
+ },
29
+ "format": {
30
+ "description": "Name of a format class provided by an enabled extension (e.g. \"Markdown\", \"Csv\"). When omitted, the format is derived from the source file extension via the format registry. \"json\" is the only built-in.",
31
+ "type": "string"
32
+ },
33
+ "schema": {
34
+ "description": "JSON Schema for validating frontmatter of content type entries.",
35
+ "type": "object",
36
+ "properties": {
37
+ "type": { "const": "object" },
38
+ "properties": {
39
+ "description": "Field definitions; values are field schemas from the effective project field union.",
40
+ "type": "object",
41
+ "additionalProperties": { "$ref": "https://jxsuite.com/schema/project/fields/v2" }
42
+ },
43
+ "required": {
44
+ "description": "Frontmatter fields every entry must provide.",
45
+ "type": "array",
46
+ "items": { "type": "string" }
47
+ }
48
+ }
49
+ },
50
+ "source": {
51
+ "description": "Path to the content directory relative to the project root.",
52
+ "examples": ["./content/blog/", "./content/docs/"],
53
+ "type": "string"
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,117 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://jxsuite.com/schemas/Content.class.json",
4
+ "title": "Content",
5
+ "description": "Content-collections project section for Jx: loads the project.json `content` section into _project.content and expands content-type $paths into route params",
6
+ "$prototype": "Class",
7
+ "extends": "Object",
8
+ "$implementation": "./content-loader.js",
9
+
10
+ "project": {
11
+ "key": "content",
12
+ "title": "Content Types",
13
+ "description": "File-based content collections loaded at build and dev-serve time",
14
+ "referenceable": true
15
+ },
16
+
17
+ "$studio": {
18
+ "settings": {
19
+ "icon": "sp-icon-view-grid",
20
+ "label": "Content Types",
21
+ "order": 50,
22
+ "layout": "map",
23
+ "entry": {
24
+ "ui": { "schema": { "control": "schema-builder" } },
25
+ "newEntry": {
26
+ "source": "./content/${key}/",
27
+ "schema": { "type": "object", "properties": {}, "required": [] }
28
+ }
29
+ }
30
+ }
31
+ },
32
+
33
+ "$defs": {
34
+ "returnTypes": {
35
+ "SectionData": {
36
+ "type": "object",
37
+ "description": "Map of content type name → ContentLoaderEntry[], with relationship references resolved"
38
+ },
39
+ "PathEntries": {
40
+ "type": "array",
41
+ "description": "Route-param objects, one per content entry: { [param]: value }",
42
+ "items": { "type": "object" }
43
+ }
44
+ },
45
+
46
+ "methods": {
47
+ "projectData": {
48
+ "role": "projectData",
49
+ "$prototype": "Function",
50
+ "access": "public",
51
+ "scope": "static",
52
+ "identifier": "projectData",
53
+ "timing": ["compiler", "server"],
54
+ "parameters": [
55
+ {
56
+ "identifier": "sectionValue",
57
+ "type": { "type": "object" },
58
+ "description": "The project.json `content` section value (content type name → definition)"
59
+ },
60
+ {
61
+ "identifier": "ctx",
62
+ "type": {
63
+ "type": "object",
64
+ "properties": {
65
+ "projectConfig": { "type": "object" },
66
+ "root": { "type": "string" },
67
+ "registry": { "type": "object" },
68
+ "io": { "type": "object" }
69
+ }
70
+ },
71
+ "description": "Host context: { projectConfig, root, registry, io }"
72
+ }
73
+ ],
74
+ "returnType": { "$ref": "#/$defs/returnTypes/SectionData" },
75
+ "description": "Load every content type in the section through the format registry, resolving relationship references"
76
+ },
77
+ "resolvePaths": {
78
+ "role": "resolvePaths",
79
+ "$prototype": "Function",
80
+ "access": "public",
81
+ "scope": "static",
82
+ "identifier": "resolvePaths",
83
+ "discriminator": "contentType",
84
+ "timing": ["compiler", "server"],
85
+ "parameters": [
86
+ {
87
+ "identifier": "pathsDef",
88
+ "type": {
89
+ "type": "object",
90
+ "properties": {
91
+ "contentType": { "type": "string" },
92
+ "param": { "type": "string", "default": "slug" },
93
+ "field": { "type": "string", "default": "id" }
94
+ },
95
+ "required": ["contentType"]
96
+ },
97
+ "description": "The $paths value carrying the contentType discriminator"
98
+ },
99
+ {
100
+ "identifier": "ctx",
101
+ "type": {
102
+ "type": "object",
103
+ "properties": {
104
+ "data": { "type": "object" },
105
+ "projectConfig": { "type": "object" },
106
+ "root": { "type": "string" }
107
+ }
108
+ },
109
+ "description": "Host context: { data, projectConfig, root } where data is the projectData result"
110
+ }
111
+ ],
112
+ "returnType": { "$ref": "#/$defs/returnTypes/PathEntries" },
113
+ "description": "Expand a content-type $paths source into one route-param object per entry (param defaults to \"slug\", field to \"id\")"
114
+ }
115
+ }
116
+ }
117
+ }
@@ -10,7 +10,7 @@
10
10
  "parameters": {
11
11
  "contentType": {
12
12
  "identifier": "contentType",
13
- "type": { "type": "string", "enum": { "$ref": "#/$context/contentTypes" } },
13
+ "type": { "type": "string", "enum": { "$ref": "#/$context/content" } },
14
14
  "description": "Content type to query"
15
15
  },
16
16
  "filter": {
@@ -23,7 +23,7 @@
23
23
  "properties": {
24
24
  "field": {
25
25
  "type": "string",
26
- "enum": { "$ref": "#/$context/contentTypes/{@contentType}/schema/properties" }
26
+ "enum": { "$ref": "#/$context/content/{@contentType}/schema/properties" }
27
27
  },
28
28
  "op": {
29
29
  "type": "string",
@@ -57,7 +57,7 @@
57
57
  "properties": {
58
58
  "field": {
59
59
  "type": "string",
60
- "enum": { "$ref": "#/$context/contentTypes/{@contentType}/schema/properties" }
60
+ "enum": { "$ref": "#/$context/content/{@contentType}/schema/properties" }
61
61
  },
62
62
  "order": { "type": "string", "enum": ["asc", "desc"], "default": "asc" }
63
63
  },
@@ -10,7 +10,7 @@
10
10
  "parameters": {
11
11
  "contentType": {
12
12
  "identifier": "contentType",
13
- "type": { "type": "string", "enum": { "$ref": "#/$context/contentTypes" } },
13
+ "type": { "type": "string", "enum": { "$ref": "#/$context/content" } },
14
14
  "description": "Content type to query"
15
15
  },
16
16
  "id": {
@@ -17,7 +17,7 @@
17
17
 
18
18
  "$studio": {
19
19
  "icon": "table",
20
- "modes": ["source"]
20
+ "modes": ["grid", "source"]
21
21
  },
22
22
 
23
23
  "$defs": {