@jarenjs/json 0.9.2 → 0.34.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.
Files changed (74) hide show
  1. package/ARCHITECTURE.md +86 -13
  2. package/README.md +248 -23
  3. package/dist/types/canonical.d.ts +37 -0
  4. package/dist/types/cow.d.ts +28 -0
  5. package/dist/types/errors.d.ts +45 -0
  6. package/dist/types/index.d.ts +3 -0
  7. package/dist/types/jslt/errors.d.ts +15 -8
  8. package/dist/types/jslt/index.d.ts +22 -0
  9. package/dist/types/jslt/packs/finance.d.ts +119 -0
  10. package/dist/types/jslt/packs/index.d.ts +310 -0
  11. package/dist/types/jslt/packs/math.d.ts +159 -0
  12. package/dist/types/jslt/packs/stats.d.ts +48 -0
  13. package/dist/types/jslt/registry.d.ts +65 -0
  14. package/dist/types/jtlt/errors.d.ts +3 -6
  15. package/dist/types/option-variants.d.ts +29 -0
  16. package/dist/types/patch.d.ts +214 -0
  17. package/dist/types/path.d.ts +139 -9
  18. package/dist/types/pointer.d.ts +100 -9
  19. package/dist/types/query/compile.d.ts +12 -0
  20. package/dist/types/query/errors.d.ts +72 -8
  21. package/dist/types/query/index.d.ts +317 -25
  22. package/dist/types/query/normalize.d.ts +24 -0
  23. package/dist/types/query/operators.d.ts +241 -1
  24. package/dist/types/query/runtime.d.ts +5 -8
  25. package/dist/types/query/types.d.ts +34 -0
  26. package/dist/types/segments.d.ts +31 -0
  27. package/dist/types/write.d.ts +204 -0
  28. package/dist/types/xquery/parse.d.ts +2 -3
  29. package/docs/JSLT-FORMAT.md +74 -3
  30. package/docs/JSLT-PRELUDE.md +1 -1
  31. package/docs/QUERY-FORMAT.md +695 -33
  32. package/package.json +18 -4
  33. package/schemas/geojson.draft-07.schema.json +323 -0
  34. package/schemas/geojson.jaren.schema.json +863 -0
  35. package/schemas/geojson.schema.json +172 -0
  36. package/schemas/jaren-jslt.authoring.schema.json +142 -0
  37. package/schemas/jaren-jslt.draft-07.schema.json +152 -11
  38. package/schemas/jaren-jslt.llm-profile.schema.json +782 -0
  39. package/schemas/jaren-jslt.schema.json +152 -11
  40. package/schemas/jaren-query.draft-07.schema.json +152 -11
  41. package/schemas/jaren-query.llm-profile.schema.json +619 -0
  42. package/schemas/jaren-query.schema.json +82 -15
  43. package/src/basic.js +1 -1
  44. package/src/canonical.js +170 -0
  45. package/src/cow.js +106 -0
  46. package/src/errors.js +68 -0
  47. package/src/index.js +3 -0
  48. package/src/jslt/dispatch.js +178 -28
  49. package/src/jslt/errors.js +19 -14
  50. package/src/jslt/index.js +37 -29
  51. package/src/jslt/packs/finance.js +49 -0
  52. package/src/jslt/packs/index.js +18 -0
  53. package/src/jslt/packs/math.js +46 -0
  54. package/src/jslt/packs/stats.js +65 -0
  55. package/src/jslt/registry.js +200 -0
  56. package/src/jslt/stylesheet.js +14 -23
  57. package/src/jtlt/desugar.js +2 -3
  58. package/src/jtlt/errors.js +6 -12
  59. package/src/jtlt/index.js +12 -29
  60. package/src/jtlt/template.js +9 -18
  61. package/src/option-variants.js +54 -0
  62. package/src/patch.js +1052 -0
  63. package/src/path.js +319 -52
  64. package/src/pointer.js +225 -44
  65. package/src/query/compile.js +790 -75
  66. package/src/query/errors.js +72 -12
  67. package/src/query/index.js +274 -42
  68. package/src/query/normalize.js +489 -78
  69. package/src/query/operators.js +620 -23
  70. package/src/query/runtime.js +5 -19
  71. package/src/query/types.js +213 -0
  72. package/src/segments.js +409 -64
  73. package/src/write.js +660 -0
  74. package/src/xquery/parse.js +37 -53
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jarenjs/json",
3
3
  "private": false,
4
- "version": "0.9.2",
4
+ "version": "0.34.0",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
7
7
  "types": "./dist/types/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "license": "MIT",
24
24
  "engines": {
25
- "node": ">=22"
25
+ "node": ">=24"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public",
@@ -32,7 +32,9 @@
32
32
  "jaren",
33
33
  "json",
34
34
  "json-pointer",
35
- "jsonpath"
35
+ "jsonpath",
36
+ "json-patch",
37
+ "merge-patch"
36
38
  ],
37
39
  "exports": {
38
40
  ".": {
@@ -43,6 +45,10 @@
43
45
  "types": "./dist/types/basic.d.ts",
44
46
  "default": "./src/basic.js"
45
47
  },
48
+ "./canonical": {
49
+ "types": "./dist/types/canonical.d.ts",
50
+ "default": "./src/canonical.js"
51
+ },
46
52
  "./pointer": {
47
53
  "types": "./dist/types/pointer.d.ts",
48
54
  "default": "./src/pointer.js"
@@ -51,6 +57,14 @@
51
57
  "types": "./dist/types/path.d.ts",
52
58
  "default": "./src/path.js"
53
59
  },
60
+ "./patch": {
61
+ "types": "./dist/types/patch.d.ts",
62
+ "default": "./src/patch.js"
63
+ },
64
+ "./write": {
65
+ "types": "./dist/types/write.d.ts",
66
+ "default": "./src/write.js"
67
+ },
54
68
  "./query": {
55
69
  "types": "./dist/types/query/index.d.ts",
56
70
  "default": "./src/query/index.js"
@@ -76,6 +90,6 @@
76
90
  "prepack": "npm run build:types"
77
91
  },
78
92
  "dependencies": {
79
- "@jarenjs/core": "^0.9.2"
93
+ "@jarenjs/core": "^0.34.0"
80
94
  }
81
95
  }
@@ -0,0 +1,323 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://jarenjs.dev/schemas/geojson/draft-07",
4
+ "title": "GeoJSON (RFC 7946)",
5
+ "description": "Structural grammar of GeoJSON objects per RFC 7946. This artifact is deliberately PORTABLE: it uses only plain draft-neutral JSON Schema keywords and no Jaren extension, so any validator can consume it. It therefore stops exactly where JSON Schema stops - it CANNOT express that a linear ring is closed (first position equal to last) or that rings follow the right-hand rule (exterior counter-clockwise, holes clockwise), because neither is a structural property. Those two invariants are among the commonest defects in real GeoJSON, and geojson.jaren.schema.json adds them through the $query keyword. Coordinates are longitude, latitude, in that order, in WGS 84 decimal degrees: RFC 7946 removed alternative coordinate reference systems, so there is no crs member to validate.",
6
+ "allOf": [
7
+ {
8
+ "$ref": "#/definitions/geoJsonObject"
9
+ }
10
+ ],
11
+ "definitions": {
12
+ "geoJsonObject": {
13
+ "description": "Any GeoJSON object: a geometry, a Feature, or a FeatureCollection.",
14
+ "oneOf": [
15
+ {
16
+ "$ref": "#/definitions/geometry"
17
+ },
18
+ {
19
+ "$ref": "#/definitions/feature"
20
+ },
21
+ {
22
+ "$ref": "#/definitions/featureCollection"
23
+ }
24
+ ]
25
+ },
26
+ "geometry": {
27
+ "description": "One of the seven geometry types of RFC 7946 section 3.1.",
28
+ "oneOf": [
29
+ {
30
+ "$ref": "#/definitions/point"
31
+ },
32
+ {
33
+ "$ref": "#/definitions/multiPoint"
34
+ },
35
+ {
36
+ "$ref": "#/definitions/lineString"
37
+ },
38
+ {
39
+ "$ref": "#/definitions/multiLineString"
40
+ },
41
+ {
42
+ "$ref": "#/definitions/polygon"
43
+ },
44
+ {
45
+ "$ref": "#/definitions/multiPolygon"
46
+ },
47
+ {
48
+ "$ref": "#/definitions/geometryCollection"
49
+ }
50
+ ]
51
+ },
52
+ "position": {
53
+ "description": "A position: longitude, latitude, and optionally altitude, in that order (RFC 7946 section 3.1.1). Longitude and latitude are bounded because the coordinate reference system is fixed to WGS 84.",
54
+ "type": "array",
55
+ "minItems": 2,
56
+ "maxItems": 3,
57
+ "items": [
58
+ {
59
+ "type": "number",
60
+ "minimum": -180,
61
+ "maximum": 180
62
+ },
63
+ {
64
+ "type": "number",
65
+ "minimum": -90,
66
+ "maximum": 90
67
+ }
68
+ ],
69
+ "additionalItems": {
70
+ "type": "number"
71
+ }
72
+ },
73
+ "linearRing": {
74
+ "description": "A closed LineString of four or more positions. JSON Schema can require the count but NOT that the first and last positions are equal, which is why this artifact alone cannot fully validate a polygon.",
75
+ "type": "array",
76
+ "minItems": 4,
77
+ "items": {
78
+ "$ref": "#/definitions/position"
79
+ }
80
+ },
81
+ "bbox": {
82
+ "description": "All axes of the most south-westerly position followed by all axes of the more north-easterly one (RFC 7946 section 5): four numbers in two dimensions, six in three.",
83
+ "type": "array",
84
+ "oneOf": [
85
+ {
86
+ "minItems": 4,
87
+ "maxItems": 4
88
+ },
89
+ {
90
+ "minItems": 6,
91
+ "maxItems": 6
92
+ }
93
+ ],
94
+ "items": {
95
+ "type": "number"
96
+ }
97
+ },
98
+ "point": {
99
+ "type": "object",
100
+ "properties": {
101
+ "type": {
102
+ "const": "Point"
103
+ },
104
+ "coordinates": {
105
+ "$ref": "#/definitions/position"
106
+ },
107
+ "bbox": {
108
+ "$ref": "#/definitions/bbox"
109
+ }
110
+ },
111
+ "required": [
112
+ "type",
113
+ "coordinates"
114
+ ],
115
+ "additionalProperties": false
116
+ },
117
+ "multiPoint": {
118
+ "type": "object",
119
+ "properties": {
120
+ "type": {
121
+ "const": "MultiPoint"
122
+ },
123
+ "coordinates": {
124
+ "type": "array",
125
+ "items": {
126
+ "$ref": "#/definitions/position"
127
+ }
128
+ },
129
+ "bbox": {
130
+ "$ref": "#/definitions/bbox"
131
+ }
132
+ },
133
+ "required": [
134
+ "type",
135
+ "coordinates"
136
+ ],
137
+ "additionalProperties": false
138
+ },
139
+ "lineString": {
140
+ "description": "Two or more positions (RFC 7946 section 3.1.4).",
141
+ "type": "object",
142
+ "properties": {
143
+ "type": {
144
+ "const": "LineString"
145
+ },
146
+ "coordinates": {
147
+ "type": "array",
148
+ "minItems": 2,
149
+ "items": {
150
+ "$ref": "#/definitions/position"
151
+ }
152
+ },
153
+ "bbox": {
154
+ "$ref": "#/definitions/bbox"
155
+ }
156
+ },
157
+ "required": [
158
+ "type",
159
+ "coordinates"
160
+ ],
161
+ "additionalProperties": false
162
+ },
163
+ "multiLineString": {
164
+ "type": "object",
165
+ "properties": {
166
+ "type": {
167
+ "const": "MultiLineString"
168
+ },
169
+ "coordinates": {
170
+ "type": "array",
171
+ "items": {
172
+ "type": "array",
173
+ "minItems": 2,
174
+ "items": {
175
+ "$ref": "#/definitions/position"
176
+ }
177
+ }
178
+ },
179
+ "bbox": {
180
+ "$ref": "#/definitions/bbox"
181
+ }
182
+ },
183
+ "required": [
184
+ "type",
185
+ "coordinates"
186
+ ],
187
+ "additionalProperties": false
188
+ },
189
+ "polygon": {
190
+ "description": "An array of linear rings: the exterior ring first, then holes (RFC 7946 section 3.1.6). Ring closure and the right-hand rule are NOT checked here - see this schema's description.",
191
+ "type": "object",
192
+ "properties": {
193
+ "type": {
194
+ "const": "Polygon"
195
+ },
196
+ "coordinates": {
197
+ "type": "array",
198
+ "items": {
199
+ "$ref": "#/definitions/linearRing"
200
+ }
201
+ },
202
+ "bbox": {
203
+ "$ref": "#/definitions/bbox"
204
+ }
205
+ },
206
+ "required": [
207
+ "type",
208
+ "coordinates"
209
+ ],
210
+ "additionalProperties": false
211
+ },
212
+ "multiPolygon": {
213
+ "type": "object",
214
+ "properties": {
215
+ "type": {
216
+ "const": "MultiPolygon"
217
+ },
218
+ "coordinates": {
219
+ "type": "array",
220
+ "items": {
221
+ "type": "array",
222
+ "items": {
223
+ "$ref": "#/definitions/linearRing"
224
+ }
225
+ }
226
+ },
227
+ "bbox": {
228
+ "$ref": "#/definitions/bbox"
229
+ }
230
+ },
231
+ "required": [
232
+ "type",
233
+ "coordinates"
234
+ ],
235
+ "additionalProperties": false
236
+ },
237
+ "geometryCollection": {
238
+ "description": "A heterogeneous collection of geometries. RFC 7946 section 3.1.8 advises against nesting one inside another.",
239
+ "type": "object",
240
+ "properties": {
241
+ "type": {
242
+ "const": "GeometryCollection"
243
+ },
244
+ "geometries": {
245
+ "type": "array",
246
+ "items": {
247
+ "$ref": "#/definitions/geometry"
248
+ }
249
+ },
250
+ "bbox": {
251
+ "$ref": "#/definitions/bbox"
252
+ }
253
+ },
254
+ "required": [
255
+ "type",
256
+ "geometries"
257
+ ],
258
+ "additionalProperties": false
259
+ },
260
+ "feature": {
261
+ "description": "A geometry with properties. Both members are REQUIRED and both are nullable (RFC 7946 section 3.2).",
262
+ "type": "object",
263
+ "properties": {
264
+ "type": {
265
+ "const": "Feature"
266
+ },
267
+ "geometry": {
268
+ "oneOf": [
269
+ {
270
+ "type": "null"
271
+ },
272
+ {
273
+ "$ref": "#/definitions/geometry"
274
+ }
275
+ ]
276
+ },
277
+ "properties": {
278
+ "type": [
279
+ "object",
280
+ "null"
281
+ ]
282
+ },
283
+ "id": {
284
+ "type": [
285
+ "string",
286
+ "number"
287
+ ]
288
+ },
289
+ "bbox": {
290
+ "$ref": "#/definitions/bbox"
291
+ }
292
+ },
293
+ "required": [
294
+ "type",
295
+ "geometry",
296
+ "properties"
297
+ ],
298
+ "additionalProperties": false
299
+ },
300
+ "featureCollection": {
301
+ "type": "object",
302
+ "properties": {
303
+ "type": {
304
+ "const": "FeatureCollection"
305
+ },
306
+ "features": {
307
+ "type": "array",
308
+ "items": {
309
+ "$ref": "#/definitions/feature"
310
+ }
311
+ },
312
+ "bbox": {
313
+ "$ref": "#/definitions/bbox"
314
+ }
315
+ },
316
+ "required": [
317
+ "type",
318
+ "features"
319
+ ],
320
+ "additionalProperties": false
321
+ }
322
+ }
323
+ }