@jxsuite/schema 0.35.0 → 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.
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Jx-extension.json manifest schema (specs/extensions.md §4). The manifest is pure data: it
3
+ * enumerates an extension package's classes and schema fragments; behavior lives in the class
4
+ * descriptors it points to.
5
+ */
6
+
7
+ export const extensionManifestSchema = {
8
+ additionalProperties: false,
9
+ description:
10
+ "Schema for jx-extension.json manifests. Located at the extension package root and " +
11
+ "exported so hosts can resolve <package>/jx-extension.json through the exports map.",
12
+ properties: {
13
+ $schema: { type: "string" },
14
+ classes: {
15
+ additionalProperties: { type: "string" },
16
+ description:
17
+ "$prototype-visible class name → class descriptor path, relative to the manifest.",
18
+ type: "object",
19
+ },
20
+ description: { description: "One-line description.", type: "string" },
21
+ name: { description: "Package name; must match package.json.", type: "string" },
22
+ schemas: {
23
+ additionalProperties: false,
24
+ description: "Schema fragments this package contributes, relative to the manifest.",
25
+ properties: {
26
+ document: {
27
+ description: "Document-schema fragment (positions like $paths values).",
28
+ type: "string",
29
+ },
30
+ fields: {
31
+ description:
32
+ "Field-union fragment: its $defs members are unioned into the per-project " +
33
+ "field-schema resource as extension field extras (specs/extensions.md §5.3).",
34
+ type: "string",
35
+ },
36
+ project: {
37
+ description: "Project-schema fragment (top-level project.json sections).",
38
+ type: "string",
39
+ },
40
+ },
41
+ type: "object",
42
+ },
43
+ title: { description: "Human-readable name for studio surfaces.", type: "string" },
44
+ },
45
+ required: ["name"],
46
+ type: "object",
47
+ } as const;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Field-schema vocabulary (specs/extensions.md §5.3, specs/relationships.md).
3
+ *
4
+ * JxFieldSchema is the JSON-Schema-subset shape for a single field inside a section entry schema
5
+ * (content frontmatter fields, table columns). Recursive positions (`items`, nested `properties`)
6
+ * reference the well-known **fields resource URI** — a schema resource the generated per-project
7
+ * entry document re-embeds under the same `$id` with the effective union (core shape +
8
+ * RelationshipRef + extension extras), shadowing the shipped default by standard compound-document
9
+ * `$id` resolution. Extension fragments reference the same URI at their field positions.
10
+ *
11
+ * (An earlier design used `$dynamicRef`/`$dynamicAnchor` here; ajv restricts `$dynamicAnchor` to
12
+ * schema-resource roots, which cannot express a non-root recursion unit, so the model uses plain
13
+ * `$id` indirection instead — verified against ajv 8.20 / 2020-12.)
14
+ */
15
+
16
+ /** The well-known $id of the project field-schema union resource. */
17
+ export const PROJECT_FIELDS_SCHEMA_ID = "https://jxsuite.com/schema/project/fields/v2";
18
+
19
+ /** The well-known $id of the document $paths-value union resource. */
20
+ export const DOCUMENT_PATHS_SCHEMA_ID = "https://jxsuite.com/schema/document/paths/v2";
21
+
22
+ export const jxFieldSchemaDef = {
23
+ description:
24
+ "A single field definition inside a section entry schema — a small, recursive subset of " +
25
+ "JSON Schema. Recursive positions reference the effective field union via the well-known " +
26
+ "fields resource $id.",
27
+ properties: {
28
+ default: {},
29
+ description: { type: "string" },
30
+ enum: { type: "array" },
31
+ format: { type: "string" },
32
+ items: { $ref: PROJECT_FIELDS_SCHEMA_ID },
33
+ properties: {
34
+ additionalProperties: { $ref: PROJECT_FIELDS_SCHEMA_ID },
35
+ type: "object",
36
+ },
37
+ required: { items: { type: "string" }, type: "array" },
38
+ type: {
39
+ enum: ["string", "number", "integer", "boolean", "array", "object"],
40
+ type: "string",
41
+ },
42
+ },
43
+ required: ["type"],
44
+ type: "object",
45
+ } as const;
46
+
47
+ export const relationshipRefSchema = {
48
+ description:
49
+ "Relationship reference field: points at a named entry of a referenceable section via " +
50
+ '"#/<sectionKey>/<name>" (specs/relationships.md). A bare reference is to-one; wrap in an ' +
51
+ "array field's items for to-many.",
52
+ properties: {
53
+ $ref: { pattern: "^#/[A-Za-z][A-Za-z0-9_-]*/[A-Za-z0-9._-]+$", type: "string" },
54
+ description: { type: "string" },
55
+ },
56
+ required: ["$ref"],
57
+ type: "object",
58
+ } as const;
package/defs/index.ts CHANGED
@@ -73,6 +73,9 @@ export {
73
73
  studioHintsSchema,
74
74
  } from "./class-def.schema";
75
75
 
76
- // Content & project
77
- export { contentTypeDefSchema } from "./content-type-def.schema";
76
+ // Project
78
77
  export { projectConfigSchema } from "./project-config.schema";
78
+
79
+ // Extensions (specs/extensions.md)
80
+ export { extensionManifestSchema } from "./extension-manifest.schema";
81
+ export { jxFieldSchemaDef, relationshipRefSchema } from "./field-schema.schema";
@@ -1,10 +1,11 @@
1
1
  export const projectConfigSchema = {
2
- additionalProperties: false,
3
2
  description:
4
3
  "Schema for Jx project.json files. " +
5
4
  "A project.json file is the root anchor file for a Jx project, " +
6
- "declaring site metadata, default settings, global styles, content types, " +
7
- "and build configuration.",
5
+ "declaring site metadata, default settings, global styles, extensions, " +
6
+ "and build configuration. Open by design: extension-contributed sections " +
7
+ "(e.g. `content`) are opaque top-level keys; the generated per-project " +
8
+ "entry document (project.schema.json) closes the composition.",
8
9
  properties: {
9
10
  $defs: {
10
11
  description: "Global type definitions available to all pages.",
@@ -63,6 +64,12 @@ export const projectConfigSchema = {
63
64
  ],
64
65
  type: "object",
65
66
  },
67
+ $schema: {
68
+ description:
69
+ "Relative path to the generated per-project schema (conventionally " +
70
+ "./project.schema.json, written by `jx schema`).",
71
+ type: "string",
72
+ },
66
73
  build: {
67
74
  description: "Build configuration.",
68
75
  properties: {
@@ -127,13 +134,6 @@ export const projectConfigSchema = {
127
134
  },
128
135
  type: "object",
129
136
  },
130
- contentTypes: {
131
- additionalProperties: { $ref: "#/$defs/ContentTypeDef" },
132
- description:
133
- "Content type definitions. Each key is a content type name; " +
134
- "the value defines the source directory, frontmatter schema, and element dependencies.",
135
- type: "object",
136
- },
137
137
  copy: {
138
138
  additionalProperties: { type: "string" },
139
139
  description:
@@ -164,6 +164,14 @@ export const projectConfigSchema = {
164
164
  },
165
165
  type: "object",
166
166
  },
167
+ extensions: {
168
+ description:
169
+ "Extension packages: bare package names (resolved project-first through the package " +
170
+ "exports map) or relative paths. Each must export jx-extension.json.",
171
+ examples: [["@jxsuite/parser"]],
172
+ items: { type: "string" },
173
+ type: "array",
174
+ },
167
175
  i18n: {
168
176
  description: "Internationalization configuration.",
169
177
  properties: {
@@ -0,0 +1,54 @@
1
+ {
2
+ "$id": "https://jxsuite.com/schema/extension-manifest/v1",
3
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4
+ "title": "Jx Extension Manifest",
5
+ "additionalProperties": false,
6
+ "description": "Schema for jx-extension.json manifests. Located at the extension package root and exported so hosts can resolve <package>/jx-extension.json through the exports map.",
7
+ "properties": {
8
+ "$schema": {
9
+ "type": "string"
10
+ },
11
+ "classes": {
12
+ "additionalProperties": {
13
+ "type": "string"
14
+ },
15
+ "description": "$prototype-visible class name → class descriptor path, relative to the manifest.",
16
+ "type": "object"
17
+ },
18
+ "description": {
19
+ "description": "One-line description.",
20
+ "type": "string"
21
+ },
22
+ "name": {
23
+ "description": "Package name; must match package.json.",
24
+ "type": "string"
25
+ },
26
+ "schemas": {
27
+ "additionalProperties": false,
28
+ "description": "Schema fragments this package contributes, relative to the manifest.",
29
+ "properties": {
30
+ "document": {
31
+ "description": "Document-schema fragment (positions like $paths values).",
32
+ "type": "string"
33
+ },
34
+ "fields": {
35
+ "description": "Field-union fragment: its $defs members are unioned into the per-project field-schema resource as extension field extras (specs/extensions.md §5.3).",
36
+ "type": "string"
37
+ },
38
+ "project": {
39
+ "description": "Project-schema fragment (top-level project.json sections).",
40
+ "type": "string"
41
+ }
42
+ },
43
+ "type": "object"
44
+ },
45
+ "title": {
46
+ "description": "Human-readable name for studio surfaces.",
47
+ "type": "string"
48
+ }
49
+ },
50
+ "required": [
51
+ "name"
52
+ ],
53
+ "type": "object"
54
+ }
package/package.json CHANGED
@@ -1,25 +1,33 @@
1
1
  {
2
2
  "dependencies": {
3
- "@webref/css": "^8.6.1",
3
+ "@webref/css": "^8.7.0",
4
4
  "@webref/elements": "^2.7.1",
5
- "@webref/idl": "^3.81.2",
5
+ "@webref/idl": "^3.81.3",
6
6
  "ajv": "^8.20.0",
7
7
  "ajv-formats": "^3.0.1"
8
8
  },
9
9
  "description": "JSON Schema 2020-12 meta-schema generator for Jx documents",
10
10
  "exports": {
11
11
  ".": "./src/schema.ts",
12
+ "./extension-registry": "./src/extension-registry.ts",
12
13
  "./format-registry": "./src/format-registry.ts",
14
+ "./project-schemas": "./src/project-schemas.ts",
15
+ "./validate-project": "./src/validate-project.ts",
13
16
  "./types": "./types.ts",
14
17
  "./guards": "./src/guards.ts",
15
18
  "./parse": "./src/parse.ts",
16
19
  "./defs": "./defs/index.ts",
17
20
  "./schema.json": "./schema.json",
18
- "./project-schema.json": "./project-schema.json"
21
+ "./project-schema.json": "./project-schema.json",
22
+ "./extension-manifest.schema.json": "./extension-manifest.schema.json",
23
+ "./schemas/project.core.schema.json": "./schemas/project.core.schema.json",
24
+ "./schemas/project.fields.schema.json": "./schemas/project.fields.schema.json",
25
+ "./schemas/document.paths.schema.json": "./schemas/document.paths.schema.json"
19
26
  },
20
27
  "files": [
21
28
  "src/",
22
29
  "defs/",
30
+ "schemas/",
23
31
  "types.ts",
24
32
  "*.json",
25
33
  "!package.json"
@@ -41,7 +49,7 @@
41
49
  "upgrade": "bunx npm-check-updates -u && bun install"
42
50
  },
43
51
  "type": "module",
44
- "version": "0.35.0",
52
+ "version": "1.0.0",
45
53
  "devDependencies": {
46
54
  "json-schema-to-ts": "^3.1.1"
47
55
  }
@@ -1,49 +1,5 @@
1
1
  {
2
2
  "$defs": {
3
- "ContentTypeDef": {
4
- "description": "Content type definition. Defines the source directory, frontmatter schema, and element dependencies.",
5
- "properties": {
6
- "$elements": {
7
- "description": "Custom elements available in markdown directives for this content type.",
8
- "items": {
9
- "oneOf": [
10
- {
11
- "properties": {
12
- "$ref": {
13
- "type": "string"
14
- }
15
- },
16
- "required": [
17
- "$ref"
18
- ],
19
- "type": "object"
20
- },
21
- {
22
- "type": "string"
23
- }
24
- ]
25
- },
26
- "type": "array"
27
- },
28
- "format": {
29
- "description": "Import name of a format class declared in the project imports map (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.",
30
- "type": "string"
31
- },
32
- "schema": {
33
- "description": "JSON Schema for validating frontmatter of content type entries.",
34
- "type": "object"
35
- },
36
- "source": {
37
- "description": "Path to the content directory relative to the project root.",
38
- "examples": [
39
- "./content/blog/",
40
- "./content/docs/"
41
- ],
42
- "type": "string"
43
- }
44
- },
45
- "type": "object"
46
- },
47
3
  "ImageConfig": {
48
4
  "description": "Image optimization configuration for the project.",
49
5
  "properties": {
@@ -106,8 +62,7 @@
106
62
  },
107
63
  "$id": "https://jxsuite.com/schema/project/v1",
108
64
  "$schema": "https://json-schema.org/draft/2020-12/schema",
109
- "additionalProperties": false,
110
- "description": "Schema for Jx project.json files. A project.json file is the root anchor file for a Jx project, declaring site metadata, default settings, global styles, content types, and build configuration.",
65
+ "description": "Schema for Jx project.json files. A project.json file is the root anchor file for a Jx project, declaring site metadata, default settings, global styles, extensions, and build configuration. Open by design: extension-contributed sections are opaque top-level keys; the generated per-project entry document (project.schema.json) closes the composition.",
111
66
  "properties": {
112
67
  "$defs": {
113
68
  "description": "Global type definitions available to all pages.",
@@ -186,6 +141,10 @@
186
141
  ],
187
142
  "type": "object"
188
143
  },
144
+ "$schema": {
145
+ "description": "Relative path to the generated per-project schema (conventionally ./project.schema.json, written by `jx schema`).",
146
+ "type": "string"
147
+ },
189
148
  "build": {
190
149
  "description": "Build configuration.",
191
150
  "properties": {
@@ -264,13 +223,6 @@
264
223
  },
265
224
  "type": "object"
266
225
  },
267
- "contentTypes": {
268
- "additionalProperties": {
269
- "$ref": "#/$defs/ContentTypeDef"
270
- },
271
- "description": "Content type definitions. Each key is a content type name; the value defines the source directory, frontmatter schema, and element dependencies.",
272
- "type": "object"
273
- },
274
226
  "copy": {
275
227
  "additionalProperties": {
276
228
  "type": "string"
@@ -309,6 +261,18 @@
309
261
  },
310
262
  "type": "object"
311
263
  },
264
+ "extensions": {
265
+ "description": "Extension packages: bare package names (resolved project-first through the package exports map) or relative paths. Each must export jx-extension.json.",
266
+ "examples": [
267
+ [
268
+ "@jxsuite/parser"
269
+ ]
270
+ ],
271
+ "items": {
272
+ "type": "string"
273
+ },
274
+ "type": "array"
275
+ },
312
276
  "i18n": {
313
277
  "description": "Internationalization configuration.",
314
278
  "properties": {
package/schema.json CHANGED
@@ -21651,50 +21651,6 @@
21651
21651
  }
21652
21652
  },
21653
21653
  "type": "object"
21654
- },
21655
- "ContentTypeDef": {
21656
- "description": "Content type definition. Defines the source directory, frontmatter schema, and element dependencies.",
21657
- "properties": {
21658
- "$elements": {
21659
- "description": "Custom elements available in markdown directives for this content type.",
21660
- "items": {
21661
- "oneOf": [
21662
- {
21663
- "properties": {
21664
- "$ref": {
21665
- "type": "string"
21666
- }
21667
- },
21668
- "required": [
21669
- "$ref"
21670
- ],
21671
- "type": "object"
21672
- },
21673
- {
21674
- "type": "string"
21675
- }
21676
- ]
21677
- },
21678
- "type": "array"
21679
- },
21680
- "format": {
21681
- "description": "Import name of a format class declared in the project imports map (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.",
21682
- "type": "string"
21683
- },
21684
- "schema": {
21685
- "description": "JSON Schema for validating frontmatter of content type entries.",
21686
- "type": "object"
21687
- },
21688
- "source": {
21689
- "description": "Path to the content directory relative to the project root.",
21690
- "examples": [
21691
- "./content/blog/",
21692
- "./content/docs/"
21693
- ],
21694
- "type": "string"
21695
- }
21696
- },
21697
- "type": "object"
21698
21654
  }
21699
21655
  },
21700
21656
  "$id": "https://jxsuite.com/schema/v1",
@@ -0,0 +1,6 @@
1
+ {
2
+ "$id": "https://jxsuite.com/schema/document/paths/v2",
3
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4
+ "description": "Default $paths-value union for documents. Per-project entry documents override this resource with the union of extension-contributed paths shapes.",
5
+ "title": "Jx Document Paths Union"
6
+ }