@zeroxsolutions/jsonapi 0.13.4 → 0.13.6
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## 0.13.6 (2026-10-21)
|
|
2
|
+
|
|
3
|
+
This was a version bump only for @zeroxsolutions/jsonapi to align it with other projects, there were no code changes.
|
|
4
|
+
|
|
5
|
+
## 0.13.5 (2026-10-20)
|
|
6
|
+
|
|
7
|
+
### 🚀 Features
|
|
8
|
+
|
|
9
|
+
- **jsonapi:** read a facet's own facets where its fieldset names them ([a370c97](https://github.com/zeroxsolutions/zeroxsolutions/commit/a370c97))
|
|
10
|
+
|
|
11
|
+
### ❤️ Thank You
|
|
12
|
+
|
|
13
|
+
- Lương Văn Tú
|
|
14
|
+
|
|
1
15
|
## 0.13.4 (2026-10-19)
|
|
2
16
|
|
|
3
17
|
This was a version bump only for @zeroxsolutions/jsonapi to align it with other projects, there were no code changes.
|
package/README.md
CHANGED
|
@@ -95,9 +95,12 @@ A read-one query answers `{ read }` alone. The permits name the `type` the read
|
|
|
95
95
|
| -------------------------------------------- | ------------------------------------------------------------------------------ |
|
|
96
96
|
| a column in the type's fieldset | that column |
|
|
97
97
|
| a relationship in the fieldset, not included | the related row's primary key, which is the linkage its relationship publishes |
|
|
98
|
-
| a facet (`facets`) in the fieldset | that relation under its own type's fieldset, exactly
|
|
98
|
+
| a facet (`facets`) in the fieldset | that relation under its own type's fieldset, exactly, its facets read the same |
|
|
99
99
|
| an `include` path | every relation on it, each under its type's fieldset and its primary key |
|
|
100
100
|
| a computed name given a `ComputedRead` | the columns and relations it names, whatever the fieldset asked |
|
|
101
101
|
|
|
102
|
+
A facet's type may declare facets of its own, such as a step's texts under a revision's steps; each loads where its
|
|
103
|
+
parent facet's fieldset names it. A chain of facets leading back to a type it left throws, since it would never end.
|
|
104
|
+
|
|
102
105
|
The filter, the order and the page window pass through unchanged. The package depends on `@zeroxsolutions/query`
|
|
103
106
|
alone: the read names are strings, and `@zeroxsolutions/db` refuses one its table does not hold with `UnknownReadName`.
|
|
@@ -27,7 +27,7 @@ export interface CollectionFindOptions<Leaf> extends ResourceFindOptions {
|
|
|
27
27
|
* | `fields[<type>]` naming columns | those columns in `read` |
|
|
28
28
|
* | a relationship in a fieldset, not included | that relation in `read` with its primary key alone, the linkage it publishes |
|
|
29
29
|
* | an `include` path | every relation on it in `read`, each under its own type's fieldset and its primary key |
|
|
30
|
-
* | a facet in a fieldset | that relation in `read` with exactly the columns its own type's fieldset names |
|
|
30
|
+
* | a facet in a fieldset | that relation in `read` with exactly the columns its own type's fieldset names, and each facet of that type the fieldset names, the same way |
|
|
31
31
|
* | `filter`, `sort`, `offset`, `limit` | `filter`, `orderBy`, `offset` and `limit`, unchanged |
|
|
32
32
|
*
|
|
33
33
|
* Each computed attribute the permits map to a read loads that read on every query, whatever fieldset was sent.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-options-of.d.ts","sourceRoot":"","sources":["../../../src/lib/find-options/find-options-of.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,UAAU,EACV,wBAAwB,EACxB,sBAAsB,EAEtB,oBAAoB,EACpB,SAAS,EACV,MAAM,uBAAuB,CAAC;AAE/B;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,4DAA4D;AAC5D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,+GAA+G;AAC/G,MAAM,WAAW,qBAAqB,CAAC,IAAI,CAAE,SAAQ,mBAAmB;IACtE,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;IAC3B,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;
|
|
1
|
+
{"version":3,"file":"find-options-of.d.ts","sourceRoot":"","sources":["../../../src/lib/find-options/find-options-of.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,UAAU,EACV,wBAAwB,EACxB,sBAAsB,EAEtB,oBAAoB,EACpB,SAAS,EACV,MAAM,uBAAuB,CAAC;AAE/B;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,4DAA4D;AAC5D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,+GAA+G;AAC/G,MAAM,WAAW,qBAAqB,CAAC,IAAI,CAAE,SAAQ,mBAAmB;IACtE,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;IAC3B,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AA0GD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,CAAC,SAAS,oBAAoB,EAChE,KAAK,EAAE,wBAAwB,CAAC,IAAI,EAAE,CAAC,CAAC,EACxC,OAAO,EAAE,CAAC,GACT,qBAAqB,CAAC,IAAI,CAAC,CAAC;AAC/B,wBAAgB,aAAa,CAAC,CAAC,SAAS,oBAAoB,EAC1D,KAAK,EAAE,sBAAsB,CAAC,CAAC,CAAC,EAChC,OAAO,EAAE,CAAC,GACT,mBAAmB,CAAC"}
|
|
@@ -29,10 +29,12 @@ function mergeComputed(level, computed) {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
* One level of the read: its fieldset's columns, the linkage of each relationship it names, each facet
|
|
33
|
-
*
|
|
32
|
+
* One level of the read: its fieldset's columns, the linkage of each relationship it names, each facet as a level of
|
|
33
|
+
* its own type, each included relation under its own type's fieldset, and what its computed attributes need.
|
|
34
|
+
*
|
|
35
|
+
* @param facetsLeft - the types the facets leading to this level left, which a facet of it may not return to
|
|
34
36
|
*/
|
|
35
|
-
function levelOf(walk, type, relations, include, path) {
|
|
37
|
+
function levelOf(walk, type, relations, include, path, facetsLeft = new Set()) {
|
|
36
38
|
const level = {};
|
|
37
39
|
const fieldset = walk.fields[type];
|
|
38
40
|
const facets = new Set(walk.permits.facets?.[type] ?? []);
|
|
@@ -43,12 +45,16 @@ function levelOf(walk, type, relations, include, path) {
|
|
|
43
45
|
if (!target)
|
|
44
46
|
continue;
|
|
45
47
|
level.relations ??= {};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
if (!facets.has(name)) {
|
|
49
|
+
level.relations[name] = { columns: [...target.primaryKey] };
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
// A facet's relations come back to the type it left, so a facet chain declared in a circle would never end.
|
|
53
|
+
if (facetsLeft.has(target.type) || target.type === type) {
|
|
54
|
+
throw new Error(`"${path}${name}" is a facet leading back to "${target.type}", which a facet above it left.`);
|
|
55
|
+
}
|
|
56
|
+
// A facet publishes no id, so its level holds only what its own type's fieldset names, its facets included.
|
|
57
|
+
level.relations[name] = levelOf(walk, target.type, target.relations, {}, `${path}${name}.`, new Set([...facetsLeft, type]));
|
|
52
58
|
}
|
|
53
59
|
}
|
|
54
60
|
for (const [name, below] of Object.entries(include)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeroxsolutions/jsonapi",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -30,7 +30,12 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"jsona": "^1.12.0",
|
|
32
32
|
"tslib": "^2.3.0",
|
|
33
|
-
"@zeroxsolutions/
|
|
34
|
-
"@zeroxsolutions/
|
|
33
|
+
"@zeroxsolutions/query": "0.7.5",
|
|
34
|
+
"@zeroxsolutions/response": "0.14.6"
|
|
35
|
+
},
|
|
36
|
+
"nx": {
|
|
37
|
+
"targets": {
|
|
38
|
+
"lint-deps": {}
|
|
39
|
+
}
|
|
35
40
|
}
|
|
36
41
|
}
|