@onehat/data 1.22.44 → 1.22.46
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/package.json +1 -1
- package/src/Entity/Entity.js +45 -3
- package/src/Property/Integer.js +2 -0
- package/src/Schema/Schema.js +6 -0
package/package.json
CHANGED
package/src/Entity/Entity.js
CHANGED
|
@@ -1537,7 +1537,7 @@ class Entity extends EventEmitter {
|
|
|
1537
1537
|
/**
|
|
1538
1538
|
* Gets the "hasChildren" Property object for this TreeNode.
|
|
1539
1539
|
* This is the Property whose value represents whether this TreeNode has any children.
|
|
1540
|
-
* @return {Property}
|
|
1540
|
+
* @return {Property} hasChildren Property
|
|
1541
1541
|
*/
|
|
1542
1542
|
getHasChildrenProperty = () => {
|
|
1543
1543
|
this.ensureTree();
|
|
@@ -1553,7 +1553,7 @@ class Entity extends EventEmitter {
|
|
|
1553
1553
|
* Gets the hasChildren value for this TreeNode.
|
|
1554
1554
|
* It does this by getting the hasChildren property's submitValue.
|
|
1555
1555
|
* It doesn't look at some value created by client on the TreeNode.
|
|
1556
|
-
* @return {any}
|
|
1556
|
+
* @return {any} hasChildren - The hasChildren value
|
|
1557
1557
|
*/
|
|
1558
1558
|
getHasChildren = () => {
|
|
1559
1559
|
this.ensureTree();
|
|
@@ -1570,12 +1570,54 @@ class Entity extends EventEmitter {
|
|
|
1570
1570
|
|
|
1571
1571
|
/**
|
|
1572
1572
|
* Getter of hasChildren for this TreeNode.
|
|
1573
|
-
* @return {any}
|
|
1573
|
+
* @return {any} hasChildren - The hasChildren value
|
|
1574
1574
|
*/
|
|
1575
1575
|
get hasChildren() {
|
|
1576
1576
|
return this.getHasChildren();
|
|
1577
1577
|
}
|
|
1578
1578
|
|
|
1579
|
+
/**
|
|
1580
|
+
* Gets the "hasChildrenOfOtherNodeTypes" Property object for this TreeNode.
|
|
1581
|
+
* This is the Property whose value represents whether this TreeNode has any children of other node types.
|
|
1582
|
+
* @return {Property} hasChildrenOfOtherNodeTypes Property
|
|
1583
|
+
*/
|
|
1584
|
+
getHasChildrenOfOtherNodeTypesProperty = () => {
|
|
1585
|
+
this.ensureTree();
|
|
1586
|
+
if (this.isDestroyed) {
|
|
1587
|
+
throw Error('this.getHasChildrenOfOtherNodeTypesProperty is no longer valid. TreeNode has been destroyed.');
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
const hasChildrenOfOtherNodeTypesProperty = this.getSchema()?.model.hasChildrenOfOtherNodeTypesProperty;
|
|
1591
|
+
return this.getProperty(hasChildrenOfOtherNodeTypesProperty);
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
/**
|
|
1595
|
+
* Gets the hasChildrenOfOtherNodeTypes value for this TreeNode.
|
|
1596
|
+
* It does this by getting the hasChildrenOfOtherNodeTypes property's submitValue.
|
|
1597
|
+
* It doesn't look at some value created by client on the TreeNode.
|
|
1598
|
+
* @return {any} hasChildrenOfOtherNodeTypes - The hasChildrenOfOtherNodeTypes value
|
|
1599
|
+
*/
|
|
1600
|
+
getHasChildrenOfOtherNodeTypes = () => {
|
|
1601
|
+
this.ensureTree();
|
|
1602
|
+
if (this.isDestroyed) {
|
|
1603
|
+
throw Error('this.getHasChildrenOfOtherNodeTypes is no longer valid. TreeNode has been destroyed.');
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
if (!_.isEmpty(this.children)) {
|
|
1607
|
+
return true; // In case the hasChildrenOfOtherNodeTypesProperty is stale. i.e. That property came from server, and we now have children here
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
return this.getHasChildrenOfOtherNodeTypesProperty()?.getSubmitValue();
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
/**
|
|
1614
|
+
* Getter of hasChildrenOfOtherNodeTypes for this TreeNode.
|
|
1615
|
+
* @return {any} hasChildrenOfOtherNodeTypes - The hasChildrenOfOtherNodeTypes value
|
|
1616
|
+
*/
|
|
1617
|
+
get hasChildrenOfOtherNodeTypes() {
|
|
1618
|
+
return this.getHasChildrenOfOtherNodeTypes();
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1579
1621
|
/**
|
|
1580
1622
|
* Getter of parent TreeNode for this TreeNode.
|
|
1581
1623
|
* @return {TreeNode} parent - The parent TreeNode
|
package/src/Property/Integer.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @module Property */
|
|
2
2
|
|
|
3
3
|
import Property from './Property.js';
|
|
4
|
+
import Formatters from '../Util/Formatters.js';
|
|
4
5
|
import Parsers from '../Util/Parsers.js';
|
|
5
6
|
import _ from 'lodash';
|
|
6
7
|
|
|
@@ -15,6 +16,7 @@ export default class IntegerProperty extends Property {
|
|
|
15
16
|
static defaults = {
|
|
16
17
|
// defaultValue: 0,
|
|
17
18
|
idStartsAt: 100 * 1000 * 1000 * 1000, // 100 billion
|
|
19
|
+
formatter: 'FormatInt',
|
|
18
20
|
};
|
|
19
21
|
|
|
20
22
|
constructor(config = {}, entity) {
|
package/src/Schema/Schema.js
CHANGED
|
@@ -89,6 +89,12 @@ export default class Schema extends EventEmitter {
|
|
|
89
89
|
*/
|
|
90
90
|
hasChildrenProperty: 'hasChildren',
|
|
91
91
|
|
|
92
|
+
/**
|
|
93
|
+
* @member {string} hasChildrenOfOtherNodeTypesProperty - name of hasChildrenOfOtherNodeTypes Property (e.g. 'categories__has_children_of_other_node_types' for Adjacency Lists, and has_children_of_other_node_types for Closure Tables)
|
|
94
|
+
* For trees only
|
|
95
|
+
*/
|
|
96
|
+
hasChildrenOfOtherNodeTypesProperty: 'hasChildrenOfOtherNodeTypes',
|
|
97
|
+
|
|
92
98
|
/**
|
|
93
99
|
* @member {boolean} isAdjacencyList - Whether this tree is an Adjacency List
|
|
94
100
|
*/
|