@contember/binding-legacy 2.0.1 → 2.0.2
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/src/core/MutationGenerator.cjs +61 -59
- package/dist/development/src/core/MutationGenerator.cjs.map +1 -1
- package/dist/development/src/core/MutationGenerator.js +61 -59
- package/dist/development/src/core/MutationGenerator.js.map +1 -1
- package/dist/development/src/core/TreeAugmenter.cjs +1 -1
- package/dist/development/src/core/TreeAugmenter.cjs.map +1 -1
- package/dist/development/src/core/TreeAugmenter.js +1 -1
- package/dist/development/src/core/TreeAugmenter.js.map +1 -1
- package/dist/production/src/core/MutationGenerator.cjs +61 -59
- package/dist/production/src/core/MutationGenerator.cjs.map +1 -1
- package/dist/production/src/core/MutationGenerator.js +61 -59
- package/dist/production/src/core/MutationGenerator.js.map +1 -1
- package/dist/production/src/core/TreeAugmenter.cjs +1 -1
- package/dist/production/src/core/TreeAugmenter.cjs.map +1 -1
- package/dist/production/src/core/TreeAugmenter.js +1 -1
- package/dist/production/src/core/TreeAugmenter.js.map +1 -1
- package/dist/types/core/MutationGenerator.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/core/MutationGenerator.ts +65 -63
- package/src/core/TreeAugmenter.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/binding-legacy",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/production/index.js",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"ae:test": "api-extractor run"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@contember/binding-common": "2.0.
|
|
33
|
-
"@contember/client": "2.0.
|
|
34
|
-
"@contember/utilities": "2.0.
|
|
32
|
+
"@contember/binding-common": "2.0.2",
|
|
33
|
+
"@contember/client": "2.0.2",
|
|
34
|
+
"@contember/utilities": "2.0.2",
|
|
35
35
|
"uuid": "9.0.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
@@ -496,48 +496,75 @@ export class MutationGenerator {
|
|
|
496
496
|
|
|
497
497
|
const result: Input.UpdateDataInput = {}
|
|
498
498
|
|
|
499
|
-
for (const
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
499
|
+
for (const siblingState of StateIterator.eachSiblingRealm(currentState)) {
|
|
500
|
+
for (const [placeholderName, fieldState] of siblingState.children) {
|
|
501
|
+
if (placeholderName === PRIMARY_KEY_NAME || placeholderName === TYPENAME_KEY_NAME) {
|
|
502
|
+
continue
|
|
503
|
+
}
|
|
504
|
+
if (processedPlaceholders.has(placeholderName)) {
|
|
505
|
+
continue
|
|
506
|
+
}
|
|
507
|
+
processedPlaceholders.add(placeholderName)
|
|
507
508
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
509
|
+
switch (fieldState.type) {
|
|
510
|
+
case 'field': {
|
|
511
|
+
if (fieldState.persistedValue !== undefined) {
|
|
512
|
+
const accessor = fieldState.getAccessor()
|
|
513
|
+
const resolvedValue = accessor.value ?? accessor.defaultValue ?? null
|
|
514
|
+
if (fieldState.persistedValue !== resolvedValue) {
|
|
515
|
+
result[placeholderName] = resolvedValue
|
|
516
|
+
}
|
|
515
517
|
}
|
|
518
|
+
break
|
|
516
519
|
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
}
|
|
528
|
-
const reducedBy = marker.parameters.reducedBy
|
|
520
|
+
case 'entityRealmStub':
|
|
521
|
+
case 'entityRealm': {
|
|
522
|
+
const marker = getEntityMarker(fieldState)
|
|
523
|
+
if (!(marker instanceof HasOneRelationMarker)) {
|
|
524
|
+
throw new BindingError()
|
|
525
|
+
}
|
|
526
|
+
if (pathBack?.fieldBackToParent === marker.parameters.field) {
|
|
527
|
+
continue
|
|
528
|
+
}
|
|
529
|
+
const reducedBy = marker.parameters.reducedBy
|
|
529
530
|
|
|
530
|
-
|
|
531
|
-
|
|
531
|
+
const persistedValue = entityData?.get?.(placeholderName)?.value
|
|
532
|
+
if (reducedBy === undefined) {
|
|
532
533
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
534
|
+
const relationData = this.getUpdateOneRelationInput(currentState, fieldState, persistedValue, placeholderName)
|
|
535
|
+
if (relationData !== undefined) {
|
|
536
|
+
result[marker.parameters.field] = relationData
|
|
537
|
+
}
|
|
537
538
|
|
|
538
539
|
|
|
539
|
-
|
|
540
|
-
|
|
540
|
+
} else {
|
|
541
|
+
const relationData = this.getUpdateManyRelationForReducedInput(currentState, fieldState, persistedValue, placeholderName, reducedBy)
|
|
542
|
+
if (relationData !== undefined) {
|
|
543
|
+
const current = result[marker.parameters.field]
|
|
544
|
+
if (Array.isArray(current)) {
|
|
545
|
+
current.push(...relationData)
|
|
546
|
+
} else {
|
|
547
|
+
result[marker.parameters.field] = relationData
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
}
|
|
552
|
+
break
|
|
553
|
+
}
|
|
554
|
+
case 'entityList': {
|
|
555
|
+
const marker = fieldState.blueprint.marker
|
|
556
|
+
if (!(marker instanceof HasManyRelationMarker)) {
|
|
557
|
+
throw new BindingError()
|
|
558
|
+
}
|
|
559
|
+
if (pathBack?.fieldBackToParent === marker.parameters.field) {
|
|
560
|
+
continue
|
|
561
|
+
}
|
|
562
|
+
const persistedEntityIds = entityData?.get?.(placeholderName)?.value ?? new Set()
|
|
563
|
+
|
|
564
|
+
if (!(persistedEntityIds instanceof Set)) {
|
|
565
|
+
continue
|
|
566
|
+
}
|
|
567
|
+
const relationData = this.getUpdateManyRelationInput(fieldState, persistedEntityIds)
|
|
541
568
|
if (relationData !== undefined) {
|
|
542
569
|
const current = result[marker.parameters.field]
|
|
543
570
|
if (Array.isArray(current)) {
|
|
@@ -546,36 +573,11 @@ export class MutationGenerator {
|
|
|
546
573
|
result[marker.parameters.field] = relationData
|
|
547
574
|
}
|
|
548
575
|
}
|
|
549
|
-
|
|
550
|
-
}
|
|
551
|
-
break
|
|
552
|
-
}
|
|
553
|
-
case 'entityList': {
|
|
554
|
-
const marker = fieldState.blueprint.marker
|
|
555
|
-
if (!(marker instanceof HasManyRelationMarker)) {
|
|
556
|
-
throw new BindingError()
|
|
557
|
-
}
|
|
558
|
-
if (pathBack?.fieldBackToParent === marker.parameters.field) {
|
|
559
|
-
continue
|
|
560
|
-
}
|
|
561
|
-
const persistedEntityIds = entityData?.get?.(placeholderName)?.value ?? new Set()
|
|
562
|
-
|
|
563
|
-
if (!(persistedEntityIds instanceof Set)) {
|
|
564
|
-
continue
|
|
565
|
-
}
|
|
566
|
-
const relationData = this.getUpdateManyRelationInput(fieldState, persistedEntityIds)
|
|
567
|
-
if (relationData !== undefined) {
|
|
568
|
-
const current = result[marker.parameters.field]
|
|
569
|
-
if (Array.isArray(current)) {
|
|
570
|
-
current.push(...relationData)
|
|
571
|
-
} else {
|
|
572
|
-
result[marker.parameters.field] = relationData
|
|
573
|
-
}
|
|
576
|
+
break
|
|
574
577
|
}
|
|
575
|
-
|
|
578
|
+
default:
|
|
579
|
+
return assertNever(fieldState)
|
|
576
580
|
}
|
|
577
|
-
default:
|
|
578
|
-
return assertNever(fieldState)
|
|
579
581
|
}
|
|
580
582
|
}
|
|
581
583
|
|
|
@@ -178,7 +178,7 @@ export class TreeAugmenter {
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
if (child.persistedValue !== childData) {
|
|
181
|
-
const shouldChangeBothValues = child.persistedValue === child.value
|
|
181
|
+
const shouldChangeBothValues = (child.persistedValue ?? null) === child.value
|
|
182
182
|
|
|
183
183
|
child.persistedValue = childData
|
|
184
184
|
if (shouldChangeBothValues) {
|