@contember/binding 1.0.0 → 1.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/dist/development/core/DataBinding.js +18 -17
  2. package/dist/development/core/DataBinding.js.map +1 -1
  3. package/dist/development/core/MarkerComparator.js +1 -1
  4. package/dist/development/core/MarkerMerger.js +1 -4
  5. package/dist/development/core/MarkerMerger.js.map +1 -1
  6. package/dist/development/core/StateInitializer.js +1 -3
  7. package/dist/development/core/StateInitializer.js.map +1 -1
  8. package/dist/development/core/VariableInputTransformer.js +4 -1
  9. package/dist/development/core/VariableInputTransformer.js.map +1 -1
  10. package/dist/development/core/operations/EntityOperations.js +1 -1
  11. package/dist/development/core/schema/Schema.js +3 -0
  12. package/dist/development/core/schema/Schema.js.map +1 -1
  13. package/dist/development/coreComponents/EntityListSubTree.js +4 -12
  14. package/dist/development/coreComponents/EntityListSubTree.js.map +1 -1
  15. package/dist/development/coreComponents/EntitySubTree.js +4 -22
  16. package/dist/development/coreComponents/EntitySubTree.js.map +1 -1
  17. package/dist/development/coreComponents/Field.js +5 -1
  18. package/dist/development/coreComponents/Field.js.map +1 -1
  19. package/dist/development/coreComponents/HasMany.js +3 -5
  20. package/dist/development/coreComponents/HasMany.js.map +1 -1
  21. package/dist/development/coreComponents/HasOne.js +3 -5
  22. package/dist/development/coreComponents/HasOne.js.map +1 -1
  23. package/dist/development/dao/Environment.js +147 -94
  24. package/dist/development/dao/Environment.js.map +1 -1
  25. package/dist/development/dao/TreeNodeEnvironmentFactory.js +159 -0
  26. package/dist/development/dao/TreeNodeEnvironmentFactory.js.map +1 -0
  27. package/dist/development/queryLanguage/MarkerFactory.js +4 -3
  28. package/dist/development/queryLanguage/MarkerFactory.js.map +1 -1
  29. package/dist/development/queryLanguage/Parser.js +18 -6
  30. package/dist/development/queryLanguage/Parser.js.map +1 -1
  31. package/dist/production/core/DataBinding.js +18 -8
  32. package/dist/production/core/DataBinding.js.map +1 -1
  33. package/dist/production/core/MarkerComparator.js +1 -1
  34. package/dist/production/core/MarkerMerger.js +1 -4
  35. package/dist/production/core/MarkerMerger.js.map +1 -1
  36. package/dist/production/core/StateInitializer.js +1 -3
  37. package/dist/production/core/StateInitializer.js.map +1 -1
  38. package/dist/production/core/VariableInputTransformer.js +4 -1
  39. package/dist/production/core/VariableInputTransformer.js.map +1 -1
  40. package/dist/production/core/operations/EntityOperations.js +1 -1
  41. package/dist/production/core/schema/Schema.js +3 -0
  42. package/dist/production/core/schema/Schema.js.map +1 -1
  43. package/dist/production/coreComponents/EntityListSubTree.js +4 -12
  44. package/dist/production/coreComponents/EntityListSubTree.js.map +1 -1
  45. package/dist/production/coreComponents/EntitySubTree.js +4 -22
  46. package/dist/production/coreComponents/EntitySubTree.js.map +1 -1
  47. package/dist/production/coreComponents/Field.js +5 -1
  48. package/dist/production/coreComponents/Field.js.map +1 -1
  49. package/dist/production/coreComponents/HasMany.js +3 -5
  50. package/dist/production/coreComponents/HasMany.js.map +1 -1
  51. package/dist/production/coreComponents/HasOne.js +3 -5
  52. package/dist/production/coreComponents/HasOne.js.map +1 -1
  53. package/dist/production/dao/Environment.js +147 -94
  54. package/dist/production/dao/Environment.js.map +1 -1
  55. package/dist/production/dao/TreeNodeEnvironmentFactory.js +159 -0
  56. package/dist/production/dao/TreeNodeEnvironmentFactory.js.map +1 -0
  57. package/dist/production/queryLanguage/MarkerFactory.js +4 -3
  58. package/dist/production/queryLanguage/MarkerFactory.js.map +1 -1
  59. package/dist/production/queryLanguage/Parser.js +15 -6
  60. package/dist/production/queryLanguage/Parser.js.map +1 -1
  61. package/dist/types/accessorTree/MutationRequestResponse.d.ts +4 -0
  62. package/dist/types/accessorTree/MutationRequestResponse.d.ts.map +1 -1
  63. package/dist/types/accessorTree/QueryRequestResponse.d.ts +4 -0
  64. package/dist/types/accessorTree/QueryRequestResponse.d.ts.map +1 -1
  65. package/dist/types/accessorTree/RequestError.d.ts +9 -1
  66. package/dist/types/accessorTree/RequestError.d.ts.map +1 -1
  67. package/dist/types/core/DataBinding.d.ts.map +1 -1
  68. package/dist/types/core/MarkerMerger.d.ts.map +1 -1
  69. package/dist/types/core/StateInitializer.d.ts.map +1 -1
  70. package/dist/types/core/VariableInputTransformer.d.ts.map +1 -1
  71. package/dist/types/core/schema/Schema.d.ts +2 -0
  72. package/dist/types/core/schema/Schema.d.ts.map +1 -1
  73. package/dist/types/core/schema/index.d.ts +0 -1
  74. package/dist/types/core/schema/index.d.ts.map +1 -1
  75. package/dist/types/coreComponents/EntityListSubTree.d.ts +1 -1
  76. package/dist/types/coreComponents/EntityListSubTree.d.ts.map +1 -1
  77. package/dist/types/coreComponents/EntitySubTree.d.ts +1 -1
  78. package/dist/types/coreComponents/EntitySubTree.d.ts.map +1 -1
  79. package/dist/types/coreComponents/Field.d.ts.map +1 -1
  80. package/dist/types/coreComponents/HasMany.d.ts +1 -1
  81. package/dist/types/coreComponents/HasMany.d.ts.map +1 -1
  82. package/dist/types/coreComponents/HasOne.d.ts +1 -1
  83. package/dist/types/coreComponents/HasOne.d.ts.map +1 -1
  84. package/dist/types/dao/Environment.d.ts +82 -43
  85. package/dist/types/dao/Environment.d.ts.map +1 -1
  86. package/dist/types/dao/TreeNodeEnvironmentFactory.d.ts +19 -0
  87. package/dist/types/dao/TreeNodeEnvironmentFactory.d.ts.map +1 -0
  88. package/dist/types/queryLanguage/MarkerFactory.d.ts.map +1 -1
  89. package/dist/types/queryLanguage/Parser.d.ts.map +1 -1
  90. package/dist/types/tsconfig.tsbuildinfo +1 -1
  91. package/package.json +9 -6
  92. package/src/accessorTree/MutationRequestResponse.ts +1 -0
  93. package/src/accessorTree/QueryRequestResponse.ts +1 -0
  94. package/src/accessorTree/RequestError.ts +7 -1
  95. package/src/core/DataBinding.ts +23 -26
  96. package/src/core/MarkerMerger.ts +1 -4
  97. package/src/core/StateInitializer.ts +1 -3
  98. package/src/core/VariableInputTransformer.ts +7 -4
  99. package/src/core/schema/Schema.ts +5 -0
  100. package/src/core/schema/index.ts +0 -1
  101. package/src/coreComponents/EntityListSubTree.tsx +5 -16
  102. package/src/coreComponents/EntitySubTree.tsx +17 -32
  103. package/src/coreComponents/Field.tsx +4 -0
  104. package/src/coreComponents/HasMany.tsx +4 -6
  105. package/src/coreComponents/HasOne.tsx +6 -7
  106. package/src/dao/Environment.ts +221 -126
  107. package/src/dao/TreeNodeEnvironmentFactory.ts +228 -0
  108. package/src/queryLanguage/MarkerFactory.ts +5 -3
  109. package/src/queryLanguage/Parser.ts +24 -11
  110. package/dist/development/core/schema/SchemaValidator.js +0 -116
  111. package/dist/development/core/schema/SchemaValidator.js.map +0 -1
  112. package/dist/types/core/schema/SchemaValidator.d.ts +0 -14
  113. package/dist/types/core/schema/SchemaValidator.d.ts.map +0 -1
  114. package/src/core/schema/SchemaValidator.ts +0 -238
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@contember/binding",
3
3
  "license": "Apache-2.0",
4
- "version": "1.0.0",
4
+ "version": "1.1.0-alpha.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "main": "./dist/production/index.js",
@@ -19,11 +19,12 @@
19
19
  ],
20
20
  "typings": "./dist/types/index.d.ts",
21
21
  "dependencies": {
22
- "@contember/client": "1.0.0",
23
- "@contember/react-client": "1.0.0",
24
- "@contember/react-multipass-rendering": "1.0.0",
25
- "@contember/react-utils": "1.0.0",
22
+ "@contember/client": "1.1.0-alpha.0",
23
+ "@contember/react-client": "1.1.0-alpha.0",
24
+ "@contember/react-multipass-rendering": "1.1.0-alpha.0",
25
+ "@contember/react-utils": "1.1.0-alpha.0",
26
26
  "chevrotain": "6.5.0",
27
+ "fast-deep-equal": "^3.1.3",
27
28
  "js-levenshtein": "1.1.6",
28
29
  "uuid": "8.3.2"
29
30
  },
@@ -33,7 +34,9 @@
33
34
  },
34
35
  "devDependencies": {
35
36
  "@types/js-levenshtein": "1.1.0",
36
- "@types/uuid": "8.3.1"
37
+ "@types/uuid": "8.3.1",
38
+ "react": "^17",
39
+ "react-dom": "^17"
37
40
  },
38
41
  "scripts": {
39
42
  "build": "pnpm run build:js:dev && pnpm run build:js:prod",
@@ -52,4 +52,5 @@ export interface MutationTransactionResponse {
52
52
 
53
53
  export interface MutationRequestResponse {
54
54
  data: MutationTransactionResponse | null
55
+ errors?: { message: string, path?: string[] }[]
55
56
  }
@@ -16,4 +16,5 @@ export interface ReceivedDataTree<A = never> {
16
16
 
17
17
  export interface QueryRequestResponse<A = never> {
18
18
  data: ReceivedDataTree<A>
19
+ errors?: { message: string, path?: string[] }[]
19
20
  }
@@ -13,4 +13,10 @@ export interface UnknownErrorRequestError {
13
13
  type: 'unknownError'
14
14
  }
15
15
 
16
- export type RequestError = UnauthorizedRequestError | NetworkErrorRequestError | UnknownErrorRequestError
16
+ export interface GqlError {
17
+ type: 'gqlError'
18
+ query: string,
19
+ errors: { message: string, path?: string[] }[]
20
+ }
21
+
22
+ export type RequestError = UnauthorizedRequestError | NetworkErrorRequestError | GqlError | UnknownErrorRequestError
@@ -29,7 +29,7 @@ import { MarkerMerger } from './MarkerMerger'
29
29
  import { MarkerTreeGenerator } from './MarkerTreeGenerator'
30
30
  import { MutationGenerator } from './MutationGenerator'
31
31
  import { QueryGenerator } from './QueryGenerator'
32
- import { Schema, SchemaLoader, SchemaValidator } from './schema'
32
+ import { Schema, SchemaLoader } from './schema'
33
33
  import { StateIterator } from './state'
34
34
  import { StateInitializer } from './StateInitializer'
35
35
  import { TreeAugmenter } from './TreeAugmenter'
@@ -163,6 +163,15 @@ export class DataBinding {
163
163
  const mutationResponse: MutationRequestResponse = await this.contentApiClient.sendRequest(mutation, {
164
164
  signal,
165
165
  })
166
+
167
+ if (mutationResponse.errors !== undefined && mutationResponse.errors.length > 0) {
168
+ this.onError({
169
+ type: 'gqlError',
170
+ query: mutation,
171
+ errors: mutationResponse.errors,
172
+ })
173
+ }
174
+
166
175
  const mutationData = mutationResponse.data?.transaction ?? {}
167
176
  const aliases = Object.keys(mutationData)
168
177
  if (!mutationResponse.data) {
@@ -261,22 +270,14 @@ export class DataBinding {
261
270
  if (options.signal?.aborted) {
262
271
  return Promise.reject(DataBindingExtendAborted)
263
272
  }
264
- const markerTreeRoot = new MarkerTreeGenerator(newFragment, options.environment ?? this.environment).generate()
273
+ const schema = await this.getOrLoadSchema()
274
+ this.treeStore.setSchema(schema)
275
+ const markerTreeRoot = new MarkerTreeGenerator(newFragment, (options.environment ?? this.environment).withSchema(schema)).generate()
265
276
 
266
277
  if (this.treeStore.effectivelyHasTreeRoot(markerTreeRoot)) {
267
278
  // This isn't perfectly accurate as theoretically, we could already have all the data necessary but this
268
279
  // could still be false.
269
280
 
270
- const schema = await this.getOrLoadSchema()
271
- this.treeStore.setSchema(schema)
272
- if (import.meta.env.DEV) {
273
- // For most trees, checking this against the schema should be unnecessary since if we already effectively
274
- // have this tree root, then assuming everything we already have is valid, this should match the schema as well.
275
- // However, we might be dealing with an isCreating tree root which is completely new. Also, we can just lean
276
- // towards the safe side since developer machines can generally handle the potentially unnecessary check anyway.
277
- SchemaValidator.assertTreeValid(schema, markerTreeRoot)
278
- }
279
-
280
281
  return this.eventManager.syncOperation(() => {
281
282
  const newTreeRootId = this.getNewTreeRootId()
282
283
  this.treeAugmenter.extendTreeStates(newTreeRootId, markerTreeRoot)
@@ -332,20 +333,7 @@ export class DataBinding {
332
333
 
333
334
  const aggregateSignal = getCombinedSignal(pendingExtensions.map(extension => extension.options.signal))
334
335
 
335
- // Even if we don't have a schema yet, we'll still optimistically fire the request so as to prevent a waterfall
336
- // in the most likely case that things will go fine and the query does match the schema. If it doesn't, then we
337
- // just get a "400 Bad Request" but that's not enough to make us delay the happy path.
338
- const [aggregatePersistedData, schema] = await Promise.all([
339
- this.fetchPersistedData(aggregateMarkerTreeRoot, aggregateSignal),
340
- this.getOrLoadSchema(),
341
- ])
342
- this.treeStore.setSchema(schema)
343
-
344
- if (import.meta.env.DEV) {
345
- for (const extension of pendingExtensions) {
346
- SchemaValidator.assertTreeValid(schema, extension.markerTreeRoot)
347
- }
348
- }
336
+ const aggregatePersistedData = await this.fetchPersistedData(aggregateMarkerTreeRoot, aggregateSignal)
349
337
 
350
338
  if (aggregateSignal?.aborted) {
351
339
  return
@@ -383,6 +371,15 @@ export class DataBinding {
383
371
  }
384
372
  this.onError(metadataToRequestError(metadata as GraphQlClientFailedRequestMetadata))
385
373
  }
374
+
375
+ if (queryResponse && queryResponse.errors !== undefined && queryResponse.errors.length > 0) {
376
+ this.onError({
377
+ type: 'gqlError',
378
+ query: query ?? 'unknown query',
379
+ errors: queryResponse.errors,
380
+ })
381
+ }
382
+
386
383
  return queryResponse
387
384
  }
388
385
 
@@ -285,10 +285,7 @@ export class MarkerMerger {
285
285
  }
286
286
 
287
287
  public static mergeEnvironments(original: Environment, fresh: Environment): Environment {
288
- if (original === fresh) {
289
- return original
290
- }
291
- return original.putDelta(fresh.getAllNames())
288
+ return original.merge(fresh)
292
289
  }
293
290
 
294
291
  private static rejectRelationScalarCombo(fieldName: FieldName): never {
@@ -153,11 +153,9 @@ export class StateInitializer {
153
153
  if (!value || (value.type !== 'entityRealm' && value.type !== 'entityRealmStub')) {
154
154
  throw new BindingError()
155
155
  }
156
+ runtimeId = !(value.entity.id instanceof UnpersistedEntityDummyId) ? value.entity.id : new UnpersistedEntityDummyId()
156
157
  if (value.type === 'entityRealm') {
157
158
  subCopyFrom = value
158
- runtimeId = value.entity.id
159
- } else {
160
- runtimeId = new UnpersistedEntityDummyId()
161
159
  }
162
160
  }
163
161
  this.initializeFromHasOneRelationMarker(realm, field, runtimeId, subCopyFrom)
@@ -11,12 +11,15 @@ export class VariableInputTransformer {
11
11
  }
12
12
 
13
13
  public static transformVariableFieldValue(variableFieldValue: VariableFieldValue, environment: Environment): Scalar {
14
- const value = environment.getValueOrElse(variableFieldValue.variableName, undefined)
14
+ const value = environment.getVariableOrElse(variableFieldValue.variableName, undefined)
15
+ ?? environment.getParameterOrElse(variableFieldValue.variableName, undefined)
16
+
17
+ if (value === undefined) {
18
+ throw new BindingError(`Variable '${variableFieldValue.variableName}' not found.`)
19
+ }
15
20
 
16
21
  if (typeof value !== 'string' && typeof value !== 'boolean' && typeof value !== 'number' && value !== null) {
17
- throw new BindingError(
18
- `The value of the '${variableFieldValue.variableName}' must be a scalar or null, not '${typeof value}'.`,
19
- )
22
+ throw new BindingError(`The value of the '${variableFieldValue.variableName}' must be a scalar or null, not '${typeof value}'.`)
20
23
  }
21
24
  return value
22
25
  }
@@ -1,10 +1,15 @@
1
1
  import type { EntityName, FieldName } from '../../treeParameters'
2
2
  import type { SchemaField } from './SchemaField'
3
3
  import type { SchemaStore } from './SchemaStore'
4
+ import { SchemaEntity } from './SchemaEntity'
4
5
 
5
6
  export class Schema {
6
7
  public constructor(public readonly store: SchemaStore) {}
7
8
 
9
+ public getEntity(entityName: EntityName): SchemaEntity | undefined {
10
+ return this.store.entities.get(entityName)
11
+ }
12
+
8
13
  public getEntityField(entityName: EntityName, field: FieldName): SchemaField | undefined {
9
14
  return this.store.entities.get(entityName)?.fields.get(field)
10
15
  }
@@ -11,4 +11,3 @@ export * from './SchemaRelation'
11
11
  export * from './SchemaRelationOrderBy'
12
12
  export * from './SchemaStore'
13
13
  export * from './SchemaUniqueConstraint'
14
- export * from './SchemaValidator'
@@ -8,14 +8,15 @@ import {
8
8
  } from '../accessorPropagation'
9
9
  import { NIL_UUID, PRIMARY_KEY_NAME } from '../bindingTypes'
10
10
  import { Environment } from '../dao'
11
- import { MarkerFactory } from '../queryLanguage'
11
+ import { MarkerFactory, QueryLanguage } from '../queryLanguage'
12
12
  import type { SugaredQualifiedEntityList, SugaredUnconstrainedQualifiedEntityList, TreeRootId } from '../treeParameters'
13
13
  import { Component } from './Component'
14
14
  import { EntityList, EntityListBaseProps } from './EntityList'
15
15
  import { Field } from './Field'
16
+ import { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'
16
17
 
17
18
  export interface EntityListSubTreeAdditionalProps {
18
- variables?: Environment.DeltaFactory
19
+ variables?: Environment.ValuesMapWithFactory
19
20
  }
20
21
 
21
22
  export type EntityListSubTreeProps<ListProps, EntityProps> = {
@@ -65,20 +66,8 @@ export const EntityListSubTree = Component(
65
66
  </EntityList>
66
67
  ),
67
68
  generateEnvironment: (props, oldEnvironment) => {
68
- const newEnvironment =
69
- props.variables === undefined
70
- ? oldEnvironment
71
- : oldEnvironment.putDelta(Environment.generateDelta(oldEnvironment, props.variables))
72
-
73
- if (newEnvironment.hasName('rootWhere') || newEnvironment.hasName('rootWhereAsFilter')) {
74
- return newEnvironment
75
- }
76
-
77
- const rootWhere = { id: NIL_UUID } as const
78
- return newEnvironment.putDelta({
79
- rootWhere,
80
- rootWhereAsFilter: whereToFilter(rootWhere),
81
- })
69
+ const environment = oldEnvironment.withVariables(props.variables)
70
+ return TreeNodeEnvironmentFactory.createEnvironmentForEntityListSubtree(environment, props)
82
71
  },
83
72
  },
84
73
  'EntityListSubTree',
@@ -1,11 +1,10 @@
1
- import { whereToFilter } from '@contember/client'
2
1
  import { useConstantValueInvariant } from '@contember/react-utils'
3
2
  import { ReactElement, ReactNode, useCallback } from 'react'
4
3
  import { useAccessorUpdateSubscription, useEntitySubTreeParameters, useGetEntitySubTree } from '../accessorPropagation'
5
4
  import { SetOrderFieldOnCreate, SetOrderFieldOnCreateOwnProps } from '../accessorSorting'
6
- import { NIL_UUID, PRIMARY_KEY_NAME } from '../bindingTypes'
5
+ import { PRIMARY_KEY_NAME } from '../bindingTypes'
7
6
  import { Environment } from '../dao'
8
- import { MarkerFactory, QueryLanguage } from '../queryLanguage'
7
+ import { MarkerFactory } from '../queryLanguage'
9
8
  import type {
10
9
  SugaredQualifiedSingleEntity,
11
10
  SugaredUnconstrainedQualifiedSingleEntity,
@@ -14,18 +13,25 @@ import type {
14
13
  import { Component } from './Component'
15
14
  import { Entity } from './Entity'
16
15
  import { Field } from './Field'
16
+ import { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'
17
17
 
18
18
  export interface EntitySubTreeAdditionalProps {
19
- variables?: Environment.DeltaFactory
19
+ variables?: Environment.ValuesMapWithFactory
20
20
  }
21
21
 
22
22
  export type EntitySubTreeAdditionalCreationProps = {} | SetOrderFieldOnCreateOwnProps
23
23
 
24
- export type EntitySubTreeProps<EntityProps> = {
25
- treeRootId?: TreeRootId
26
- children?: ReactNode
27
- } & EntitySubTreeAdditionalProps &
28
- (SugaredQualifiedSingleEntity | (SugaredUnconstrainedQualifiedSingleEntity & EntitySubTreeAdditionalCreationProps))
24
+ export type EntitySubTreeProps<EntityProps> =
25
+ & {
26
+ treeRootId?: TreeRootId
27
+ children?: ReactNode
28
+ }
29
+ & EntitySubTreeAdditionalProps
30
+ & (
31
+ | SugaredQualifiedSingleEntity
32
+ | (SugaredUnconstrainedQualifiedSingleEntity & EntitySubTreeAdditionalCreationProps)
33
+ )
34
+
29
35
  export const EntitySubTree = Component(
30
36
  <EntityProps extends {}>(props: EntitySubTreeProps<EntityProps>) => {
31
37
  useConstantValueInvariant(props.isCreating, 'EntitySubTree: cannot update isCreating')
@@ -69,29 +75,8 @@ export const EntitySubTree = Component(
69
75
  </>
70
76
  ),
71
77
  generateEnvironment: (props, oldEnvironment) => {
72
- const newEnvironment =
73
- props.variables === undefined
74
- ? oldEnvironment
75
- : oldEnvironment.putDelta(Environment.generateDelta(oldEnvironment, props.variables))
76
-
77
- if (newEnvironment.hasName('rootWhere') || newEnvironment.hasName('rootWhereAsFilter')) {
78
- return newEnvironment
79
- }
80
-
81
- if (props.isCreating) {
82
- const rootWhere = { id: NIL_UUID } as const
83
- return newEnvironment.putDelta({
84
- rootWhere,
85
- rootWhereAsFilter: whereToFilter(rootWhere),
86
- rootShouldExists: 'no',
87
- })
88
- }
89
- const qualifiedSingleEntity = QueryLanguage.desugarQualifiedSingleEntity(props, newEnvironment, { missingSetOnCreate: 'fill' })
90
- return newEnvironment.putDelta({
91
- rootWhere: qualifiedSingleEntity.where,
92
- rootWhereAsFilter: whereToFilter(qualifiedSingleEntity.where),
93
- rootShouldExists: qualifiedSingleEntity.setOnCreate ? 'maybe' : 'yes',
94
- })
78
+ const environment = oldEnvironment.withVariables(props.variables)
79
+ return TreeNodeEnvironmentFactory.createEnvironmentForEntitySubtree(environment, props)
95
80
  },
96
81
  },
97
82
  'EntitySubTree',
@@ -4,6 +4,7 @@ import { useField } from '../accessorPropagation'
4
4
  import { MarkerFactory } from '../queryLanguage'
5
5
  import type { FieldValue, SugaredRelativeSingleField } from '../treeParameters'
6
6
  import { Component } from './Component'
7
+ import { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'
7
8
 
8
9
  export interface FieldBasicProps extends SugaredRelativeSingleField {}
9
10
 
@@ -34,6 +35,9 @@ export const Field = Component(
34
35
  },
35
36
  {
36
37
  generateLeafMarker: (props, environment) => MarkerFactory.createFieldMarker(props, environment),
38
+ generateEnvironment: (props, environment) => {
39
+ return TreeNodeEnvironmentFactory.createEnvironmentForField(environment, props)
40
+ },
37
41
  },
38
42
  'Field',
39
43
  ) as <Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => ReactElement
@@ -5,13 +5,13 @@ import { Environment } from '../dao'
5
5
  import { MarkerFactory } from '../queryLanguage'
6
6
  import type { SugaredRelativeEntityList } from '../treeParameters'
7
7
  import { Component } from './Component'
8
- import type { EntityBaseProps } from './Entity'
9
8
  import { EntityList, EntityListBaseProps } from './EntityList'
10
9
  import { Field } from './Field'
10
+ import { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'
11
11
 
12
12
  export type HasManyProps<ListProps = never, EntityProps = never> = SugaredRelativeEntityList & {
13
13
  children?: ReactNode
14
- variables?: Environment.DeltaFactory
14
+ variables?: Environment.ValuesMapWithFactory
15
15
  } & (
16
16
  | {}
17
17
  | {
@@ -28,10 +28,8 @@ export const HasMany = Component(
28
28
  },
29
29
  {
30
30
  generateEnvironment: (props, oldEnvironment) => {
31
- if (props.variables === undefined) {
32
- return oldEnvironment
33
- }
34
- return oldEnvironment.putDelta(Environment.generateDelta(oldEnvironment, props.variables))
31
+ const environment = oldEnvironment.withVariables(props.variables)
32
+ return TreeNodeEnvironmentFactory.createEnvironmentForEntityList(environment, props)
35
33
  },
36
34
  staticRender: props => (
37
35
  <EntityList {...props} accessor={undefined as any}>
@@ -1,16 +1,17 @@
1
- import type { ComponentType, ReactElement, ReactNode } from 'react'
1
+ import type { ReactElement, ReactNode } from 'react'
2
2
  import { useEntity } from '../accessorPropagation'
3
3
  import { PRIMARY_KEY_NAME } from '../bindingTypes'
4
4
  import { Environment } from '../dao'
5
5
  import { MarkerFactory } from '../queryLanguage'
6
6
  import type { SugaredRelativeSingleEntity } from '../treeParameters'
7
7
  import { Component } from './Component'
8
- import { Entity, EntityBaseProps } from './Entity'
8
+ import { Entity } from './Entity'
9
9
  import { Field } from './Field'
10
+ import { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'
10
11
 
11
12
  export type HasOneProps<EntityProps = never> = SugaredRelativeSingleEntity & {
12
13
  children?: ReactNode
13
- variables?: Environment.DeltaFactory
14
+ variables?: Environment.ValuesMapWithFactory
14
15
  }
15
16
 
16
17
  export const HasOne = Component(
@@ -21,10 +22,8 @@ export const HasOne = Component(
21
22
  },
22
23
  {
23
24
  generateEnvironment: (props, oldEnvironment) => {
24
- if (props.variables === undefined) {
25
- return oldEnvironment
26
- }
27
- return oldEnvironment.putDelta(Environment.generateDelta(oldEnvironment, props.variables))
25
+ const environment = oldEnvironment.withVariables(props.variables)
26
+ return TreeNodeEnvironmentFactory.createEnvironmentForEntity(environment, props)
28
27
  },
29
28
  staticRender: props => (
30
29
  <Entity {...props} accessor={undefined as any}>