@contember/binding 1.1.0-alpha.15 → 1.1.0-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/accessorPropagation/AccessorProvider.js.map +1 -1
- package/dist/development/accessorPropagation/BindingOperationsProvider.js.map +1 -1
- package/dist/development/accessorPropagation/EntityKeyProvider.js.map +1 -1
- package/dist/development/accessorPropagation/EnvironmentContext.js.map +1 -1
- package/dist/development/accessorPropagation/TreeRootIdProvider.js.map +1 -1
- package/dist/development/accessorSorting/SetOrderFieldOnCreate.js.map +1 -1
- package/dist/development/accessorTree/AccessorTree.js.map +1 -1
- package/dist/development/accessorTree/useDataBinding.js +19 -2
- package/dist/development/accessorTree/useDataBinding.js.map +1 -1
- package/dist/development/core/DataBinding.js +2 -2
- package/dist/development/core/DataBinding.js.map +1 -1
- package/dist/development/core/MarkerMerger.js +7 -3
- package/dist/development/core/MarkerMerger.js.map +1 -1
- package/dist/development/core/MutationGenerator.js +6 -0
- package/dist/development/core/MutationGenerator.js.map +1 -1
- package/dist/development/coreComponents/Component.js.map +1 -1
- package/dist/development/coreComponents/DataBindingProvider.js.map +1 -1
- package/dist/development/coreComponents/Entity.js.map +1 -1
- package/dist/development/coreComponents/EntityList.js.map +1 -1
- package/dist/development/coreComponents/EntityListSubTree.js.map +1 -1
- package/dist/development/coreComponents/EntitySubTree.js.map +1 -1
- package/dist/development/coreComponents/Field.js.map +1 -1
- package/dist/development/coreComponents/HasMany.js.map +1 -1
- package/dist/development/coreComponents/HasOne.js.map +1 -1
- package/dist/development/coreComponents/ParentEntity.js.map +1 -1
- package/dist/development/dao/Environment.js.map +1 -1
- package/dist/development/helperComponents/DeferredSubTrees.js.map +1 -1
- package/dist/development/helperComponents/EntityView.js.map +1 -1
- package/dist/development/helperComponents/FieldView.js.map +1 -1
- package/dist/development/helperComponents/If.js.map +1 -1
- package/dist/development/helperComponents/StaticRender.js.map +1 -1
- package/dist/development/helperComponents/SugaredField.js.map +1 -1
- package/dist/production/accessorPropagation/AccessorProvider.js.map +1 -1
- package/dist/production/accessorPropagation/BindingOperationsProvider.js.map +1 -1
- package/dist/production/accessorPropagation/EntityKeyProvider.js.map +1 -1
- package/dist/production/accessorPropagation/EnvironmentContext.js.map +1 -1
- package/dist/production/accessorPropagation/TreeRootIdProvider.js.map +1 -1
- package/dist/production/accessorSorting/SetOrderFieldOnCreate.js.map +1 -1
- package/dist/production/accessorTree/AccessorTree.js.map +1 -1
- package/dist/production/accessorTree/useDataBinding.js +19 -2
- package/dist/production/accessorTree/useDataBinding.js.map +1 -1
- package/dist/production/core/DataBinding.js +2 -2
- package/dist/production/core/DataBinding.js.map +1 -1
- package/dist/production/core/MarkerMerger.js +7 -3
- package/dist/production/core/MarkerMerger.js.map +1 -1
- package/dist/production/core/MutationGenerator.js +6 -0
- package/dist/production/core/MutationGenerator.js.map +1 -1
- package/dist/production/coreComponents/Component.js.map +1 -1
- package/dist/production/coreComponents/DataBindingProvider.js.map +1 -1
- package/dist/production/coreComponents/Entity.js.map +1 -1
- package/dist/production/coreComponents/EntityList.js.map +1 -1
- package/dist/production/coreComponents/EntityListSubTree.js.map +1 -1
- package/dist/production/coreComponents/EntitySubTree.js.map +1 -1
- package/dist/production/coreComponents/Field.js.map +1 -1
- package/dist/production/coreComponents/HasMany.js.map +1 -1
- package/dist/production/coreComponents/HasOne.js.map +1 -1
- package/dist/production/coreComponents/ParentEntity.js.map +1 -1
- package/dist/production/dao/Environment.js.map +1 -1
- package/dist/production/helperComponents/DeferredSubTrees.js.map +1 -1
- package/dist/production/helperComponents/EntityView.js.map +1 -1
- package/dist/production/helperComponents/FieldView.js.map +1 -1
- package/dist/production/helperComponents/If.js.map +1 -1
- package/dist/production/helperComponents/StaticRender.js.map +1 -1
- package/dist/production/helperComponents/SugaredField.js.map +1 -1
- package/dist/types/accessorTree/useDataBinding.d.ts.map +1 -1
- package/dist/types/core/MarkerMerger.d.ts.map +1 -1
- package/dist/types/core/MutationGenerator.d.ts.map +1 -1
- package/dist/types/dao/Environment.d.ts +3 -2
- package/dist/types/dao/Environment.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/accessorTree/useDataBinding.ts +23 -2
- package/src/core/DataBinding.ts +2 -2
- package/src/core/MarkerMerger.ts +7 -5
- package/src/core/MutationGenerator.ts +6 -0
- package/src/dao/Environment.ts +4 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/binding",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "1.1.0-alpha.
|
|
4
|
+
"version": "1.1.0-alpha.17",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/production/index.js",
|
|
@@ -19,24 +19,24 @@
|
|
|
19
19
|
],
|
|
20
20
|
"typings": "./dist/types/index.d.ts",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@contember/client": "1.1.0-alpha.
|
|
23
|
-
"@contember/react-client": "1.1.0-alpha.
|
|
24
|
-
"@contember/react-multipass-rendering": "1.1.0-alpha.
|
|
25
|
-
"@contember/react-utils": "1.1.0-alpha.
|
|
22
|
+
"@contember/client": "1.1.0-alpha.17",
|
|
23
|
+
"@contember/react-client": "1.1.0-alpha.17",
|
|
24
|
+
"@contember/react-multipass-rendering": "1.1.0-alpha.17",
|
|
25
|
+
"@contember/react-utils": "1.1.0-alpha.17",
|
|
26
26
|
"chevrotain": "6.5.0",
|
|
27
27
|
"fast-deep-equal": "^3.1.3",
|
|
28
28
|
"js-levenshtein": "1.1.6",
|
|
29
29
|
"uuid": "8.3.2"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"react": "^17",
|
|
33
|
-
"react-dom": "^17"
|
|
32
|
+
"react": "^17 || ^18",
|
|
33
|
+
"react-dom": "^17 || ^18"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/js-levenshtein": "1.1.0",
|
|
37
37
|
"@types/uuid": "8.3.1",
|
|
38
|
-
"react": "^
|
|
39
|
-
"react-dom": "^
|
|
38
|
+
"react": "^18",
|
|
39
|
+
"react-dom": "^18"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "pnpm run build:js:dev && pnpm run build:js:prod",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
GraphQlClientFailedRequestMetadata,
|
|
2
3
|
useCurrentContentGraphQlClient,
|
|
3
4
|
useCurrentSystemGraphQlClient,
|
|
4
5
|
useTenantGraphQlClient,
|
|
@@ -10,6 +11,7 @@ import { DataBinding } from '../core'
|
|
|
10
11
|
import type { AccessorTreeState } from './AccessorTreeState'
|
|
11
12
|
import type { AccessorTreeStateOptions } from './AccessorTreeStateOptions'
|
|
12
13
|
import { accessorTreeStateReducer } from './accessorTreeStateReducer'
|
|
14
|
+
import { metadataToRequestError } from './metadataToRequestError'
|
|
13
15
|
import type { RequestError } from './RequestError'
|
|
14
16
|
import { Environment } from '../dao'
|
|
15
17
|
import { Schema, SchemaLoader } from '../core/schema'
|
|
@@ -64,10 +66,29 @@ export const useDataBinding = ({
|
|
|
64
66
|
})
|
|
65
67
|
|
|
66
68
|
useEffect(() => {
|
|
69
|
+
if (schema !== undefined) {
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
|
|
67
73
|
(async () => {
|
|
68
|
-
|
|
74
|
+
try {
|
|
75
|
+
setSchema(await SchemaLoader.loadSchema(contentClient))
|
|
76
|
+
|
|
77
|
+
} catch (metadata) {
|
|
78
|
+
if (typeof metadata === 'object' && metadata !== null && (metadata as { name?: unknown }).name === 'AbortError') {
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (isMountedRef.current) {
|
|
83
|
+
dispatch({
|
|
84
|
+
type: 'failWithError',
|
|
85
|
+
error: metadataToRequestError(metadata as GraphQlClientFailedRequestMetadata),
|
|
86
|
+
binding: state.binding!,
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
}
|
|
69
90
|
})()
|
|
70
|
-
}, [contentClient])
|
|
91
|
+
}, [contentClient, isMountedRef, schema, state.binding])
|
|
71
92
|
|
|
72
93
|
useEffect(() => {
|
|
73
94
|
if (schema) {
|
package/src/core/DataBinding.ts
CHANGED
|
@@ -324,12 +324,12 @@ export class DataBinding {
|
|
|
324
324
|
|
|
325
325
|
const aggregatePersistedData = await this.fetchPersistedData(aggregateMarkerTreeRoot, aggregateSignal)
|
|
326
326
|
|
|
327
|
-
if (aggregateSignal?.aborted) {
|
|
327
|
+
if (aggregateSignal?.aborted || aggregatePersistedData === undefined) {
|
|
328
328
|
return
|
|
329
329
|
}
|
|
330
330
|
|
|
331
331
|
this.eventManager.syncOperation(() => {
|
|
332
|
-
this.treeAugmenter.extendPersistedData(aggregatePersistedData
|
|
332
|
+
this.treeAugmenter.extendPersistedData(aggregatePersistedData.data, aggregateMarkerTreeRoot)
|
|
333
333
|
|
|
334
334
|
for (const extension of pendingExtensions) {
|
|
335
335
|
this.treeAugmenter.extendTreeStates(extension.newTreeRootId, extension.markerTreeRoot)
|
package/src/core/MarkerMerger.ts
CHANGED
|
@@ -265,12 +265,14 @@ export class MarkerMerger {
|
|
|
265
265
|
if (original === fresh) {
|
|
266
266
|
return original
|
|
267
267
|
}
|
|
268
|
-
if (original.
|
|
269
|
-
|
|
270
|
-
return fresh
|
|
268
|
+
if (original.defaultValue !== undefined && fresh.defaultValue !== undefined && original.defaultValue !== fresh.defaultValue) {
|
|
269
|
+
throw new BindingError(`MarkerTreeGenerator merging: multiple fields "${original.fieldName}" with different defaultValue found: ${JSON.stringify([original.defaultValue, fresh.defaultValue])}, `)
|
|
271
270
|
}
|
|
272
|
-
|
|
273
|
-
|
|
271
|
+
return new FieldMarker(
|
|
272
|
+
original.fieldName,
|
|
273
|
+
original.defaultValue ?? fresh.defaultValue,
|
|
274
|
+
original.isNonbearing && fresh.isNonbearing,
|
|
275
|
+
)
|
|
274
276
|
}
|
|
275
277
|
|
|
276
278
|
public static mergeInSystemFields(original: EntityFieldMarkersContainer | undefined): EntityFieldMarkersContainer {
|
|
@@ -54,6 +54,7 @@ export class MutationGenerator {
|
|
|
54
54
|
let builder: QueryBuilder = new CrudQueryBuilder.CrudQueryBuilder()
|
|
55
55
|
const operations: SubMutationOperation[] = []
|
|
56
56
|
const processedPlaceholdersByEntity: ProcessedPlaceholdersByEntity = new Map()
|
|
57
|
+
const processedDeletes = new Set<string>()
|
|
57
58
|
|
|
58
59
|
|
|
59
60
|
for (const [treeRootId, rootStates] of this.treeStore.subTreeStatesByRoot.entries()) {
|
|
@@ -99,6 +100,11 @@ export class MutationGenerator {
|
|
|
99
100
|
continue
|
|
100
101
|
}
|
|
101
102
|
if (removalType === 'delete') {
|
|
103
|
+
const key = `${subTreeState.entityName}#${removedId}`
|
|
104
|
+
if (processedDeletes.has(key)) {
|
|
105
|
+
continue
|
|
106
|
+
}
|
|
107
|
+
processedDeletes.add(key)
|
|
102
108
|
const alias = this.createAlias()
|
|
103
109
|
builder = this.addDeleteMutation(
|
|
104
110
|
subTreeState.entityName,
|
package/src/dao/Environment.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { BindingError } from '../BindingError'
|
|
|
3
3
|
import type { Filter } from '../treeParameters'
|
|
4
4
|
import equal from 'fast-deep-equal/es6'
|
|
5
5
|
import { Schema, SchemaColumn, SchemaEntity, SchemaRelation } from '../core/schema'
|
|
6
|
+
import { GraphQlLiteral } from '@contember/client'
|
|
6
7
|
|
|
7
8
|
class Environment {
|
|
8
9
|
private constructor(
|
|
@@ -83,7 +84,7 @@ class Environment {
|
|
|
83
84
|
/** @deprecated use getVariableOrElse or getParameterOrElse */
|
|
84
85
|
public getValueOrElse<F, V extends Environment.Value = Environment.Value>(key: string, fallback: F): V | F {
|
|
85
86
|
console.warn('Environment.getValueOrElse() is deprecated, use Environment.getVariableOrElse() or Environment.getParameterOrElse() instead.')
|
|
86
|
-
return this.getVariableOrElse(key, undefined) ?? this.getParameterOrElse(key, fallback) as
|
|
87
|
+
return this.getVariableOrElse(key, undefined) ?? this.getParameterOrElse(key, fallback) as any
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
/** @deprecated */
|
|
@@ -242,9 +243,9 @@ class Environment {
|
|
|
242
243
|
namespace Environment {
|
|
243
244
|
export type Name = string
|
|
244
245
|
|
|
245
|
-
export type Value = ReactNode
|
|
246
|
+
export type Value = ReactNode | GraphQlLiteral | Filter
|
|
246
247
|
|
|
247
|
-
export type ResolvedValue = Value
|
|
248
|
+
export type ResolvedValue = Value
|
|
248
249
|
|
|
249
250
|
export interface Options {
|
|
250
251
|
node?: AnyNode
|