@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.
@@ -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": {
@@ -234,7 +193,7 @@
234
193
  },
235
194
  "format": {
236
195
  "default": "directory",
237
- "description": "Output format.",
196
+ "description": "Reserved; currently unused. Accepted for forward compatibility with single-file output (desktop single-file mode) — the build emits per-route directories regardless.",
238
197
  "enum": [
239
198
  "directory",
240
199
  "single"
@@ -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
@@ -224,13 +224,35 @@
224
224
  "type": "string"
225
225
  },
226
226
  "body": {
227
- "description": "Inline function body string. First implicit parameter is state.",
227
+ "description": "Inline function body: an opaque JS source string (first implicit parameter is state), or a structured statement array (spec §20) — explicit structured function declaration, analyzable by tooling and editable visually. The escalation ladder within the shape is structured statements → JS string.",
228
228
  "examples": [
229
229
  "state.count++",
230
230
  "state.items.push({ id: Date.now(), text: \"\", done: false })",
231
- "return state.score >= 90 ? \"gold\" : \"silver\""
231
+ "return state.score >= 90 ? \"gold\" : \"silver\"",
232
+ [
233
+ {
234
+ "operator": "push",
235
+ "target": {
236
+ "$ref": "#/state/cart"
237
+ },
238
+ "value": 1
239
+ },
240
+ {
241
+ "dispatchEvent": "cart-changed",
242
+ "detail": {
243
+ "$ref": "#/state/cart"
244
+ }
245
+ }
246
+ ]
232
247
  ],
233
- "type": "string"
248
+ "oneOf": [
249
+ {
250
+ "type": "string"
251
+ },
252
+ {
253
+ "$ref": "#/$defs/StatementList"
254
+ }
255
+ ]
234
256
  },
235
257
  "description": {
236
258
  "type": "string"
@@ -951,10 +973,10 @@
951
973
  },
952
974
  "ExpressionPointer": {
953
975
  "additionalProperties": false,
954
- "description": "A JSON Pointer $ref operand within an expression node.",
976
+ "description": "A JSON Pointer $ref operand within an expression node. $args/<name> resolves a named formula's parameter (callable entries only).",
955
977
  "properties": {
956
978
  "$ref": {
957
- "pattern": "^(\\$map/|\\$reduce/|event#/|#/|parent#/|window#/|document#/)",
979
+ "pattern": "^(\\$map/|\\$reduce/|\\$args/|event#/|#/|parent#/|window#/|document#/)",
958
980
  "type": "string"
959
981
  }
960
982
  },
@@ -985,9 +1007,27 @@
985
1007
  "$ref": "#/$defs/ExpressionOperand"
986
1008
  },
987
1009
  "type": "array"
1010
+ },
1011
+ {
1012
+ "description": "Plain-object literal (e.g. an Intl options bag). Objects carrying $ref or operator keys are pointers/nodes, never literals.",
1013
+ "not": {
1014
+ "anyOf": [
1015
+ {
1016
+ "required": [
1017
+ "$ref"
1018
+ ]
1019
+ },
1020
+ {
1021
+ "required": [
1022
+ "operator"
1023
+ ]
1024
+ }
1025
+ ]
1026
+ },
1027
+ "type": "object"
988
1028
  }
989
1029
  ],
990
- "description": "A non-reactive operand: scalar or array of operands."
1030
+ "description": "A non-reactive operand: scalar, plain-object literal, or array of operands."
991
1031
  },
992
1032
  "ExpressionOperand": {
993
1033
  "anyOf": [
@@ -1023,7 +1063,53 @@
1023
1063
  ">",
1024
1064
  ">=",
1025
1065
  "&&",
1026
- "||"
1066
+ "||",
1067
+ "??"
1068
+ ]
1069
+ },
1070
+ "ConditionalOperator": {
1071
+ "const": "?:"
1072
+ },
1073
+ "SwitchOperator": {
1074
+ "const": "switch"
1075
+ },
1076
+ "CallOperator": {
1077
+ "const": "call"
1078
+ },
1079
+ "PureMethod": {
1080
+ "description": "A genuine pure String.prototype / Array.prototype / Number.prototype method (spec §19.4d). The ES2023 change-by-copy family (toSorted, toReversed, toSpliced, with) stands in where mutation would otherwise occur. Receiver in target; value carries the argument (bare scalar) or argument list (array).",
1081
+ "enum": [
1082
+ "includes",
1083
+ "indexOf",
1084
+ "lastIndexOf",
1085
+ "join",
1086
+ "slice",
1087
+ "concat",
1088
+ "at",
1089
+ "flat",
1090
+ "toSorted",
1091
+ "toReversed",
1092
+ "toSpliced",
1093
+ "with",
1094
+ "toUpperCase",
1095
+ "toLowerCase",
1096
+ "trim",
1097
+ "trimStart",
1098
+ "trimEnd",
1099
+ "split",
1100
+ "startsWith",
1101
+ "endsWith",
1102
+ "padStart",
1103
+ "padEnd",
1104
+ "replaceAll",
1105
+ "repeat",
1106
+ "charAt",
1107
+ "normalize",
1108
+ "toLocaleUpperCase",
1109
+ "toLocaleLowerCase",
1110
+ "toFixed",
1111
+ "toPrecision",
1112
+ "toLocaleString"
1027
1113
  ]
1028
1114
  },
1029
1115
  "AssignmentOperator": {
@@ -1206,7 +1292,14 @@
1206
1292
  "$ref": "#/$defs/ReduceMethod"
1207
1293
  },
1208
1294
  "target": {
1209
- "$ref": "#/$defs/ExpressionPointer"
1295
+ "anyOf": [
1296
+ {
1297
+ "$ref": "#/$defs/ExpressionPointer"
1298
+ },
1299
+ {
1300
+ "$ref": "#/$defs/ExpressionNode"
1301
+ }
1302
+ ]
1210
1303
  },
1211
1304
  "value": {
1212
1305
  "$ref": "#/$defs/ExpressionNode"
@@ -1217,7 +1310,7 @@
1217
1310
  "value",
1218
1311
  "initial"
1219
1312
  ],
1220
- "title": "reduce — pure fold; per-item expression in value, seed in initial"
1313
+ "title": "reduce — pure fold over a pointer or derived array; seed in initial"
1221
1314
  },
1222
1315
  {
1223
1316
  "not": {
@@ -1230,7 +1323,14 @@
1230
1323
  "$ref": "#/$defs/MapFilterMethod"
1231
1324
  },
1232
1325
  "target": {
1233
- "$ref": "#/$defs/ExpressionPointer"
1326
+ "anyOf": [
1327
+ {
1328
+ "$ref": "#/$defs/ExpressionPointer"
1329
+ },
1330
+ {
1331
+ "$ref": "#/$defs/ExpressionNode"
1332
+ }
1333
+ ]
1234
1334
  },
1235
1335
  "value": {
1236
1336
  "$ref": "#/$defs/ExpressionNode"
@@ -1240,10 +1340,114 @@
1240
1340
  "operator",
1241
1341
  "value"
1242
1342
  ],
1243
- "title": "map / filter — pure; per-item expression in value, no initial"
1343
+ "title": "map / filter — pure over a pointer or derived array; per-item expression in value"
1344
+ },
1345
+ {
1346
+ "description": "The ECMAScript conditional (ternary) operator, pure: target is the test, value the consequent, initial the alternate (the reduce precedent for repurposing initial). Chain else-if by nesting another ?: node in initial.",
1347
+ "properties": {
1348
+ "operator": {
1349
+ "$ref": "#/$defs/ConditionalOperator"
1350
+ }
1351
+ },
1352
+ "required": [
1353
+ "operator",
1354
+ "value",
1355
+ "initial"
1356
+ ],
1357
+ "title": "?: — pure conditional; test in target, consequent in value, alternate in initial"
1358
+ },
1359
+ {
1360
+ "description": "Value-keyed multiway selection, pure: target is the discriminant (matched against case keys by its string form, like element-level $switch), cases maps matched values to result operands, default is the operand when no case matches (result is undefined without it). Condition-chain branching composes from nested ?: nodes instead.",
1361
+ "not": {
1362
+ "anyOf": [
1363
+ {
1364
+ "required": [
1365
+ "value"
1366
+ ]
1367
+ },
1368
+ {
1369
+ "required": [
1370
+ "initial"
1371
+ ]
1372
+ }
1373
+ ]
1374
+ },
1375
+ "properties": {
1376
+ "cases": {
1377
+ "additionalProperties": {
1378
+ "$ref": "#/$defs/ExpressionOperand"
1379
+ },
1380
+ "type": "object"
1381
+ },
1382
+ "default": {
1383
+ "$ref": "#/$defs/ExpressionOperand"
1384
+ },
1385
+ "operator": {
1386
+ "$ref": "#/$defs/SwitchOperator"
1387
+ }
1388
+ },
1389
+ "required": [
1390
+ "operator",
1391
+ "cases"
1392
+ ],
1393
+ "title": "switch — pure value-keyed selection; discriminant in target, results in cases/default"
1394
+ },
1395
+ {
1396
+ "description": "A pure standard-library method call: target is the receiver (any operand — never mutated; change-by-copy names replace the mutating originals), value the optional argument (bare scalar) or argument list (array). A missing receiver or method yields undefined, matching null-safe path reads.",
1397
+ "not": {
1398
+ "required": [
1399
+ "initial"
1400
+ ]
1401
+ },
1402
+ "properties": {
1403
+ "operator": {
1404
+ "$ref": "#/$defs/PureMethod"
1405
+ }
1406
+ },
1407
+ "required": [
1408
+ "operator"
1409
+ ],
1410
+ "title": "Pure method — genuine prototype methods; receiver in target, args in value"
1411
+ },
1412
+ {
1413
+ "description": "Invoke a callable, pure in formula position: target is the callee pointer — a named formula entry (#/state/…) or a blessed pure global via window#/ (Math.*, JSON.*, Object.keys/values/entries, and the Intl helpers Intl/formatNumber, Intl/formatDate, Intl/formatRelativeTime) — and value is the positional argument list (the splice args-in-value precedent). Argument order follows the callee's declared parameters.",
1414
+ "not": {
1415
+ "required": [
1416
+ "initial"
1417
+ ]
1418
+ },
1419
+ "properties": {
1420
+ "operator": {
1421
+ "$ref": "#/$defs/CallOperator"
1422
+ },
1423
+ "target": {
1424
+ "$ref": "#/$defs/ExpressionPointer"
1425
+ },
1426
+ "value": {
1427
+ "items": {
1428
+ "$ref": "#/$defs/ExpressionOperand"
1429
+ },
1430
+ "type": "array"
1431
+ }
1432
+ },
1433
+ "required": [
1434
+ "operator"
1435
+ ],
1436
+ "title": "call — invoke a named formula or blessed global; callee in target, args in value"
1244
1437
  }
1245
1438
  ],
1246
1439
  "properties": {
1440
+ "cases": {
1441
+ "additionalProperties": {
1442
+ "$ref": "#/$defs/ExpressionOperand"
1443
+ },
1444
+ "description": "switch only: matched discriminant value (string form) → result operand.",
1445
+ "type": "object"
1446
+ },
1447
+ "default": {
1448
+ "$ref": "#/$defs/ExpressionOperand",
1449
+ "description": "switch only: result operand when no case key matches."
1450
+ },
1247
1451
  "initial": {
1248
1452
  "$ref": "#/$defs/ExpressionOperand"
1249
1453
  },
@@ -1265,7 +1469,7 @@
1265
1469
  },
1266
1470
  "ExpressionEntry": {
1267
1471
  "additionalProperties": false,
1268
- "description": "A declarative expression entry (Shape 5). Used as a state entry or inline event handler.",
1472
+ "description": "A declarative expression entry (Shape 5). Used as a state entry or inline event handler. With parameters it is a named formula: a pure, reusable computation invoked via the call operator, its parameters resolved through $args/<name> refs in the body.",
1269
1473
  "properties": {
1270
1474
  "$description": {
1271
1475
  "type": "string"
@@ -1275,6 +1479,20 @@
1275
1479
  },
1276
1480
  "$title": {
1277
1481
  "type": "string"
1482
+ },
1483
+ "parameters": {
1484
+ "description": "Named-formula parameters (CEM convention, as on Function entries): bare names or CEM parameter objects. Present ⇒ the entry is callable, not a computed value.",
1485
+ "items": {
1486
+ "anyOf": [
1487
+ {
1488
+ "type": "string"
1489
+ },
1490
+ {
1491
+ "$ref": "#/$defs/CemParameter"
1492
+ }
1493
+ ]
1494
+ },
1495
+ "type": "array"
1278
1496
  }
1279
1497
  },
1280
1498
  "required": [
@@ -1282,6 +1500,99 @@
1282
1500
  ],
1283
1501
  "type": "object"
1284
1502
  },
1503
+ "Statement": {
1504
+ "description": "One statement of a structured function body. Either a bare expression node in statement position (a mutation like =/push, or a call — its result discarded unless captured by an assignment), an if/then/else branch (JSON Schema conditional keywords; if holds a pure expression, then/else hold statement lists), a $switch multiway branch (discriminant matched by string form against cases keys, like element-level $switch), or a dispatchEvent statement (WHATWG DOM: dispatches a CustomEvent from the handler's current target, with CustomEventInit members detail/bubbles/composed).",
1505
+ "oneOf": [
1506
+ {
1507
+ "$ref": "#/$defs/ExpressionNode"
1508
+ },
1509
+ {
1510
+ "additionalProperties": false,
1511
+ "properties": {
1512
+ "else": {
1513
+ "items": {
1514
+ "$ref": "#/$defs/Statement"
1515
+ },
1516
+ "type": "array"
1517
+ },
1518
+ "if": {
1519
+ "$ref": "#/$defs/ExpressionOperand"
1520
+ },
1521
+ "then": {
1522
+ "items": {
1523
+ "$ref": "#/$defs/Statement"
1524
+ },
1525
+ "type": "array"
1526
+ }
1527
+ },
1528
+ "required": [
1529
+ "if",
1530
+ "then"
1531
+ ],
1532
+ "title": "if / then / else — conditional branch (JSON Schema keyword triple)",
1533
+ "type": "object"
1534
+ },
1535
+ {
1536
+ "additionalProperties": false,
1537
+ "properties": {
1538
+ "$switch": {
1539
+ "$ref": "#/$defs/ExpressionOperand"
1540
+ },
1541
+ "cases": {
1542
+ "additionalProperties": {
1543
+ "items": {
1544
+ "$ref": "#/$defs/Statement"
1545
+ },
1546
+ "type": "array"
1547
+ },
1548
+ "type": "object"
1549
+ },
1550
+ "default": {
1551
+ "items": {
1552
+ "$ref": "#/$defs/Statement"
1553
+ },
1554
+ "type": "array"
1555
+ }
1556
+ },
1557
+ "required": [
1558
+ "$switch",
1559
+ "cases"
1560
+ ],
1561
+ "title": "$switch / cases — multiway branch (element-level convention, ECMA switch semantics)",
1562
+ "type": "object"
1563
+ },
1564
+ {
1565
+ "additionalProperties": false,
1566
+ "properties": {
1567
+ "bubbles": {
1568
+ "type": "boolean"
1569
+ },
1570
+ "composed": {
1571
+ "type": "boolean"
1572
+ },
1573
+ "detail": {
1574
+ "$ref": "#/$defs/ExpressionOperand"
1575
+ },
1576
+ "dispatchEvent": {
1577
+ "description": "The CustomEvent type to dispatch (WHATWG DOM dispatchEvent).",
1578
+ "type": "string"
1579
+ }
1580
+ },
1581
+ "required": [
1582
+ "dispatchEvent"
1583
+ ],
1584
+ "title": "dispatchEvent — emit a CustomEvent (WHATWG naming, CustomEventInit members)",
1585
+ "type": "object"
1586
+ }
1587
+ ]
1588
+ },
1589
+ "StatementList": {
1590
+ "description": "A structured function body: statements executed sequentially (one yielding a promise is awaited before the next, per ECMA async/await semantics).",
1591
+ "items": {
1592
+ "$ref": "#/$defs/Statement"
1593
+ },
1594
+ "type": "array"
1595
+ },
1285
1596
  "ElementDef": {
1286
1597
  "additionalProperties": {
1287
1598
  "$ref": "#/$defs/ElementPropertyValue"
@@ -21651,50 +21962,6 @@
21651
21962
  }
21652
21963
  },
21653
21964
  "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
21965
  }
21699
21966
  },
21700
21967
  "$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
+ }