@jxsuite/schema 0.35.0 → 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/defs/expression-node.schema.ts +118 -9
- package/defs/extension-manifest.schema.ts +47 -0
- package/defs/field-schema.schema.ts +58 -0
- package/defs/function-def.schema.ts +7 -2
- package/defs/index.ts +10 -2
- package/defs/project-config.schema.ts +20 -11
- package/defs/statement.schema.ts +65 -0
- package/extension-manifest.schema.json +54 -0
- package/package.json +12 -4
- package/project-schema.json +18 -54
- package/schema.json +323 -56
- package/schemas/document.paths.schema.json +6 -0
- package/schemas/project.core.schema.json +441 -0
- package/schemas/project.fields.schema.json +14 -0
- package/src/extension-registry.ts +270 -0
- package/src/format-registry.ts +83 -13
- package/src/guards.ts +21 -0
- package/src/project-schemas.ts +262 -0
- package/src/schema.ts +118 -7
- package/src/validate-project.ts +144 -0
- package/types.ts +94 -11
- package/defs/content-type-def.schema.ts +0 -37
package/types.ts
CHANGED
|
@@ -3,7 +3,6 @@ import type { FromSchema } from "json-schema-to-ts";
|
|
|
3
3
|
import type { headEntrySchema } from "./defs/head-entry.schema";
|
|
4
4
|
import type { imageConfigSchema } from "./defs/image-config.schema";
|
|
5
5
|
import type { cemEventSchema, cemParameterSchema } from "./defs/cem.schema";
|
|
6
|
-
import type { contentTypeDefSchema } from "./defs/content-type-def.schema";
|
|
7
6
|
import type { projectConfigSchema } from "./defs/project-config.schema";
|
|
8
7
|
import type { refObjectSchema } from "./defs/ref-object.schema";
|
|
9
8
|
import type { styleObjectSchema } from "./defs/style-object.schema";
|
|
@@ -32,7 +31,6 @@ export namespace Strict {
|
|
|
32
31
|
export type ImageConfig = FromSchema<typeof imageConfigSchema>;
|
|
33
32
|
export type CemParameter = FromSchema<typeof cemParameterSchema>;
|
|
34
33
|
export type CemEvent = FromSchema<typeof cemEventSchema>;
|
|
35
|
-
export type ContentTypeDef = FromSchema<typeof contentTypeDefSchema>;
|
|
36
34
|
export type RefObject = FromSchema<typeof refObjectSchema>;
|
|
37
35
|
export type Style = FromSchema<typeof styleObjectSchema>;
|
|
38
36
|
export type Element = FromSchema<typeof elementDefSchema>;
|
|
@@ -90,18 +88,29 @@ export type JxExpressionOperand =
|
|
|
90
88
|
| number
|
|
91
89
|
| boolean
|
|
92
90
|
| null
|
|
93
|
-
| JxExpressionOperand[]
|
|
91
|
+
| JxExpressionOperand[]
|
|
92
|
+
// Plain-object literal (e.g. an Intl options bag); $ref/operator shapes are the members above.
|
|
93
|
+
| Record<string, JsonValue>;
|
|
94
94
|
|
|
95
95
|
export interface JxExpressionNode {
|
|
96
96
|
operator: string;
|
|
97
97
|
target: JxExpressionOperand;
|
|
98
98
|
value?: JxExpressionOperand;
|
|
99
99
|
initial?: JxExpressionOperand;
|
|
100
|
+
/** `switch` only: matched discriminant value (string form) → result operand. */
|
|
101
|
+
cases?: Record<string, JxExpressionOperand>;
|
|
102
|
+
/** `switch` only: result operand when no case key matches. */
|
|
103
|
+
default?: JxExpressionOperand;
|
|
100
104
|
}
|
|
101
105
|
|
|
102
106
|
/** A state entry (or event binding) whose value is computed from a declarative expression. */
|
|
103
107
|
export interface JxExpressionDef {
|
|
104
108
|
$expression: JxExpressionNode;
|
|
109
|
+
/**
|
|
110
|
+
* Named-formula parameters (CEM convention, as on Function entries). Present ⇒ the entry is a
|
|
111
|
+
* callable formula invoked via the `call` operator, with `$args/<name>` refs in its body.
|
|
112
|
+
*/
|
|
113
|
+
parameters?: (string | CemParameter)[];
|
|
105
114
|
[key: string]: unknown;
|
|
106
115
|
}
|
|
107
116
|
|
|
@@ -110,11 +119,50 @@ export interface JxExpressionDef {
|
|
|
110
119
|
// Detection algorithm in buildScope(). Use the guards in `@jxsuite/schema/guards`
|
|
111
120
|
// To discriminate.
|
|
112
121
|
|
|
122
|
+
// ─── Statement Model (spec §20) ─────────────────────────────────────────────────
|
|
123
|
+
// Structured function bodies: `body` as a statement array instead of opaque JS source,
|
|
124
|
+
// Mirroring ESTree's BlockStatement.body = Statement[].
|
|
125
|
+
|
|
126
|
+
/** An `{ if, then, else }` branch — the JSON Schema 2020-12 conditional keyword triple. */
|
|
127
|
+
export interface JxIfStatement {
|
|
128
|
+
if: JxExpressionOperand;
|
|
129
|
+
then: JxStatement[];
|
|
130
|
+
else?: JxStatement[];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** A `{ $switch, cases }` multiway branch in statement position (element-level convention). */
|
|
134
|
+
export interface JxSwitchStatement {
|
|
135
|
+
$switch: JxExpressionOperand;
|
|
136
|
+
cases: Record<string, JxStatement[]>;
|
|
137
|
+
default?: JxStatement[];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** A WHATWG `dispatchEvent` statement: emits a CustomEvent with CustomEventInit members. */
|
|
141
|
+
export interface JxDispatchStatement {
|
|
142
|
+
dispatchEvent: string;
|
|
143
|
+
detail?: JxExpressionOperand;
|
|
144
|
+
bubbles?: boolean;
|
|
145
|
+
composed?: boolean;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* One statement of a structured function body: a bare expression node in statement position
|
|
150
|
+
* (mutation or `call`), a branch, a multiway branch, or an event dispatch.
|
|
151
|
+
*/
|
|
152
|
+
export type JxStatement =
|
|
153
|
+
| JxExpressionNode
|
|
154
|
+
| JxIfStatement
|
|
155
|
+
| JxSwitchStatement
|
|
156
|
+
| JxDispatchStatement;
|
|
157
|
+
|
|
113
158
|
/** A function declaration: inline `body` or external `$src`/`$export`. */
|
|
114
159
|
export interface JxFunctionDef {
|
|
115
160
|
$prototype: "Function";
|
|
116
|
-
/**
|
|
117
|
-
|
|
161
|
+
/**
|
|
162
|
+
* Inline function body: opaque JS source (the reactive scope is the implicit first parameter) or
|
|
163
|
+
* a structured statement array (spec §20).
|
|
164
|
+
*/
|
|
165
|
+
body?: string | JxStatement[];
|
|
118
166
|
/** Parameters after the implicit scope parameter: bare names or CEM parameter objects. */
|
|
119
167
|
parameters?: (string | CemParameter)[];
|
|
120
168
|
/** Explicit function name; defaults to the state key. */
|
|
@@ -186,8 +234,6 @@ export interface CemEvent {
|
|
|
186
234
|
deprecated?: boolean | string;
|
|
187
235
|
}
|
|
188
236
|
|
|
189
|
-
export type ContentTypeDef = FromSchema<typeof contentTypeDefSchema>;
|
|
190
|
-
|
|
191
237
|
export type RefObject = FromSchema<typeof refObjectSchema>;
|
|
192
238
|
|
|
193
239
|
export interface JxStyle {
|
|
@@ -445,6 +491,8 @@ export interface DeployConfig {
|
|
|
445
491
|
}
|
|
446
492
|
|
|
447
493
|
export interface ProjectConfig {
|
|
494
|
+
/** Relative path to the generated per-project schema (written by `jx schema`). */
|
|
495
|
+
$schema?: string;
|
|
448
496
|
name?: string;
|
|
449
497
|
url?: string;
|
|
450
498
|
state?: Record<string, unknown>;
|
|
@@ -460,7 +508,12 @@ export interface ProjectConfig {
|
|
|
460
508
|
};
|
|
461
509
|
images?: ImageConfig;
|
|
462
510
|
imports?: Record<string, string>;
|
|
463
|
-
|
|
511
|
+
/**
|
|
512
|
+
* Extension packages: bare package names (resolved project-first) or relative paths. Each must
|
|
513
|
+
* export jx-extension.json. Extension-contributed sections (e.g. `content`) are opaque top-level
|
|
514
|
+
* keys absorbed by the index signature.
|
|
515
|
+
*/
|
|
516
|
+
extensions?: string[];
|
|
464
517
|
/** Redirect map: source path → destination (or destination with HTTP status). */
|
|
465
518
|
redirects?: Record<string, string | { destination: string; status?: number }>;
|
|
466
519
|
defaults?: {
|
|
@@ -480,13 +533,15 @@ export interface ProjectConfig {
|
|
|
480
533
|
export type JxAttributeValue = Bindable<string | number | boolean>;
|
|
481
534
|
|
|
482
535
|
/**
|
|
483
|
-
* A dynamic-route path source (spec §4.3):
|
|
484
|
-
*
|
|
536
|
+
* A dynamic-route path source (spec §4.3): explicit values, data-file ref, a legacy array of param
|
|
537
|
+
* objects, or an extension-discriminated source (an object carrying a `resolvePaths` discriminator
|
|
538
|
+
* key registered by an enabled extension, e.g. the parser's `contentType` — the extension owns the
|
|
539
|
+
* narrow shape).
|
|
485
540
|
*/
|
|
486
541
|
export type JxPathsDef =
|
|
487
|
-
| { contentType: string; param?: string; field?: string }
|
|
488
542
|
| { values: JsonValue[]; param?: string }
|
|
489
543
|
| { $ref: string; param?: string; field?: string }
|
|
544
|
+
| { param?: string; field?: string; [discriminator: string]: unknown }
|
|
490
545
|
| Record<string, JsonValue>[];
|
|
491
546
|
|
|
492
547
|
/**
|
|
@@ -541,6 +596,8 @@ export interface JxMutableNode {
|
|
|
541
596
|
export type JxPath = (string | number)[];
|
|
542
597
|
|
|
543
598
|
// ─── Content Type Schema ────────────────────────────────────────────────────────
|
|
599
|
+
// Part-3 cleanup: move to parser — the parser extension owns the content-section shapes now; these
|
|
600
|
+
// Stay here only while the studio still imports them from @jxsuite/schema/types.
|
|
544
601
|
|
|
545
602
|
/** One field within a content-type JSON schema; recursive for nested objects. */
|
|
546
603
|
export interface ContentTypeSchemaField {
|
|
@@ -558,3 +615,29 @@ export interface ContentTypeSchema {
|
|
|
558
615
|
required?: string[];
|
|
559
616
|
[key: string]: unknown;
|
|
560
617
|
}
|
|
618
|
+
|
|
619
|
+
// ─── Content Wire Types ─────────────────────────────────────────────────────────
|
|
620
|
+
// Core wire shapes for content loading (specs/extensions.md §8): format classes' `load`
|
|
621
|
+
// Capabilities return ContentLoaderEntry[], and hosts pass the entries through untouched.
|
|
622
|
+
// Extensions implement them; core only threads them.
|
|
623
|
+
|
|
624
|
+
/** A table-of-contents entry extracted from a loaded content document. */
|
|
625
|
+
export interface TocEntry {
|
|
626
|
+
depth: number;
|
|
627
|
+
text: string;
|
|
628
|
+
id: string;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/** One loaded content entry, as produced by a format class's `load` capability. */
|
|
632
|
+
export interface ContentLoaderEntry {
|
|
633
|
+
id: string;
|
|
634
|
+
data: Record<string, unknown>;
|
|
635
|
+
body: string | null;
|
|
636
|
+
$children?: (JxElement | string)[];
|
|
637
|
+
_meta?: {
|
|
638
|
+
excerpt?: string;
|
|
639
|
+
toc?: TocEntry[];
|
|
640
|
+
readingTime?: number;
|
|
641
|
+
wordCount?: number;
|
|
642
|
+
};
|
|
643
|
+
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export const contentTypeDefSchema = {
|
|
2
|
-
description:
|
|
3
|
-
"Content type definition. Defines the source directory, frontmatter schema, and element dependencies.",
|
|
4
|
-
properties: {
|
|
5
|
-
$elements: {
|
|
6
|
-
description: "Custom elements available in markdown directives for this content type.",
|
|
7
|
-
items: {
|
|
8
|
-
oneOf: [
|
|
9
|
-
{
|
|
10
|
-
properties: { $ref: { type: "string" } },
|
|
11
|
-
required: ["$ref"],
|
|
12
|
-
type: "object",
|
|
13
|
-
},
|
|
14
|
-
{ type: "string" },
|
|
15
|
-
],
|
|
16
|
-
},
|
|
17
|
-
type: "array",
|
|
18
|
-
},
|
|
19
|
-
format: {
|
|
20
|
-
description:
|
|
21
|
-
"Import name of a format class declared in the project imports map " +
|
|
22
|
-
'(e.g. "Markdown", "Csv"). When omitted, the format is derived from the ' +
|
|
23
|
-
'source file extension via the format registry. "json" is the only built-in.',
|
|
24
|
-
type: "string",
|
|
25
|
-
},
|
|
26
|
-
schema: {
|
|
27
|
-
description: "JSON Schema for validating frontmatter of content type entries.",
|
|
28
|
-
type: "object",
|
|
29
|
-
},
|
|
30
|
-
source: {
|
|
31
|
-
description: "Path to the content directory relative to the project root.",
|
|
32
|
-
examples: ["./content/blog/", "./content/docs/"],
|
|
33
|
-
type: "string",
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
type: "object",
|
|
37
|
-
} as const;
|