@jxsuite/schema 0.28.0 → 0.28.3
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/class-schema.json +341 -341
- package/defs/cem.schema.ts +11 -11
- package/defs/children-value.schema.ts +6 -6
- package/defs/class-def.schema.ts +131 -131
- package/defs/content-type-def.schema.ts +18 -18
- package/defs/element-def.schema.ts +36 -36
- package/defs/expression-node.schema.ts +37 -37
- package/defs/external-class-def.schema.ts +41 -41
- package/defs/function-def.schema.ts +31 -31
- package/defs/head-entry.schema.ts +6 -6
- package/defs/image-config.schema.ts +19 -13
- package/defs/json-schema-type.schema.ts +1 -1
- package/defs/project-config.schema.ts +122 -122
- package/defs/pure-type-def.schema.ts +12 -12
- package/defs/ref-object.schema.ts +19 -19
- package/defs/state-entry.schema.ts +3 -3
- package/defs/style-object.schema.ts +7 -7
- package/defs/tag-name.schema.ts +1 -1
- package/defs/typed-state-def.schema.ts +14 -14
- package/package.json +3 -1
- package/project-schema.json +284 -286
- package/schema.json +982 -984
- package/src/format-registry.ts +28 -13
- package/src/guards.ts +195 -0
- package/src/parse.ts +57 -0
- package/src/schema.ts +229 -225
- package/types.ts +340 -52
package/types.ts
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import type { FromSchema } from "json-schema-to-ts";
|
|
2
2
|
|
|
3
|
-
import { headEntrySchema } from "./defs/head-entry.schema";
|
|
4
|
-
import { imageConfigSchema } from "./defs/image-config.schema";
|
|
5
|
-
import {
|
|
6
|
-
import { contentTypeDefSchema } from "./defs/content-type-def.schema";
|
|
7
|
-
import { projectConfigSchema } from "./defs/project-config.schema";
|
|
8
|
-
import { refObjectSchema } from "./defs/ref-object.schema";
|
|
9
|
-
import { styleObjectSchema } from "./defs/style-object.schema";
|
|
10
|
-
import { elementDefSchema } from "./defs/element-def.schema";
|
|
11
|
-
import { functionDefSchema } from "./defs/function-def.schema";
|
|
12
|
-
import { externalClassDefSchema } from "./defs/external-class-def.schema";
|
|
13
|
-
import { typedStateDefSchema } from "./defs/typed-state-def.schema";
|
|
14
|
-
import { pureTypeDefSchema } from "./defs/pure-type-def.schema";
|
|
15
|
-
import {
|
|
16
|
-
import { stateEntrySchema, stateMapSchema
|
|
17
|
-
import {
|
|
3
|
+
import type { headEntrySchema } from "./defs/head-entry.schema";
|
|
4
|
+
import type { imageConfigSchema } from "./defs/image-config.schema";
|
|
5
|
+
import type { cemEventSchema, cemParameterSchema } from "./defs/cem.schema";
|
|
6
|
+
import type { contentTypeDefSchema } from "./defs/content-type-def.schema";
|
|
7
|
+
import type { projectConfigSchema } from "./defs/project-config.schema";
|
|
8
|
+
import type { refObjectSchema } from "./defs/ref-object.schema";
|
|
9
|
+
import type { styleObjectSchema } from "./defs/style-object.schema";
|
|
10
|
+
import type { elementDefSchema } from "./defs/element-def.schema";
|
|
11
|
+
import type { functionDefSchema } from "./defs/function-def.schema";
|
|
12
|
+
import type { externalClassDefSchema } from "./defs/external-class-def.schema";
|
|
13
|
+
import type { typedStateDefSchema } from "./defs/typed-state-def.schema";
|
|
14
|
+
import type { pureTypeDefSchema } from "./defs/pure-type-def.schema";
|
|
15
|
+
import type { expressionEntrySchema, expressionNodeSchema } from "./defs/expression-node.schema";
|
|
16
|
+
import type { defsMapSchema, stateEntrySchema, stateMapSchema } from "./defs/state-entry.schema";
|
|
17
|
+
import type {
|
|
18
|
+
classConstructorDefSchema,
|
|
18
19
|
classDefSchema,
|
|
19
20
|
classFieldDefSchema,
|
|
20
21
|
classMethodDefSchema,
|
|
21
22
|
classParameterDefSchema,
|
|
22
|
-
classConstructorDefSchema,
|
|
23
23
|
} from "./defs/class-def.schema";
|
|
24
24
|
|
|
25
25
|
// ─── Strict Schema-Derived Types ────────────────────────────────────────────────
|
|
26
26
|
// These are the precise types derived from the JSON Schema defs via FromSchema.
|
|
27
27
|
// Use these when you need exact schema conformance (e.g., validation, serialization).
|
|
28
28
|
|
|
29
|
+
// oxlint-disable typescript/no-namespace, no-shadow -- type-only grouping of schema-derived types whose members intentionally mirror the loose top-level type names (Strict.ImageConfig vs ImageConfig); an ES module split would fragment the schema package's public surface
|
|
29
30
|
export namespace Strict {
|
|
30
31
|
export type HeadEntry = FromSchema<typeof headEntrySchema>;
|
|
31
32
|
export type ImageConfig = FromSchema<typeof imageConfigSchema>;
|
|
@@ -51,10 +52,102 @@ export namespace Strict {
|
|
|
51
52
|
export type ClassConstructorDef = FromSchema<typeof classConstructorDefSchema>;
|
|
52
53
|
export type ProjectConfig = FromSchema<typeof projectConfigSchema>;
|
|
53
54
|
}
|
|
55
|
+
// oxlint-enable typescript/no-namespace, no-shadow
|
|
56
|
+
|
|
57
|
+
// ─── JSON Value Model ───────────────────────────────────────────────────────────
|
|
58
|
+
// Jx documents are JSON. These types describe what can actually appear in one,
|
|
59
|
+
// As opposed to `unknown` (nothing known) or `any` (checking disabled).
|
|
60
|
+
|
|
61
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
62
|
+
export type JsonValue = JsonPrimitive | JsonValue[] | JsonObject;
|
|
63
|
+
export interface JsonObject {
|
|
64
|
+
[key: string]: JsonValue;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ─── Binding Model ──────────────────────────────────────────────────────────────
|
|
68
|
+
// Any bindable position in a document holds either a literal value or a JSON
|
|
69
|
+
// Pointer reference into the reactive scope.
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* A JSON Pointer reference into document state, e.g. `{ $ref: "#/state/count" }`. (A type literal
|
|
73
|
+
* rather than an interface so it stays assignable to JsonValue.)
|
|
74
|
+
*/
|
|
75
|
+
export interface JxRef {
|
|
76
|
+
$ref: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** A value that may be given literally or bound via `$ref`. */
|
|
80
|
+
export type Bindable<T> = T | JxRef;
|
|
81
|
+
|
|
82
|
+
// ─── Expression Model ───────────────────────────────────────────────────────────
|
|
83
|
+
// Declarative expressions: operator + target (+ value), with operands that are
|
|
84
|
+
// Pointers, literals, or nested expression nodes.
|
|
85
|
+
|
|
86
|
+
export type JxExpressionOperand =
|
|
87
|
+
| JxRef
|
|
88
|
+
| JxExpressionNode
|
|
89
|
+
| string
|
|
90
|
+
| number
|
|
91
|
+
| boolean
|
|
92
|
+
| null
|
|
93
|
+
| JxExpressionOperand[];
|
|
94
|
+
|
|
95
|
+
export interface JxExpressionNode {
|
|
96
|
+
operator: string;
|
|
97
|
+
target: JxExpressionOperand;
|
|
98
|
+
value?: JxExpressionOperand;
|
|
99
|
+
initial?: JxExpressionOperand;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** A state entry (or event binding) whose value is computed from a declarative expression. */
|
|
103
|
+
export interface JxExpressionDef {
|
|
104
|
+
$expression: JxExpressionNode;
|
|
105
|
+
[key: string]: unknown;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// ─── State Definition Model ─────────────────────────────────────────────────────
|
|
109
|
+
// The shapes a `state` entry can take, mirroring the runtime's five-shape
|
|
110
|
+
// Detection algorithm in buildScope(). Use the guards in `@jxsuite/schema/guards`
|
|
111
|
+
// To discriminate.
|
|
112
|
+
|
|
113
|
+
/** A function declaration: inline `body` or external `$src`/`$export`. */
|
|
114
|
+
export interface JxFunctionDef {
|
|
115
|
+
$prototype: "Function";
|
|
116
|
+
/** Inline function body. The reactive scope is the implicit first parameter. */
|
|
117
|
+
body?: string;
|
|
118
|
+
/** Parameters after the implicit scope parameter: bare names or CEM parameter objects. */
|
|
119
|
+
parameters?: (string | CemParameter)[];
|
|
120
|
+
/** Explicit function name; defaults to the state key. */
|
|
121
|
+
name?: string;
|
|
122
|
+
/** External module specifier; mutually exclusive with `body`. */
|
|
123
|
+
$src?: string;
|
|
124
|
+
/** Named export within `$src`; defaults to the state key. */
|
|
125
|
+
$export?: string;
|
|
126
|
+
/** Legacy alias for `parameters` (bare names only). */
|
|
127
|
+
arguments?: string[];
|
|
128
|
+
timing?: "compiler" | "server" | "client";
|
|
129
|
+
debounce?: number;
|
|
130
|
+
emits?: CemEvent[];
|
|
131
|
+
description?: string;
|
|
132
|
+
deprecated?: string | boolean;
|
|
133
|
+
[key: string]: unknown;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** A `timing: "server"` function proxy — executed server-side, no `$prototype`. */
|
|
137
|
+
export interface JxServerFnDef {
|
|
138
|
+
timing: "server";
|
|
139
|
+
$src: string;
|
|
140
|
+
$export: string;
|
|
141
|
+
parameters?: (string | CemParameter)[];
|
|
142
|
+
/** Named arguments forwarded to the server function: literals or `$ref` bindings. */
|
|
143
|
+
arguments?: Record<string, JsonValue>;
|
|
144
|
+
debounce?: number;
|
|
145
|
+
[key: string]: unknown;
|
|
146
|
+
}
|
|
54
147
|
|
|
55
148
|
// ─── Consumer-Friendly Types ────────────────────────────────────────────────────
|
|
56
149
|
// Relaxed types for everyday use in the runtime/compiler/studio. These add an index
|
|
57
|
-
//
|
|
150
|
+
// Signature for dynamic property access while preserving the known property structure.
|
|
58
151
|
|
|
59
152
|
export interface JxHeadEntry {
|
|
60
153
|
tagName: string;
|
|
@@ -72,28 +165,42 @@ export interface ImageConfig {
|
|
|
72
165
|
sizes?: string;
|
|
73
166
|
lazyLoad?: boolean;
|
|
74
167
|
service?: "build" | "cloudflare";
|
|
75
|
-
binding?: string;
|
|
76
168
|
remoteDomains?: string[];
|
|
77
169
|
}
|
|
78
170
|
|
|
79
|
-
|
|
80
|
-
export
|
|
171
|
+
/** A CEM-compatible function parameter. JSON-precise (assignable to JsonValue). */
|
|
172
|
+
export interface CemParameter {
|
|
173
|
+
name: string;
|
|
174
|
+
/** Parameter type — JSON Schema or CEM `{ text }` format. */
|
|
175
|
+
type?: JsonValue;
|
|
176
|
+
description?: string;
|
|
177
|
+
optional?: boolean;
|
|
178
|
+
default?: JsonValue;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** A CEM-compatible event a function dispatches. JSON-precise (assignable to JsonValue). */
|
|
182
|
+
export interface CemEvent {
|
|
183
|
+
name: string;
|
|
184
|
+
type?: JsonValue;
|
|
185
|
+
description?: string;
|
|
186
|
+
deprecated?: boolean | string;
|
|
187
|
+
}
|
|
81
188
|
|
|
82
189
|
export type ContentTypeDef = FromSchema<typeof contentTypeDefSchema>;
|
|
83
190
|
|
|
84
191
|
export type RefObject = FromSchema<typeof refObjectSchema>;
|
|
85
192
|
|
|
86
|
-
export
|
|
193
|
+
export interface JxStyle {
|
|
87
194
|
[property: string]: string | number | JxStyle | undefined;
|
|
88
|
-
}
|
|
195
|
+
}
|
|
89
196
|
|
|
90
197
|
export interface JxElement {
|
|
91
198
|
tagName?: string;
|
|
92
|
-
textContent?: string | null;
|
|
199
|
+
textContent?: string | null | JxRef;
|
|
93
200
|
innerHTML?: string;
|
|
94
201
|
children?: (JxElement | string)[] | JxMappedArray;
|
|
95
202
|
style?: JxStyle;
|
|
96
|
-
attributes?: Record<string,
|
|
203
|
+
attributes?: Record<string, JxAttributeValue>;
|
|
97
204
|
className?: string;
|
|
98
205
|
id?: string;
|
|
99
206
|
hidden?: boolean;
|
|
@@ -102,8 +209,8 @@ export interface JxElement {
|
|
|
102
209
|
lang?: string;
|
|
103
210
|
dir?: string;
|
|
104
211
|
$ref?: string;
|
|
105
|
-
$props?: Record<string,
|
|
106
|
-
$switch?:
|
|
212
|
+
$props?: Record<string, JsonValue>;
|
|
213
|
+
$switch?: string | JxRef;
|
|
107
214
|
cases?: Record<string, JxElement>;
|
|
108
215
|
$prototype?: string;
|
|
109
216
|
$static?: boolean;
|
|
@@ -118,18 +225,20 @@ export interface JxElement {
|
|
|
118
225
|
|
|
119
226
|
export interface JxMappedArray {
|
|
120
227
|
$prototype: "Array";
|
|
121
|
-
items:
|
|
228
|
+
items: Bindable<JsonValue[]>;
|
|
122
229
|
map?: JxElement;
|
|
123
|
-
filter?:
|
|
124
|
-
sort?:
|
|
230
|
+
filter?: Bindable<string>;
|
|
231
|
+
sort?: Bindable<string>;
|
|
125
232
|
}
|
|
126
233
|
|
|
127
234
|
export interface JxDocument extends JxElement {
|
|
128
235
|
state?: Record<string, JxStateDefinition>;
|
|
236
|
+
$layout?: string | false;
|
|
237
|
+
$paths?: JxPathsDef;
|
|
129
238
|
$elements?: (JxElement | string)[];
|
|
130
239
|
$head?: JxHeadEntry[];
|
|
131
240
|
$media?: Record<string, string>;
|
|
132
|
-
$defs?: Record<string,
|
|
241
|
+
$defs?: Record<string, JsonValue>;
|
|
133
242
|
imports?: Record<string, string>;
|
|
134
243
|
}
|
|
135
244
|
|
|
@@ -144,35 +253,88 @@ export type PureTypeDef = FromSchema<typeof pureTypeDefSchema>;
|
|
|
144
253
|
export type ExpressionNode = FromSchema<typeof expressionNodeSchema>;
|
|
145
254
|
export type ExpressionEntry = FromSchema<typeof expressionEntrySchema>;
|
|
146
255
|
|
|
147
|
-
|
|
256
|
+
/**
|
|
257
|
+
* Every shape a `state` entry can take — the runtime's five-shape detection algorithm: naked values
|
|
258
|
+
* (Shape 1), expanded signals / pure type defs (Shape 2/2b), function declarations (Shape 4),
|
|
259
|
+
* expressions (Shape 5), prototype instances, and server function proxies. Discriminate with the
|
|
260
|
+
* guards in `@jxsuite/schema/guards`.
|
|
261
|
+
*/
|
|
262
|
+
export type JxStateDefinition =
|
|
263
|
+
| JsonPrimitive
|
|
264
|
+
| JsonValue[]
|
|
265
|
+
| JxFunctionDef
|
|
266
|
+
| JxPrototypeDef
|
|
267
|
+
| JxExpressionDef
|
|
268
|
+
| JxServerFnDef
|
|
269
|
+
| JxStateObject;
|
|
148
270
|
|
|
271
|
+
/** An expanded signal (`{ default }`), pure type definition, or naked plain object. */
|
|
149
272
|
export interface JxStateObject {
|
|
150
273
|
type?: string;
|
|
151
|
-
default?:
|
|
152
|
-
properties?: Record<string,
|
|
153
|
-
items?:
|
|
154
|
-
enum?:
|
|
274
|
+
default?: JsonValue;
|
|
275
|
+
properties?: Record<string, JxStateObject>;
|
|
276
|
+
items?: JxStateObject | JxStateObject[];
|
|
277
|
+
enum?: JsonValue[];
|
|
278
|
+
description?: string;
|
|
279
|
+
/** Linked HTML attribute name for CEM extraction. */
|
|
280
|
+
attribute?: string;
|
|
281
|
+
/** Whether property changes reflect back to the HTML attribute. */
|
|
282
|
+
reflects?: boolean;
|
|
283
|
+
deprecated?: string | boolean;
|
|
155
284
|
[key: string]: unknown;
|
|
156
285
|
}
|
|
157
286
|
|
|
287
|
+
/** A `$prototype` instance entry (Request, Storage, ContentCollection, custom classes, …). */
|
|
158
288
|
export interface JxPrototypeDef {
|
|
159
289
|
$prototype: string;
|
|
160
290
|
$src?: string;
|
|
161
291
|
$export?: string;
|
|
162
|
-
body
|
|
163
|
-
|
|
292
|
+
/** Function body (Function entries) or request body (Request entries). */
|
|
293
|
+
body?: string | JsonObject;
|
|
294
|
+
parameters?: (string | CemParameter)[];
|
|
164
295
|
arguments?: string[];
|
|
165
296
|
timing?: "compiler" | "server" | "client";
|
|
166
|
-
default?:
|
|
297
|
+
default?: JsonValue;
|
|
167
298
|
debounce?: number;
|
|
168
299
|
contentType?: string;
|
|
169
|
-
filter?: Record<string,
|
|
300
|
+
filter?: Record<string, JsonValue>;
|
|
170
301
|
sort?: { field: string; order?: string };
|
|
171
302
|
limit?: number;
|
|
172
|
-
id?: string
|
|
303
|
+
id?: Bindable<string>;
|
|
304
|
+
/** Request prototype config. */
|
|
305
|
+
url?: string;
|
|
306
|
+
method?: string;
|
|
307
|
+
manual?: boolean;
|
|
308
|
+
headers?: Record<string, string>;
|
|
309
|
+
/** Storage prototype config (LocalStorage / SessionStorage key). */
|
|
310
|
+
key?: string;
|
|
311
|
+
/** Cookie prototype config. */
|
|
312
|
+
name?: string;
|
|
313
|
+
maxAge?: number;
|
|
314
|
+
path?: string;
|
|
315
|
+
domain?: string;
|
|
316
|
+
secure?: boolean;
|
|
317
|
+
sameSite?: string;
|
|
318
|
+
/** IndexedDB prototype config. */
|
|
319
|
+
database?: string;
|
|
320
|
+
store?: string;
|
|
321
|
+
version?: number;
|
|
322
|
+
keyPath?: string;
|
|
323
|
+
autoIncrement?: boolean;
|
|
324
|
+
indexes?: { name: string; keyPath: string; unique?: boolean }[];
|
|
325
|
+
/** FormData prototype config. */
|
|
326
|
+
fields?: Record<string, JsonValue>;
|
|
173
327
|
[key: string]: unknown;
|
|
174
328
|
}
|
|
175
329
|
|
|
330
|
+
// ─── Event Binding Model ────────────────────────────────────────────────────────
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* The value of an `on*` document key: a `$ref` to a state function, an inline function declaration,
|
|
334
|
+
* or a declarative expression.
|
|
335
|
+
*/
|
|
336
|
+
export type JxEventBinding = JxRef | JxFunctionDef | JxExpressionDef;
|
|
337
|
+
|
|
176
338
|
export type StateMap = FromSchema<typeof stateMapSchema>;
|
|
177
339
|
export type DefsMap = FromSchema<typeof defsMapSchema>;
|
|
178
340
|
|
|
@@ -182,6 +344,84 @@ export type ClassMethodDef = FromSchema<typeof classMethodDefSchema>;
|
|
|
182
344
|
export type ClassParameterDef = FromSchema<typeof classParameterDefSchema>;
|
|
183
345
|
export type ClassConstructorDef = FromSchema<typeof classConstructorDefSchema>;
|
|
184
346
|
|
|
347
|
+
// ─── Class Definition Model (consumer-friendly) ────────────────────────────────
|
|
348
|
+
// Working types for .class.json schema-defined classes, mirroring class-def.schema.
|
|
349
|
+
|
|
350
|
+
/** A typed parameter definition (or a `$ref` into `$defs/parameters`). */
|
|
351
|
+
export interface JxClassParamDef {
|
|
352
|
+
identifier?: string;
|
|
353
|
+
$ref?: string;
|
|
354
|
+
type?: unknown;
|
|
355
|
+
format?: string;
|
|
356
|
+
default?: JsonValue;
|
|
357
|
+
description?: string;
|
|
358
|
+
[key: string]: unknown;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export interface JxClassFieldDef {
|
|
362
|
+
role?: "field";
|
|
363
|
+
access?: "public" | "private" | "protected";
|
|
364
|
+
scope?: "instance" | "static";
|
|
365
|
+
identifier?: string;
|
|
366
|
+
type?: unknown;
|
|
367
|
+
$prototype?: string;
|
|
368
|
+
initializer?: JsonValue;
|
|
369
|
+
default?: JsonValue;
|
|
370
|
+
description?: string;
|
|
371
|
+
[key: string]: unknown;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export interface JxClassCtorDef {
|
|
375
|
+
role?: "constructor";
|
|
376
|
+
$prototype?: "Function";
|
|
377
|
+
parameters?: JxClassParamDef[];
|
|
378
|
+
superCall?: { arguments?: string[] };
|
|
379
|
+
body?: string | string[];
|
|
380
|
+
description?: string;
|
|
381
|
+
[key: string]: unknown;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export interface JxClassMethodDef {
|
|
385
|
+
role?: "method" | "accessor" | "parse" | "serialize" | "discover" | "load";
|
|
386
|
+
$prototype?: "Function";
|
|
387
|
+
access?: "public" | "private" | "protected";
|
|
388
|
+
scope?: "instance" | "static";
|
|
389
|
+
identifier?: string;
|
|
390
|
+
timing?: ("compiler" | "server" | "client")[];
|
|
391
|
+
parameters?: JxClassParamDef[];
|
|
392
|
+
returnType?: { $ref?: string };
|
|
393
|
+
body?: string | string[];
|
|
394
|
+
getter?: { body?: string };
|
|
395
|
+
setter?: { parameters?: JxClassParamDef[]; body?: string };
|
|
396
|
+
description?: string;
|
|
397
|
+
[key: string]: unknown;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/** A .class.json document: `$prototype: "Class"` with fields/constructor/methods in `$defs`. */
|
|
401
|
+
export interface JxClassDef {
|
|
402
|
+
$prototype: "Class";
|
|
403
|
+
$schema?: string;
|
|
404
|
+
$id?: string;
|
|
405
|
+
title?: string;
|
|
406
|
+
description?: string;
|
|
407
|
+
extends?: string | JxRef;
|
|
408
|
+
$implementation?: string;
|
|
409
|
+
$defs?: {
|
|
410
|
+
fields?: Record<string, JxClassFieldDef>;
|
|
411
|
+
/**
|
|
412
|
+
* The constructor definition. On objects parsed from JSON without an explicit "constructor"
|
|
413
|
+
* key, plain property access yields `Object.prototype.constructor` (a Function) — narrow with
|
|
414
|
+
* `typeof === "object"` before use.
|
|
415
|
+
*/
|
|
416
|
+
// oxlint-disable-next-line typescript/ban-types, typescript/no-unsafe-function-type -- only `Function` absorbs the inherited Object.prototype.constructor on plain object literals
|
|
417
|
+
constructor?: JxClassCtorDef | Function;
|
|
418
|
+
methods?: Record<string, JxClassMethodDef>;
|
|
419
|
+
parameters?: Record<string, JxClassParamDef>;
|
|
420
|
+
[key: string]: unknown;
|
|
421
|
+
};
|
|
422
|
+
[key: string]: unknown;
|
|
423
|
+
}
|
|
424
|
+
|
|
185
425
|
export interface ProjectConfig {
|
|
186
426
|
name?: string;
|
|
187
427
|
url?: string;
|
|
@@ -194,36 +434,73 @@ export interface ProjectConfig {
|
|
|
194
434
|
images?: ImageConfig;
|
|
195
435
|
imports?: Record<string, string>;
|
|
196
436
|
contentTypes?: Record<string, ContentTypeDef>;
|
|
197
|
-
|
|
437
|
+
/** Redirect map: source path → destination (or destination with HTTP status). */
|
|
438
|
+
redirects?: Record<string, string | { destination: string; status?: number }>;
|
|
439
|
+
defaults?: {
|
|
440
|
+
/** Default layout path; `null` means explicitly no layout. */
|
|
441
|
+
layout?: string | null;
|
|
442
|
+
lang?: string;
|
|
443
|
+
charset?: string;
|
|
444
|
+
[key: string]: unknown;
|
|
445
|
+
};
|
|
198
446
|
style?: JxStyle;
|
|
199
447
|
[key: string]: unknown;
|
|
200
448
|
}
|
|
201
449
|
|
|
202
450
|
// ─── Editor/Mutation Types ──────────────────────────────────────────────────────
|
|
203
451
|
|
|
452
|
+
/** The value of an HTML attribute in a document: a literal or a `$ref` binding. */
|
|
453
|
+
export type JxAttributeValue = Bindable<string | number | boolean>;
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* A dynamic-route path source (spec §4.3): content-type based, explicit values, data-file ref, or a
|
|
457
|
+
* legacy array of param objects.
|
|
458
|
+
*/
|
|
459
|
+
export type JxPathsDef =
|
|
460
|
+
| { contentType: string; param?: string; field?: string }
|
|
461
|
+
| { values: JsonValue[]; param?: string }
|
|
462
|
+
| { $ref: string; param?: string; field?: string }
|
|
463
|
+
| Record<string, JsonValue>[];
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* The editor's working representation of a document node. Known properties are fully typed;
|
|
467
|
+
* unrecognized keys (open schema) surface as `unknown` and must be narrowed with the guards in
|
|
468
|
+
* `@jxsuite/schema/guards` before use.
|
|
469
|
+
*/
|
|
204
470
|
export interface JxMutableNode {
|
|
205
471
|
tagName?: string;
|
|
206
|
-
textContent?: string | null;
|
|
472
|
+
textContent?: string | null | JxRef;
|
|
207
473
|
innerHTML?: string;
|
|
208
|
-
children?: (JxMutableNode | string)[];
|
|
209
|
-
style?:
|
|
210
|
-
attributes?: Record<string,
|
|
474
|
+
children?: (JxMutableNode | string)[] | JxMappedArray;
|
|
475
|
+
style?: JxStyle;
|
|
476
|
+
attributes?: Record<string, JxAttributeValue>;
|
|
211
477
|
className?: string;
|
|
212
478
|
id?: string;
|
|
479
|
+
title?: string;
|
|
213
480
|
$ref?: string;
|
|
214
|
-
$props?: Record<string,
|
|
215
|
-
$switch?: string |
|
|
481
|
+
$props?: Record<string, JsonValue>;
|
|
482
|
+
$switch?: string | JxRef;
|
|
216
483
|
cases?: Record<string, JxMutableNode>;
|
|
217
484
|
$prototype?: string;
|
|
218
485
|
$title?: string;
|
|
219
486
|
$id?: string;
|
|
220
487
|
$src?: string;
|
|
221
|
-
|
|
222
|
-
$
|
|
488
|
+
$layout?: string | false;
|
|
489
|
+
$static?: boolean;
|
|
490
|
+
$paths?: JxPathsDef;
|
|
491
|
+
state?: Record<string, JxStateDefinition>;
|
|
492
|
+
/** Repeater fields when this node is a mapped-array container. */
|
|
493
|
+
items?: Bindable<JsonValue[]>;
|
|
494
|
+
filter?: Bindable<string>;
|
|
495
|
+
sort?: Bindable<string>;
|
|
496
|
+
map?: JxMutableNode;
|
|
497
|
+
$elements?: (JxMutableNode | string | JxRef)[];
|
|
223
498
|
$head?: JxHeadEntry[];
|
|
224
499
|
$media?: Record<string, string>;
|
|
225
|
-
$defs?: Record<string,
|
|
226
|
-
|
|
500
|
+
$defs?: Record<string, JsonValue>;
|
|
501
|
+
imports?: Record<string, string>;
|
|
502
|
+
observedAttributes?: string[];
|
|
503
|
+
[key: string]: unknown;
|
|
227
504
|
}
|
|
228
505
|
|
|
229
506
|
// ─── Paths ──────────────────────────────────────────────────────────────────────
|
|
@@ -232,8 +509,19 @@ export type JxPath = (string | number)[];
|
|
|
232
509
|
|
|
233
510
|
// ─── Content Type Schema ────────────────────────────────────────────────────────
|
|
234
511
|
|
|
512
|
+
/** One field within a content-type JSON schema; recursive for nested objects. */
|
|
513
|
+
export interface ContentTypeSchemaField {
|
|
514
|
+
type?: string;
|
|
515
|
+
$ref?: string;
|
|
516
|
+
properties?: Record<string, ContentTypeSchemaField>;
|
|
517
|
+
items?: ContentTypeSchemaField;
|
|
518
|
+
required?: string[];
|
|
519
|
+
description?: string;
|
|
520
|
+
[key: string]: unknown;
|
|
521
|
+
}
|
|
522
|
+
|
|
235
523
|
export interface ContentTypeSchema {
|
|
236
|
-
properties?: Record<string,
|
|
524
|
+
properties?: Record<string, ContentTypeSchemaField>;
|
|
237
525
|
required?: string[];
|
|
238
526
|
[key: string]: unknown;
|
|
239
527
|
}
|