@contember/binding-legacy 2.1.0-alpha.30 → 2.1.0-alpha.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -5
- package/src/accessorTree/NormalizedPersistedData.ts +1 -1
- package/src/accessors/EntityAccessorImpl.ts +13 -11
- package/src/accessors/EntityListAccessorImpl.ts +16 -7
- package/src/core/AccessorErrorManager.ts +2 -2
- package/src/core/DataBinding.ts +24 -15
- package/src/core/ErrorsPreprocessor.ts +4 -5
- package/src/core/EventManager.ts +34 -46
- package/src/core/MutationGenerator.ts +23 -27
- package/src/core/QueryGenerator.ts +4 -5
- package/src/core/RealmKeyGenerator.ts +5 -3
- package/src/core/RequestResponseNormalizer.ts +3 -8
- package/src/core/StateInitializer.ts +10 -18
- package/src/core/TreeAugmenter.ts +8 -15
- package/src/core/TreeStore.ts +5 -4
- package/src/core/operations/EntityOperations.ts +25 -25
- package/src/core/operations/FieldOperations.ts +15 -17
- package/src/core/operations/ListOperations.ts +15 -15
- package/src/core/operations/OperationsHelpers.ts +2 -2
- package/src/core/state/EntityListState.ts +3 -9
- package/src/fieldHelpers/helpers/TemporalFieldHelper.ts +3 -3
- package/src/utils/assertNever.ts +4 -4
- package/tests/example.test.ts +2 -2
- package/dist/development/index.cjs +0 -34
- package/dist/development/index.cjs.map +0 -1
- package/dist/development/index.js +0 -28
- package/dist/development/index.js.map +0 -1
- package/dist/development/src/accessorTree/NormalizedPersistedData.cjs +0 -10
- package/dist/development/src/accessorTree/NormalizedPersistedData.cjs.map +0 -1
- package/dist/development/src/accessorTree/NormalizedPersistedData.js +0 -10
- package/dist/development/src/accessorTree/NormalizedPersistedData.js.map +0 -1
- package/dist/development/src/accessors/EntityAccessorImpl.cjs +0 -179
- package/dist/development/src/accessors/EntityAccessorImpl.cjs.map +0 -1
- package/dist/development/src/accessors/EntityAccessorImpl.js +0 -179
- package/dist/development/src/accessors/EntityAccessorImpl.js.map +0 -1
- package/dist/development/src/accessors/EntityListAccessorImpl.cjs +0 -112
- package/dist/development/src/accessors/EntityListAccessorImpl.cjs.map +0 -1
- package/dist/development/src/accessors/EntityListAccessorImpl.js +0 -112
- package/dist/development/src/accessors/EntityListAccessorImpl.js.map +0 -1
- package/dist/development/src/accessors/FieldAccessorImpl.cjs +0 -54
- package/dist/development/src/accessors/FieldAccessorImpl.cjs.map +0 -1
- package/dist/development/src/accessors/FieldAccessorImpl.js +0 -54
- package/dist/development/src/accessors/FieldAccessorImpl.js.map +0 -1
- package/dist/development/src/core/AccessorErrorManager.cjs +0 -200
- package/dist/development/src/core/AccessorErrorManager.cjs.map +0 -1
- package/dist/development/src/core/AccessorErrorManager.js +0 -200
- package/dist/development/src/core/AccessorErrorManager.js.map +0 -1
- package/dist/development/src/core/Config.cjs +0 -29
- package/dist/development/src/core/Config.cjs.map +0 -1
- package/dist/development/src/core/Config.js +0 -29
- package/dist/development/src/core/Config.js.map +0 -1
- package/dist/development/src/core/DataBinding.cjs +0 -354
- package/dist/development/src/core/DataBinding.cjs.map +0 -1
- package/dist/development/src/core/DataBinding.js +0 -354
- package/dist/development/src/core/DataBinding.js.map +0 -1
- package/dist/development/src/core/DirtinessTracker.cjs +0 -26
- package/dist/development/src/core/DirtinessTracker.cjs.map +0 -1
- package/dist/development/src/core/DirtinessTracker.js +0 -26
- package/dist/development/src/core/DirtinessTracker.js.map +0 -1
- package/dist/development/src/core/ErrorsPreprocessor.cjs +0 -180
- package/dist/development/src/core/ErrorsPreprocessor.cjs.map +0 -1
- package/dist/development/src/core/ErrorsPreprocessor.js +0 -180
- package/dist/development/src/core/ErrorsPreprocessor.js.map +0 -1
- package/dist/development/src/core/EventManager.cjs +0 -439
- package/dist/development/src/core/EventManager.cjs.map +0 -1
- package/dist/development/src/core/EventManager.js +0 -439
- package/dist/development/src/core/EventManager.js.map +0 -1
- package/dist/development/src/core/MutationGenerator.cjs +0 -670
- package/dist/development/src/core/MutationGenerator.cjs.map +0 -1
- package/dist/development/src/core/MutationGenerator.js +0 -670
- package/dist/development/src/core/MutationGenerator.js.map +0 -1
- package/dist/development/src/core/QueryGenerator.cjs +0 -110
- package/dist/development/src/core/QueryGenerator.cjs.map +0 -1
- package/dist/development/src/core/QueryGenerator.js +0 -110
- package/dist/development/src/core/QueryGenerator.js.map +0 -1
- package/dist/development/src/core/RealmKeyGenerator.cjs +0 -42
- package/dist/development/src/core/RealmKeyGenerator.cjs.map +0 -1
- package/dist/development/src/core/RealmKeyGenerator.js +0 -42
- package/dist/development/src/core/RealmKeyGenerator.js.map +0 -1
- package/dist/development/src/core/RequestResponseNormalizer.cjs +0 -136
- package/dist/development/src/core/RequestResponseNormalizer.cjs.map +0 -1
- package/dist/development/src/core/RequestResponseNormalizer.js +0 -136
- package/dist/development/src/core/RequestResponseNormalizer.js.map +0 -1
- package/dist/development/src/core/StateInitializer.cjs +0 -379
- package/dist/development/src/core/StateInitializer.cjs.map +0 -1
- package/dist/development/src/core/StateInitializer.js +0 -379
- package/dist/development/src/core/StateInitializer.js.map +0 -1
- package/dist/development/src/core/TreeAugmenter.cjs +0 -354
- package/dist/development/src/core/TreeAugmenter.cjs.map +0 -1
- package/dist/development/src/core/TreeAugmenter.js +0 -354
- package/dist/development/src/core/TreeAugmenter.js.map +0 -1
- package/dist/development/src/core/TreeStore.cjs +0 -172
- package/dist/development/src/core/TreeStore.cjs.map +0 -1
- package/dist/development/src/core/TreeStore.js +0 -172
- package/dist/development/src/core/TreeStore.js.map +0 -1
- package/dist/development/src/core/exceptions/ErrorLocator.cjs +0 -59
- package/dist/development/src/core/exceptions/ErrorLocator.cjs.map +0 -1
- package/dist/development/src/core/exceptions/ErrorLocator.js +0 -59
- package/dist/development/src/core/exceptions/ErrorLocator.js.map +0 -1
- package/dist/development/src/core/exceptions/MarkerSugarer.cjs +0 -51
- package/dist/development/src/core/exceptions/MarkerSugarer.cjs.map +0 -1
- package/dist/development/src/core/exceptions/MarkerSugarer.js +0 -51
- package/dist/development/src/core/exceptions/MarkerSugarer.js.map +0 -1
- package/dist/development/src/core/exceptions/TreeParameterSugarer.cjs +0 -33
- package/dist/development/src/core/exceptions/TreeParameterSugarer.cjs.map +0 -1
- package/dist/development/src/core/exceptions/TreeParameterSugarer.js +0 -33
- package/dist/development/src/core/exceptions/TreeParameterSugarer.js.map +0 -1
- package/dist/development/src/core/factories/createBatchUpdatesOptions.cjs +0 -23
- package/dist/development/src/core/factories/createBatchUpdatesOptions.cjs.map +0 -1
- package/dist/development/src/core/factories/createBatchUpdatesOptions.js +0 -23
- package/dist/development/src/core/factories/createBatchUpdatesOptions.js.map +0 -1
- package/dist/development/src/core/operations/EntityOperations.cjs +0 -226
- package/dist/development/src/core/operations/EntityOperations.cjs.map +0 -1
- package/dist/development/src/core/operations/EntityOperations.js +0 -226
- package/dist/development/src/core/operations/EntityOperations.js.map +0 -1
- package/dist/development/src/core/operations/FieldOperations.cjs +0 -92
- package/dist/development/src/core/operations/FieldOperations.cjs.map +0 -1
- package/dist/development/src/core/operations/FieldOperations.js +0 -92
- package/dist/development/src/core/operations/FieldOperations.js.map +0 -1
- package/dist/development/src/core/operations/ListOperations.cjs +0 -158
- package/dist/development/src/core/operations/ListOperations.cjs.map +0 -1
- package/dist/development/src/core/operations/ListOperations.js +0 -158
- package/dist/development/src/core/operations/ListOperations.js.map +0 -1
- package/dist/development/src/core/operations/OperationsHelpers.cjs +0 -87
- package/dist/development/src/core/operations/OperationsHelpers.cjs.map +0 -1
- package/dist/development/src/core/operations/OperationsHelpers.js +0 -87
- package/dist/development/src/core/operations/OperationsHelpers.js.map +0 -1
- package/dist/development/src/core/requestAliases/MutationAlias.cjs +0 -14
- package/dist/development/src/core/requestAliases/MutationAlias.cjs.map +0 -1
- package/dist/development/src/core/requestAliases/MutationAlias.js +0 -14
- package/dist/development/src/core/requestAliases/MutationAlias.js.map +0 -1
- package/dist/development/src/core/state/StateIterator.cjs +0 -100
- package/dist/development/src/core/state/StateIterator.cjs.map +0 -1
- package/dist/development/src/core/state/StateIterator.js +0 -100
- package/dist/development/src/core/state/StateIterator.js.map +0 -1
- package/dist/development/src/core/state/getEntityMarker.cjs +0 -5
- package/dist/development/src/core/state/getEntityMarker.cjs.map +0 -1
- package/dist/development/src/core/state/getEntityMarker.js +0 -5
- package/dist/development/src/core/state/getEntityMarker.js.map +0 -1
- package/dist/development/src/core/utils/getCombinedSignal.cjs +0 -33
- package/dist/development/src/core/utils/getCombinedSignal.cjs.map +0 -1
- package/dist/development/src/core/utils/getCombinedSignal.js +0 -33
- package/dist/development/src/core/utils/getCombinedSignal.js.map +0 -1
- package/dist/development/src/fieldHelpers/helpers/FieldHelper.cjs +0 -13
- package/dist/development/src/fieldHelpers/helpers/FieldHelper.cjs.map +0 -1
- package/dist/development/src/fieldHelpers/helpers/FieldHelper.js +0 -13
- package/dist/development/src/fieldHelpers/helpers/FieldHelper.js.map +0 -1
- package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.cjs +0 -18
- package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.cjs.map +0 -1
- package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.js +0 -18
- package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.js.map +0 -1
- package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.cjs +0 -16
- package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.cjs.map +0 -1
- package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.js +0 -16
- package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.js.map +0 -1
- package/dist/development/src/utils/generateEnumerabilityPreventingEntropy.cjs +0 -7
- package/dist/development/src/utils/generateEnumerabilityPreventingEntropy.cjs.map +0 -1
- package/dist/development/src/utils/generateEnumerabilityPreventingEntropy.js +0 -7
- package/dist/development/src/utils/generateEnumerabilityPreventingEntropy.js.map +0 -1
- package/dist/development/src/utils/isEmptyObject.cjs +0 -12
- package/dist/development/src/utils/isEmptyObject.cjs.map +0 -1
- package/dist/development/src/utils/isEmptyObject.js +0 -12
- package/dist/development/src/utils/isEmptyObject.js.map +0 -1
- package/dist/production/index.cjs +0 -34
- package/dist/production/index.cjs.map +0 -1
- package/dist/production/index.js +0 -28
- package/dist/production/index.js.map +0 -1
- package/dist/production/src/accessorTree/NormalizedPersistedData.cjs +0 -10
- package/dist/production/src/accessorTree/NormalizedPersistedData.cjs.map +0 -1
- package/dist/production/src/accessorTree/NormalizedPersistedData.js +0 -10
- package/dist/production/src/accessorTree/NormalizedPersistedData.js.map +0 -1
- package/dist/production/src/accessors/EntityAccessorImpl.cjs +0 -179
- package/dist/production/src/accessors/EntityAccessorImpl.cjs.map +0 -1
- package/dist/production/src/accessors/EntityAccessorImpl.js +0 -179
- package/dist/production/src/accessors/EntityAccessorImpl.js.map +0 -1
- package/dist/production/src/accessors/EntityListAccessorImpl.cjs +0 -112
- package/dist/production/src/accessors/EntityListAccessorImpl.cjs.map +0 -1
- package/dist/production/src/accessors/EntityListAccessorImpl.js +0 -112
- package/dist/production/src/accessors/EntityListAccessorImpl.js.map +0 -1
- package/dist/production/src/accessors/FieldAccessorImpl.cjs +0 -54
- package/dist/production/src/accessors/FieldAccessorImpl.cjs.map +0 -1
- package/dist/production/src/accessors/FieldAccessorImpl.js +0 -54
- package/dist/production/src/accessors/FieldAccessorImpl.js.map +0 -1
- package/dist/production/src/core/AccessorErrorManager.cjs +0 -200
- package/dist/production/src/core/AccessorErrorManager.cjs.map +0 -1
- package/dist/production/src/core/AccessorErrorManager.js +0 -200
- package/dist/production/src/core/AccessorErrorManager.js.map +0 -1
- package/dist/production/src/core/Config.cjs +0 -29
- package/dist/production/src/core/Config.cjs.map +0 -1
- package/dist/production/src/core/Config.js +0 -29
- package/dist/production/src/core/Config.js.map +0 -1
- package/dist/production/src/core/DataBinding.cjs +0 -354
- package/dist/production/src/core/DataBinding.cjs.map +0 -1
- package/dist/production/src/core/DataBinding.js +0 -354
- package/dist/production/src/core/DataBinding.js.map +0 -1
- package/dist/production/src/core/DirtinessTracker.cjs +0 -26
- package/dist/production/src/core/DirtinessTracker.cjs.map +0 -1
- package/dist/production/src/core/DirtinessTracker.js +0 -26
- package/dist/production/src/core/DirtinessTracker.js.map +0 -1
- package/dist/production/src/core/ErrorsPreprocessor.cjs +0 -180
- package/dist/production/src/core/ErrorsPreprocessor.cjs.map +0 -1
- package/dist/production/src/core/ErrorsPreprocessor.js +0 -180
- package/dist/production/src/core/ErrorsPreprocessor.js.map +0 -1
- package/dist/production/src/core/EventManager.cjs +0 -413
- package/dist/production/src/core/EventManager.cjs.map +0 -1
- package/dist/production/src/core/EventManager.js +0 -413
- package/dist/production/src/core/EventManager.js.map +0 -1
- package/dist/production/src/core/MutationGenerator.cjs +0 -670
- package/dist/production/src/core/MutationGenerator.cjs.map +0 -1
- package/dist/production/src/core/MutationGenerator.js +0 -670
- package/dist/production/src/core/MutationGenerator.js.map +0 -1
- package/dist/production/src/core/QueryGenerator.cjs +0 -110
- package/dist/production/src/core/QueryGenerator.cjs.map +0 -1
- package/dist/production/src/core/QueryGenerator.js +0 -110
- package/dist/production/src/core/QueryGenerator.js.map +0 -1
- package/dist/production/src/core/RealmKeyGenerator.cjs +0 -42
- package/dist/production/src/core/RealmKeyGenerator.cjs.map +0 -1
- package/dist/production/src/core/RealmKeyGenerator.js +0 -42
- package/dist/production/src/core/RealmKeyGenerator.js.map +0 -1
- package/dist/production/src/core/RequestResponseNormalizer.cjs +0 -136
- package/dist/production/src/core/RequestResponseNormalizer.cjs.map +0 -1
- package/dist/production/src/core/RequestResponseNormalizer.js +0 -136
- package/dist/production/src/core/RequestResponseNormalizer.js.map +0 -1
- package/dist/production/src/core/StateInitializer.cjs +0 -379
- package/dist/production/src/core/StateInitializer.cjs.map +0 -1
- package/dist/production/src/core/StateInitializer.js +0 -379
- package/dist/production/src/core/StateInitializer.js.map +0 -1
- package/dist/production/src/core/TreeAugmenter.cjs +0 -354
- package/dist/production/src/core/TreeAugmenter.cjs.map +0 -1
- package/dist/production/src/core/TreeAugmenter.js +0 -354
- package/dist/production/src/core/TreeAugmenter.js.map +0 -1
- package/dist/production/src/core/TreeStore.cjs +0 -172
- package/dist/production/src/core/TreeStore.cjs.map +0 -1
- package/dist/production/src/core/TreeStore.js +0 -172
- package/dist/production/src/core/TreeStore.js.map +0 -1
- package/dist/production/src/core/exceptions/ErrorLocator.cjs +0 -59
- package/dist/production/src/core/exceptions/ErrorLocator.cjs.map +0 -1
- package/dist/production/src/core/exceptions/ErrorLocator.js +0 -59
- package/dist/production/src/core/exceptions/ErrorLocator.js.map +0 -1
- package/dist/production/src/core/exceptions/MarkerSugarer.cjs +0 -51
- package/dist/production/src/core/exceptions/MarkerSugarer.cjs.map +0 -1
- package/dist/production/src/core/exceptions/MarkerSugarer.js +0 -51
- package/dist/production/src/core/exceptions/MarkerSugarer.js.map +0 -1
- package/dist/production/src/core/exceptions/TreeParameterSugarer.cjs +0 -33
- package/dist/production/src/core/exceptions/TreeParameterSugarer.cjs.map +0 -1
- package/dist/production/src/core/exceptions/TreeParameterSugarer.js +0 -33
- package/dist/production/src/core/exceptions/TreeParameterSugarer.js.map +0 -1
- package/dist/production/src/core/factories/createBatchUpdatesOptions.cjs +0 -23
- package/dist/production/src/core/factories/createBatchUpdatesOptions.cjs.map +0 -1
- package/dist/production/src/core/factories/createBatchUpdatesOptions.js +0 -23
- package/dist/production/src/core/factories/createBatchUpdatesOptions.js.map +0 -1
- package/dist/production/src/core/operations/EntityOperations.cjs +0 -226
- package/dist/production/src/core/operations/EntityOperations.cjs.map +0 -1
- package/dist/production/src/core/operations/EntityOperations.js +0 -226
- package/dist/production/src/core/operations/EntityOperations.js.map +0 -1
- package/dist/production/src/core/operations/FieldOperations.cjs +0 -73
- package/dist/production/src/core/operations/FieldOperations.cjs.map +0 -1
- package/dist/production/src/core/operations/FieldOperations.js +0 -73
- package/dist/production/src/core/operations/FieldOperations.js.map +0 -1
- package/dist/production/src/core/operations/ListOperations.cjs +0 -158
- package/dist/production/src/core/operations/ListOperations.cjs.map +0 -1
- package/dist/production/src/core/operations/ListOperations.js +0 -158
- package/dist/production/src/core/operations/ListOperations.js.map +0 -1
- package/dist/production/src/core/operations/OperationsHelpers.cjs +0 -87
- package/dist/production/src/core/operations/OperationsHelpers.cjs.map +0 -1
- package/dist/production/src/core/operations/OperationsHelpers.js +0 -87
- package/dist/production/src/core/operations/OperationsHelpers.js.map +0 -1
- package/dist/production/src/core/requestAliases/MutationAlias.cjs +0 -14
- package/dist/production/src/core/requestAliases/MutationAlias.cjs.map +0 -1
- package/dist/production/src/core/requestAliases/MutationAlias.js +0 -14
- package/dist/production/src/core/requestAliases/MutationAlias.js.map +0 -1
- package/dist/production/src/core/state/StateIterator.cjs +0 -100
- package/dist/production/src/core/state/StateIterator.cjs.map +0 -1
- package/dist/production/src/core/state/StateIterator.js +0 -100
- package/dist/production/src/core/state/StateIterator.js.map +0 -1
- package/dist/production/src/core/state/getEntityMarker.cjs +0 -5
- package/dist/production/src/core/state/getEntityMarker.cjs.map +0 -1
- package/dist/production/src/core/state/getEntityMarker.js +0 -5
- package/dist/production/src/core/state/getEntityMarker.js.map +0 -1
- package/dist/production/src/core/utils/getCombinedSignal.cjs +0 -33
- package/dist/production/src/core/utils/getCombinedSignal.cjs.map +0 -1
- package/dist/production/src/core/utils/getCombinedSignal.js +0 -33
- package/dist/production/src/core/utils/getCombinedSignal.js.map +0 -1
- package/dist/production/src/fieldHelpers/helpers/FieldHelper.cjs +0 -13
- package/dist/production/src/fieldHelpers/helpers/FieldHelper.cjs.map +0 -1
- package/dist/production/src/fieldHelpers/helpers/FieldHelper.js +0 -13
- package/dist/production/src/fieldHelpers/helpers/FieldHelper.js.map +0 -1
- package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.cjs +0 -18
- package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.cjs.map +0 -1
- package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.js +0 -18
- package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.js.map +0 -1
- package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.cjs +0 -16
- package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.cjs.map +0 -1
- package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.js +0 -16
- package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.js.map +0 -1
- package/dist/production/src/utils/generateEnumerabilityPreventingEntropy.cjs +0 -7
- package/dist/production/src/utils/generateEnumerabilityPreventingEntropy.cjs.map +0 -1
- package/dist/production/src/utils/generateEnumerabilityPreventingEntropy.js +0 -7
- package/dist/production/src/utils/generateEnumerabilityPreventingEntropy.js.map +0 -1
- package/dist/production/src/utils/isEmptyObject.cjs +0 -12
- package/dist/production/src/utils/isEmptyObject.cjs.map +0 -1
- package/dist/production/src/utils/isEmptyObject.js +0 -12
- package/dist/production/src/utils/isEmptyObject.js.map +0 -1
- package/dist/types/accessorTree/NormalizedPersistedData.d.ts +0 -18
- package/dist/types/accessorTree/NormalizedPersistedData.d.ts.map +0 -1
- package/dist/types/accessorTree/index.d.ts +0 -2
- package/dist/types/accessorTree/index.d.ts.map +0 -1
- package/dist/types/accessors/BindingConfig.d.ts +0 -6
- package/dist/types/accessors/BindingConfig.d.ts.map +0 -1
- package/dist/types/accessors/EntityAccessorImpl.d.ts +0 -56
- package/dist/types/accessors/EntityAccessorImpl.d.ts.map +0 -1
- package/dist/types/accessors/EntityListAccessorImpl.d.ts +0 -57
- package/dist/types/accessors/EntityListAccessorImpl.d.ts.map +0 -1
- package/dist/types/accessors/FieldAccessorImpl.d.ts +0 -32
- package/dist/types/accessors/FieldAccessorImpl.d.ts.map +0 -1
- package/dist/types/accessors/index.d.ts +0 -5
- package/dist/types/accessors/index.d.ts.map +0 -1
- package/dist/types/core/AccessorErrorManager.d.ts +0 -25
- package/dist/types/core/AccessorErrorManager.d.ts.map +0 -1
- package/dist/types/core/Config.d.ts +0 -9
- package/dist/types/core/Config.d.ts.map +0 -1
- package/dist/types/core/DataBinding.d.ts +0 -54
- package/dist/types/core/DataBinding.d.ts.map +0 -1
- package/dist/types/core/DirtinessTracker.d.ts +0 -9
- package/dist/types/core/DirtinessTracker.d.ts.map +0 -1
- package/dist/types/core/ErrorsPreprocessor.d.ts +0 -34
- package/dist/types/core/ErrorsPreprocessor.d.ts.map +0 -1
- package/dist/types/core/EventManager.d.ts +0 -57
- package/dist/types/core/EventManager.d.ts.map +0 -1
- package/dist/types/core/MutationGenerator.d.ts +0 -49
- package/dist/types/core/MutationGenerator.d.ts.map +0 -1
- package/dist/types/core/QueryGenerator.d.ts +0 -13
- package/dist/types/core/QueryGenerator.d.ts.map +0 -1
- package/dist/types/core/RealmKeyGenerator.d.ts +0 -10
- package/dist/types/core/RealmKeyGenerator.d.ts.map +0 -1
- package/dist/types/core/RequestResponseNormalizer.d.ts +0 -11
- package/dist/types/core/RequestResponseNormalizer.d.ts.map +0 -1
- package/dist/types/core/StateInitializer.d.ts +0 -34
- package/dist/types/core/StateInitializer.d.ts.map +0 -1
- package/dist/types/core/TreeAugmenter.d.ts +0 -25
- package/dist/types/core/TreeAugmenter.d.ts.map +0 -1
- package/dist/types/core/TreeStore.d.ts +0 -30
- package/dist/types/core/TreeStore.d.ts.map +0 -1
- package/dist/types/core/UpdateMetadata.d.ts +0 -4
- package/dist/types/core/UpdateMetadata.d.ts.map +0 -1
- package/dist/types/core/exceptions/ErrorLocator.d.ts +0 -8
- package/dist/types/core/exceptions/ErrorLocator.d.ts.map +0 -1
- package/dist/types/core/exceptions/MarkerSugarer.d.ts +0 -10
- package/dist/types/core/exceptions/MarkerSugarer.d.ts.map +0 -1
- package/dist/types/core/exceptions/TreeParameterSugarer.d.ts +0 -11
- package/dist/types/core/exceptions/TreeParameterSugarer.d.ts.map +0 -1
- package/dist/types/core/factories/createBatchUpdatesOptions.d.ts +0 -5
- package/dist/types/core/factories/createBatchUpdatesOptions.d.ts.map +0 -1
- package/dist/types/core/factories/index.d.ts +0 -2
- package/dist/types/core/factories/index.d.ts.map +0 -1
- package/dist/types/core/index.d.ts +0 -9
- package/dist/types/core/index.d.ts.map +0 -1
- package/dist/types/core/operations/EntityOperations.d.ts +0 -26
- package/dist/types/core/operations/EntityOperations.d.ts.map +0 -1
- package/dist/types/core/operations/FieldOperations.d.ts +0 -22
- package/dist/types/core/operations/FieldOperations.d.ts.map +0 -1
- package/dist/types/core/operations/ListOperations.d.ts +0 -32
- package/dist/types/core/operations/ListOperations.d.ts.map +0 -1
- package/dist/types/core/operations/OperationsHelpers.d.ts +0 -14
- package/dist/types/core/operations/OperationsHelpers.d.ts.map +0 -1
- package/dist/types/core/operations/index.d.ts +0 -4
- package/dist/types/core/operations/index.d.ts.map +0 -1
- package/dist/types/core/requestAliases/MutationAlias.d.ts +0 -6
- package/dist/types/core/requestAliases/MutationAlias.d.ts.map +0 -1
- package/dist/types/core/requestAliases/index.d.ts +0 -2
- package/dist/types/core/requestAliases/index.d.ts.map +0 -1
- package/dist/types/core/state/EntityListState.d.ts +0 -29
- package/dist/types/core/state/EntityListState.d.ts.map +0 -1
- package/dist/types/core/state/EntityRealmState.d.ts +0 -44
- package/dist/types/core/state/EntityRealmState.d.ts.map +0 -1
- package/dist/types/core/state/EntityState.d.ts +0 -11
- package/dist/types/core/state/EntityState.d.ts.map +0 -1
- package/dist/types/core/state/FieldState.d.ts +0 -19
- package/dist/types/core/state/FieldState.d.ts.map +0 -1
- package/dist/types/core/state/StateIterator.d.ts +0 -14
- package/dist/types/core/state/StateIterator.d.ts.map +0 -1
- package/dist/types/core/state/StateNode.d.ts +0 -8
- package/dist/types/core/state/StateNode.d.ts.map +0 -1
- package/dist/types/core/state/getEntityMarker.d.ts +0 -3
- package/dist/types/core/state/getEntityMarker.d.ts.map +0 -1
- package/dist/types/core/state/index.d.ts +0 -8
- package/dist/types/core/state/index.d.ts.map +0 -1
- package/dist/types/core/utils/getCombinedSignal.d.ts +0 -2
- package/dist/types/core/utils/getCombinedSignal.d.ts.map +0 -1
- package/dist/types/core/utils/index.d.ts +0 -2
- package/dist/types/core/utils/index.d.ts.map +0 -1
- package/dist/types/fieldHelpers/helpers/FieldHelper.d.ts +0 -7
- package/dist/types/fieldHelpers/helpers/FieldHelper.d.ts.map +0 -1
- package/dist/types/fieldHelpers/helpers/TemporalFieldHelper.d.ts +0 -10
- package/dist/types/fieldHelpers/helpers/TemporalFieldHelper.d.ts.map +0 -1
- package/dist/types/fieldHelpers/helpers/UuidFieldHelper.d.ts +0 -10
- package/dist/types/fieldHelpers/helpers/UuidFieldHelper.d.ts.map +0 -1
- package/dist/types/fieldHelpers/helpers/index.d.ts +0 -3
- package/dist/types/fieldHelpers/helpers/index.d.ts.map +0 -1
- package/dist/types/fieldHelpers/index.d.ts +0 -2
- package/dist/types/fieldHelpers/index.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/tsconfig.tsbuildinfo +0 -1
- package/dist/types/utils/assertNever.d.ts +0 -2
- package/dist/types/utils/assertNever.d.ts.map +0 -1
- package/dist/types/utils/generateEnumerabilityPreventingEntropy.d.ts +0 -2
- package/dist/types/utils/generateEnumerabilityPreventingEntropy.d.ts.map +0 -1
- package/dist/types/utils/index.d.ts +0 -4
- package/dist/types/utils/index.d.ts.map +0 -1
- package/dist/types/utils/isEmptyObject.d.ts +0 -2
- package/dist/types/utils/isEmptyObject.d.ts.map +0 -1
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const bindingCommon = require("@contember/binding-common");
|
|
4
|
-
const MutationAlias = require("./requestAliases/MutationAlias.cjs");
|
|
5
|
-
class ErrorsPreprocessor {
|
|
6
|
-
constructor(requestResponse, operations) {
|
|
7
|
-
this.requestResponse = requestResponse;
|
|
8
|
-
this.operations = operations;
|
|
9
|
-
}
|
|
10
|
-
preprocess() {
|
|
11
|
-
const treeRoot = /* @__PURE__ */ new Map();
|
|
12
|
-
if (this.requestResponse === void 0) {
|
|
13
|
-
return treeRoot;
|
|
14
|
-
}
|
|
15
|
-
for (const operation of this.operations) {
|
|
16
|
-
const mutationResponse = this.requestResponse.data[operation.alias];
|
|
17
|
-
const processedResponse = this.processMutationResponse(mutationResponse);
|
|
18
|
-
if (processedResponse === void 0) {
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
const { subTreeType, subTreePlaceholder, id } = operation;
|
|
22
|
-
if (subTreeType === "single") {
|
|
23
|
-
if (treeRoot.has(subTreePlaceholder)) {
|
|
24
|
-
return this.rejectCorruptData();
|
|
25
|
-
}
|
|
26
|
-
treeRoot.set(subTreePlaceholder, processedResponse);
|
|
27
|
-
} else if (subTreeType === "list") {
|
|
28
|
-
const child = treeRoot.get(subTreePlaceholder);
|
|
29
|
-
if (child === void 0) {
|
|
30
|
-
treeRoot.set(subTreePlaceholder, {
|
|
31
|
-
nodeType: "iNode",
|
|
32
|
-
children: /* @__PURE__ */ new Map([[id, processedResponse]]),
|
|
33
|
-
validation: [],
|
|
34
|
-
execution: []
|
|
35
|
-
});
|
|
36
|
-
} else if (child.nodeType === "iNode") {
|
|
37
|
-
child.children.set(id, processedResponse);
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
return bindingCommon.assertNever(subTreeType);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return treeRoot;
|
|
44
|
-
}
|
|
45
|
-
processMutationResponse(mutationResponse) {
|
|
46
|
-
if (mutationResponse.ok && mutationResponse.validation?.valid && mutationResponse.errors.length === 0) {
|
|
47
|
-
return void 0;
|
|
48
|
-
}
|
|
49
|
-
if (mutationResponse.validation?.errors.length) {
|
|
50
|
-
return this.getErrorNode(mutationResponse.validation?.errors);
|
|
51
|
-
}
|
|
52
|
-
if (mutationResponse.errors.length) {
|
|
53
|
-
return this.getErrorNode(mutationResponse.errors);
|
|
54
|
-
}
|
|
55
|
-
return void 0;
|
|
56
|
-
}
|
|
57
|
-
getErrorNode(errors) {
|
|
58
|
-
const [head, ...tail] = errors;
|
|
59
|
-
let rootNode = this.getRootNode(head);
|
|
60
|
-
errorLoop: for (const error of tail) {
|
|
61
|
-
let currentNode = rootNode;
|
|
62
|
-
const path = "paths" in error ? error.paths[0] ?? [] : error.path;
|
|
63
|
-
for (let i = 0, pathLength = path.length; i < pathLength; i++) {
|
|
64
|
-
const pathNode = path[i];
|
|
65
|
-
if (currentNode.nodeType === "leaf") {
|
|
66
|
-
currentNode.nodeType = "iNode";
|
|
67
|
-
currentNode.children = /* @__PURE__ */ new Map();
|
|
68
|
-
}
|
|
69
|
-
if ("field" in pathNode) {
|
|
70
|
-
if (currentNode.nodeType === "iNode") {
|
|
71
|
-
let alias = pathNode.field;
|
|
72
|
-
let nextIndex = i + 1;
|
|
73
|
-
if (nextIndex in path) {
|
|
74
|
-
const nextPathNode = path[nextIndex];
|
|
75
|
-
if ("index" in nextPathNode && typeof nextPathNode.alias === "string" && nextPathNode.alias.startsWith(pathNode.field)) {
|
|
76
|
-
i++;
|
|
77
|
-
nextIndex++;
|
|
78
|
-
alias = nextPathNode.alias;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (!currentNode.children.has(alias)) {
|
|
82
|
-
currentNode.children.set(alias, this.getRootNode(error, nextIndex));
|
|
83
|
-
if (nextIndex <= path.length) {
|
|
84
|
-
continue errorLoop;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
currentNode = currentNode.children.get(alias);
|
|
88
|
-
} else {
|
|
89
|
-
this.rejectCorruptData();
|
|
90
|
-
}
|
|
91
|
-
} else if ("index" in path) {
|
|
92
|
-
if (currentNode.nodeType === "iNode") {
|
|
93
|
-
const alias = pathNode.alias;
|
|
94
|
-
if (alias === null) {
|
|
95
|
-
throw new ErrorsPreprocessor.ErrorsPreprocessorError(
|
|
96
|
-
`Corrupt data: undefined alias for node with index ${pathNode.index}.`
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
const entityId = MutationAlias.MutationAlias.decodeEntityId(alias);
|
|
100
|
-
if (!currentNode.children.has(entityId)) {
|
|
101
|
-
currentNode.children.set(entityId, this.getRootNode(error, i + 1));
|
|
102
|
-
if (i + 1 <= path.length) {
|
|
103
|
-
continue errorLoop;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
currentNode = currentNode.children.get(entityId);
|
|
107
|
-
} else {
|
|
108
|
-
this.rejectCorruptData();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (this.isExecutionError(error)) {
|
|
113
|
-
currentNode.execution.push({ type: "execution", code: error.type, developerMessage: error.message });
|
|
114
|
-
} else {
|
|
115
|
-
currentNode.validation.push(this.createValidationError(error.message.text));
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return rootNode;
|
|
119
|
-
}
|
|
120
|
-
getRootNode(error, startIndex = 0) {
|
|
121
|
-
let rootNode = {
|
|
122
|
-
validation: this.isExecutionError(error) ? [] : [this.createValidationError(error.message.text)],
|
|
123
|
-
execution: this.isExecutionError(error) ? [{ type: "execution", code: error.type, developerMessage: error.message }] : [],
|
|
124
|
-
nodeType: "leaf"
|
|
125
|
-
};
|
|
126
|
-
const path = "paths" in error ? error.paths[0] ?? [] : error.path;
|
|
127
|
-
for (let i = path.length - 1; i >= startIndex; i--) {
|
|
128
|
-
const pathNode = path[i];
|
|
129
|
-
if ("field" in pathNode) {
|
|
130
|
-
rootNode = {
|
|
131
|
-
validation: [],
|
|
132
|
-
execution: [],
|
|
133
|
-
nodeType: "iNode",
|
|
134
|
-
children: /* @__PURE__ */ new Map([[pathNode.field, rootNode]])
|
|
135
|
-
};
|
|
136
|
-
} else if ("index" in pathNode) {
|
|
137
|
-
const alias = pathNode.alias;
|
|
138
|
-
if (alias === null) {
|
|
139
|
-
throw new ErrorsPreprocessor.ErrorsPreprocessorError(
|
|
140
|
-
`Corrupt data: undefined alias for node with index ${pathNode.index}.`
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
rootNode = {
|
|
144
|
-
validation: [],
|
|
145
|
-
execution: [],
|
|
146
|
-
nodeType: "iNode",
|
|
147
|
-
children: /* @__PURE__ */ new Map([[MutationAlias.MutationAlias.decodeEntityId(alias), rootNode]])
|
|
148
|
-
};
|
|
149
|
-
} else {
|
|
150
|
-
bindingCommon.assertNever(pathNode);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return rootNode;
|
|
154
|
-
}
|
|
155
|
-
createValidationError(message) {
|
|
156
|
-
if (message === "Field is required") {
|
|
157
|
-
return {
|
|
158
|
-
type: "validation",
|
|
159
|
-
code: "fieldRequired",
|
|
160
|
-
message
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
return { type: "validation", message, code: void 0 };
|
|
164
|
-
}
|
|
165
|
-
isExecutionError(error) {
|
|
166
|
-
return "type" in error;
|
|
167
|
-
}
|
|
168
|
-
rejectCorruptData() {
|
|
169
|
-
throw new ErrorsPreprocessor.ErrorsPreprocessorError(
|
|
170
|
-
"Received corrupted data: a node cannot be simultaneously field-indexed and path-indexed."
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
((ErrorsPreprocessor2) => {
|
|
175
|
-
class ErrorsPreprocessorError extends Error {
|
|
176
|
-
}
|
|
177
|
-
ErrorsPreprocessor2.ErrorsPreprocessorError = ErrorsPreprocessorError;
|
|
178
|
-
})(ErrorsPreprocessor || (ErrorsPreprocessor = {}));
|
|
179
|
-
exports.ErrorsPreprocessor = ErrorsPreprocessor;
|
|
180
|
-
//# sourceMappingURL=ErrorsPreprocessor.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorsPreprocessor.cjs","sources":["../../../../../packages/binding-legacy/src/core/ErrorsPreprocessor.ts"],"sourcesContent":["import type { EntityId, ErrorAccessor, FieldName, PlaceholderName } from '@contember/binding-common'\nimport { DataBindingTransactionResult } from '@contember/binding-common'\nimport { assertNever } from '@contember/binding-common'\nimport { MutationAlias } from './requestAliases'\nimport { SubMutationOperation } from './MutationGenerator'\nimport { MutationError, MutationResult, ValidationError } from '@contember/client'\n\nclass ErrorsPreprocessor {\n\tpublic constructor(\n\t\tprivate readonly requestResponse: DataBindingTransactionResult,\n\t\tprivate readonly operations: SubMutationOperation[],\n\t) {}\n\n\tpublic preprocess(): ErrorsPreprocessor.ErrorTreeRoot {\n\t\tconst treeRoot: ErrorsPreprocessor.ErrorTreeRoot = new Map()\n\n\t\tif (this.requestResponse === undefined) {\n\t\t\treturn treeRoot\n\t\t}\n\n\t\tfor (const operation of this.operations) {\n\t\t\tconst mutationResponse = this.requestResponse.data[operation.alias]\n\t\t\tconst processedResponse = this.processMutationResponse(mutationResponse)\n\n\t\t\tif (processedResponse === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst { subTreeType, subTreePlaceholder, id } = operation\n\n\t\t\tif (subTreeType === 'single') {\n\t\t\t\tif (treeRoot.has(subTreePlaceholder)) {\n\t\t\t\t\treturn this.rejectCorruptData()\n\t\t\t\t}\n\t\t\t\ttreeRoot.set(subTreePlaceholder, processedResponse)\n\t\t\t} else if (subTreeType === 'list') {\n\t\t\t\tconst child = treeRoot.get(subTreePlaceholder)\n\n\t\t\t\tif (child === undefined) {\n\t\t\t\t\ttreeRoot.set(subTreePlaceholder, {\n\t\t\t\t\t\tnodeType: 'iNode',\n\t\t\t\t\t\tchildren: new Map([[id, processedResponse]]),\n\t\t\t\t\t\tvalidation: [],\n\t\t\t\t\t\texecution: [],\n\t\t\t\t\t})\n\t\t\t\t} else if (child.nodeType === 'iNode') {\n\t\t\t\t\tchild.children.set(id, processedResponse)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn assertNever(subTreeType)\n\t\t\t}\n\n\t\t}\n\t\treturn treeRoot\n\t}\n\n\tprivate processMutationResponse(mutationResponse: MutationResult): ErrorsPreprocessor.ErrorNode | undefined {\n\t\tif (mutationResponse.ok && mutationResponse.validation?.valid && mutationResponse.errors.length === 0) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (mutationResponse.validation?.errors.length) {\n\t\t\treturn this.getErrorNode(mutationResponse.validation?.errors)\n\t\t}\n\t\tif (mutationResponse.errors.length) {\n\t\t\treturn this.getErrorNode(mutationResponse.errors)\n\t\t}\n\t\treturn undefined\n\t}\n\n\tprivate getErrorNode(errors: ValidationError[] | MutationError[]): ErrorsPreprocessor.ErrorNode {\n\t\tconst [head, ...tail] = errors\n\n\t\tlet rootNode = this.getRootNode(head)\n\n\t\terrorLoop: for (const error of tail) {\n\t\t\tlet currentNode = rootNode\n\n\t\t\tconst path = 'paths' in error ? (error.paths[0] ?? []) : error.path\n\n\t\t\tfor (let i = 0, pathLength = path.length; i < pathLength; i++) {\n\t\t\t\tconst pathNode = path[i]\n\n\t\t\t\tif (currentNode.nodeType === 'leaf') {\n\t\t\t\t\t(currentNode as any as ErrorsPreprocessor.ErrorINode).nodeType = 'iNode'\n\t\t\t\t\t;(currentNode as any as ErrorsPreprocessor.ErrorINode).children = new Map()\n\t\t\t\t}\n\n\t\t\t\tif ('field' in pathNode) {\n\t\t\t\t\tif (currentNode.nodeType === 'iNode') {\n\t\t\t\t\t\tlet alias = pathNode.field\n\t\t\t\t\t\tlet nextIndex = i + 1\n\t\t\t\t\t\tif (nextIndex in path) {\n\t\t\t\t\t\t\tconst nextPathNode = path[nextIndex]\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t'index' in nextPathNode &&\n\t\t\t\t\t\t\t\ttypeof nextPathNode.alias === 'string' &&\n\t\t\t\t\t\t\t\tnextPathNode.alias.startsWith(pathNode.field)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// We're dealing with a reduced hasMany relation.\n\t\t\t\t\t\t\t\ti++\n\t\t\t\t\t\t\t\tnextIndex++\n\t\t\t\t\t\t\t\talias = nextPathNode.alias\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!currentNode.children.has(alias)) {\n\t\t\t\t\t\t\tcurrentNode.children.set(alias, this.getRootNode(error, nextIndex))\n\t\t\t\t\t\t\tif (nextIndex <= path.length) {\n\t\t\t\t\t\t\t\t// This path has been handled by getRootNode\n\t\t\t\t\t\t\t\tcontinue errorLoop\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcurrentNode = currentNode.children.get(alias)!\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.rejectCorruptData()\n\t\t\t\t\t}\n\t\t\t\t} else if ('index' in path) {\n\t\t\t\t\tif (currentNode.nodeType === 'iNode') {\n\t\t\t\t\t\tconst alias = pathNode.alias\n\n\t\t\t\t\t\tif (alias === null) {\n\t\t\t\t\t\t\tthrow new ErrorsPreprocessor.ErrorsPreprocessorError(\n\t\t\t\t\t\t\t\t`Corrupt data: undefined alias for node with index ${pathNode.index}.`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst entityId = MutationAlias.decodeEntityId(alias)\n\n\t\t\t\t\t\tif (!currentNode.children.has(entityId)) {\n\t\t\t\t\t\t\tcurrentNode.children.set(entityId, this.getRootNode(error, i + 1))\n\t\t\t\t\t\t\tif (i + 1 <= path.length) {\n\t\t\t\t\t\t\t\t// This path has been handled by getRootNode\n\t\t\t\t\t\t\t\tcontinue errorLoop\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcurrentNode = currentNode.children.get(entityId)!\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.rejectCorruptData()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.isExecutionError(error)) {\n\t\t\t\tcurrentNode.execution.push({ type: 'execution', code: error.type, developerMessage: error.message })\n\t\t\t} else {\n\t\t\t\tcurrentNode.validation.push(this.createValidationError(error.message.text))\n\t\t\t}\n\t\t}\n\n\t\treturn rootNode\n\t}\n\n\tprivate getRootNode(error: ValidationError | MutationError, startIndex: number = 0): ErrorsPreprocessor.ErrorNode {\n\t\tlet rootNode: ErrorsPreprocessor.ErrorNode = {\n\t\t\tvalidation: this.isExecutionError(error) ? [] : [this.createValidationError(error.message.text)],\n\t\t\texecution: this.isExecutionError(error) ? [{ type: 'execution', code: error.type, developerMessage: error.message }] : [],\n\t\t\tnodeType: 'leaf',\n\t\t}\n\t\tconst path = 'paths' in error ? (error.paths[0] ?? []) : error.path\n\t\tfor (let i = path.length - 1; i >= startIndex; i--) {\n\t\t\tconst pathNode = path[i]\n\t\t\tif ('field' in pathNode) {\n\t\t\t\trootNode = {\n\t\t\t\t\tvalidation: [],\n\t\t\t\t\texecution: [],\n\t\t\t\t\tnodeType: 'iNode',\n\t\t\t\t\tchildren: new Map([[pathNode.field, rootNode]]),\n\t\t\t\t}\n\t\t\t} else if ('index' in pathNode) {\n\t\t\t\tconst alias = pathNode.alias\n\n\t\t\t\tif (alias === null) {\n\t\t\t\t\tthrow new ErrorsPreprocessor.ErrorsPreprocessorError(\n\t\t\t\t\t\t`Corrupt data: undefined alias for node with index ${pathNode.index}.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\trootNode = {\n\t\t\t\t\tvalidation: [],\n\t\t\t\t\texecution: [],\n\t\t\t\t\tnodeType: 'iNode',\n\t\t\t\t\tchildren: new Map([[MutationAlias.decodeEntityId(alias), rootNode]]),\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tassertNever(pathNode)\n\t\t\t}\n\t\t}\n\n\t\treturn rootNode\n\t}\n\n\tprivate createValidationError(message: string): ErrorAccessor.ValidationError {\n\t\tif (message === 'Field is required') {\n\t\t\t// TODO this is just awful. Validation errors currently don't have error codes which makes it more difficult\n\t\t\t// \tto translate the error messages. This is the most common such error, and so we just make up a code\n\t\t\t// \tin order to facilitate error handling further downstream.\n\t\t\treturn {\n\t\t\t\ttype: 'validation',\n\t\t\t\tcode: 'fieldRequired',\n\t\t\t\tmessage,\n\t\t\t}\n\t\t}\n\t\treturn { type: 'validation', message, code: undefined }\n\t}\n\n\tprivate isExecutionError(error: ValidationError | MutationError): error is MutationError {\n\t\treturn 'type' in error\n\t}\n\n\tprivate rejectCorruptData(): never {\n\t\tthrow new ErrorsPreprocessor.ErrorsPreprocessorError(\n\t\t\t'Received corrupted data: a node cannot be simultaneously field-indexed and path-indexed.',\n\t\t)\n\t}\n}\n\nnamespace ErrorsPreprocessor {\n\texport interface BaseErrorNode {\n\t\tvalidation: ErrorAccessor.ValidationError[]\n\t\texecution: ErrorAccessor.ExecutionError[]\n\t}\n\n\texport interface LeafErrorNode extends BaseErrorNode {\n\t\tnodeType: 'leaf'\n\t}\n\n\texport interface ErrorINode extends BaseErrorNode {\n\t\tnodeType: 'iNode'\n\t\tchildren: Map<FieldName | EntityId, ErrorNode>\n\t}\n\n\texport type ErrorNode = ErrorINode | LeafErrorNode\n\n\texport type ErrorTreeRoot = Map<PlaceholderName, ErrorNode>\n\n\texport class ErrorsPreprocessorError extends Error {}\n}\n\nexport { ErrorsPreprocessor }\n"],"names":["assertNever","MutationAlias","ErrorsPreprocessor"],"mappings":";;;;AAOA,MAAM,mBAAmB;AAAA,EACjB,YACW,iBACA,YAChB;AAFgB,SAAA,kBAAA;AACA,SAAA,aAAA;AAAA,EAAA;AAAA,EAGX,aAA+C;AAC/C,UAAA,+BAAiD,IAAI;AAEvD,QAAA,KAAK,oBAAoB,QAAW;AAChC,aAAA;AAAA,IAAA;AAGG,eAAA,aAAa,KAAK,YAAY;AACxC,YAAM,mBAAmB,KAAK,gBAAgB,KAAK,UAAU,KAAK;AAC5D,YAAA,oBAAoB,KAAK,wBAAwB,gBAAgB;AAEvE,UAAI,sBAAsB,QAAW;AACpC;AAAA,MAAA;AAED,YAAM,EAAE,aAAa,oBAAoB,GAAO,IAAA;AAEhD,UAAI,gBAAgB,UAAU;AACzB,YAAA,SAAS,IAAI,kBAAkB,GAAG;AACrC,iBAAO,KAAK,kBAAkB;AAAA,QAAA;AAEtB,iBAAA,IAAI,oBAAoB,iBAAiB;AAAA,MAAA,WACxC,gBAAgB,QAAQ;AA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Y,qBAAqB;AAI7B,aAAA;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN;AAAA,MACD;AAAA,IAAA;AAED,WAAO,EAAE,MAAM,cAAc,SAAS,MAAM,OAAU;AAAA,EAAA;AAAA,EAG/C,iBAAiB,OAAgE;AACxF,WAAO,UAAU;AAAA,EAAA;AAAA,EAGV,oBAA2B;AAClC,UAAM,IAAI,mBAAmB;AAAA,MAC5B;AAAA,IACD;AAAA,EAAA;AAEF;AAAA,CAEA,CAAUE,wBAAV;AAAA,EAmBQ,MAAM,gCAAgC,MAAM;AAAA,EAAA;AAA5CA,sBAAM,0BAAA;AAAA,GAnBJ,uBAAA,qBAAA,CAAA,EAAA;;"}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { assertNever } from "@contember/binding-common";
|
|
2
|
-
import { MutationAlias } from "./requestAliases/MutationAlias.js";
|
|
3
|
-
class ErrorsPreprocessor {
|
|
4
|
-
constructor(requestResponse, operations) {
|
|
5
|
-
this.requestResponse = requestResponse;
|
|
6
|
-
this.operations = operations;
|
|
7
|
-
}
|
|
8
|
-
preprocess() {
|
|
9
|
-
const treeRoot = /* @__PURE__ */ new Map();
|
|
10
|
-
if (this.requestResponse === void 0) {
|
|
11
|
-
return treeRoot;
|
|
12
|
-
}
|
|
13
|
-
for (const operation of this.operations) {
|
|
14
|
-
const mutationResponse = this.requestResponse.data[operation.alias];
|
|
15
|
-
const processedResponse = this.processMutationResponse(mutationResponse);
|
|
16
|
-
if (processedResponse === void 0) {
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
const { subTreeType, subTreePlaceholder, id } = operation;
|
|
20
|
-
if (subTreeType === "single") {
|
|
21
|
-
if (treeRoot.has(subTreePlaceholder)) {
|
|
22
|
-
return this.rejectCorruptData();
|
|
23
|
-
}
|
|
24
|
-
treeRoot.set(subTreePlaceholder, processedResponse);
|
|
25
|
-
} else if (subTreeType === "list") {
|
|
26
|
-
const child = treeRoot.get(subTreePlaceholder);
|
|
27
|
-
if (child === void 0) {
|
|
28
|
-
treeRoot.set(subTreePlaceholder, {
|
|
29
|
-
nodeType: "iNode",
|
|
30
|
-
children: /* @__PURE__ */ new Map([[id, processedResponse]]),
|
|
31
|
-
validation: [],
|
|
32
|
-
execution: []
|
|
33
|
-
});
|
|
34
|
-
} else if (child.nodeType === "iNode") {
|
|
35
|
-
child.children.set(id, processedResponse);
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
return assertNever(subTreeType);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return treeRoot;
|
|
42
|
-
}
|
|
43
|
-
processMutationResponse(mutationResponse) {
|
|
44
|
-
if (mutationResponse.ok && mutationResponse.validation?.valid && mutationResponse.errors.length === 0) {
|
|
45
|
-
return void 0;
|
|
46
|
-
}
|
|
47
|
-
if (mutationResponse.validation?.errors.length) {
|
|
48
|
-
return this.getErrorNode(mutationResponse.validation?.errors);
|
|
49
|
-
}
|
|
50
|
-
if (mutationResponse.errors.length) {
|
|
51
|
-
return this.getErrorNode(mutationResponse.errors);
|
|
52
|
-
}
|
|
53
|
-
return void 0;
|
|
54
|
-
}
|
|
55
|
-
getErrorNode(errors) {
|
|
56
|
-
const [head, ...tail] = errors;
|
|
57
|
-
let rootNode = this.getRootNode(head);
|
|
58
|
-
errorLoop: for (const error of tail) {
|
|
59
|
-
let currentNode = rootNode;
|
|
60
|
-
const path = "paths" in error ? error.paths[0] ?? [] : error.path;
|
|
61
|
-
for (let i = 0, pathLength = path.length; i < pathLength; i++) {
|
|
62
|
-
const pathNode = path[i];
|
|
63
|
-
if (currentNode.nodeType === "leaf") {
|
|
64
|
-
currentNode.nodeType = "iNode";
|
|
65
|
-
currentNode.children = /* @__PURE__ */ new Map();
|
|
66
|
-
}
|
|
67
|
-
if ("field" in pathNode) {
|
|
68
|
-
if (currentNode.nodeType === "iNode") {
|
|
69
|
-
let alias = pathNode.field;
|
|
70
|
-
let nextIndex = i + 1;
|
|
71
|
-
if (nextIndex in path) {
|
|
72
|
-
const nextPathNode = path[nextIndex];
|
|
73
|
-
if ("index" in nextPathNode && typeof nextPathNode.alias === "string" && nextPathNode.alias.startsWith(pathNode.field)) {
|
|
74
|
-
i++;
|
|
75
|
-
nextIndex++;
|
|
76
|
-
alias = nextPathNode.alias;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (!currentNode.children.has(alias)) {
|
|
80
|
-
currentNode.children.set(alias, this.getRootNode(error, nextIndex));
|
|
81
|
-
if (nextIndex <= path.length) {
|
|
82
|
-
continue errorLoop;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
currentNode = currentNode.children.get(alias);
|
|
86
|
-
} else {
|
|
87
|
-
this.rejectCorruptData();
|
|
88
|
-
}
|
|
89
|
-
} else if ("index" in path) {
|
|
90
|
-
if (currentNode.nodeType === "iNode") {
|
|
91
|
-
const alias = pathNode.alias;
|
|
92
|
-
if (alias === null) {
|
|
93
|
-
throw new ErrorsPreprocessor.ErrorsPreprocessorError(
|
|
94
|
-
`Corrupt data: undefined alias for node with index ${pathNode.index}.`
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
const entityId = MutationAlias.decodeEntityId(alias);
|
|
98
|
-
if (!currentNode.children.has(entityId)) {
|
|
99
|
-
currentNode.children.set(entityId, this.getRootNode(error, i + 1));
|
|
100
|
-
if (i + 1 <= path.length) {
|
|
101
|
-
continue errorLoop;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
currentNode = currentNode.children.get(entityId);
|
|
105
|
-
} else {
|
|
106
|
-
this.rejectCorruptData();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (this.isExecutionError(error)) {
|
|
111
|
-
currentNode.execution.push({ type: "execution", code: error.type, developerMessage: error.message });
|
|
112
|
-
} else {
|
|
113
|
-
currentNode.validation.push(this.createValidationError(error.message.text));
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return rootNode;
|
|
117
|
-
}
|
|
118
|
-
getRootNode(error, startIndex = 0) {
|
|
119
|
-
let rootNode = {
|
|
120
|
-
validation: this.isExecutionError(error) ? [] : [this.createValidationError(error.message.text)],
|
|
121
|
-
execution: this.isExecutionError(error) ? [{ type: "execution", code: error.type, developerMessage: error.message }] : [],
|
|
122
|
-
nodeType: "leaf"
|
|
123
|
-
};
|
|
124
|
-
const path = "paths" in error ? error.paths[0] ?? [] : error.path;
|
|
125
|
-
for (let i = path.length - 1; i >= startIndex; i--) {
|
|
126
|
-
const pathNode = path[i];
|
|
127
|
-
if ("field" in pathNode) {
|
|
128
|
-
rootNode = {
|
|
129
|
-
validation: [],
|
|
130
|
-
execution: [],
|
|
131
|
-
nodeType: "iNode",
|
|
132
|
-
children: /* @__PURE__ */ new Map([[pathNode.field, rootNode]])
|
|
133
|
-
};
|
|
134
|
-
} else if ("index" in pathNode) {
|
|
135
|
-
const alias = pathNode.alias;
|
|
136
|
-
if (alias === null) {
|
|
137
|
-
throw new ErrorsPreprocessor.ErrorsPreprocessorError(
|
|
138
|
-
`Corrupt data: undefined alias for node with index ${pathNode.index}.`
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
rootNode = {
|
|
142
|
-
validation: [],
|
|
143
|
-
execution: [],
|
|
144
|
-
nodeType: "iNode",
|
|
145
|
-
children: /* @__PURE__ */ new Map([[MutationAlias.decodeEntityId(alias), rootNode]])
|
|
146
|
-
};
|
|
147
|
-
} else {
|
|
148
|
-
assertNever(pathNode);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return rootNode;
|
|
152
|
-
}
|
|
153
|
-
createValidationError(message) {
|
|
154
|
-
if (message === "Field is required") {
|
|
155
|
-
return {
|
|
156
|
-
type: "validation",
|
|
157
|
-
code: "fieldRequired",
|
|
158
|
-
message
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
return { type: "validation", message, code: void 0 };
|
|
162
|
-
}
|
|
163
|
-
isExecutionError(error) {
|
|
164
|
-
return "type" in error;
|
|
165
|
-
}
|
|
166
|
-
rejectCorruptData() {
|
|
167
|
-
throw new ErrorsPreprocessor.ErrorsPreprocessorError(
|
|
168
|
-
"Received corrupted data: a node cannot be simultaneously field-indexed and path-indexed."
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
((ErrorsPreprocessor2) => {
|
|
173
|
-
class ErrorsPreprocessorError extends Error {
|
|
174
|
-
}
|
|
175
|
-
ErrorsPreprocessor2.ErrorsPreprocessorError = ErrorsPreprocessorError;
|
|
176
|
-
})(ErrorsPreprocessor || (ErrorsPreprocessor = {}));
|
|
177
|
-
export {
|
|
178
|
-
ErrorsPreprocessor
|
|
179
|
-
};
|
|
180
|
-
//# sourceMappingURL=ErrorsPreprocessor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorsPreprocessor.js","sources":["../../../../../packages/binding-legacy/src/core/ErrorsPreprocessor.ts"],"sourcesContent":["import type { EntityId, ErrorAccessor, FieldName, PlaceholderName } from '@contember/binding-common'\nimport { DataBindingTransactionResult } from '@contember/binding-common'\nimport { assertNever } from '@contember/binding-common'\nimport { MutationAlias } from './requestAliases'\nimport { SubMutationOperation } from './MutationGenerator'\nimport { MutationError, MutationResult, ValidationError } from '@contember/client'\n\nclass ErrorsPreprocessor {\n\tpublic constructor(\n\t\tprivate readonly requestResponse: DataBindingTransactionResult,\n\t\tprivate readonly operations: SubMutationOperation[],\n\t) {}\n\n\tpublic preprocess(): ErrorsPreprocessor.ErrorTreeRoot {\n\t\tconst treeRoot: ErrorsPreprocessor.ErrorTreeRoot = new Map()\n\n\t\tif (this.requestResponse === undefined) {\n\t\t\treturn treeRoot\n\t\t}\n\n\t\tfor (const operation of this.operations) {\n\t\t\tconst mutationResponse = this.requestResponse.data[operation.alias]\n\t\t\tconst processedResponse = this.processMutationResponse(mutationResponse)\n\n\t\t\tif (processedResponse === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst { subTreeType, subTreePlaceholder, id } = operation\n\n\t\t\tif (subTreeType === 'single') {\n\t\t\t\tif (treeRoot.has(subTreePlaceholder)) {\n\t\t\t\t\treturn this.rejectCorruptData()\n\t\t\t\t}\n\t\t\t\ttreeRoot.set(subTreePlaceholder, processedResponse)\n\t\t\t} else if (subTreeType === 'list') {\n\t\t\t\tconst child = treeRoot.get(subTreePlaceholder)\n\n\t\t\t\tif (child === undefined) {\n\t\t\t\t\ttreeRoot.set(subTreePlaceholder, {\n\t\t\t\t\t\tnodeType: 'iNode',\n\t\t\t\t\t\tchildren: new Map([[id, processedResponse]]),\n\t\t\t\t\t\tvalidation: [],\n\t\t\t\t\t\texecution: [],\n\t\t\t\t\t})\n\t\t\t\t} else if (child.nodeType === 'iNode') {\n\t\t\t\t\tchild.children.set(id, processedResponse)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn assertNever(subTreeType)\n\t\t\t}\n\n\t\t}\n\t\treturn treeRoot\n\t}\n\n\tprivate processMutationResponse(mutationResponse: MutationResult): ErrorsPreprocessor.ErrorNode | undefined {\n\t\tif (mutationResponse.ok && mutationResponse.validation?.valid && mutationResponse.errors.length === 0) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (mutationResponse.validation?.errors.length) {\n\t\t\treturn this.getErrorNode(mutationResponse.validation?.errors)\n\t\t}\n\t\tif (mutationResponse.errors.length) {\n\t\t\treturn this.getErrorNode(mutationResponse.errors)\n\t\t}\n\t\treturn undefined\n\t}\n\n\tprivate getErrorNode(errors: ValidationError[] | MutationError[]): ErrorsPreprocessor.ErrorNode {\n\t\tconst [head, ...tail] = errors\n\n\t\tlet rootNode = this.getRootNode(head)\n\n\t\terrorLoop: for (const error of tail) {\n\t\t\tlet currentNode = rootNode\n\n\t\t\tconst path = 'paths' in error ? (error.paths[0] ?? []) : error.path\n\n\t\t\tfor (let i = 0, pathLength = path.length; i < pathLength; i++) {\n\t\t\t\tconst pathNode = path[i]\n\n\t\t\t\tif (currentNode.nodeType === 'leaf') {\n\t\t\t\t\t(currentNode as any as ErrorsPreprocessor.ErrorINode).nodeType = 'iNode'\n\t\t\t\t\t;(currentNode as any as ErrorsPreprocessor.ErrorINode).children = new Map()\n\t\t\t\t}\n\n\t\t\t\tif ('field' in pathNode) {\n\t\t\t\t\tif (currentNode.nodeType === 'iNode') {\n\t\t\t\t\t\tlet alias = pathNode.field\n\t\t\t\t\t\tlet nextIndex = i + 1\n\t\t\t\t\t\tif (nextIndex in path) {\n\t\t\t\t\t\t\tconst nextPathNode = path[nextIndex]\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t'index' in nextPathNode &&\n\t\t\t\t\t\t\t\ttypeof nextPathNode.alias === 'string' &&\n\t\t\t\t\t\t\t\tnextPathNode.alias.startsWith(pathNode.field)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// We're dealing with a reduced hasMany relation.\n\t\t\t\t\t\t\t\ti++\n\t\t\t\t\t\t\t\tnextIndex++\n\t\t\t\t\t\t\t\talias = nextPathNode.alias\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!currentNode.children.has(alias)) {\n\t\t\t\t\t\t\tcurrentNode.children.set(alias, this.getRootNode(error, nextIndex))\n\t\t\t\t\t\t\tif (nextIndex <= path.length) {\n\t\t\t\t\t\t\t\t// This path has been handled by getRootNode\n\t\t\t\t\t\t\t\tcontinue errorLoop\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcurrentNode = currentNode.children.get(alias)!\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.rejectCorruptData()\n\t\t\t\t\t}\n\t\t\t\t} else if ('index' in path) {\n\t\t\t\t\tif (currentNode.nodeType === 'iNode') {\n\t\t\t\t\t\tconst alias = pathNode.alias\n\n\t\t\t\t\t\tif (alias === null) {\n\t\t\t\t\t\t\tthrow new ErrorsPreprocessor.ErrorsPreprocessorError(\n\t\t\t\t\t\t\t\t`Corrupt data: undefined alias for node with index ${pathNode.index}.`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst entityId = MutationAlias.decodeEntityId(alias)\n\n\t\t\t\t\t\tif (!currentNode.children.has(entityId)) {\n\t\t\t\t\t\t\tcurrentNode.children.set(entityId, this.getRootNode(error, i + 1))\n\t\t\t\t\t\t\tif (i + 1 <= path.length) {\n\t\t\t\t\t\t\t\t// This path has been handled by getRootNode\n\t\t\t\t\t\t\t\tcontinue errorLoop\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcurrentNode = currentNode.children.get(entityId)!\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.rejectCorruptData()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.isExecutionError(error)) {\n\t\t\t\tcurrentNode.execution.push({ type: 'execution', code: error.type, developerMessage: error.message })\n\t\t\t} else {\n\t\t\t\tcurrentNode.validation.push(this.createValidationError(error.message.text))\n\t\t\t}\n\t\t}\n\n\t\treturn rootNode\n\t}\n\n\tprivate getRootNode(error: ValidationError | MutationError, startIndex: number = 0): ErrorsPreprocessor.ErrorNode {\n\t\tlet rootNode: ErrorsPreprocessor.ErrorNode = {\n\t\t\tvalidation: this.isExecutionError(error) ? [] : [this.createValidationError(error.message.text)],\n\t\t\texecution: this.isExecutionError(error) ? [{ type: 'execution', code: error.type, developerMessage: error.message }] : [],\n\t\t\tnodeType: 'leaf',\n\t\t}\n\t\tconst path = 'paths' in error ? (error.paths[0] ?? []) : error.path\n\t\tfor (let i = path.length - 1; i >= startIndex; i--) {\n\t\t\tconst pathNode = path[i]\n\t\t\tif ('field' in pathNode) {\n\t\t\t\trootNode = {\n\t\t\t\t\tvalidation: [],\n\t\t\t\t\texecution: [],\n\t\t\t\t\tnodeType: 'iNode',\n\t\t\t\t\tchildren: new Map([[pathNode.field, rootNode]]),\n\t\t\t\t}\n\t\t\t} else if ('index' in pathNode) {\n\t\t\t\tconst alias = pathNode.alias\n\n\t\t\t\tif (alias === null) {\n\t\t\t\t\tthrow new ErrorsPreprocessor.ErrorsPreprocessorError(\n\t\t\t\t\t\t`Corrupt data: undefined alias for node with index ${pathNode.index}.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\trootNode = {\n\t\t\t\t\tvalidation: [],\n\t\t\t\t\texecution: [],\n\t\t\t\t\tnodeType: 'iNode',\n\t\t\t\t\tchildren: new Map([[MutationAlias.decodeEntityId(alias), rootNode]]),\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tassertNever(pathNode)\n\t\t\t}\n\t\t}\n\n\t\treturn rootNode\n\t}\n\n\tprivate createValidationError(message: string): ErrorAccessor.ValidationError {\n\t\tif (message === 'Field is required') {\n\t\t\t// TODO this is just awful. Validation errors currently don't have error codes which makes it more difficult\n\t\t\t// \tto translate the error messages. This is the most common such error, and so we just make up a code\n\t\t\t// \tin order to facilitate error handling further downstream.\n\t\t\treturn {\n\t\t\t\ttype: 'validation',\n\t\t\t\tcode: 'fieldRequired',\n\t\t\t\tmessage,\n\t\t\t}\n\t\t}\n\t\treturn { type: 'validation', message, code: undefined }\n\t}\n\n\tprivate isExecutionError(error: ValidationError | MutationError): error is MutationError {\n\t\treturn 'type' in error\n\t}\n\n\tprivate rejectCorruptData(): never {\n\t\tthrow new ErrorsPreprocessor.ErrorsPreprocessorError(\n\t\t\t'Received corrupted data: a node cannot be simultaneously field-indexed and path-indexed.',\n\t\t)\n\t}\n}\n\nnamespace ErrorsPreprocessor {\n\texport interface BaseErrorNode {\n\t\tvalidation: ErrorAccessor.ValidationError[]\n\t\texecution: ErrorAccessor.ExecutionError[]\n\t}\n\n\texport interface LeafErrorNode extends BaseErrorNode {\n\t\tnodeType: 'leaf'\n\t}\n\n\texport interface ErrorINode extends BaseErrorNode {\n\t\tnodeType: 'iNode'\n\t\tchildren: Map<FieldName | EntityId, ErrorNode>\n\t}\n\n\texport type ErrorNode = ErrorINode | LeafErrorNode\n\n\texport type ErrorTreeRoot = Map<PlaceholderName, ErrorNode>\n\n\texport class ErrorsPreprocessorError extends Error {}\n}\n\nexport { ErrorsPreprocessor }\n"],"names":["ErrorsPreprocessor"],"mappings":";;AAOA,MAAM,mBAAmB;AAAA,EACjB,YACW,iBACA,YAChB;AAFgB,SAAA,kBAAA;AACA,SAAA,aAAA;AAAA,EAAA;AAAA,EAGX,aAA+C;AAC/C,UAAA,+BAAiD,IAAI;AAEvD,QAAA,KAAK,oBAAoB,QAAW;AAChC,aAAA;AAAA,IAAA;AAGG,eAAA,aAAa,KAAK,YAAY;AACxC,YAAM,mBAAmB,KAAK,gBAAgB,KAAK,UAAU,KAAK;AAC5D,YAAA,oBAAoB,KAAK,wBAAwB,gBAAgB;AAEvE,UAAI,sBAAsB,QAAW;AACpC;AAAA,MAAA;AAED,YAAM,EAAE,aAAa,oBAAoB,GAAO,IAAA;AAEhD,UAAI,gBAAgB,UAAU;AACzB,YAAA,SAAS,IAAI,kBAAkB,GAAG;AACrC,iBAAO,KAAK,kBAAkB;AAAA,QAAA;AAEtB,iBAAA,IAAI,oBAAoB,iBAAiB;AAAA,MAAA,WACxC,gBAAgB,QAAQ;AAC5B,cAAA,QAAQ,SAAS,IAAI,kBAAkB;AAE7C,YAAI,UAAU,QAAW;AACxB,mBAAS,IAAI,oBAAoB;AAAA,YAChC,UAAU;AAAA,YACV,8BAAc,IAAI,CAAC,CAAC,IAAI,iBAAiB,CAAC,CAAC;AAAA,YAC3C,YAAY,CAAC;AAAA,YACb,WAAW,CAAA;AAAA,UAAC,CACZ;AAAA,QAAA,WACS,MAAM,aAAa,SAAS;AAChC,gBAAA,SAAS,IAAI,IAAI,iBAAiB;AAAA,QAAA;AAAA,MACzC,OACM;AACN,eAAO,YAAY,WAAW;AAAA,MAAA;AAAA,IAC/B;AAGM,WAAA;AAAA,EAAA;AAAA,EAGA,wBAAwB,kBAA4E;AACvG,QAAA,iBAAiB,MAAM,iBAAiB,YAAY,SAAS,iBAAiB,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