@contember/binding 1.1.0-alpha.1 → 1.1.0-alpha.4

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 (200) hide show
  1. package/dist/development/accessorPropagation/useEntityListSubTree.js +4 -2
  2. package/dist/development/accessorPropagation/useEntityListSubTree.js.map +1 -1
  3. package/dist/development/accessorPropagation/useEntitySubTree.js +4 -2
  4. package/dist/development/accessorPropagation/useEntitySubTree.js.map +1 -1
  5. package/dist/development/accessorPropagation/useExtendTree.js +27 -0
  6. package/dist/development/accessorPropagation/useExtendTree.js.map +1 -0
  7. package/dist/development/accessorTree/AccessorTree.js +9 -4
  8. package/dist/development/accessorTree/AccessorTree.js.map +1 -1
  9. package/dist/development/accessorTree/AccessorTreeStateContext.js +6 -0
  10. package/dist/development/accessorTree/AccessorTreeStateContext.js.map +1 -0
  11. package/dist/development/accessorTree/useAccessorTreeState.js +5 -0
  12. package/dist/development/accessorTree/useAccessorTreeState.js.map +1 -0
  13. package/dist/development/core/DataBinding.js +1 -1
  14. package/dist/development/core/DataBinding.js.map +1 -1
  15. package/dist/development/core/DirtinessTracker.js +4 -13
  16. package/dist/development/core/DirtinessTracker.js.map +1 -1
  17. package/dist/development/core/EventManager.js +12 -7
  18. package/dist/development/core/EventManager.js.map +1 -1
  19. package/dist/development/core/MutationGenerator.js +95 -89
  20. package/dist/development/core/MutationGenerator.js.map +1 -1
  21. package/dist/development/core/StateInitializer.js +15 -18
  22. package/dist/development/core/StateInitializer.js.map +1 -1
  23. package/dist/development/core/TreeStore.js +2 -2
  24. package/dist/development/core/TreeStore.js.map +1 -1
  25. package/dist/development/core/operations/EntityOperations.js +8 -7
  26. package/dist/development/core/operations/EntityOperations.js.map +1 -1
  27. package/dist/development/core/operations/ListOperations.js +1 -1
  28. package/dist/development/core/operations/ListOperations.js.map +1 -1
  29. package/dist/development/core/schema/SchemaPreprocessor.js +1 -1
  30. package/dist/development/core/schema/SchemaPreprocessor.js.map +1 -1
  31. package/dist/development/coreComponents/Entity.js +1 -1
  32. package/dist/development/coreComponents/Entity.js.map +1 -1
  33. package/dist/development/coreComponents/EntityList.js +1 -1
  34. package/dist/development/coreComponents/EntityList.js.map +1 -1
  35. package/dist/development/dao/Environment.js +11 -1
  36. package/dist/development/dao/Environment.js.map +1 -1
  37. package/dist/development/dao/TreeNodeEnvironmentFactory.js +2 -2
  38. package/dist/development/dao/TreeNodeEnvironmentFactory.js.map +1 -1
  39. package/dist/development/helperComponents/DeferredSubTrees.js +16 -8
  40. package/dist/development/helperComponents/DeferredSubTrees.js.map +1 -1
  41. package/dist/development/helperComponents/If.js +39 -0
  42. package/dist/development/helperComponents/If.js.map +1 -0
  43. package/dist/development/helperComponents/SugaredField.js +1 -1
  44. package/dist/development/helperComponents/helpers/FilterEvaluator.js +38 -0
  45. package/dist/development/helperComponents/helpers/FilterEvaluator.js.map +1 -0
  46. package/dist/development/helperComponents/helpers/FilterFieldsCollector.js +41 -0
  47. package/dist/development/helperComponents/helpers/FilterFieldsCollector.js.map +1 -0
  48. package/dist/development/helperComponents/helpers/evaluateCondition.js +46 -0
  49. package/dist/development/helperComponents/helpers/evaluateCondition.js.map +1 -0
  50. package/dist/development/index.js +3 -0
  51. package/dist/development/index.js.map +1 -1
  52. package/dist/development/markers/EntityListSubTreeMarker.js +1 -1
  53. package/dist/development/markers/EntityListSubTreeMarker.js.map +1 -1
  54. package/dist/development/markers/EntitySubTreeMarker.js +1 -1
  55. package/dist/development/markers/EntitySubTreeMarker.js.map +1 -1
  56. package/dist/development/markers/PlaceholderGenerator.js +4 -4
  57. package/dist/development/markers/PlaceholderGenerator.js.map +1 -1
  58. package/dist/development/utils/Hashing.js +21 -6
  59. package/dist/development/utils/Hashing.js.map +1 -1
  60. package/dist/production/accessorPropagation/useEntityListSubTree.js +4 -2
  61. package/dist/production/accessorPropagation/useEntityListSubTree.js.map +1 -1
  62. package/dist/production/accessorPropagation/useEntitySubTree.js +4 -2
  63. package/dist/production/accessorPropagation/useEntitySubTree.js.map +1 -1
  64. package/dist/production/accessorPropagation/useExtendTree.js +27 -0
  65. package/dist/production/accessorPropagation/useExtendTree.js.map +1 -0
  66. package/dist/production/accessorTree/AccessorTree.js +9 -4
  67. package/dist/production/accessorTree/AccessorTree.js.map +1 -1
  68. package/dist/production/accessorTree/AccessorTreeStateContext.js +6 -0
  69. package/dist/production/accessorTree/AccessorTreeStateContext.js.map +1 -0
  70. package/dist/production/accessorTree/useAccessorTreeState.js +5 -0
  71. package/dist/production/accessorTree/useAccessorTreeState.js.map +1 -0
  72. package/dist/production/core/DataBinding.js +1 -1
  73. package/dist/production/core/DataBinding.js.map +1 -1
  74. package/dist/production/core/DirtinessTracker.js +4 -13
  75. package/dist/production/core/DirtinessTracker.js.map +1 -1
  76. package/dist/production/core/EventManager.js +11 -6
  77. package/dist/production/core/EventManager.js.map +1 -1
  78. package/dist/production/core/MutationGenerator.js +95 -89
  79. package/dist/production/core/MutationGenerator.js.map +1 -1
  80. package/dist/production/core/StateInitializer.js +15 -18
  81. package/dist/production/core/StateInitializer.js.map +1 -1
  82. package/dist/production/core/TreeStore.js +2 -2
  83. package/dist/production/core/TreeStore.js.map +1 -1
  84. package/dist/production/core/operations/EntityOperations.js +8 -7
  85. package/dist/production/core/operations/EntityOperations.js.map +1 -1
  86. package/dist/production/core/operations/ListOperations.js +1 -1
  87. package/dist/production/core/operations/ListOperations.js.map +1 -1
  88. package/dist/production/core/schema/SchemaPreprocessor.js +1 -1
  89. package/dist/production/core/schema/SchemaPreprocessor.js.map +1 -1
  90. package/dist/production/coreComponents/Entity.js +1 -1
  91. package/dist/production/coreComponents/Entity.js.map +1 -1
  92. package/dist/production/coreComponents/EntityList.js +1 -1
  93. package/dist/production/coreComponents/EntityList.js.map +1 -1
  94. package/dist/production/dao/Environment.js +11 -1
  95. package/dist/production/dao/Environment.js.map +1 -1
  96. package/dist/production/dao/TreeNodeEnvironmentFactory.js +2 -2
  97. package/dist/production/dao/TreeNodeEnvironmentFactory.js.map +1 -1
  98. package/dist/production/helperComponents/DeferredSubTrees.js +16 -8
  99. package/dist/production/helperComponents/DeferredSubTrees.js.map +1 -1
  100. package/dist/production/helperComponents/If.js +39 -0
  101. package/dist/production/helperComponents/If.js.map +1 -0
  102. package/dist/production/helperComponents/SugaredField.js +1 -1
  103. package/dist/production/helperComponents/helpers/FilterEvaluator.js +38 -0
  104. package/dist/production/helperComponents/helpers/FilterEvaluator.js.map +1 -0
  105. package/dist/production/helperComponents/helpers/FilterFieldsCollector.js +41 -0
  106. package/dist/production/helperComponents/helpers/FilterFieldsCollector.js.map +1 -0
  107. package/dist/production/helperComponents/helpers/evaluateCondition.js +46 -0
  108. package/dist/production/helperComponents/helpers/evaluateCondition.js.map +1 -0
  109. package/dist/production/index.js +3 -0
  110. package/dist/production/index.js.map +1 -1
  111. package/dist/production/markers/EntityListSubTreeMarker.js +1 -1
  112. package/dist/production/markers/EntityListSubTreeMarker.js.map +1 -1
  113. package/dist/production/markers/EntitySubTreeMarker.js +1 -1
  114. package/dist/production/markers/EntitySubTreeMarker.js.map +1 -1
  115. package/dist/production/markers/PlaceholderGenerator.js +4 -4
  116. package/dist/production/markers/PlaceholderGenerator.js.map +1 -1
  117. package/dist/production/utils/Hashing.js +21 -6
  118. package/dist/production/utils/Hashing.js.map +1 -1
  119. package/dist/types/accessorPropagation/index.d.ts +1 -0
  120. package/dist/types/accessorPropagation/index.d.ts.map +1 -1
  121. package/dist/types/accessorPropagation/useEntityListSubTree.d.ts +2 -1
  122. package/dist/types/accessorPropagation/useEntityListSubTree.d.ts.map +1 -1
  123. package/dist/types/accessorPropagation/useEntitySubTree.d.ts +2 -1
  124. package/dist/types/accessorPropagation/useEntitySubTree.d.ts.map +1 -1
  125. package/dist/types/accessorPropagation/useExtendTree.d.ts +5 -0
  126. package/dist/types/accessorPropagation/useExtendTree.d.ts.map +1 -0
  127. package/dist/types/accessorTree/AccessorTree.d.ts.map +1 -1
  128. package/dist/types/accessorTree/AccessorTreeStateContext.d.ts +4 -0
  129. package/dist/types/accessorTree/AccessorTreeStateContext.d.ts.map +1 -0
  130. package/dist/types/accessorTree/index.d.ts +1 -0
  131. package/dist/types/accessorTree/index.d.ts.map +1 -1
  132. package/dist/types/accessorTree/useAccessorTreeState.d.ts +2 -0
  133. package/dist/types/accessorTree/useAccessorTreeState.d.ts.map +1 -0
  134. package/dist/types/core/DataBinding.d.ts.map +1 -1
  135. package/dist/types/core/DirtinessTracker.d.ts +2 -5
  136. package/dist/types/core/DirtinessTracker.d.ts.map +1 -1
  137. package/dist/types/core/EventManager.d.ts +1 -1
  138. package/dist/types/core/EventManager.d.ts.map +1 -1
  139. package/dist/types/core/MutationGenerator.d.ts.map +1 -1
  140. package/dist/types/core/StateInitializer.d.ts +1 -5
  141. package/dist/types/core/StateInitializer.d.ts.map +1 -1
  142. package/dist/types/core/TreeStore.d.ts.map +1 -1
  143. package/dist/types/core/operations/EntityOperations.d.ts.map +1 -1
  144. package/dist/types/core/operations/ListOperations.d.ts.map +1 -1
  145. package/dist/types/core/schema/RawSchemaEntity.d.ts +3 -2
  146. package/dist/types/core/schema/RawSchemaEntity.d.ts.map +1 -1
  147. package/dist/types/core/schema/SchemaEntity.d.ts +1 -1
  148. package/dist/types/core/schema/SchemaEntity.d.ts.map +1 -1
  149. package/dist/types/dao/Environment.d.ts +2 -0
  150. package/dist/types/dao/Environment.d.ts.map +1 -1
  151. package/dist/types/helperComponents/DeferredSubTrees.d.ts.map +1 -1
  152. package/dist/types/helperComponents/If.d.ts +14 -0
  153. package/dist/types/helperComponents/If.d.ts.map +1 -0
  154. package/dist/types/helperComponents/helpers/FilterEvaluator.d.ts +9 -0
  155. package/dist/types/helperComponents/helpers/FilterEvaluator.d.ts.map +1 -0
  156. package/dist/types/helperComponents/helpers/FilterFieldsCollector.d.ts +10 -0
  157. package/dist/types/helperComponents/helpers/FilterFieldsCollector.d.ts.map +1 -0
  158. package/dist/types/helperComponents/helpers/evaluateCondition.d.ts +4 -0
  159. package/dist/types/helperComponents/helpers/evaluateCondition.d.ts.map +1 -0
  160. package/dist/types/helperComponents/index.d.ts +1 -0
  161. package/dist/types/helperComponents/index.d.ts.map +1 -1
  162. package/dist/types/markers/PlaceholderGenerator.d.ts +3 -2
  163. package/dist/types/markers/PlaceholderGenerator.d.ts.map +1 -1
  164. package/dist/types/tsconfig.tsbuildinfo +1 -1
  165. package/dist/types/utils/Hashing.d.ts +3 -2
  166. package/dist/types/utils/Hashing.d.ts.map +1 -1
  167. package/package.json +7 -5
  168. package/src/accessorPropagation/index.ts +1 -0
  169. package/src/accessorPropagation/useEntityListSubTree.ts +8 -1
  170. package/src/accessorPropagation/useEntitySubTree.ts +8 -1
  171. package/src/accessorPropagation/useExtendTree.ts +30 -0
  172. package/src/accessorTree/AccessorTree.tsx +18 -12
  173. package/src/accessorTree/AccessorTreeStateContext.ts +6 -0
  174. package/src/accessorTree/index.ts +1 -0
  175. package/src/accessorTree/useAccessorTreeState.ts +4 -0
  176. package/src/core/DataBinding.ts +0 -1
  177. package/src/core/DirtinessTracker.ts +4 -16
  178. package/src/core/EventManager.ts +14 -8
  179. package/src/core/MutationGenerator.ts +132 -125
  180. package/src/core/StateInitializer.ts +22 -29
  181. package/src/core/TreeStore.ts +2 -0
  182. package/src/core/operations/EntityOperations.ts +8 -9
  183. package/src/core/operations/ListOperations.ts +2 -1
  184. package/src/core/schema/RawSchemaEntity.ts +1 -2
  185. package/src/core/schema/SchemaEntity.ts +1 -1
  186. package/src/core/schema/SchemaPreprocessor.ts +1 -1
  187. package/src/coreComponents/Entity.tsx +1 -1
  188. package/src/coreComponents/EntityList.tsx +1 -1
  189. package/src/dao/Environment.ts +12 -1
  190. package/src/dao/TreeNodeEnvironmentFactory.ts +2 -2
  191. package/src/helperComponents/DeferredSubTrees.tsx +19 -13
  192. package/src/helperComponents/If.tsx +71 -0
  193. package/src/helperComponents/helpers/FilterEvaluator.ts +48 -0
  194. package/src/helperComponents/helpers/FilterFieldsCollector.ts +49 -0
  195. package/src/helperComponents/helpers/evaluateCondition.ts +52 -0
  196. package/src/helperComponents/index.ts +1 -0
  197. package/src/markers/EntityListSubTreeMarker.ts +1 -1
  198. package/src/markers/EntitySubTreeMarker.ts +1 -1
  199. package/src/markers/PlaceholderGenerator.ts +5 -2
  200. package/src/utils/Hashing.ts +23 -8
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNodeEnvironmentFactory.js","sources":["../../../src/dao/TreeNodeEnvironmentFactory.ts"],"sourcesContent":["import { Environment } from './Environment'\nimport {\n\tHasOneRelation,\n\tSugaredQualifiedEntityList,\n\tSugaredQualifiedSingleEntity,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleEntity,\n\tSugaredRelativeSingleField,\n\tSugaredUnconstrainedQualifiedEntityList,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n} from '../treeParameters'\nimport { QueryLanguage } from '../queryLanguage'\nimport { BindingError } from '../BindingError'\nimport { NIL_UUID } from '../bindingTypes'\nimport { whereToFilter } from '@contember/client'\nimport { BaseRelation, Schema, SchemaColumn, SchemaEntity, SchemaField, SchemaRelation } from '../core/schema'\nimport levenshtein from 'js-levenshtein'\n\nexport class TreeNodeEnvironmentFactory {\n\n\tpublic static createEnvironmentForEntityListSubtree(\n\t\tenvironment: Environment,\n\t\tsugaredEntityList: SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList,\n\t): Environment {\n\t\tlet entityList\n\t\tlet rootWhere\n\t\tlet expectedCardinality: Environment.SubTreeNode['expectedCardinality']\n\n\t\tif (sugaredEntityList.isCreating) {\n\t\t\tentityList = QueryLanguage.desugarUnconstrainedQualifiedEntityList(sugaredEntityList, environment)\n\t\t\trootWhere = { id: { eq: NIL_UUID } } as const\n\t\t\texpectedCardinality = 'zero'\n\n\t\t} else {\n\t\t\tentityList = QueryLanguage.desugarQualifiedEntityList(sugaredEntityList, environment)\n\t\t\trootWhere = entityList.filter ?? {}\n\t\t\texpectedCardinality = 'zero-to-many'\n\t\t}\n\n\t\tconst entitySchema = this.resolveEntity(environment.getSchema(), entityList.entityName, 'entity list')\n\n\t\treturn environment.withSubTree({\n\t\t\ttype: 'subtree-entity-list',\n\t\t\tentity: entitySchema,\n\t\t\texpectedCardinality,\n\t\t\tfilter: rootWhere,\n\t\t})\n\t}\n\n\tpublic static createEnvironmentForEntitySubtree(\n\t\tenvironment: Environment,\n\t\tsugaredEntityList: SugaredQualifiedSingleEntity | SugaredUnconstrainedQualifiedSingleEntity,\n\t): Environment {\n\t\tlet entity\n\t\tlet rootWhere\n\t\tlet expectedCardinality: Environment.SubTreeNode['expectedCardinality']\n\n\t\tif (sugaredEntityList.isCreating) {\n\t\t\trootWhere = { id: { eq: NIL_UUID } } as const\n\t\t\texpectedCardinality = 'zero'\n\t\t\tentity = QueryLanguage.desugarUnconstrainedQualifiedSingleEntity(sugaredEntityList, environment)\n\n\t\t} else {\n\t\t\tentity = QueryLanguage.desugarQualifiedSingleEntity(sugaredEntityList, environment, { missingSetOnCreate: 'fill' })\n\t\t\trootWhere = whereToFilter(entity.where)\n\t\t\texpectedCardinality = entity.setOnCreate ? 'zero-or-one' : 'one'\n\t\t}\n\n\t\tconst entitySchema = this.resolveEntity(environment.getSchema(), entity.entityName, 'entity')\n\n\t\treturn environment.withSubTree({\n\t\t\ttype: 'subtree-entity',\n\t\t\tentity: entitySchema,\n\t\t\texpectedCardinality: expectedCardinality,\n\t\t\tfilter: rootWhere,\n\t\t})\n\t}\n\n\tpublic static createEnvironmentForEntityList(\n\t\tenvironment: Environment,\n\t\tsugaredRelativeEntityList: SugaredRelativeEntityList,\n\t): Environment {\n\t\tconst relativeEntityList = QueryLanguage.desugarRelativeEntityList(sugaredRelativeEntityList, environment)\n\t\tconst hasOneEnvironment = this.traverseHasOnePath(environment, relativeEntityList.hasOneRelationPath)\n\t\tconst hasManyField = relativeEntityList.hasManyRelation.field\n\n\t\tconst field = this.assertHasManyRelation(hasOneEnvironment, hasManyField)\n\n\t\tconst targetEntity = environment.getSchema().getEntity(field.targetEntity)\n\t\tif (!targetEntity) {\n\t\t\tthrow new BindingError('should not happen')\n\t\t}\n\t\treturn hasOneEnvironment.withSubTreeChild({\n\t\t\ttype: 'entity-list',\n\t\t\tfield,\n\t\t\tentity: targetEntity,\n\t\t})\n\t}\n\n\tpublic static createEnvironmentForEntity(\n\t\tenvironment: Environment,\n\t\tsugaredRelativeSingleEntity: SugaredRelativeSingleEntity,\n\t) {\n\t\tconst relativeSingleEntity = QueryLanguage.desugarRelativeSingleEntity(sugaredRelativeSingleEntity, environment)\n\n\t\treturn this.traverseHasOnePath(environment, relativeSingleEntity.hasOneRelationPath)\n\t}\n\n\tpublic static createEnvironmentForField(\n\t\tenvironment: Environment,\n\t\tsugaredRelativeSingleField: SugaredRelativeSingleField,\n\t) {\n\t\tconst relativeSingleField = QueryLanguage.desugarRelativeSingleField(sugaredRelativeSingleField, environment)\n\t\tconst hasOneEnvironment = this.traverseHasOnePath(environment, relativeSingleField.hasOneRelationPath)\n\n\t\tconst field = this.resolveColumn(hasOneEnvironment, relativeSingleField.field)\n\n\t\treturn hasOneEnvironment.withSubTreeChild({\n\t\t\ttype: 'column',\n\t\t\tentity: environment.getSubTreeNode().entity,\n\t\t\tfield,\n\t\t})\n\t}\n\n\tprivate static traverseHasOnePath(\n\t\tenvironment: Environment,\n\t\thasOneRelationPath: HasOneRelation[],\n\t): Environment {\n\t\tfor (const pathItem of hasOneRelationPath) {\n\t\t\tconst field = this.resolveHasOneRelation(environment, pathItem.field, !!pathItem.reducedBy)\n\t\t\tconst targetEntity = environment.getSchema().getEntity(field.targetEntity)\n\t\t\tif (!targetEntity) {\n\t\t\t\tthrow new BindingError('should not happen')\n\t\t\t}\n\t\t\tenvironment = environment.withSubTreeChild({\n\t\t\t\ttype: 'entity',\n\t\t\t\tfield,\n\t\t\t\tentity: targetEntity,\n\t\t\t})\n\t\t}\n\t\treturn environment\n\t}\n\n\tprivate static resolveHasOneRelation(environment: Environment, field: string, isReduced: boolean): SchemaRelation {\n\t\tif (isReduced) {\n\t\t\treturn this.resolveRelation(environment, field, 'reduced has-one relation', ['ManyHasMany', 'OneHasMany'])\n\t\t}\n\t\treturn this.resolveRelation(environment, field, 'a has-one relation', ['ManyHasOne', 'OneHasOne'])\n\t}\n\n\tprivate static assertHasManyRelation(environment: Environment, field: string): SchemaRelation {\n\t\treturn this.resolveRelation(environment, field, 'a has-many relation', ['ManyHasMany', 'OneHasMany'])\n\t}\n\n\n\tprivate static resolveRelation(environment: Environment, field: string, relationDescription: string, expectedRelationType: BaseRelation['type'][]): SchemaRelation {\n\t\treturn this.resolveField(environment, field, (field): field is SchemaRelation => {\n\t\t\treturn field.__typename === '_Relation' && expectedRelationType.includes(field.type)\n\t\t}, relationDescription)\n\t}\n\n\tprivate static resolveEntity(schema: Schema, entityName: string, type: 'entity' | 'entity list'): SchemaEntity {\n\t\tconst entity = schema.getEntity(entityName)\n\t\tif (!entity) {\n\t\t\tconst alternative = this.recommendAlternative(entityName, schema.store.entities.keys())\n\t\t\tconst didYouMean = alternative ? `Did you mean '${alternative}'?` : ''\n\t\t\tthrow new BindingError(`Invalid ${type} sub tree: Entity '${entityName}' doesn't exist. ${didYouMean}`)\n\t\t}\n\t\treturn entity\n\t}\n\n\tprivate static resolveColumn(environment: Environment, fieldName: string): SchemaColumn {\n\t\treturn this.resolveField(environment, fieldName, (field): field is SchemaColumn => field.__typename === '_Column', 'an ordinary field')\n\t\t// TODO check that defaultValue matches the type\n\t\t// TODO run custom validators\n\t}\n\n\tprivate static resolveField<T extends SchemaField>(environment: Environment, fieldName: string, matcher: (field: SchemaField) => field is T, expectedDescription: string): T {\n\t\tconst treeLocation = environment.getSubTreeNode()\n\t\tconst entity = treeLocation.entity\n\t\tconst field = entity.fields.get(fieldName)\n\t\tif (!field) {\n\t\t\tconst alternative = this.recommendAlternative(\n\t\t\t\tfieldName,\n\t\t\t\tArray.from(entity.fields)\n\t\t\t\t\t.filter(([, field]) => matcher(field))\n\t\t\t\t\t.map(([fieldName]) => fieldName),\n\t\t\t)\n\t\t\tconst didYouMean = alternative ? `Did you mean '${alternative}'?` : ''\n\t\t\tthrow new BindingError(`Field '${fieldName}' doesn't exist on ${this.describeLocation(environment)}. ${didYouMean}`)\n\t\t}\n\t\tif (!matcher(field)) {\n\t\t\tconst actual = field.__typename === '_Column' ? 'an ordinary field' : `a ${field.type} relation`\n\t\t\tthrow new BindingError(\n\t\t\t\t`Invalid field: the name '${field.name}' on ${this.describeLocation(environment)} ` +\n\t\t\t\t`refers to ${actual} but is being used as a ${expectedDescription}.`,\n\t\t\t)\n\t\t}\n\t\treturn field\n\t}\n\n\tprivate static describeLocation(environment: Environment): string {\n\t\tconst path = []\n\t\tfor (let env = environment;; env = env.getParent()) {\n\t\t\tconst node = env.getSubTreeNode()\n\t\t\tif (node.type === 'subtree-entity' || node.type === 'subtree-entity-list') {\n\t\t\t\tconst pathText = path.length ? ` in path ${path.join('.')}` : ''\n\t\t\t\treturn `entity '${node.entity.name}'${pathText}`\n\t\t\t}\n\t\t\tpath.push(node.field.name)\n\t\t}\n\t}\n\n\tpublic static recommendAlternative(original: string, possibleAlternatives: Iterable<string>): string | undefined {\n\t\tlet bestAlternative: string | undefined = undefined\n\t\tlet bestAlternativeDistance = Number.MAX_SAFE_INTEGER\n\n\t\tfor (const alternative of possibleAlternatives) {\n\t\t\tconst distance = levenshtein(original, alternative)\n\n\t\t\tif (distance < bestAlternativeDistance) {\n\t\t\t\tbestAlternative = alternative\n\t\t\t\tbestAlternativeDistance = distance\n\t\t\t}\n\t\t}\n\t\treturn bestAlternative\n\t}\n}\n"],"names":[],"mappings":";;;;;AAkBO,MAAM,2BAA2B;AAAA,SAEzB,sCACb,aACA,mBACc;AACV,QAAA;AACA,QAAA;AACA,QAAA;AAEJ,QAAI,kBAAkB,YAAY;AACpB,mBAAA,cAAc,wCAAwC,mBAAmB,WAAW;AACjG,kBAAY,EAAE,IAAI,EAAE,IAAI,SAAW,EAAA;AACb,4BAAA;AAAA,IAAA,OAEhB;A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iB,aAAkC;AACjE,UAAM,OAAO,CAAA;AACb,aAAS,MAAM,eAAc,MAAM,IAAI,aAAa;AAC7C,YAAA,OAAO,IAAI;AACjB,UAAI,KAAK,SAAS,oBAAoB,KAAK,SAAS,uBAAuB;AAC1E,cAAM,WAAW,KAAK,SAAS,YAAY,KAAK,KAAK,GAAG,MAAM;AACvD,eAAA,WAAW,KAAK,OAAO,QAAQ;AAAA,MACvC;AACK,WAAA,KAAK,KAAK,MAAM,IAAI;AAAA,IAC1B;AAAA,EACD;AAAA,SAEc,qBAAqB,UAAkB,sBAA4D;AAChH,QAAI,kBAAsC;AAC1C,QAAI,0BAA0B,OAAO;AAErC,eAAW,eAAe,sBAAsB;AACzC,YAAA,WAAW,YAAY,UAAU,WAAW;AAElD,UAAI,WAAW,yBAAyB;AACrB,0BAAA;AACQ,kCAAA;AAAA,MAC3B;AAAA,IACD;AACO,WAAA;AAAA,EACR;AACD;;"}
1
+ {"version":3,"file":"TreeNodeEnvironmentFactory.js","sources":["../../../src/dao/TreeNodeEnvironmentFactory.ts"],"sourcesContent":["import { Environment } from './Environment'\nimport {\n\tHasOneRelation,\n\tSugaredQualifiedEntityList,\n\tSugaredQualifiedSingleEntity,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleEntity,\n\tSugaredRelativeSingleField,\n\tSugaredUnconstrainedQualifiedEntityList,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n} from '../treeParameters'\nimport { QueryLanguage } from '../queryLanguage'\nimport { BindingError } from '../BindingError'\nimport { NIL_UUID } from '../bindingTypes'\nimport { whereToFilter } from '@contember/client'\nimport { BaseRelation, Schema, SchemaColumn, SchemaEntity, SchemaField, SchemaRelation } from '../core/schema'\nimport levenshtein from 'js-levenshtein'\n\nexport class TreeNodeEnvironmentFactory {\n\n\tpublic static createEnvironmentForEntityListSubtree(\n\t\tenvironment: Environment,\n\t\tsugaredEntityList: SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList,\n\t): Environment {\n\t\tlet entityList\n\t\tlet rootWhere\n\t\tlet expectedCardinality: Environment.SubTreeNode['expectedCardinality']\n\n\t\tif (sugaredEntityList.isCreating) {\n\t\t\tentityList = QueryLanguage.desugarUnconstrainedQualifiedEntityList(sugaredEntityList, environment)\n\t\t\trootWhere = { id: { eq: NIL_UUID } } as const\n\t\t\texpectedCardinality = 'zero'\n\n\t\t} else {\n\t\t\tentityList = QueryLanguage.desugarQualifiedEntityList(sugaredEntityList, environment)\n\t\t\trootWhere = entityList.filter ?? {}\n\t\t\texpectedCardinality = 'zero-to-many'\n\t\t}\n\n\t\tconst entitySchema = this.resolveEntity(environment.getSchema(), entityList.entityName, 'entity list')\n\n\t\treturn environment.withSubTree({\n\t\t\ttype: 'subtree-entity-list',\n\t\t\tentity: entitySchema,\n\t\t\texpectedCardinality,\n\t\t\tfilter: rootWhere,\n\t\t})\n\t}\n\n\tpublic static createEnvironmentForEntitySubtree(\n\t\tenvironment: Environment,\n\t\tsugaredEntityList: SugaredQualifiedSingleEntity | SugaredUnconstrainedQualifiedSingleEntity,\n\t): Environment {\n\t\tlet entity\n\t\tlet rootWhere\n\t\tlet expectedCardinality: Environment.SubTreeNode['expectedCardinality']\n\n\t\tif (sugaredEntityList.isCreating) {\n\t\t\trootWhere = { id: { eq: NIL_UUID } } as const\n\t\t\texpectedCardinality = 'zero'\n\t\t\tentity = QueryLanguage.desugarUnconstrainedQualifiedSingleEntity(sugaredEntityList, environment)\n\n\t\t} else {\n\t\t\tentity = QueryLanguage.desugarQualifiedSingleEntity(sugaredEntityList, environment, { missingSetOnCreate: 'fill' })\n\t\t\trootWhere = whereToFilter(entity.where)\n\t\t\texpectedCardinality = entity.setOnCreate ? 'zero-or-one' : 'one'\n\t\t}\n\n\t\tconst entitySchema = this.resolveEntity(environment.getSchema(), entity.entityName, 'entity')\n\n\t\treturn environment.withSubTree({\n\t\t\ttype: 'subtree-entity',\n\t\t\tentity: entitySchema,\n\t\t\texpectedCardinality: expectedCardinality,\n\t\t\tfilter: rootWhere,\n\t\t})\n\t}\n\n\tpublic static createEnvironmentForEntityList(\n\t\tenvironment: Environment,\n\t\tsugaredRelativeEntityList: SugaredRelativeEntityList,\n\t): Environment {\n\t\tconst relativeEntityList = QueryLanguage.desugarRelativeEntityList(sugaredRelativeEntityList, environment)\n\t\tconst hasOneEnvironment = this.traverseHasOnePath(environment, relativeEntityList.hasOneRelationPath)\n\t\tconst hasManyField = relativeEntityList.hasManyRelation.field\n\n\t\tconst field = this.assertHasManyRelation(hasOneEnvironment, hasManyField)\n\n\t\tconst targetEntity = environment.getSchema().getEntity(field.targetEntity)\n\t\tif (!targetEntity) {\n\t\t\tthrow new BindingError('should not happen')\n\t\t}\n\t\treturn hasOneEnvironment.withSubTreeChild({\n\t\t\ttype: 'entity-list',\n\t\t\tfield,\n\t\t\tentity: targetEntity,\n\t\t})\n\t}\n\n\tpublic static createEnvironmentForEntity(\n\t\tenvironment: Environment,\n\t\tsugaredRelativeSingleEntity: SugaredRelativeSingleEntity,\n\t) {\n\t\tconst relativeSingleEntity = QueryLanguage.desugarRelativeSingleEntity(sugaredRelativeSingleEntity, environment)\n\n\t\treturn this.traverseHasOnePath(environment, relativeSingleEntity.hasOneRelationPath)\n\t}\n\n\tpublic static createEnvironmentForField(\n\t\tenvironment: Environment,\n\t\tsugaredRelativeSingleField: SugaredRelativeSingleField,\n\t) {\n\t\tconst relativeSingleField = QueryLanguage.desugarRelativeSingleField(sugaredRelativeSingleField, environment)\n\t\tconst hasOneEnvironment = this.traverseHasOnePath(environment, relativeSingleField.hasOneRelationPath)\n\n\t\tconst field = this.resolveColumn(hasOneEnvironment, relativeSingleField.field)\n\n\t\treturn hasOneEnvironment.withSubTreeChild({\n\t\t\ttype: 'column',\n\t\t\tentity: environment.getSubTreeNode().entity,\n\t\t\tfield,\n\t\t})\n\t}\n\n\tprivate static traverseHasOnePath(\n\t\tenvironment: Environment,\n\t\thasOneRelationPath: HasOneRelation[],\n\t): Environment {\n\t\tfor (const pathItem of hasOneRelationPath) {\n\t\t\tconst field = this.resolveHasOneRelation(environment, pathItem.field, !!pathItem.reducedBy)\n\t\t\tconst targetEntity = environment.getSchema().getEntity(field.targetEntity)\n\t\t\tif (!targetEntity) {\n\t\t\t\tthrow new BindingError('should not happen')\n\t\t\t}\n\t\t\tenvironment = environment.withSubTreeChild({\n\t\t\t\ttype: 'entity',\n\t\t\t\tfield,\n\t\t\t\tentity: targetEntity,\n\t\t\t})\n\t\t}\n\t\treturn environment\n\t}\n\n\tprivate static resolveHasOneRelation(environment: Environment, field: string, isReduced: boolean): SchemaRelation {\n\t\tif (isReduced) {\n\t\t\treturn this.resolveRelation(environment, field, 'reduced has-one relation', ['ManyHasMany', 'OneHasMany'])\n\t\t}\n\t\treturn this.resolveRelation(environment, field, 'a has-one relation', ['ManyHasOne', 'OneHasOne'])\n\t}\n\n\tprivate static assertHasManyRelation(environment: Environment, field: string): SchemaRelation {\n\t\treturn this.resolveRelation(environment, field, 'a has-many relation', ['ManyHasMany', 'OneHasMany'])\n\t}\n\n\n\tprivate static resolveRelation(environment: Environment, field: string, relationDescription: string, expectedRelationType: BaseRelation['type'][]): SchemaRelation {\n\t\treturn this.resolveField(environment, field, (field): field is SchemaRelation => {\n\t\t\treturn field.__typename === '_Relation' && expectedRelationType.includes(field.type)\n\t\t}, relationDescription)\n\t}\n\n\tprivate static resolveEntity(schema: Schema, entityName: string, type: 'entity' | 'entity list'): SchemaEntity {\n\t\tconst entity = schema.getEntity(entityName)\n\t\tif (!entity) {\n\t\t\tconst alternative = this.recommendAlternative(entityName, schema.store.entities.keys())\n\t\t\tconst didYouMean = alternative ? `Did you mean '${alternative}'?` : ''\n\t\t\tthrow new BindingError(`Invalid ${type} sub tree: Entity '${entityName}' doesn't exist. ${didYouMean}`)\n\t\t}\n\t\treturn entity\n\t}\n\n\tprivate static resolveColumn(environment: Environment, fieldName: string): SchemaColumn {\n\t\treturn this.resolveField(environment, fieldName, (field): field is SchemaColumn => field.__typename === '_Column', 'an ordinary field')\n\t\t// TODO check that defaultValue matches the type\n\t\t// TODO run custom validators\n\t}\n\n\tprivate static resolveField<T extends SchemaField>(environment: Environment, fieldName: string, matcher: (field: SchemaField) => field is T, expectedDescription: string): T {\n\t\tconst treeLocation = environment.getSubTreeNode()\n\t\tconst entity = treeLocation.entity\n\t\tconst field = entity.fields.get(fieldName)\n\t\tif (!field) {\n\t\t\tconst alternative = this.recommendAlternative(\n\t\t\t\tfieldName,\n\t\t\t\tArray.from(entity.fields)\n\t\t\t\t\t.filter(([, field]) => matcher(field))\n\t\t\t\t\t.map(([fieldName]) => fieldName),\n\t\t\t)\n\t\t\tconst didYouMean = alternative ? `Did you mean '${alternative}'?` : ''\n\t\t\tthrow new BindingError(`Field '${fieldName}' doesn't exist on ${this.describeLocation(environment)}. ${didYouMean}`)\n\t\t}\n\t\tif (!matcher(field)) {\n\t\t\tconst actual = field.__typename === '_Column' ? 'an ordinary field' : `a ${field.type} relation`\n\t\t\tthrow new BindingError(\n\t\t\t\t`Invalid field: the name '${field.name}' on ${this.describeLocation(environment)} ` +\n\t\t\t\t`refers to ${actual} but is being used as a ${expectedDescription}.`,\n\t\t\t)\n\t\t}\n\t\treturn field\n\t}\n\n\tprivate static describeLocation(environment: Environment): string {\n\t\tconst path = []\n\t\tconst loc = environment.getSubTreeNode()\n\t\tfor (let env = environment;; env = env.getParent()) {\n\t\t\tconst node = env.getSubTreeNode()\n\t\t\tif (node.type === 'subtree-entity' || node.type === 'subtree-entity-list') {\n\t\t\t\treturn `entity '${loc.entity.name}' in path '${[node.entity.name, ...path].join('.')}'`\n\t\t\t}\n\t\t\tpath.push(node.field.name)\n\t\t}\n\t}\n\n\tpublic static recommendAlternative(original: string, possibleAlternatives: Iterable<string>): string | undefined {\n\t\tlet bestAlternative: string | undefined = undefined\n\t\tlet bestAlternativeDistance = Number.MAX_SAFE_INTEGER\n\n\t\tfor (const alternative of possibleAlternatives) {\n\t\t\tconst distance = levenshtein(original, alternative)\n\n\t\t\tif (distance < bestAlternativeDistance) {\n\t\t\t\tbestAlternative = alternative\n\t\t\t\tbestAlternativeDistance = distance\n\t\t\t}\n\t\t}\n\t\treturn bestAlternative\n\t}\n}\n"],"names":[],"mappings":";;;;;AAkBO,MAAM,2BAA2B;AAAA,SAEzB,sCACb,aACA,mBACc;AACV,QAAA;AACA,QAAA;AACA,QAAA;AAEJ,QAAI,kBAAkB,YAAY;AACpB,mBAAA,cAAc,wCAAwC,mBAAmB,WAAW;AACjG,kBAAY,EAAE,IAAI,EAAE,IAAI,SAAW,EAAA;AACb,4BAAA;AAAA,IAAA,OAEhB;AACO,mBAAA,cAAc,2BAA2B,mBAAmB,WAAW;AACxE,kBAAA,WAAW,UAAU;AACX,4BAAA;AAAA,IACvB;AAEM,UAAA,eAAe,KAAK,cAAc,YAAY,aAAa,WAAW,YAAY,aAAa;AAErG,WAAO,YAAY,YAAY;AAAA,MAC9B,MAAM;AAAA,MACN,QAAQ;AAAA,MACR;AAAA,MACA,QAAQ;AAAA,IAAA,CACR;AAAA,EACF;AAAA,SAEc,kCACb,aACA,mBACc;AACV,QAAA;AACA,QAAA;AACA,QAAA;AAEJ,QAAI,kBAAkB,YAAY;AACjC,kBAAY,EAAE,IAAI,EAAE,IAAI,SAAW,EAAA;AACb,4BAAA;AACb,eAAA,cAAc,0CAA0C,mBAAmB,WAAW;AAAA,IAAA,OAEzF;AACN,eAAS,cAAc,6BAA6B,mBAAmB,aAAa,EAAE,oBAAoB,QAAQ;AACtG,kBAAA,cAAc,OAAO,KAAK;AAChB,4BAAA,OAAO,cAAc,gBAAgB;AAAA,IAC5D;AAEM,UAAA,eAAe,KAAK,cAAc,YAAY,aAAa,OAAO,YAAY,QAAQ;AAE5F,WAAO,YAAY,YAAY;AAAA,MAC9B,MAAM;AAAA,MACN,QAAQ;AAAA,MACR;AAAA,MACA,QAAQ;AAAA,IAAA,CACR;AAAA,EACF;AAAA,SAEc,+BACb,aACA,2BACc;AACd,UAAM,qBAAqB,cAAc,0BAA0B,2BAA2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,UAAS,CACjC;AACM,YAAA,aAAa,cAAc,iBAAiB,kBAAkB;AAC9D,YAAA,IAAI,aAAa,UAAU,+BAA+B,KAAK,iBAAiB,WAAW,MAAM,YAAY;AAAA,IACpH;AACI,QAAA,CAAC,QAAQ,KAAK,GAAG;AACpB,YAAM,SAAS,MAAM,eAAe,YAAY,sBAAsB,KAAK,MAAM;AAC3E,YAAA,IAAI,aACT,4BAA4B,MAAM,YAAY,KAAK,iBAAiB,WAAW,eAClE,iCAAiC,sBAC/C;AAAA,IACD;AACO,WAAA;AAAA,EACR;AAAA,SAEe,iBAAiB,aAAkC;AACjE,UAAM,OAAO,CAAA;AACP,UAAA,MAAM,YAAY;AACxB,aAAS,MAAM,eAAc,MAAM,IAAI,aAAa;AAC7C,YAAA,OAAO,IAAI;AACjB,UAAI,KAAK,SAAS,oBAAoB,KAAK,SAAS,uBAAuB;AAC1E,eAAO,WAAW,IAAI,OAAO,kBAAkB,CAAC,KAAK,OAAO,MAAM,GAAG,IAAI,EAAE,KAAK,GAAG;AAAA,MACpF;AACK,WAAA,KAAK,KAAK,MAAM,IAAI;AAAA,IAC1B;AAAA,EACD;AAAA,SAEc,qBAAqB,UAAkB,sBAA4D;AAChH,QAAI,kBAAsC;AAC1C,QAAI,0BAA0B,OAAO;AAErC,eAAW,eAAe,sBAAsB;AACzC,YAAA,WAAW,YAAY,UAAU,WAAW;AAElD,UAAI,WAAW,yBAAyB;AACrB,0BAAA;AACQ,kCAAA;AAAA,MAC3B;AAAA,IACD;AACO,WAAA;AAAA,EACR;AACD;;"}
@@ -1,10 +1,13 @@
1
1
  import { createElement, Fragment, useState, useCallback, useEffect } from "react";
2
+ import { useConstantValueInvariant } from "@contember/react-utils";
2
3
  import { Component } from "../coreComponents/Component.js";
3
4
  import { useBindingOperations } from "../accessorPropagation/useBindingOperations.js";
4
5
  import { useMutationState } from "../accessorTree/useMutationState.js";
6
+ import { useHasEntity } from "../accessorPropagation/useHasEntity.js";
5
7
  import { useEntityBeforePersist } from "../entityEvents/useEntityBeforePersist.js";
6
8
  import { TreeRootIdProvider } from "../accessorPropagation/TreeRootIdProvider.js";
7
9
  import { MarkerFactory } from "../queryLanguage/MarkerFactory.js";
10
+ import { useEnvironment } from "../accessorPropagation/useEnvironment.js";
8
11
  import { EntityFieldMarkersContainer } from "../markers/EntityFieldMarkersContainer.js";
9
12
  import { EntityFieldsWithHoistablesMarker } from "../markers/EntityFieldsWithHoistablesMarker.js";
10
13
  const DeferredSubTrees = Component((props) => {
@@ -13,30 +16,35 @@ const DeferredSubTrees = Component((props) => {
13
16
  const [loadState, setLoadState] = useState({ name: "initial" });
14
17
  const [abortController] = useState(() => new AbortController());
15
18
  const signal = abortController.signal;
16
- useEntityBeforePersist(useCallback((getAccessor) => {
17
- if (getAccessor().existsOnServer) {
18
- return;
19
- }
20
- setLoadState({ name: "initial" });
21
- }, []));
19
+ const hasEntity = useHasEntity();
20
+ useConstantValueInvariant(hasEntity);
21
+ if (hasEntity) {
22
+ useEntityBeforePersist(useCallback((getAccessor) => {
23
+ if (getAccessor().existsOnServer) {
24
+ return;
25
+ }
26
+ setLoadState({ name: "initial" });
27
+ }, []));
28
+ }
22
29
  useEffect(() => {
23
30
  return () => {
24
31
  abortController.abort();
25
32
  };
26
33
  }, [abortController]);
34
+ const environment = useEnvironment();
27
35
  useEffect(() => {
28
36
  if (isMutating || loadState.name !== "initial" || signal.aborted) {
29
37
  return;
30
38
  }
31
39
  setLoadState({ name: "loading" });
32
40
  const newFragment = /* @__PURE__ */ createElement(OnlyKeepSubTrees, null, props.children);
33
- extendTree(newFragment, { signal }).then((treeRootId) => !signal.aborted && setLoadState({ name: "success", treeRootId })).catch((error) => {
41
+ extendTree(newFragment, { signal, environment }).then((treeRootId) => !signal.aborted && setLoadState({ name: "success", treeRootId })).catch((error) => {
34
42
  if (signal.aborted) {
35
43
  return;
36
44
  }
37
45
  throw error;
38
46
  });
39
- }, [extendTree, isMutating, loadState.name, props.children, signal]);
47
+ }, [environment, extendTree, isMutating, loadState.name, props.children, signal]);
40
48
  switch (loadState.name) {
41
49
  case "initial":
42
50
  case "loading":
@@ -1 +1 @@
1
- {"version":3,"file":"DeferredSubTrees.js","sources":["../../../src/helperComponents/DeferredSubTrees.tsx"],"sourcesContent":["import { ReactNode, useCallback, useEffect, useState } from 'react'\nimport { TreeRootIdProvider, useBindingOperations } from '../accessorPropagation'\nimport { useMutationState } from '../accessorTree'\nimport { Component } from '../coreComponents'\nimport { useEntityBeforePersist } from '../entityEvents'\nimport { EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from '../markers'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { TreeRootId } from '../treeParameters'\n\nexport interface DeferredSubTreesProps {\n\tfallback: ReactNode\n\tchildren: ReactNode\n}\n\ntype LoadState =\n\t| { name: 'initial' }\n\t| { name: 'loading' }\n\t| {\n\t\t\tname: 'success'\n\t\t\ttreeRootId: TreeRootId | undefined\n\t }\n\nexport const DeferredSubTrees = Component<DeferredSubTreesProps>(\n\tprops => {\n\t\tconst { extendTree } = useBindingOperations()\n\t\tconst isMutating = useMutationState()\n\n\t\tconst [loadState, setLoadState] = useState<LoadState>({ name: 'initial' })\n\n\t\tconst [abortController] = useState(() => new AbortController())\n\t\tconst signal = abortController.signal\n\n\t\tuseEntityBeforePersist(\n\t\t\tuseCallback(getAccessor => {\n\t\t\t\t// This is a hack. We're really just circumventing the change of ids after a creation so that nested\n\t\t\t\t// components don't error.\n\t\t\t\tif (getAccessor().existsOnServer) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tsetLoadState({ name: 'initial' })\n\t\t\t}, []),\n\t\t)\n\n\t\tuseEffect(() => {\n\t\t\treturn () => {\n\t\t\t\tabortController.abort()\n\t\t\t}\n\t\t}, [abortController])\n\n\t\tuseEffect(() => {\n\t\t\tif (isMutating || loadState.name !== 'initial' || signal.aborted) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetLoadState({ name: 'loading' })\n\n\t\t\tconst newFragment = <OnlyKeepSubTrees>{props.children}</OnlyKeepSubTrees>\n\n\t\t\textendTree(newFragment, { signal })\n\t\t\t\t.then(treeRootId => !signal.aborted && setLoadState({ name: 'success', treeRootId }))\n\t\t\t\t.catch(error => {\n\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t})\n\t\t}, [extendTree, isMutating, loadState.name, props.children, signal])\n\n\t\tswitch (loadState.name) {\n\t\t\tcase 'initial':\n\t\t\tcase 'loading':\n\t\t\t\treturn <>{props.fallback}</>\n\t\t\tcase 'success':\n\t\t\t\t// This is tricky. The relations & fields within children will just render normally as if this\n\t\t\t\t// component didn't exist. The sub trees, however, will read the new treeRootId and draw their data\n\t\t\t\t// from the newly loaded batch provided by this component. That way the sub trees (and only the sub trees!)\n\t\t\t\t// effectively get lazy loaded.\n\t\t\t\treturn <TreeRootIdProvider treeRootId={loadState.treeRootId}>{props.children}</TreeRootIdProvider>\n\t\t}\n\t},\n\t{\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t{props.children}\n\t\t\t\t{props.fallback}\n\t\t\t</>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tconst fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment)\n\n\t\t\t// We want to get rid of the subTrees but leave whatever relations and fields are present.\n\t\t\t//\n\t\t\t// Mutating from here is fine since we've literally just created it and no other code could possibly possess\n\t\t\t// a reference to this.\n\t\t\tfieldsWithHoistablesMarker.subTrees?.clear()\n\n\t\t\treturn fieldsWithHoistablesMarker\n\t\t},\n\t},\n\t'DeferredSubTree',\n)\n\nconst OnlyKeepSubTrees = Component<{ children: ReactNode }>(\n\t() => null,\n\t{\n\t\tgenerateBranchMarker: (props, fields) => {\n\t\t\t// This is the complement of the equivalent method above: this time we're only keeping the sub trees.\n\t\t\tconst emptyFields = MarkerFactory.createEntityFieldMarkersContainer(undefined)\n\n\t\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\t\treturn emptyFields\n\t\t\t}\n\t\t\treturn new EntityFieldsWithHoistablesMarker(emptyFields, fields.subTrees, undefined)\n\t\t},\n\t},\n\t'OnlyKeepSubTrees',\n)\n"],"names":["_jsx","_jsxFragment"],"mappings":";;;;;;;;;AAsBa,MAAA,mBAAmB,UAC/B,CAAS,UAAA;AACF,QAAA,EAAE,eAAe;AACvB,QAAM,aAAa;AAEnB,QAAM,CAAC,WAAW,gBAAgB,SAAoB,EAAE,MAAM,WAAW;AAEzE,QAAM,CAAC,mBAAmB,SAAS,MAAM,IAAI,gBAAiB,CAAA;AAC9D,QAAM,SAAS,gBAAgB;AAE/B,yBACC,YAAY,CAAe,gBAAA;AAGtB,QAAA,cAAc,gBAAgB;AACjC;AAAA,IACD;AACa,iBAAA,EAAE,MAAM,UAAA,CAAW;AAAA,EAAA,GAC9B,CAAA,CAAE,CACN;AAEA,YAAU,MAAM;AACf,WAAO,MAAM;AACZ,sBAAgB,MAAM;AAAA,IAAA;AAAA,EACvB,GACE,CAAC,eAAe,CAAC;AAEpB,YAAU,MAAM;AACf,QAAI,cAAc,UAAU,SAAS,aAAa,OAAO,SAAS;AACjE;AAAA,IACD;AACa,iBAAA,EAAE,MAAM,UAAA,CAAW;AAEhC,UAAM,cAAcA,8BAAC,kBAAkB,MAAA,MAAM,QAAS;AAEtD,eAAW,aAAa,EAAE,OAAA,CAAQ,EAChC,KAAK,gBAAc,CAAC,OAAO,WAAW,aAAa,EAAE,MAAM,WAAW,WAAY,CAAA,CAAC,EACnF,MAAM,CAAS,UAAA;AACf,UAAI,OAAO,SAAS;AACnB;AAAA,MACD;AACM,YAAA;AAAA,IAAA,CACN;AAAA,EAAA,GACA,CAAC,YAAY,YAAY,UAAU,MAAM,MAAM,UAAU,MAAM,CAAC;AAEnE,UAAQ,UAAU;AAAA,SACZ;AAAA,SACA;AACG,aAAAA,8BAAAC,UAAA,MAAG,MAAM,QAAS;AAAA,SACrB;AAKJ,aAAQD,8BAAA,oBAAA;AAAA,QAAmB,YAAY,UAAU;AAAA,MAAA,GAAa,MAAM,QAAS;AAAA;AAEhF,GACA;AAAA,EACC,cAAc,CACb,UAAAA,8BAAAC,UAAA,MACE,MAAM,UACN,MAAM,QACR;AAAA,EAED,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACrD,UAAM,6BAA6B,cAAc,uCAAuC,QAAQ,WAAW;AAM3G,+BAA2B,UAAU;AAE9B,WAAA;AAAA,EACR;AACD,GACA,iBACD;AAEA,MAAM,mBAAmB,UACxB,MAAM,MACN;AAAA,EACC,sBAAsB,CAAC,OAAO,WAAW;AAElC,UAAA,cAAc,cAAc,kCAAkC,MAAS;AAE7E,QAAI,kBAAkB,6BAA6B;AAC3C,aAAA;AAAA,IACR;AACA,WAAO,IAAI,iCAAiC,aAAa,OAAO,UAAU,MAAS;AAAA,EACpF;AACD,GACA,kBACD;;"}
1
+ {"version":3,"file":"DeferredSubTrees.js","sources":["../../../src/helperComponents/DeferredSubTrees.tsx"],"sourcesContent":["import { ReactNode, useCallback, useEffect, useState } from 'react'\nimport { TreeRootIdProvider, useBindingOperations, useHasEntity, useEnvironment } from '../accessorPropagation'\nimport { useMutationState } from '../accessorTree'\nimport { Component } from '../coreComponents'\nimport { useEntityBeforePersist } from '../entityEvents'\nimport { EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from '../markers'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { TreeRootId } from '../treeParameters'\nimport { useConstantValueInvariant } from '@contember/react-utils'\n\nexport interface DeferredSubTreesProps {\n\tfallback: ReactNode\n\tchildren: ReactNode\n}\n\ntype LoadState =\n\t| { name: 'initial' }\n\t| { name: 'loading' }\n\t| {\n\t\t\tname: 'success'\n\t\t\ttreeRootId: TreeRootId | undefined\n\t }\n\nexport const DeferredSubTrees = Component<DeferredSubTreesProps>(\n\tprops => {\n\t\tconst { extendTree } = useBindingOperations()\n\t\tconst isMutating = useMutationState()\n\n\t\tconst [loadState, setLoadState] = useState<LoadState>({ name: 'initial' })\n\n\t\tconst [abortController] = useState(() => new AbortController())\n\t\tconst signal = abortController.signal\n\n\t\tconst hasEntity = useHasEntity()\n\t\tuseConstantValueInvariant(hasEntity)\n\t\tif (hasEntity) {\n\t\t\tuseEntityBeforePersist(\n\t\t\t\tuseCallback(getAccessor => {\n\t\t\t\t\t// This is a hack. We're really just circumventing the change of ids after a creation so that nested\n\t\t\t\t\t// components don't error.\n\t\t\t\t\tif (getAccessor().existsOnServer) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tsetLoadState({ name: 'initial' })\n\t\t\t\t}, []),\n\t\t\t)\n\t\t}\n\n\t\tuseEffect(() => {\n\t\t\treturn () => {\n\t\t\t\tabortController.abort()\n\t\t\t}\n\t\t}, [abortController])\n\n\t\tconst environment = useEnvironment()\n\t\tuseEffect(() => {\n\t\t\tif (isMutating || loadState.name !== 'initial' || signal.aborted) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetLoadState({ name: 'loading' })\n\n\t\t\tconst newFragment = <OnlyKeepSubTrees>{props.children}</OnlyKeepSubTrees>\n\n\t\t\textendTree(newFragment, { signal, environment })\n\t\t\t\t.then(treeRootId => !signal.aborted && setLoadState({ name: 'success', treeRootId }))\n\t\t\t\t.catch(error => {\n\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t})\n\t\t}, [environment, extendTree, isMutating, loadState.name, props.children, signal])\n\n\t\tswitch (loadState.name) {\n\t\t\tcase 'initial':\n\t\t\tcase 'loading':\n\t\t\t\treturn <>{props.fallback}</>\n\t\t\tcase 'success':\n\t\t\t\t// This is tricky. The relations & fields within children will just render normally as if this\n\t\t\t\t// component didn't exist. The sub trees, however, will read the new treeRootId and draw their data\n\t\t\t\t// from the newly loaded batch provided by this component. That way the sub trees (and only the sub trees!)\n\t\t\t\t// effectively get lazy loaded.\n\t\t\t\treturn <TreeRootIdProvider treeRootId={loadState.treeRootId}>{props.children}</TreeRootIdProvider>\n\t\t}\n\t},\n\t{\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t{props.children}\n\t\t\t\t{props.fallback}\n\t\t\t</>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tconst fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment)\n\n\t\t\t// We want to get rid of the subTrees but leave whatever relations and fields are present.\n\t\t\t//\n\t\t\t// Mutating from here is fine since we've literally just created it and no other code could possibly possess\n\t\t\t// a reference to this.\n\t\t\tfieldsWithHoistablesMarker.subTrees?.clear()\n\n\t\t\treturn fieldsWithHoistablesMarker\n\t\t},\n\t},\n\t'DeferredSubTree',\n)\n\nconst OnlyKeepSubTrees = Component<{ children: ReactNode }>(\n\t() => null,\n\t{\n\t\tgenerateBranchMarker: (props, fields) => {\n\t\t\t// This is the complement of the equivalent method above: this time we're only keeping the sub trees.\n\t\t\tconst emptyFields = MarkerFactory.createEntityFieldMarkersContainer(undefined)\n\n\t\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\t\treturn emptyFields\n\t\t\t}\n\t\t\treturn new EntityFieldsWithHoistablesMarker(emptyFields, fields.subTrees, undefined)\n\t\t},\n\t},\n\t'OnlyKeepSubTrees',\n)\n"],"names":["_jsx","_jsxFragment"],"mappings":";;;;;;;;;;;;AAuBa,MAAA,mBAAmB,UAC/B,CAAS,UAAA;AACF,QAAA,EAAE,eAAe;AACvB,QAAM,aAAa;AAEnB,QAAM,CAAC,WAAW,gBAAgB,SAAoB,EAAE,MAAM,WAAW;AAEzE,QAAM,CAAC,mBAAmB,SAAS,MAAM,IAAI,gBAAiB,CAAA;AAC9D,QAAM,SAAS,gBAAgB;AAE/B,QAAM,YAAY;AAClB,4BAA0B,SAAS;AACnC,MAAI,WAAW;AACd,2BACC,YAAY,CAAe,gBAAA;AAGtB,U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,kCAAkC,MAAS;AAE7E,QAAI,kBAAkB,6BAA6B;AAC3C,aAAA;AAAA,IACR;AACA,WAAO,IAAI,iCAAiC,aAAa,OAAO,UAAU,MAAS;AAAA,EACpF;AACD,GACA,kBACD;;"}
@@ -0,0 +1,39 @@
1
+ import { createElement, Fragment, useMemo } from "react";
2
+ import { FilterFieldsCollector } from "./helpers/FilterFieldsCollector.js";
3
+ import { FilterEvaluator } from "./helpers/FilterEvaluator.js";
4
+ import { Field } from "../coreComponents/Field.js";
5
+ import { Component } from "../coreComponents/Component.js";
6
+ import { useEntity } from "../accessorPropagation/useEntity.js";
7
+ import { QueryLanguage } from "../queryLanguage/QueryLanguage.js";
8
+ import { useEnvironment } from "../accessorPropagation/useEnvironment.js";
9
+ const If = Component((props) => {
10
+ return typeof props.condition !== "function" ? /* @__PURE__ */ createElement(IfFilter, {
11
+ condition: props.condition
12
+ }, props.children) : /* @__PURE__ */ createElement(IfCallback, {
13
+ condition: props.condition
14
+ }, props.children);
15
+ }, "If");
16
+ const IfCallback = Component(({ children, condition }) => {
17
+ const entity = useEntity();
18
+ const evaluated = useMemo(() => condition(entity), [condition, entity]);
19
+ return evaluated ? /* @__PURE__ */ createElement(Fragment, null, children) : null;
20
+ }, ({ children }) => {
21
+ return /* @__PURE__ */ createElement(Fragment, null, children);
22
+ }, "IfCallback");
23
+ const IfFilter = Component(({ children, condition }) => {
24
+ const env = useEnvironment();
25
+ const entity = useEntity();
26
+ const schema = env.getSchema();
27
+ const evaluated = useMemo(() => new FilterEvaluator(schema).evaluateFilter(entity, QueryLanguage.desugarFilter(condition, env)), [condition, entity, env, schema]);
28
+ return evaluated ? /* @__PURE__ */ createElement(Fragment, null, children) : null;
29
+ }, ({ children, condition }, env) => {
30
+ const desugaredFilter = QueryLanguage.desugarFilter(condition, env);
31
+ const collectedFields = new FilterFieldsCollector(env.getSchema(), desugaredFilter).collectFields(env.getSubTreeNode().entity);
32
+ const additionalFields = /* @__PURE__ */ createElement(Fragment, null, Array.from(collectedFields).map((it) => /* @__PURE__ */ createElement(Field, {
33
+ field: it,
34
+ key: it
35
+ })));
36
+ return /* @__PURE__ */ createElement(Fragment, null, additionalFields, children);
37
+ }, "IfFilter");
38
+ export { If };
39
+ //# sourceMappingURL=If.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"If.js","sources":["../../../src/helperComponents/If.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useMemo } from 'react'\nimport { Component, Field } from '../coreComponents'\nimport { EntityAccessor } from '../accessors'\nimport { QueryLanguage } from '../queryLanguage'\nimport { useEntity, useEnvironment } from '../accessorPropagation'\nimport { Filter } from '../treeParameters'\nimport { FilterFieldsCollector } from './helpers/FilterFieldsCollector'\nimport { FilterEvaluator } from './helpers/FilterEvaluator'\n\nexport type IfProps =\n\t| IfFilterProps\n\t| IfCallbackProps\n\nexport interface IfFilterProps {\n\tcondition: string | Filter\n\tchildren?: ReactNode\n}\n\nexport interface IfCallbackProps {\n\tcondition: (accessor: EntityAccessor) => boolean\n\tchildren?: ReactNode\n}\n\nexport const If = Component<IfProps>(props => {\n\t\treturn typeof props.condition !== 'function'\n\t\t\t? <IfFilter condition={props.condition}>{props.children}</IfFilter>\n\t\t\t: <IfCallback condition={props.condition}>{props.children}</IfCallback>\n\t},\n\t'If',\n)\n\nconst IfCallback = Component<IfCallbackProps>(\n\t({ children, condition }) => {\n\t\tconst entity = useEntity()\n\t\tconst evaluated = useMemo(() => condition(entity), [condition, entity])\n\n\t\treturn evaluated ? <>{children}</> : null\n\t},\n\t({ children }) => {\n\t\treturn <>{children}</>\n\t},\n\t'IfCallback',\n)\n\nconst IfFilter = Component<IfFilterProps>(\n\t({ children, condition }) => {\n\t\tconst env = useEnvironment()\n\t\tconst entity = useEntity()\n\n\t\tconst schema = env.getSchema()\n\t\tconst evaluated = useMemo(\n\t\t\t() => new FilterEvaluator(schema).evaluateFilter(entity, QueryLanguage.desugarFilter(condition, env)),\n\t\t\t[condition, entity, env, schema],\n\t\t)\n\n\t\treturn evaluated ? <>{children}</> : null\n\t},\n\t({ children, condition }, env) => {\n\t\tconst desugaredFilter = QueryLanguage.desugarFilter(condition, env)\n\t\tconst collectedFields = new FilterFieldsCollector(env.getSchema(), desugaredFilter).collectFields(env.getSubTreeNode().entity)\n\t\tconst additionalFields = <>{Array.from(collectedFields).map(it => <Field field={it} key={it} />)}</>\n\n\t\treturn <>\n\t\t\t{additionalFields}\n\t\t\t{children}\n\t\t</>\n\t},\n\t'IfFilter',\n)\n\n"],"names":["_jsx","_jsxFragment"],"mappings":";;;;;;;;AAwBa,MAAA,KAAK,UAAmB,CAAS,UAAA;AAC5C,SAAO,OAAO,MAAM,cAAc,aAC9BA,8BAAA,UAAA;AAAA,IAAS,WAAW,MAAM;AAAA,EAAY,GAAA,MAAM,QAAS,IACrDA,8BAAA,YAAA;AAAA,IAAW,WAAW,MAAM;AAAA,EAAA,GAAY,MAAM,QAAS;AAC5D,GACA,IACD;AAEA,MAAM,aAAa,UAClB,CAAC,EAAE,UAAU,gBAAgB;AAC5B,QAAM,SAAS;AACT,QAAA,YAAY,QAAQ,MAAM,UAAU,MAAM,GAAG,CAAC,WAAW,MAAM,CAAC;AAE/D,SAAA,YAAeA,8BAAAC,UAAA,MAAA,QAAS,IAAM;AACtC,GACA,CAAC,EAAE,eAAe;AACjB,uDAAU,QAAS;AACpB,GACA,YACD;AAEA,MAAM,WAAW,UAChB,CAAC,EAAE,UAAU,gBAAgB;AAC5B,QAAM,MAAM;AACZ,QAAM,SAAS;AAET,QAAA,SAAS,IAAI;AACb,QAAA,YAAY,QACjB,MAAM,IAAI,gBAAgB,MAAM,EAAE,eAAe,QAAQ,cAAc,cAAc,WAAW,GAAG,CAAC,GACpG,CAAC,WAAW,QAAQ,KAAK,MAAM,CAChC;AAEO,SAAA,YAAeD,8BAAAC,UAAA,MAAA,QAAS,IAAM;AACtC,GACA,CAAC,EAAE,UAAU,aAAa,QAAQ;AACjC,QAAM,kBAAkB,cAAc,cAAc,WAAW,GAAG;AAClE,QAAM,kBAAkB,IAAI,sBAAsB,IAAI,UAAU,GAAG,eAAe,EAAE,cAAc,IAAI,eAAe,EAAE,MAAM;AACvH,QAAA,iEAAsB,MAAM,KAAK,eAAe,EAAE,IAAI,QAAOD,8BAAA,OAAA;AAAA,IAAM,OAAO;AAAA,IAAI,KAAK;AAAA,EAAI,CAAA,CAAE,CAAE;AAE1F,SAAAA,8BAAAC,UAAA,MACL,kBACA,QACF;AACD,GACA,UACD;;"}
@@ -1,6 +1,6 @@
1
1
  import { createElement } from "react";
2
- import { Field } from "../coreComponents/Field.js";
3
2
  import { Component } from "../coreComponents/Component.js";
3
+ import { Field } from "../coreComponents/Field.js";
4
4
  const SugaredField = Component((props) => {
5
5
  if (typeof props.field === "string") {
6
6
  return /* @__PURE__ */ createElement(Field, {
@@ -0,0 +1,38 @@
1
+ import { BindingError } from "../../BindingError.js";
2
+ import { evaluateCondition } from "./evaluateCondition.js";
3
+ class FilterEvaluator {
4
+ constructor(schema) {
5
+ this.schema = schema;
6
+ }
7
+ evaluateFilter(entity, filter) {
8
+ const entitySchema = this.schema.getEntity(entity.name);
9
+ if (!entitySchema) {
10
+ throw new BindingError();
11
+ }
12
+ let acc = true;
13
+ for (const [key, value] of Object.entries(filter)) {
14
+ if (key === "and" || key === "or") {
15
+ if (!Array.isArray(value)) {
16
+ throw new BindingError();
17
+ }
18
+ const operation = key === "and" ? "every" : "some";
19
+ acc && (acc = value[operation]((it) => this.evaluateFilter(entity, it)));
20
+ } else if (key === "not") {
21
+ acc && (acc = !this.evaluateFilter(entity, value));
22
+ } else {
23
+ const field = entitySchema.fields.get(key);
24
+ if (!field) {
25
+ throw new BindingError();
26
+ }
27
+ if (field.__typename === "_Column") {
28
+ acc && (acc = evaluateCondition(entity.getField(key).value, value));
29
+ } else {
30
+ acc && (acc = this.evaluateFilter(entity.getEntity(key), value));
31
+ }
32
+ }
33
+ }
34
+ return acc;
35
+ }
36
+ }
37
+ export { FilterEvaluator };
38
+ //# sourceMappingURL=FilterEvaluator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilterEvaluator.js","sources":["../../../../src/helperComponents/helpers/FilterEvaluator.ts"],"sourcesContent":["import { Schema } from '../../core/schema'\nimport { Input } from '@contember/client'\nimport { EntityAccessor } from '../../accessors'\nimport { Filter } from '../../treeParameters'\nimport { BindingError } from '../../BindingError'\nimport { evaluateCondition } from './evaluateCondition'\n\n\nexport class FilterEvaluator {\n\tconstructor(\n\t\tprivate readonly schema: Schema,\n\t) {\n\t}\n\n\tevaluateFilter(entity: EntityAccessor, filter: Filter): boolean {\n\t\tconst entitySchema = this.schema.getEntity(entity.name)\n\t\tif (!entitySchema) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\tlet acc = true\n\t\tfor (const [key, value] of Object.entries(filter)) {\n\t\t\tif (key === 'and' || key === 'or') {\n\t\t\t\t\tif (!Array.isArray(value)) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\n\t\t\t\t\tconst operation = key === 'and' ? 'every' : 'some' as const\n\t\t\t\t\tacc &&= value[operation](it => this.evaluateFilter(entity, it))\n\n\t\t\t} else if (key === 'not') {\n\t\t\t\t\tacc &&= !this.evaluateFilter(entity, value as Filter)\n\n\t\t\t} else {\n\t\t\t\tconst field = entitySchema.fields.get(key)\n\t\t\t\tif (!field) {\n\t\t\t\t\tthrow new BindingError()\n\t\t\t\t}\n\n\t\t\t\tif (field.__typename === '_Column') {\n\t\t\t\t\tacc &&= evaluateCondition(entity.getField(key).value, value as Input.Condition)\n\t\t\t\t} else {\n\t\t\t\t\tacc &&= this.evaluateFilter(entity.getEntity(key), value as Filter)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn acc\n\t}\n}\n"],"names":[],"mappings":";;AAQO,MAAM,gBAAgB;AAAA,EAC5B,YACkB,QAChB;AADgB,SAAA,SAAA;AAAA,EAElB;AAAA,EAEA,eAAe,QAAwB,QAAyB;AAC/D,UAAM,eAAe,KAAK,OAAO,UAAU,OAAO,IAAI;AACtD,QAAI,CAAC,cAAc;AAClB,YAAM,IAAI,aAAa;AAAA,IACxB;AACA,QAAI,MAAM;AACV,eAAW,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,GAAG;AAC9C,UAAA,QAAQ,SAAS,QAAQ,MAAM;AACjC,YAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AAC1B,gBAAM,IAAI,aAAa;AAAA,QACxB;AAEM,cAAA,YAAY,QAAQ,QAAQ,UAAU;AAC5C,sBAAQ,MAAM,WAAW,CAAA,OAAM,KAAK,eAAe,QAAQ,EAAE,CAAC;AAAA,MAAA,WAErD,QAAQ,OAAO;AACxB,sBAAQ,CAAC,KAAK,eAAe,QAAQ,KAAe;AAAA,MAAA,OAE/C;AACN,cAAM,QAAQ,aAAa,OAAO,IAAI,GAAG;AACzC,YAAI,CAAC,OAAO;AACX,gBAAM,IAAI,aAAa;AAAA,QACxB;AAEI,YAAA,MAAM,eAAe,WAAW;AACnC,wBAAQ,kBAAkB,OAAO,SAAS,GAAG,EAAE,OAAO,KAAwB;AAAA,QAAA,OACxE;AACN,wBAAQ,KAAK,eAAe,OAAO,UAAU,GAAG,GAAG,KAAe;AAAA,QACnE;AAAA,MACD;AAAA,IACD;AACO,WAAA;AAAA,EACR;AACD;;"}
@@ -0,0 +1,41 @@
1
+ import { BindingError } from "../../BindingError.js";
2
+ class FilterFieldsCollector {
3
+ constructor(schema, rootFilter) {
4
+ this.schema = schema;
5
+ this.rootFilter = rootFilter;
6
+ }
7
+ collectFields(entity) {
8
+ const result = /* @__PURE__ */ new Set();
9
+ this.collectFieldsInternal(this.rootFilter, entity, [], result);
10
+ return result;
11
+ }
12
+ collectFieldsInternal(filter, entity, path, result) {
13
+ for (const [key, value] of Object.entries(filter)) {
14
+ if (key === "and" || key === "or") {
15
+ if (!Array.isArray(value)) {
16
+ throw new BindingError();
17
+ }
18
+ value?.forEach((it) => this.collectFieldsInternal(it, entity, path, result));
19
+ } else if (key === "not") {
20
+ this.collectFieldsInternal(value, entity, path, result);
21
+ } else {
22
+ const field = entity.fields.get(key);
23
+ if (!field) {
24
+ throw new BindingError(`Invalid field: the name "${key}" does not exist on entity "${entity.name}" in a ${path.length === 0 ? "root" : `path "${path.join(".")}"`} of a following filter:
25
+ ` + JSON.stringify(this.rootFilter, null, " "));
26
+ }
27
+ if (field.__typename === "_Column") {
28
+ result.add([...path, key].join("."));
29
+ } else {
30
+ const entity2 = this.schema.getEntity(field.targetEntity);
31
+ if (!entity2) {
32
+ throw new BindingError();
33
+ }
34
+ this.collectFieldsInternal(value, entity2, [...path, key], result);
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }
40
+ export { FilterFieldsCollector };
41
+ //# sourceMappingURL=FilterFieldsCollector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilterFieldsCollector.js","sources":["../../../../src/helperComponents/helpers/FilterFieldsCollector.ts"],"sourcesContent":["import { Schema, SchemaEntity } from '../../core/schema'\nimport { Filter } from '../../treeParameters'\nimport { BindingError } from '../../BindingError'\n\nexport class FilterFieldsCollector {\n\tconstructor(\n\t\tprivate readonly schema: Schema,\n\t\tprivate readonly rootFilter: Filter,\n\t) {\n\t}\n\n\n\tcollectFields(entity: SchemaEntity): Set<string> {\n\t\tconst result = new Set<string>()\n\t\tthis.collectFieldsInternal(this.rootFilter, entity, [], result)\n\t\treturn result\n\t}\n\n\tprivate collectFieldsInternal(filter: Filter, entity: SchemaEntity, path: string[], result: Set<string>): void {\n\t\tfor (const [key, value] of Object.entries(filter)) {\n\t\t\tif (key === 'and' || key === 'or') {\n\t\t\t\t\tif (!Array.isArray(value)) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\tvalue?.forEach(it => this.collectFieldsInternal(it, entity, path, result))\n\n\t\t\t} else if (key === 'not') {\n\t\t\t\t\tthis.collectFieldsInternal(value as Filter, entity, path, result)\n\n\t\t\t} else {\n\t\t\t\tconst field = entity.fields.get(key)\n\t\t\t\tif (!field) {\n\t\t\t\t\tthrow new BindingError(`Invalid field: the name \"${key}\" does not exist on entity \"${entity.name}\" `\n\t\t\t\t\t\t+ `in a ${path.length === 0 ? 'root' : `path \"${path.join('.')}\"`} of a following filter:\\n`\n\t\t\t\t\t\t+ JSON.stringify(this.rootFilter, null, ' '))\n\t\t\t\t}\n\t\t\t\tif (field.__typename === '_Column') {\n\t\t\t\t\tresult.add([...path, key].join('.'))\n\t\t\t\t} else {\n\t\t\t\t\tconst entity = this.schema.getEntity(field.targetEntity)\n\t\t\t\t\tif (!entity) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\tthis.collectFieldsInternal(value as Filter, entity, [...path, key], result)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";AAIO,MAAM,sBAAsB;AAAA,EAClC,YACkB,QACA,YAChB;AAFgB,SAAA,SAAA;AACA,SAAA,aAAA;AAAA,EAElB;AAAA,EAGA,cAAc,QAAmC;AAC1C,UAAA,6BAAa;AACnB,SAAK,sBAAsB,KAAK,YAAY,QAAQ,CAAA,GAAI,MAAM;AACvD,WAAA;AAAA,EACR;AAAA,EAEQ,sBAAsB,QAAgB,QAAsB,MAAgB,QAA2B;AAC9G,eAAW,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,GAAG;AAC9C,UAAA,QAAQ,SAAS,QAAQ,MAAM;AACjC,YAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AAC1B,gBAAM,IAAI,aAAa;AAAA,QACxB;AACO,eAAA,QAAQ,QAAM,KAAK,sBAAsB,IAAI,QAAQ,MAAM,MAAM,CAAC;AAAA,MAAA,WAEhE,QAAQ,OAAO;AACxB,aAAK,sBAAsB,OAAiB,QAAQ,MAAM,MAAM;AAAA,MAAA,OAE3D;AACN,cAAM,QAAQ,OAAO,OAAO,IAAI,GAAG;AACnC,YAAI,CAAC,OAAO;AACX,gBAAM,IAAI,aAAa,4BAA4B,kCAAkC,OAAO,cACjF,KAAK,WAAW,IAAI,SAAS,SAAS,KAAK,KAAK,GAAG;AAAA,IAC3D,KAAK,UAAU,KAAK,YAAY,MAAM,IAAI,CAAC;AAAA,QAC/C;AACI,YAAA,MAAM,eAAe,WAAW;AAC5B,iBAAA,IAAI,CAAC,GAAG,MAAM,GAAG,EAAE,KAAK,GAAG,CAAC;AAAA,QAAA,OAC7B;AACN,gBAAM,UAAS,KAAK,OAAO,UAAU,MAAM,YAAY;AACvD,cAAI,CAAC,SAAQ;AACZ,kBAAM,IAAI,aAAa;AAAA,UACxB;AACK,eAAA,sBAAsB,OAAiB,SAAQ,CAAC,GAAG,MAAM,GAAG,GAAG,MAAM;AAAA,QAC3E;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;;"}
@@ -0,0 +1,46 @@
1
+ import { GraphQlLiteral } from "@contember/client";
2
+ import { BindingError } from "../../BindingError.js";
3
+ const unwrapGraphqlLiteral = (value) => {
4
+ if (value instanceof GraphQlLiteral) {
5
+ return value.value;
6
+ }
7
+ return value;
8
+ };
9
+ const evaluateCondition = (value, condition) => {
10
+ const handlers = {
11
+ and: (expr) => expr.every((it) => evaluateCondition(value, it)),
12
+ or: (expr) => expr.some((it) => evaluateCondition(value, it)),
13
+ not: (expr) => !evaluateCondition(value, expr),
14
+ eq: (expr) => value === unwrapGraphqlLiteral(expr),
15
+ notEq: (expr) => value !== unwrapGraphqlLiteral(expr),
16
+ isNull: (expr) => value === null === expr,
17
+ in: (expr) => expr.map(unwrapGraphqlLiteral).includes(value),
18
+ notIn: (expr) => !expr.map(unwrapGraphqlLiteral).includes(value),
19
+ lt: (expr) => value !== null && value < unwrapGraphqlLiteral(expr),
20
+ lte: (expr) => value !== null && value <= unwrapGraphqlLiteral(expr),
21
+ gt: (expr) => value !== null && value > unwrapGraphqlLiteral(expr),
22
+ gte: (expr) => value !== null && value >= unwrapGraphqlLiteral(expr),
23
+ contains: (expr) => typeof value === "string" && value.includes(unwrapGraphqlLiteral(expr)),
24
+ startsWith: (expr) => typeof value === "string" && value.startsWith(unwrapGraphqlLiteral(expr)),
25
+ endsWith: (expr) => typeof value === "string" && value.endsWith(unwrapGraphqlLiteral(expr)),
26
+ containsCI: (expr) => typeof value === "string" && value.toLowerCase().includes(unwrapGraphqlLiteral(expr).toLowerCase()),
27
+ startsWithCI: (expr) => typeof value === "string" && value.toLowerCase().startsWith(unwrapGraphqlLiteral(expr).toLowerCase()),
28
+ endsWithCI: (expr) => typeof value === "string" && value.toLowerCase().endsWith(unwrapGraphqlLiteral(expr).toLowerCase()),
29
+ never: () => false,
30
+ always: () => true,
31
+ null: (expr) => value === null === expr
32
+ };
33
+ return Object.entries(condition).every(([operator, argument]) => {
34
+ if (value === void 0) {
35
+ return true;
36
+ }
37
+ const handlerKey = operator;
38
+ const handler = handlers[handlerKey];
39
+ if (!handler) {
40
+ throw new BindingError();
41
+ }
42
+ return handler(argument);
43
+ });
44
+ };
45
+ export { evaluateCondition };
46
+ //# sourceMappingURL=evaluateCondition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluateCondition.js","sources":["../../../../src/helperComponents/helpers/evaluateCondition.ts"],"sourcesContent":["import { GraphQlLiteral, Input } from '@contember/client'\nimport { Scalar } from '../../treeParameters'\nimport { BindingError } from '../../BindingError'\n\nconst unwrapGraphqlLiteral = (value: Input.ColumnValue<GraphQlLiteral>): any => {\n\tif (value instanceof GraphQlLiteral) {\n\t\treturn value.value\n\t}\n\treturn value\n}\n\nexport const evaluateCondition = (value: Scalar | null, condition: Input.Condition<Input.ColumnValue<GraphQlLiteral>>) => {\n\t\tconst handlers: {\n\t\t\t[K in keyof Required<Input.Condition<any>>]: (\n\t\t\t\tparam: Exclude<Input.Condition<any>[K], undefined>,\n\t\t\t) => boolean\n\t\t} = {\n\t\t\tand: expr => expr.every(it => evaluateCondition(value, it)),\n\t\t\tor: expr => expr.some(it => evaluateCondition(value, it)),\n\t\t\tnot: expr => !evaluateCondition(value, expr),\n\t\t\teq: expr => value === unwrapGraphqlLiteral(expr),\n\t\t\tnotEq: expr => value !== unwrapGraphqlLiteral(expr),\n\t\t\tisNull: expr => (value === null) === expr,\n\t\t\tin: expr => expr.map(unwrapGraphqlLiteral).includes(value),\n\t\t\tnotIn: expr => !expr.map(unwrapGraphqlLiteral).includes(value),\n\t\t\tlt: expr => value !== null && value < unwrapGraphqlLiteral(expr),\n\t\t\tlte: expr => value !== null && value <= unwrapGraphqlLiteral(expr),\n\t\t\tgt: expr => value !== null && value > unwrapGraphqlLiteral(expr),\n\t\t\tgte: expr => value !== null && value >= unwrapGraphqlLiteral(expr),\n\t\t\tcontains: expr => typeof value === 'string' && value.includes(unwrapGraphqlLiteral(expr)),\n\t\t\tstartsWith: expr => typeof value === 'string' && value.startsWith(unwrapGraphqlLiteral(expr)),\n\t\t\tendsWith: expr => typeof value === 'string' && value.endsWith(unwrapGraphqlLiteral(expr)),\n\t\t\tcontainsCI: expr => typeof value === 'string' && value.toLowerCase().includes(unwrapGraphqlLiteral(expr).toLowerCase()),\n\t\t\tstartsWithCI: expr => typeof value === 'string' && value.toLowerCase().startsWith(unwrapGraphqlLiteral(expr).toLowerCase()),\n\t\t\tendsWithCI: expr => typeof value === 'string' && value.toLowerCase().endsWith(unwrapGraphqlLiteral(expr).toLowerCase()),\n\t\t\tnever: () => false,\n\t\t\talways: () => true,\n\t\t\t// deprecated\n\t\t\tnull: expr => (value === null) === expr,\n\t\t}\n\t\treturn Object.entries(condition).every(([operator, argument]) => {\n\t\t\tif (value === undefined) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tconst handlerKey = operator as keyof typeof handlers\n\t\t\tconst handler = handlers[handlerKey]\n\t\t\tif (!handler) {\n\t\t\t\tthrow new BindingError()\n\t\t\t}\n\t\t\treturn handler(argument)\n\t\t})\n\t}\n"],"names":[],"mappings":";;AAIA,MAAM,uBAAuB,CAAC,UAAkD;AAC/E,MAAI,iBAAiB,gBAAgB;AACpC,WAAO,MAAM;AAAA,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,qBAAqB,IAAI,EAAE,aAAa;AAAA,IAC1H,YAAY,CAAA,SAAQ,OAAO,UAAU,YAAY,MAAM,YAAY,EAAE,SAAS,qBAAqB,IAAI,EAAE,aAAa;AAAA,IACtH,OAAO,MAAM;AAAA,IACb,QAAQ,MAAM;AAAA,IAEd,MAAM,CAAS,SAAA,UAAU,SAAU;AAAA,EAAA;AAE7B,SAAA,OAAO,QAAQ,SAAS,EAAE,MAAM,CAAC,CAAC,UAAU,cAAc;AAChE,QAAI,UAAU,QAAW;AACjB,aAAA;AAAA,IACR;AACA,UAAM,aAAa;AACnB,UAAM,UAAU,SAAS;AACzB,QAAI,CAAC,SAAS;AACb,YAAM,IAAI,aAAa;AAAA,IACxB;AACA,WAAO,QAAQ,QAAQ;AAAA,EAAA,CACvB;AACF;;"}
@@ -20,6 +20,7 @@ export { useEntityListSubTreeParameters } from "./accessorPropagation/useEntityL
20
20
  export { useEntitySubTree } from "./accessorPropagation/useEntitySubTree.js";
21
21
  export { useEntitySubTreeParameters } from "./accessorPropagation/useEntitySubTreeParameters.js";
22
22
  export { useEnvironment } from "./accessorPropagation/useEnvironment.js";
23
+ export { useExtendTree } from "./accessorPropagation/useExtendTree.js";
23
24
  export { useField } from "./accessorPropagation/useField.js";
24
25
  export { useGetEntityByKey } from "./accessorPropagation/useGetEntityByKey.js";
25
26
  export { useGetEntityListSubTree } from "./accessorPropagation/useGetEntityListSubTree.js";
@@ -45,6 +46,7 @@ export { metadataToRequestError } from "./accessorTree/metadataToRequestError.js
45
46
  export { MutationStateContext } from "./accessorTree/MutationStateContext.js";
46
47
  export { NormalizedPersistedData } from "./accessorTree/NormalizedPersistedData.js";
47
48
  export { ClientGeneratedUuid, ServerId, UnpersistedEntityDummyId } from "./accessorTree/RuntimeId.js";
49
+ export { useAccessorTreeState } from "./accessorTree/useAccessorTreeState.js";
48
50
  export { useDataBinding } from "./accessorTree/useDataBinding.js";
49
51
  export { useDirtinessState } from "./accessorTree/useDirtinessState.js";
50
52
  export { useMutationState } from "./accessorTree/useMutationState.js";
@@ -74,6 +76,7 @@ export { useEntityPersistSuccess } from "./entityEvents/useEntityPersistSuccess.
74
76
  export { useOnConnectionUpdate } from "./entityEvents/useOnConnectionUpdate.js";
75
77
  export { DeferredSubTrees } from "./helperComponents/DeferredSubTrees.js";
76
78
  export { EntityView } from "./helperComponents/EntityView.js";
79
+ export { If } from "./helperComponents/If.js";
77
80
  export { FieldView } from "./helperComponents/FieldView.js";
78
81
  export { StaticRender } from "./helperComponents/StaticRender.js";
79
82
  export { SugaredField } from "./helperComponents/SugaredField.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -11,7 +11,7 @@ class EntityListSubTreeMarker {
11
11
  this.parameters = parameters;
12
12
  this.fields = fields;
13
13
  this.environment = environment;
14
- this.placeholderName = PlaceholderGenerator.getEntityListSubTreePlaceholder(this.parameters);
14
+ this.placeholderName = PlaceholderGenerator.getEntityListSubTreePlaceholder(this.parameters, this.environment);
15
15
  }
16
16
  get entityName() {
17
17
  return this.parameters.entityName;
@@ -1 +1 @@
1
- {"version":3,"file":"EntityListSubTreeMarker.js","sources":["../../../src/markers/EntityListSubTreeMarker.ts"],"sourcesContent":["import type { Environment } from '../dao'\nimport type { QualifiedEntityList, UnconstrainedQualifiedEntityList } from '../treeParameters'\nimport type { EntityFieldMarkersContainer } from './EntityFieldMarkersContainer'\nimport { PlaceholderGenerator } from './PlaceholderGenerator'\n\nexport class EntityListSubTreeMarker {\n\tpublic readonly placeholderName: string\n\n\tpublic constructor(\n\t\tpublic readonly parameters: QualifiedEntityList | UnconstrainedQualifiedEntityList,\n\t\tpublic readonly fields: EntityFieldMarkersContainer,\n\t\tpublic readonly environment: Environment,\n\t) {\n\t\tthis.placeholderName = PlaceholderGenerator.getEntityListSubTreePlaceholder(this.parameters)\n\t}\n\n\tpublic get entityName() {\n\t\treturn this.parameters.entityName\n\t}\n}\n"],"names":[],"mappings":";;;;;;;AAKO,MAAM,wBAAwB;AAAA,EAG7B,YACU,YACA,QACA,aACf;AANc;AAGC,SAAA,aAAA;AACA,SAAA,SAAA;AACA,SAAA,cAAA;AAEhB,SAAK,kBAAkB,qBAAqB,gCAAgC,KAAK,UAAU;AAAA,EAC5F;AAAA,MAEW,aAAa;AACvB,WAAO,KAAK,WAAW;AAAA,EACxB;AACD;;"}
1
+ {"version":3,"file":"EntityListSubTreeMarker.js","sources":["../../../src/markers/EntityListSubTreeMarker.ts"],"sourcesContent":["import type { Environment } from '../dao'\nimport type { QualifiedEntityList, UnconstrainedQualifiedEntityList } from '../treeParameters'\nimport type { EntityFieldMarkersContainer } from './EntityFieldMarkersContainer'\nimport { PlaceholderGenerator } from './PlaceholderGenerator'\n\nexport class EntityListSubTreeMarker {\n\tpublic readonly placeholderName: string\n\n\tpublic constructor(\n\t\tpublic readonly parameters: QualifiedEntityList | UnconstrainedQualifiedEntityList,\n\t\tpublic readonly fields: EntityFieldMarkersContainer,\n\t\tpublic readonly environment: Environment,\n\t) {\n\t\tthis.placeholderName = PlaceholderGenerator.getEntityListSubTreePlaceholder(this.parameters, this.environment)\n\t}\n\n\tpublic get entityName() {\n\t\treturn this.parameters.entityName\n\t}\n}\n"],"names":[],"mappings":";;;;;;;AAKO,MAAM,wBAAwB;AAAA,EAG7B,YACU,YACA,QACA,aACf;AANc;AAGC,SAAA,aAAA;AACA,SAAA,SAAA;AACA,SAAA,cAAA;AAEhB,SAAK,kBAAkB,qBAAqB,gCAAgC,KAAK,YAAY,KAAK,WAAW;AAAA,EAC9G;AAAA,MAEW,aAAa;AACvB,WAAO,KAAK,WAAW;AAAA,EACxB;AACD;;"}
@@ -11,7 +11,7 @@ class EntitySubTreeMarker {
11
11
  this.parameters = parameters;
12
12
  this.fields = fields;
13
13
  this.environment = environment;
14
- this.placeholderName = PlaceholderGenerator.getEntitySubTreePlaceholder(this.parameters);
14
+ this.placeholderName = PlaceholderGenerator.getEntitySubTreePlaceholder(this.parameters, this.environment);
15
15
  }
16
16
  get entityName() {
17
17
  return this.parameters.entityName;
@@ -1 +1 @@
1
- {"version":3,"file":"EntitySubTreeMarker.js","sources":["../../../src/markers/EntitySubTreeMarker.ts"],"sourcesContent":["import type { Environment } from '../dao'\nimport type { QualifiedSingleEntity, UnconstrainedQualifiedSingleEntity } from '../treeParameters'\nimport type { EntityFieldMarkersContainer } from './EntityFieldMarkersContainer'\nimport { PlaceholderGenerator } from './PlaceholderGenerator'\n\nexport class EntitySubTreeMarker {\n\tpublic readonly placeholderName: string\n\n\tpublic constructor(\n\t\tpublic readonly parameters: QualifiedSingleEntity | UnconstrainedQualifiedSingleEntity,\n\t\tpublic readonly fields: EntityFieldMarkersContainer,\n\t\tpublic readonly environment: Environment,\n\t) {\n\t\tthis.placeholderName = PlaceholderGenerator.getEntitySubTreePlaceholder(this.parameters)\n\t}\n\n\tpublic get entityName() {\n\t\treturn this.parameters.entityName\n\t}\n}\n"],"names":[],"mappings":";;;;;;;AAKO,MAAM,oBAAoB;AAAA,EAGzB,YACU,YACA,QACA,aACf;AANc;AAGC,SAAA,aAAA;AACA,SAAA,SAAA;AACA,SAAA,cAAA;AAEhB,SAAK,kBAAkB,qBAAqB,4BAA4B,KAAK,UAAU;AAAA,EACxF;AAAA,MAEW,aAAa;AACvB,WAAO,KAAK,WAAW;AAAA,EACxB;AACD;;"}
1
+ {"version":3,"file":"EntitySubTreeMarker.js","sources":["../../../src/markers/EntitySubTreeMarker.ts"],"sourcesContent":["import type { Environment } from '../dao'\nimport type { QualifiedSingleEntity, UnconstrainedQualifiedSingleEntity } from '../treeParameters'\nimport type { EntityFieldMarkersContainer } from './EntityFieldMarkersContainer'\nimport { PlaceholderGenerator } from './PlaceholderGenerator'\n\nexport class EntitySubTreeMarker {\n\tpublic readonly placeholderName: string\n\n\tpublic constructor(\n\t\tpublic readonly parameters: QualifiedSingleEntity | UnconstrainedQualifiedSingleEntity,\n\t\tpublic readonly fields: EntityFieldMarkersContainer,\n\t\tpublic readonly environment: Environment,\n\t) {\n\t\tthis.placeholderName = PlaceholderGenerator.getEntitySubTreePlaceholder(this.parameters, this.environment)\n\t}\n\n\tpublic get entityName() {\n\t\treturn this.parameters.entityName\n\t}\n}\n"],"names":[],"mappings":";;;;;;;AAKO,MAAM,oBAAoB;AAAA,EAGzB,YACU,YACA,QACA,aACf;AANc;AAGC,SAAA,aAAA;AACA,SAAA,SAAA;AACA,SAAA,cAAA;AAEhB,SAAK,kBAAkB,qBAAqB,4BAA4B,KAAK,YAAY,KAAK,WAAW;AAAA,EAC1G;AAAA,MAEW,aAAa;AACvB,WAAO,KAAK,WAAW;AAAA,EACxB;AACD;;"}
@@ -9,11 +9,11 @@ class PlaceholderGenerator {
9
9
  static getHasManyRelationPlaceholder(relation) {
10
10
  return `${relation.field}_${Hashing.hashHasManyRelation(relation)}`;
11
11
  }
12
- static getEntitySubTreePlaceholder(subTreeParameters) {
13
- return `est_${Hashing.hashEntitySubTreeParameters(subTreeParameters)}`;
12
+ static getEntitySubTreePlaceholder(subTreeParameters, environment) {
13
+ return `est_${Hashing.hashEntitySubTreeParameters(subTreeParameters, environment)}`;
14
14
  }
15
- static getEntityListSubTreePlaceholder(subTreeParameters) {
16
- return `lst_${Hashing.hashEntityListSubTreeParameters(subTreeParameters)}`;
15
+ static getEntityListSubTreePlaceholder(subTreeParameters, environment) {
16
+ return `lst_${Hashing.hashEntityListSubTreeParameters(subTreeParameters, environment)}`;
17
17
  }
18
18
  }
19
19
  export { PlaceholderGenerator };
@@ -1 +1 @@
1
- {"version":3,"file":"PlaceholderGenerator.js","sources":["../../../src/markers/PlaceholderGenerator.ts"],"sourcesContent":["import type {\n\tFieldName,\n\tHasManyRelation,\n\tHasOneRelation,\n\tQualifiedEntityList,\n\tQualifiedSingleEntity,\n\tUnconstrainedQualifiedEntityList,\n\tUnconstrainedQualifiedSingleEntity,\n} from '../treeParameters'\nimport { Hashing } from '../utils'\n\nexport class PlaceholderGenerator {\n\tpublic static getFieldPlaceholder(fieldName: FieldName): string {\n\t\treturn fieldName\n\t}\n\n\tpublic static getHasOneRelationPlaceholder(relation: HasOneRelation): string {\n\t\treturn `${relation.field}_${Hashing.hashHasOneRelation(relation)}`\n\t}\n\n\tpublic static getHasManyRelationPlaceholder(relation: HasManyRelation): string {\n\t\treturn `${relation.field}_${Hashing.hashHasManyRelation(relation)}`\n\t}\n\n\tpublic static getEntitySubTreePlaceholder(\n\t\tsubTreeParameters: QualifiedSingleEntity | UnconstrainedQualifiedSingleEntity,\n\t): string {\n\t\treturn `est_${Hashing.hashEntitySubTreeParameters(subTreeParameters)}`\n\t}\n\n\tpublic static getEntityListSubTreePlaceholder(\n\t\tsubTreeParameters: QualifiedEntityList | UnconstrainedQualifiedEntityList,\n\t): string {\n\t\treturn `lst_${Hashing.hashEntityListSubTreeParameters(subTreeParameters)}`\n\t}\n}\n"],"names":[],"mappings":";AAWO,MAAM,qBAAqB;AAAA,SACnB,oBAAoB,WAA8B;AACxD,WAAA;AAAA,EACR;AAAA,SAEc,6BAA6B,UAAkC;AAC5E,WAAO,GAAG,SAAS,SAAS,QAAQ,mBAAmB,QAAQ;AAAA,EAChE;AAAA,SAEc,8BAA8B,UAAmC;AAC9E,WAAO,GAAG,SAAS,SAAS,QAAQ,oBAAoB,QAAQ;AAAA,EACjE;AAAA,SAEc,4BACb,mBACS;AACF,WAAA,OAAO,QAAQ,4BAA4B,iBAAiB;AAAA,EACpE;AAAA,SAEc,gCACb,mBACS;AACF,WAAA,OAAO,QAAQ,gCAAgC,iBAAiB;AAAA,EACxE;AACD;;"}
1
+ {"version":3,"file":"PlaceholderGenerator.js","sources":["../../../src/markers/PlaceholderGenerator.ts"],"sourcesContent":["import type {\n\tFieldName,\n\tHasManyRelation,\n\tHasOneRelation,\n\tQualifiedEntityList,\n\tQualifiedSingleEntity,\n\tUnconstrainedQualifiedEntityList,\n\tUnconstrainedQualifiedSingleEntity,\n} from '../treeParameters'\nimport { Hashing } from '../utils'\nimport { Environment } from '../dao'\n\nexport class PlaceholderGenerator {\n\tpublic static getFieldPlaceholder(fieldName: FieldName): string {\n\t\treturn fieldName\n\t}\n\n\tpublic static getHasOneRelationPlaceholder(relation: HasOneRelation): string {\n\t\treturn `${relation.field}_${Hashing.hashHasOneRelation(relation)}`\n\t}\n\n\tpublic static getHasManyRelationPlaceholder(relation: HasManyRelation): string {\n\t\treturn `${relation.field}_${Hashing.hashHasManyRelation(relation)}`\n\t}\n\n\tpublic static getEntitySubTreePlaceholder(\n\t\tsubTreeParameters: QualifiedSingleEntity | UnconstrainedQualifiedSingleEntity,\n\t\tenvironment: Environment,\n\t): string {\n\t\treturn `est_${Hashing.hashEntitySubTreeParameters(subTreeParameters, environment)}`\n\t}\n\n\tpublic static getEntityListSubTreePlaceholder(\n\t\tsubTreeParameters: QualifiedEntityList | UnconstrainedQualifiedEntityList,\n\t\tenvironment: Environment,\n\t): string {\n\t\treturn `lst_${Hashing.hashEntityListSubTreeParameters(subTreeParameters, environment)}`\n\t}\n}\n"],"names":[],"mappings":";AAYO,MAAM,qBAAqB;AAAA,SACnB,oBAAoB,WAA8B;AACxD,WAAA;AAAA,EACR;AAAA,SAEc,6BAA6B,UAAkC;AAC5E,WAAO,GAAG,SAAS,SAAS,QAAQ,mBAAmB,QAAQ;AAAA,EAChE;AAAA,SAEc,8BAA8B,UAAmC;AAC9E,WAAO,GAAG,SAAS,SAAS,QAAQ,oBAAoB,QAAQ;AAAA,EACjE;AAAA,SAEc,4BACb,mBACA,aACS;AACT,WAAO,OAAO,QAAQ,4BAA4B,mBAAmB,WAAW;AAAA,EACjF;AAAA,SAEc,gCACb,mBACA,aACS;AACT,WAAO,OAAO,QAAQ,gCAAgC,mBAAmB,WAAW;AAAA,EACrF;AACD;;"}
@@ -19,9 +19,13 @@ class Hashing {
19
19
  ];
20
20
  return Hashing.hashArray(where);
21
21
  }
22
- static hashEntityListSubTreeParameters(parameters) {
22
+ static hashEntityListSubTreeParameters(parameters, environment) {
23
23
  if (parameters.isCreating) {
24
- return Hashing.hashArray([parameters.isCreating, parameters.entityName]);
24
+ return Hashing.hashArray([
25
+ parameters.isCreating,
26
+ parameters.entityName,
27
+ environment.getAllVariables()
28
+ ]);
25
29
  }
26
30
  return Hashing.hashArray([
27
31
  parameters.isCreating,
@@ -29,14 +33,25 @@ class Hashing {
29
33
  parameters.filter,
30
34
  parameters.orderBy,
31
35
  parameters.offset,
32
- parameters.limit
36
+ parameters.limit,
37
+ environment.getAllVariables()
33
38
  ]);
34
39
  }
35
- static hashEntitySubTreeParameters(parameters) {
40
+ static hashEntitySubTreeParameters(parameters, environment) {
36
41
  if (parameters.isCreating) {
37
- return Hashing.hashArray([parameters.isCreating, parameters.entityName]);
42
+ return Hashing.hashArray([
43
+ parameters.isCreating,
44
+ parameters.entityName,
45
+ environment.getAllVariables()
46
+ ]);
38
47
  }
39
- return Hashing.hashArray([parameters.isCreating, parameters.where, parameters.entityName, parameters.filter]);
48
+ return Hashing.hashArray([
49
+ parameters.isCreating,
50
+ parameters.where,
51
+ parameters.entityName,
52
+ parameters.filter,
53
+ environment.getAllVariables()
54
+ ]);
40
55
  }
41
56
  static hashArray(array) {
42
57
  const json = array.map((item) => JSON.stringify(item)).join("_");
@@ -1 +1 @@
1
- {"version":3,"file":"Hashing.js","sources":["../../../src/utils/Hashing.ts"],"sourcesContent":["import type {\n\tFilter,\n\tHasManyRelation,\n\tHasOneRelation,\n\tOrderBy,\n\tQualifiedEntityList,\n\tQualifiedSingleEntity,\n\tUnconstrainedQualifiedEntityList,\n\tUnconstrainedQualifiedSingleEntity,\n\tUniqueWhere,\n} from '../treeParameters'\n\n// TODO update hashing so that for offset, 0 == undefined\nexport class Hashing {\n\tpublic static hashHasOneRelation(relation: HasOneRelation): number {\n\t\tconst where: Array<Filter | UniqueWhere | string | undefined> = [\n\t\t\t'upToOne',\n\t\t\trelation.field,\n\t\t\trelation.filter,\n\t\t\trelation.reducedBy,\n\t\t]\n\n\t\treturn Hashing.hashArray(where)\n\t}\n\n\tpublic static hashHasManyRelation(relation: HasManyRelation): number {\n\t\tconst where: Array<Filter | UniqueWhere | OrderBy | string | number | undefined> = [\n\t\t\t'possiblyMany',\n\t\t\trelation.field,\n\t\t\trelation.filter,\n\t\t\t'offset' in relation ? relation.offset : undefined,\n\t\t\t'limit' in relation ? relation.limit : undefined,\n\t\t\t'orderBy' in relation ? relation.orderBy : undefined,\n\t\t]\n\n\t\treturn Hashing.hashArray(where)\n\t}\n\n\tpublic static hashEntityListSubTreeParameters(\n\t\tparameters: QualifiedEntityList | UnconstrainedQualifiedEntityList,\n\t): number {\n\t\tif (parameters.isCreating) {\n\t\t\treturn Hashing.hashArray([parameters.isCreating, parameters.entityName])\n\t\t}\n\t\treturn Hashing.hashArray([\n\t\t\tparameters.isCreating,\n\t\t\tparameters.entityName,\n\t\t\tparameters.filter,\n\t\t\tparameters.orderBy,\n\t\t\tparameters.offset,\n\t\t\tparameters.limit,\n\t\t])\n\t}\n\n\tpublic static hashEntitySubTreeParameters(\n\t\tparameters: QualifiedSingleEntity | UnconstrainedQualifiedSingleEntity,\n\t): number {\n\t\tif (parameters.isCreating) {\n\t\t\treturn Hashing.hashArray([parameters.isCreating, parameters.entityName])\n\t\t}\n\t\treturn Hashing.hashArray([parameters.isCreating, parameters.where, parameters.entityName, parameters.filter])\n\t}\n\n\tprivate static hashArray(array: any[]): number {\n\t\tconst json = array.map(item => JSON.stringify(item)).join('_')\n\t\treturn Hashing.hash(json)\n\t}\n\n\t// Taken from Java\n\tpublic static hash(str: string): number {\n\t\tlet hash = 0\n\t\tif (str.length === 0) {\n\t\t\treturn hash\n\t\t}\n\t\tfor (let i = 0; i < str.length; i++) {\n\t\t\thash = (hash << 5) - hash + str.charCodeAt(i)\n\t\t\thash = hash & hash // Convert to 32bit integer\n\t\t}\n\t\treturn Math.abs(hash)\n\t}\n}\n"],"names":[],"mappings":"AAaO,MAAM,QAAQ;AAAA,SACN,mBAAmB,UAAkC;AAClE,UAAM,QAA0D;AAAA,MAC/D;AAAA,MACA,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,IAAA;AAGH,WAAA,QAAQ,UAAU,KAAK;AAAA,EAC/B;AAAA,SAEc,oBAAoB,UAAmC;AACpE,UAAM,QAA6E;AAAA,MAClF;AAAA,MACA,SAAS;AAAA,MACT,SAAS;AAAA,MACT,YAAY,WAAW,SAAS,SAAS;AAAA,MACzC,WAAW,WAAW,SAAS,QAAQ;AAAA,MACvC,aAAa,WAAW,SAAS,UAAU;AAAA,IAAA;AAGrC,WAAA,QAAQ,UAAU,KAAK;AAAA,EAC/B;AAAA,SAEc,gCACb,YACS;AACT,QAAI,WAAW,YAAY;AAC1B,aAAO,QAAQ,UAAU,CAAC,WAAW,YAAY,WAAW,UAAU,CAAC;AAAA,IACxE;AACA,WAAO,QAAQ,UAAU;AAAA,MACxB,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,IAAA,CACX;AAAA,EACF;AAAA,SAEc,4BACb,YACS;AACT,QAAI,WAAW,YAAY;AAC1B,aAAO,QAAQ,UAAU,CAAC,WAAW,YAAY,WAAW,UAAU,CAAC;AAAA,IACxE;AACO,WAAA,QAAQ,UAAU,CAAC,WAAW,YAAY,WAAW,OAAO,WAAW,YAAY,WAAW,MAAM,CAAC;AAAA,EAC7G;AAAA,SAEe,UAAU,OAAsB;AACxC,UAAA,OAAO,MAAM,IAAI,CAAQ,SAAA,KAAK,UAAU,IAAI,CAAC,EAAE,KAAK,GAAG;AACtD,WAAA,QAAQ,KAAK,IAAI;AAAA,EACzB;AAAA,SAGc,KAAK,KAAqB;AACvC,QAAI,OAAO;AACP,QAAA,IAAI,WAAW,GAAG;AACd,aAAA;AAAA,IACR;AACA,aAAS,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK;AACpC,aAAgB,SAAA,KAAK,OAAO,IAAI,WAAW,CAAC;AAC5C,aAAO,OAAO;AAAA,IACf;AACO,WAAA,KAAK,IAAI,IAAI;AAAA,EACrB;AACD;;"}
1
+ {"version":3,"file":"Hashing.js","sources":["../../../src/utils/Hashing.ts"],"sourcesContent":["import type {\n\tHasManyRelation,\n\tHasOneRelation,\n\tQualifiedEntityList,\n\tQualifiedSingleEntity,\n\tUnconstrainedQualifiedEntityList,\n\tUnconstrainedQualifiedSingleEntity,\n} from '../treeParameters'\nimport { Environment } from '../dao'\n\n// TODO update hashing so that for offset, 0 == undefined\nexport class Hashing {\n\tpublic static hashHasOneRelation(relation: HasOneRelation): number {\n\t\tconst where = [\n\t\t\t'upToOne',\n\t\t\trelation.field,\n\t\t\trelation.filter,\n\t\t\trelation.reducedBy,\n\t\t]\n\n\t\treturn Hashing.hashArray(where)\n\t}\n\n\tpublic static hashHasManyRelation(relation: HasManyRelation): number {\n\t\tconst where = [\n\t\t\t'possiblyMany',\n\t\t\trelation.field,\n\t\t\trelation.filter,\n\t\t\t'offset' in relation ? relation.offset : undefined,\n\t\t\t'limit' in relation ? relation.limit : undefined,\n\t\t\t'orderBy' in relation ? relation.orderBy : undefined,\n\t\t]\n\n\t\treturn Hashing.hashArray(where)\n\t}\n\n\tpublic static hashEntityListSubTreeParameters(\n\t\tparameters: QualifiedEntityList | UnconstrainedQualifiedEntityList,\n\t\tenvironment: Environment,\n\t): number {\n\t\tif (parameters.isCreating) {\n\t\t\treturn Hashing.hashArray([\n\t\t\t\tparameters.isCreating,\n\t\t\t\tparameters.entityName,\n\t\t\t\tenvironment.getAllVariables(),\n\t\t\t])\n\t\t}\n\t\treturn Hashing.hashArray([\n\t\t\tparameters.isCreating,\n\t\t\tparameters.entityName,\n\t\t\tparameters.filter,\n\t\t\tparameters.orderBy,\n\t\t\tparameters.offset,\n\t\t\tparameters.limit,\n\t\t\tenvironment.getAllVariables(),\n\t\t])\n\t}\n\n\tpublic static hashEntitySubTreeParameters(\n\t\tparameters: QualifiedSingleEntity | UnconstrainedQualifiedSingleEntity,\n\t\tenvironment: Environment,\n\t): number {\n\t\tif (parameters.isCreating) {\n\t\t\treturn Hashing.hashArray([\n\t\t\t\tparameters.isCreating,\n\t\t\t\tparameters.entityName,\n\t\t\t\tenvironment.getAllVariables(),\n\t\t\t])\n\t\t}\n\t\treturn Hashing.hashArray([\n\t\t\tparameters.isCreating,\n\t\t\tparameters.where,\n\t\t\tparameters.entityName,\n\t\t\tparameters.filter,\n\t\t\tenvironment.getAllVariables(),\n\t\t])\n\t}\n\n\tprivate static hashArray(array: any[]): number {\n\t\tconst json = array.map(item => JSON.stringify(item)).join('_')\n\t\treturn Hashing.hash(json)\n\t}\n\n\t// Taken from Java\n\tpublic static hash(str: string): number {\n\t\tlet hash = 0\n\t\tif (str.length === 0) {\n\t\t\treturn hash\n\t\t}\n\t\tfor (let i = 0; i < str.length; i++) {\n\t\t\thash = (hash << 5) - hash + str.charCodeAt(i)\n\t\t\thash = hash & hash // Convert to 32bit integer\n\t\t}\n\t\treturn Math.abs(hash)\n\t}\n}\n"],"names":[],"mappings":"AAWO,MAAM,QAAQ;AAAA,SACN,mBAAmB,UAAkC;AAClE,UAAM,QAAQ;AAAA,MACb;AAAA,MACA,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,IAAA;AAGH,WAAA,QAAQ,UAAU,KAAK;AAAA,EAC/B;AAAA,SAEc,oBAAoB,UAAmC;AACpE,UAAM,QAAQ;AAAA,MACb;AAAA,MACA,SAAS;AAAA,MACT,SAAS;AAAA,MACT,YAAY,WAAW,SAAS,SAAS;AAAA,MACzC,WA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back } from "react";
2
2
  import { useAccessorUpdateSubscription } from "./useAccessorUpdateSubscription.js";
3
3
  import { useEntityListSubTreeParameters } from "./useEntityListSubTreeParameters.js";
4
4
  import { useGetEntityListSubTree } from "./useGetEntityListSubTree.js";
5
- const useEntityListSubTree = (qualifiedEntityList) => {
5
+ const useEntityListSubTree = (qualifiedEntityList, ...treeId) => {
6
6
  const getSubTree = useGetEntityListSubTree();
7
7
  const parameters = useEntityListSubTreeParameters(qualifiedEntityList);
8
- const getAccessor = useCallback(() => getSubTree(parameters), [getSubTree, parameters]);
8
+ const hasTreeId = treeId.length > 0;
9
+ const treeIdVal = treeId[0];
10
+ const getAccessor = useCallback(() => getSubTree(parameters, ...hasTreeId ? [treeIdVal] : []), [getSubTree, hasTreeId, parameters, treeIdVal]);
9
11
  return useAccessorUpdateSubscription(getAccessor);
10
12
  };
11
13
  export { useEntityListSubTree };
@@ -1 +1 @@
1
- {"version":3,"file":"useEntityListSubTree.js","sources":["../../../src/accessorPropagation/useEntityListSubTree.ts"],"sourcesContent":["import { useCallback } from 'react'\nimport type { EntityListAccessor } from '../accessors'\nimport type { Alias, SugaredQualifiedEntityList, SugaredUnconstrainedQualifiedEntityList } from '../treeParameters'\nimport { useAccessorUpdateSubscription } from './useAccessorUpdateSubscription'\nimport { useEntityListSubTreeParameters } from './useEntityListSubTreeParameters'\nimport { useGetEntityListSubTree } from './useGetEntityListSubTree'\n\nexport const useEntityListSubTree = (\n\tqualifiedEntityList: Alias | SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList,\n): EntityListAccessor => {\n\tconst getSubTree = useGetEntityListSubTree()\n\tconst parameters = useEntityListSubTreeParameters(qualifiedEntityList)\n\tconst getAccessor = useCallback(() => getSubTree(parameters), [getSubTree, parameters])\n\n\t// if (typeof parameters !== 'string' && parameters.value.hasOneRelationPath.length) {\n\t// \tthrow new BindingError(`useEntityListSubTree: cannot use hasOneRelationPath!`)\n\t// }\n\n\treturn useAccessorUpdateSubscription(getAccessor)\n}\n"],"names":[],"mappings":";;;;AAOa,MAAA,uBAAuB,CACnC,wBACwB;AACxB,QAAM,aAAa;AACb,QAAA,aAAa,+BAA+B,mBAAmB;AAC/D,QAAA,cAAc,YAAY,MAAM,WAAW,UAAU,GAAG,CAAC,YAAY,UAAU,CAAC;AAMtF,SAAO,8BAA8B,WAAW;AACjD;;"}
1
+ {"version":3,"file":"useEntityListSubTree.js","sources":["../../../src/accessorPropagation/useEntityListSubTree.ts"],"sourcesContent":["import { useCallback } from 'react'\nimport type { EntityListAccessor } from '../accessors'\nimport type { Alias, SugaredQualifiedEntityList, SugaredUnconstrainedQualifiedEntityList } from '../treeParameters'\nimport { useAccessorUpdateSubscription } from './useAccessorUpdateSubscription'\nimport { useEntityListSubTreeParameters } from './useEntityListSubTreeParameters'\nimport { useGetEntityListSubTree } from './useGetEntityListSubTree'\nimport { TreeRootId } from '../treeParameters'\n\nexport const useEntityListSubTree = (\n\tqualifiedEntityList: Alias | SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList,\n\t...treeId: [TreeRootId | undefined] | []\n): EntityListAccessor => {\n\tconst getSubTree = useGetEntityListSubTree()\n\tconst parameters = useEntityListSubTreeParameters(qualifiedEntityList)\n\tconst hasTreeId = treeId.length > 0\n\tconst treeIdVal = treeId[0]\n\tconst getAccessor = useCallback(\n\t\t() => getSubTree(parameters, ...(hasTreeId ? [treeIdVal] : [])),\n\t\t[getSubTree, hasTreeId, parameters, treeIdVal],\n\t)\n\n\t// if (typeof parameters !== 'string' && parameters.value.hasOneRelationPath.length) {\n\t// \tthrow new BindingError(`useEntityListSubTree: cannot use hasOneRelationPath!`)\n\t// }\n\n\treturn useAccessorUpdateSubscription(getAccessor)\n}\n"],"names":[],"mappings":";;;;AAQa,MAAA,uBAAuB,CACnC,wBACG,WACqB;AACxB,QAAM,aAAa;AACb,QAAA,aAAa,+BAA+B,mBAAmB;AAC/D,QAAA,YAAY,OAAO,SAAS;AAClC,QAAM,YAAY,OAAO;AACzB,QAAM,cAAc,YACnB,MAAM,WAAW,YAAY,GAAI,YAAY,CAAC,SAAS,IAAI,CAAG,CAAA,GAC9D,CAAC,YAAY,WAAW,YAAY,SAAS,CAC9C;AAMA,SAAO,8BAA8B,WAAW;AACjD;;"}
@@ -2,10 +2,12 @@ import { useCallback } from "react";
2
2
  import { useAccessorUpdateSubscription } from "./useAccessorUpdateSubscription.js";
3
3
  import { useEntitySubTreeParameters } from "./useEntitySubTreeParameters.js";
4
4
  import { useGetEntitySubTree } from "./useGetEntitySubTree.js";
5
- const useEntitySubTree = (qualifiedSingleEntity) => {
5
+ const useEntitySubTree = (qualifiedSingleEntity, ...treeId) => {
6
6
  const getSubTree = useGetEntitySubTree();
7
7
  const parameters = useEntitySubTreeParameters(qualifiedSingleEntity);
8
- const getAccessor = useCallback(() => getSubTree(parameters), [getSubTree, parameters]);
8
+ const hasTreeId = treeId.length > 0;
9
+ const treeIdVal = treeId[0];
10
+ const getAccessor = useCallback(() => getSubTree(parameters, ...hasTreeId ? [treeIdVal] : []), [getSubTree, hasTreeId, parameters, treeIdVal]);
9
11
  return useAccessorUpdateSubscription(getAccessor);
10
12
  };
11
13
  export { useEntitySubTree };
@@ -1 +1 @@
1
- {"version":3,"file":"useEntitySubTree.js","sources":["../../../src/accessorPropagation/useEntitySubTree.ts"],"sourcesContent":["import { useCallback } from 'react'\nimport type { EntityAccessor } from '../accessors'\nimport type { Alias, SugaredQualifiedSingleEntity, SugaredUnconstrainedQualifiedSingleEntity } from '../treeParameters'\nimport { useAccessorUpdateSubscription } from './useAccessorUpdateSubscription'\nimport { useEntitySubTreeParameters } from './useEntitySubTreeParameters'\nimport { useGetEntitySubTree } from './useGetEntitySubTree'\n\nexport const useEntitySubTree = (\n\tqualifiedSingleEntity: Alias | SugaredQualifiedSingleEntity | SugaredUnconstrainedQualifiedSingleEntity,\n): EntityAccessor => {\n\tconst getSubTree = useGetEntitySubTree()\n\tconst parameters = useEntitySubTreeParameters(qualifiedSingleEntity)\n\tconst getAccessor = useCallback(() => getSubTree(parameters), [getSubTree, parameters])\n\n\t// if (typeof parameters !== 'string' && parameters.hasOneRelationPath.length) {\n\t// \tthrow new BindingError(`useEntitySubTree: cannot use hasOneRelationPath!`)\n\t// }\n\treturn useAccessorUpdateSubscription(getAccessor)\n}\n"],"names":[],"mappings":";;;;AAOa,MAAA,mBAAmB,CAC/B,0BACoB;AACpB,QAAM,aAAa;AACb,QAAA,aAAa,2BAA2B,qBAAqB;AAC7D,QAAA,cAAc,YAAY,MAAM,WAAW,UAAU,GAAG,CAAC,YAAY,UAAU,CAAC;AAKtF,SAAO,8BAA8B,WAAW;AACjD;;"}
1
+ {"version":3,"file":"useEntitySubTree.js","sources":["../../../src/accessorPropagation/useEntitySubTree.ts"],"sourcesContent":["import { useCallback } from 'react'\nimport type { EntityAccessor } from '../accessors'\nimport type { Alias, SugaredQualifiedSingleEntity, SugaredUnconstrainedQualifiedSingleEntity } from '../treeParameters'\nimport { useAccessorUpdateSubscription } from './useAccessorUpdateSubscription'\nimport { useEntitySubTreeParameters } from './useEntitySubTreeParameters'\nimport { useGetEntitySubTree } from './useGetEntitySubTree'\nimport { TreeRootId } from '../treeParameters'\n\nexport const useEntitySubTree = (\n\tqualifiedSingleEntity: Alias | SugaredQualifiedSingleEntity | SugaredUnconstrainedQualifiedSingleEntity,\n\t...treeId: [TreeRootId | undefined] | []\n): EntityAccessor => {\n\tconst getSubTree = useGetEntitySubTree()\n\tconst parameters = useEntitySubTreeParameters(qualifiedSingleEntity)\n\tconst hasTreeId = treeId.length > 0\n\tconst treeIdVal = treeId[0]\n\tconst getAccessor = useCallback(\n\t\t() => getSubTree(parameters, ...(hasTreeId ? [treeIdVal] : [])),\n\t\t[getSubTree, hasTreeId, parameters, treeIdVal],\n\t)\n\n\t// if (typeof parameters !== 'string' && parameters.hasOneRelationPath.length) {\n\t// \tthrow new BindingError(`useEntitySubTree: cannot use hasOneRelationPath!`)\n\t// }\n\treturn useAccessorUpdateSubscription(getAccessor)\n}\n"],"names":[],"mappings":";;;;AAQa,MAAA,mBAAmB,CAC/B,0BACG,WACiB;AACpB,QAAM,aAAa;AACb,QAAA,aAAa,2BAA2B,qBAAqB;AAC7D,QAAA,YAAY,OAAO,SAAS;AAClC,QAAM,YAAY,OAAO;AACzB,QAAM,cAAc,YACnB,MAAM,WAAW,YAAY,GAAI,YAAY,CAAC,SAAS,IAAI,CAAG,CAAA,GAC9D,CAAC,YAAY,WAAW,YAAY,SAAS,CAC9C;AAKA,SAAO,8BAA8B,WAAW;AACjD;;"}