@contember/binding 1.3.0-alpha.2 → 1.3.0-alpha.21
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/accessorTree/RuntimeId.cjs +5 -5
- package/dist/development/accessorTree/RuntimeId.cjs.map +1 -1
- package/dist/development/accessorTree/RuntimeId.js +5 -5
- package/dist/development/accessorTree/RuntimeId.js.map +1 -1
- package/dist/development/accessors/EntityAccessor.cjs +12 -2
- package/dist/development/accessors/EntityAccessor.cjs.map +1 -1
- package/dist/development/accessors/EntityAccessor.js +12 -2
- package/dist/development/accessors/EntityAccessor.js.map +1 -1
- package/dist/development/accessors/EntityListAccessor.cjs +8 -1
- package/dist/development/accessors/EntityListAccessor.cjs.map +1 -1
- package/dist/development/accessors/EntityListAccessor.js +8 -1
- package/dist/development/accessors/EntityListAccessor.js.map +1 -1
- package/dist/development/accessors/ErrorAccessor.cjs.map +1 -1
- package/dist/development/accessors/ErrorAccessor.js.map +1 -1
- package/dist/development/accessors/FieldAccessor.cjs +3 -0
- package/dist/development/accessors/FieldAccessor.cjs.map +1 -1
- package/dist/development/accessors/FieldAccessor.js +3 -0
- package/dist/development/accessors/FieldAccessor.js.map +1 -1
- package/dist/development/core/AccessorErrorManager.cjs +1 -1
- package/dist/development/core/AccessorErrorManager.cjs.map +1 -1
- package/dist/development/core/AccessorErrorManager.js +1 -1
- package/dist/development/core/AccessorErrorManager.js.map +1 -1
- package/dist/development/core/Config.cjs +3 -3
- package/dist/development/core/Config.cjs.map +1 -1
- package/dist/development/core/Config.js +3 -3
- package/dist/development/core/Config.js.map +1 -1
- package/dist/development/core/DataBinding.cjs +7 -6
- package/dist/development/core/DataBinding.cjs.map +1 -1
- package/dist/development/core/DataBinding.js +7 -6
- package/dist/development/core/DataBinding.js.map +1 -1
- package/dist/development/core/ErrorsPreprocessor.cjs.map +1 -1
- package/dist/development/core/ErrorsPreprocessor.js.map +1 -1
- package/dist/development/core/EventManager.cjs.map +1 -1
- package/dist/development/core/EventManager.js.map +1 -1
- package/dist/development/core/MarkerComparator.cjs.map +1 -1
- package/dist/development/core/MarkerComparator.js.map +1 -1
- package/dist/development/core/MarkerMerger.cjs.map +1 -1
- package/dist/development/core/MarkerMerger.js.map +1 -1
- package/dist/development/core/MutationGenerator.cjs +36 -6
- package/dist/development/core/MutationGenerator.cjs.map +1 -1
- package/dist/development/core/MutationGenerator.js +36 -6
- package/dist/development/core/MutationGenerator.js.map +1 -1
- package/dist/development/core/QueryGenerator.cjs.map +1 -1
- package/dist/development/core/QueryGenerator.js.map +1 -1
- package/dist/development/core/RealmKeyGenerator.cjs.map +1 -1
- package/dist/development/core/RealmKeyGenerator.js.map +1 -1
- package/dist/development/core/StateInitializer.cjs +1 -0
- package/dist/development/core/StateInitializer.cjs.map +1 -1
- package/dist/development/core/StateInitializer.js +1 -0
- package/dist/development/core/StateInitializer.js.map +1 -1
- package/dist/development/core/TreeParameterMerger.cjs.map +1 -1
- package/dist/development/core/TreeParameterMerger.js.map +1 -1
- package/dist/development/core/TreeStore.cjs.map +1 -1
- package/dist/development/core/TreeStore.js.map +1 -1
- package/dist/development/core/VariableInputTransformer.cjs.map +1 -1
- package/dist/development/core/VariableInputTransformer.js.map +1 -1
- package/dist/development/core/exceptions/TreeParameterSugarer.cjs.map +1 -1
- package/dist/development/core/exceptions/TreeParameterSugarer.js.map +1 -1
- package/dist/development/core/factories/createBatchUpdatesOptions.cjs.map +1 -1
- package/dist/development/core/factories/createBatchUpdatesOptions.js.map +1 -1
- package/dist/development/core/operations/EntityOperations.cjs.map +1 -1
- package/dist/development/core/operations/EntityOperations.js.map +1 -1
- package/dist/development/core/operations/FieldOperations.cjs.map +1 -1
- package/dist/development/core/operations/FieldOperations.js.map +1 -1
- package/dist/development/core/operations/ListOperations.cjs.map +1 -1
- package/dist/development/core/operations/ListOperations.js.map +1 -1
- package/dist/development/core/operations/OperationsHelpers.cjs.map +1 -1
- package/dist/development/core/operations/OperationsHelpers.js.map +1 -1
- package/dist/development/core/requestAliases/MutationAlias.cjs.map +1 -1
- package/dist/development/core/requestAliases/MutationAlias.js.map +1 -1
- package/dist/development/core/schema/Schema.cjs.map +1 -1
- package/dist/development/core/schema/Schema.js.map +1 -1
- package/dist/development/dao/Environment.cjs.map +1 -1
- package/dist/development/dao/Environment.js.map +1 -1
- package/dist/development/index.cjs +2 -0
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +2 -0
- package/dist/development/index.js.map +1 -1
- package/dist/development/markers/PlaceholderGenerator.cjs.map +1 -1
- package/dist/development/markers/PlaceholderGenerator.js.map +1 -1
- package/dist/development/queryLanguage/Parser.cjs +6 -6
- package/dist/development/queryLanguage/Parser.cjs.map +1 -1
- package/dist/development/queryLanguage/Parser.js +6 -6
- package/dist/development/queryLanguage/Parser.js.map +1 -1
- package/dist/development/queryLanguage/QueryLanguage.cjs +13 -13
- package/dist/development/queryLanguage/QueryLanguage.cjs.map +1 -1
- package/dist/development/queryLanguage/QueryLanguage.js +13 -13
- package/dist/development/queryLanguage/QueryLanguage.js.map +1 -1
- package/dist/development/treeParameters/EventListenersStore.cjs.map +1 -1
- package/dist/development/treeParameters/EventListenersStore.js.map +1 -1
- package/dist/development/utils/TreeNodeUtils.cjs.map +1 -1
- package/dist/development/utils/TreeNodeUtils.js.map +1 -1
- package/dist/development/utils/assert.cjs.map +1 -1
- package/dist/development/utils/assert.js.map +1 -1
- package/dist/development/utils/ucfirst.cjs.map +1 -1
- package/dist/development/utils/ucfirst.js.map +1 -1
- package/dist/production/accessorTree/RuntimeId.cjs +5 -5
- package/dist/production/accessorTree/RuntimeId.cjs.map +1 -1
- package/dist/production/accessorTree/RuntimeId.js +5 -5
- package/dist/production/accessorTree/RuntimeId.js.map +1 -1
- package/dist/production/accessors/EntityAccessor.cjs +12 -2
- package/dist/production/accessors/EntityAccessor.cjs.map +1 -1
- package/dist/production/accessors/EntityAccessor.js +12 -2
- package/dist/production/accessors/EntityAccessor.js.map +1 -1
- package/dist/production/accessors/EntityListAccessor.cjs +8 -1
- package/dist/production/accessors/EntityListAccessor.cjs.map +1 -1
- package/dist/production/accessors/EntityListAccessor.js +8 -1
- package/dist/production/accessors/EntityListAccessor.js.map +1 -1
- package/dist/production/accessors/ErrorAccessor.cjs.map +1 -1
- package/dist/production/accessors/ErrorAccessor.js.map +1 -1
- package/dist/production/accessors/FieldAccessor.cjs +3 -0
- package/dist/production/accessors/FieldAccessor.cjs.map +1 -1
- package/dist/production/accessors/FieldAccessor.js +3 -0
- package/dist/production/accessors/FieldAccessor.js.map +1 -1
- package/dist/production/core/AccessorErrorManager.cjs +1 -1
- package/dist/production/core/AccessorErrorManager.cjs.map +1 -1
- package/dist/production/core/AccessorErrorManager.js +1 -1
- package/dist/production/core/AccessorErrorManager.js.map +1 -1
- package/dist/production/core/Config.cjs +3 -3
- package/dist/production/core/Config.cjs.map +1 -1
- package/dist/production/core/Config.js +3 -3
- package/dist/production/core/Config.js.map +1 -1
- package/dist/production/core/DataBinding.cjs +7 -6
- package/dist/production/core/DataBinding.cjs.map +1 -1
- package/dist/production/core/DataBinding.js +7 -6
- package/dist/production/core/DataBinding.js.map +1 -1
- package/dist/production/core/ErrorsPreprocessor.cjs.map +1 -1
- package/dist/production/core/ErrorsPreprocessor.js.map +1 -1
- package/dist/production/core/EventManager.cjs.map +1 -1
- package/dist/production/core/EventManager.js.map +1 -1
- package/dist/production/core/MarkerComparator.cjs.map +1 -1
- package/dist/production/core/MarkerComparator.js.map +1 -1
- package/dist/production/core/MarkerMerger.cjs.map +1 -1
- package/dist/production/core/MarkerMerger.js.map +1 -1
- package/dist/production/core/MutationGenerator.cjs +36 -6
- package/dist/production/core/MutationGenerator.cjs.map +1 -1
- package/dist/production/core/MutationGenerator.js +36 -6
- package/dist/production/core/MutationGenerator.js.map +1 -1
- package/dist/production/core/QueryGenerator.cjs.map +1 -1
- package/dist/production/core/QueryGenerator.js.map +1 -1
- package/dist/production/core/RealmKeyGenerator.cjs.map +1 -1
- package/dist/production/core/RealmKeyGenerator.js.map +1 -1
- package/dist/production/core/StateInitializer.cjs +1 -0
- package/dist/production/core/StateInitializer.cjs.map +1 -1
- package/dist/production/core/StateInitializer.js +1 -0
- package/dist/production/core/StateInitializer.js.map +1 -1
- package/dist/production/core/TreeParameterMerger.cjs.map +1 -1
- package/dist/production/core/TreeParameterMerger.js.map +1 -1
- package/dist/production/core/TreeStore.cjs.map +1 -1
- package/dist/production/core/TreeStore.js.map +1 -1
- package/dist/production/core/VariableInputTransformer.cjs.map +1 -1
- package/dist/production/core/VariableInputTransformer.js.map +1 -1
- package/dist/production/core/exceptions/TreeParameterSugarer.cjs.map +1 -1
- package/dist/production/core/exceptions/TreeParameterSugarer.js.map +1 -1
- package/dist/production/core/factories/createBatchUpdatesOptions.cjs.map +1 -1
- package/dist/production/core/factories/createBatchUpdatesOptions.js.map +1 -1
- package/dist/production/core/operations/EntityOperations.cjs.map +1 -1
- package/dist/production/core/operations/EntityOperations.js.map +1 -1
- package/dist/production/core/operations/ListOperations.cjs.map +1 -1
- package/dist/production/core/operations/ListOperations.js.map +1 -1
- package/dist/production/core/operations/OperationsHelpers.cjs.map +1 -1
- package/dist/production/core/operations/OperationsHelpers.js.map +1 -1
- package/dist/production/core/requestAliases/MutationAlias.cjs.map +1 -1
- package/dist/production/core/requestAliases/MutationAlias.js.map +1 -1
- package/dist/production/core/schema/Schema.cjs.map +1 -1
- package/dist/production/core/schema/Schema.js.map +1 -1
- package/dist/production/dao/Environment.cjs.map +1 -1
- package/dist/production/dao/Environment.js.map +1 -1
- package/dist/production/index.cjs +2 -0
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +2 -0
- package/dist/production/index.js.map +1 -1
- package/dist/production/markers/PlaceholderGenerator.cjs.map +1 -1
- package/dist/production/markers/PlaceholderGenerator.js.map +1 -1
- package/dist/production/queryLanguage/Parser.cjs +6 -6
- package/dist/production/queryLanguage/Parser.cjs.map +1 -1
- package/dist/production/queryLanguage/Parser.js +6 -6
- package/dist/production/queryLanguage/Parser.js.map +1 -1
- package/dist/production/queryLanguage/QueryLanguage.cjs +13 -13
- package/dist/production/queryLanguage/QueryLanguage.cjs.map +1 -1
- package/dist/production/queryLanguage/QueryLanguage.js +13 -13
- package/dist/production/queryLanguage/QueryLanguage.js.map +1 -1
- package/dist/production/treeParameters/EventListenersStore.cjs.map +1 -1
- package/dist/production/treeParameters/EventListenersStore.js.map +1 -1
- package/dist/production/utils/TreeNodeUtils.cjs.map +1 -1
- package/dist/production/utils/TreeNodeUtils.js.map +1 -1
- package/dist/production/utils/assert.cjs.map +1 -1
- package/dist/production/utils/assert.js.map +1 -1
- package/dist/production/utils/ucfirst.cjs.map +1 -1
- package/dist/production/utils/ucfirst.js.map +1 -1
- package/dist/types/accessorTree/PersistResult.d.ts +2 -0
- package/dist/types/accessorTree/PersistResult.d.ts.map +1 -1
- package/dist/types/accessors/EntityAccessor.d.ts +4 -4
- package/dist/types/accessors/EntityAccessor.d.ts.map +1 -1
- package/dist/types/accessors/EntityListAccessor.d.ts +6 -2
- package/dist/types/accessors/EntityListAccessor.d.ts.map +1 -1
- package/dist/types/accessors/ErrorAccessor.d.ts +3 -0
- package/dist/types/accessors/ErrorAccessor.d.ts.map +1 -1
- package/dist/types/accessors/FieldAccessor.d.ts +2 -0
- package/dist/types/accessors/FieldAccessor.d.ts.map +1 -1
- package/dist/types/core/DataBinding.d.ts.map +1 -1
- package/dist/types/core/MutationGenerator.d.ts.map +1 -1
- package/dist/types/core/StateInitializer.d.ts.map +1 -1
- package/dist/types/core/index.d.ts +1 -0
- package/dist/types/core/index.d.ts.map +1 -1
- package/dist/types/dao/Environment.d.ts +7 -7
- package/dist/types/dao/Environment.d.ts.map +1 -1
- package/dist/types/dao/TreeNodeEnvironmentFactory.d.ts +6 -2
- package/dist/types/dao/TreeNodeEnvironmentFactory.d.ts.map +1 -1
- package/dist/types/treeParameters/EventListenersStore.d.ts +2 -1
- package/dist/types/treeParameters/EventListenersStore.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/accessorTree/PersistResult.ts +2 -0
- package/src/accessors/EntityAccessor.ts +17 -9
- package/src/accessors/EntityListAccessor.ts +11 -1
- package/src/accessors/ErrorAccessor.ts +4 -0
- package/src/accessors/FieldAccessor.ts +5 -0
- package/src/core/DataBinding.ts +3 -2
- package/src/core/MutationGenerator.ts +36 -6
- package/src/core/StateInitializer.ts +1 -0
- package/src/core/index.ts +1 -0
- package/src/dao/Environment.ts +7 -7
- package/src/treeParameters/EventListenersStore.ts +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkerMerger.js","sources":["../../../src/core/MarkerMerger.ts"],"sourcesContent":["import { BindingError } from '../BindingError'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport type { Environment } from '../dao'\nimport {\n\tEntityFieldMarkers,\n\tEntityFieldMarkersContainer,\n\tEntityFieldPlaceholders,\n\tEntityListSubTreeMarker,\n\tEntitySubTreeMarker,\n\tFieldMarker,\n\tHasManyRelationMarker,\n\tHasOneRelationMarker,\n\tMarkerTreeRoot,\n\tMeaningfulMarker,\n\tSubTreeMarkers,\n} from '../markers'\nimport type { Alias, FieldName, PlaceholderName } from '../treeParameters'\nimport { assertNever } from '../utils'\nimport { TreeParameterMerger } from './TreeParameterMerger'\n\nexport class MarkerMerger {\n\t// This method assumes their placeholder names are the same\n\tpublic static mergeMarkers(original: MeaningfulMarker, fresh: MeaningfulMarker): MeaningfulMarker {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tif (original instanceof FieldMarker) {\n\t\t\tif (fresh instanceof FieldMarker) {\n\t\t\t\treturn this.mergeFieldMarkers(original, fresh)\n\t\t\t} else if (fresh instanceof HasOneRelationMarker || fresh instanceof HasManyRelationMarker) {\n\t\t\t\treturn this.rejectRelationScalarCombo(original.fieldName)\n\t\t\t} else if (fresh instanceof EntitySubTreeMarker || fresh instanceof EntityListSubTreeMarker) {\n\t\t\t\tthrow new BindingError('Merging fields and sub trees is an undefined operation.')\n\t\t\t}\n\t\t\tassertNever(fresh)\n\t\t} else if (original instanceof HasOneRelationMarker) {\n\t\t\tif (fresh instanceof HasOneRelationMarker) {\n\t\t\t\treturn this.mergeHasOneRelationMarkers(original, fresh)\n\t\t\t} else if (fresh instanceof FieldMarker) {\n\t\t\t\treturn this.rejectRelationScalarCombo(original.parameters.field)\n\t\t\t} else if (fresh instanceof HasManyRelationMarker) {\n\t\t\t\tthrow new BindingError() // TODO not implemented\n\t\t\t} else if (fresh instanceof EntitySubTreeMarker || fresh instanceof EntityListSubTreeMarker) {\n\t\t\t\tthrow new BindingError('MarkerTreeGenerator merging: SubTreeMarkers can only be merged with other sub trees.')\n\t\t\t}\n\t\t\tassertNever(fresh)\n\t\t} else if (original instanceof HasManyRelationMarker) {\n\t\t\tif (fresh instanceof HasManyRelationMarker) {\n\t\t\t\treturn this.mergeHasManyRelationMarkers(original, fresh)\n\t\t\t} else if (fresh instanceof FieldMarker) {\n\t\t\t\treturn this.rejectRelationScalarCombo(original.parameters.field)\n\t\t\t} else if (fresh instanceof HasOneRelationMarker) {\n\t\t\t\tthrow new BindingError() // TODO not implemented\n\t\t\t} else if (fresh instanceof EntitySubTreeMarker || fresh instanceof EntityListSubTreeMarker) {\n\t\t\t\tthrow new BindingError('MarkerTreeGenerator merging: SubTreeMarkers can only be merged with other sub trees.')\n\t\t\t}\n\t\t\tassertNever(fresh)\n\t\t} else if (original instanceof EntitySubTreeMarker) {\n\t\t\tif (fresh instanceof EntitySubTreeMarker) {\n\t\t\t\treturn this.mergeEntitySubTreeMarkers(original, fresh)\n\t\t\t} else {\n\t\t\t\tthrow new BindingError(\n\t\t\t\t\t'MarkerTreeGenerator merging: EntitySubTreeMarker can only be merged with other entity sub trees.',\n\t\t\t\t)\n\t\t\t}\n\t\t} else if (original instanceof EntityListSubTreeMarker) {\n\t\t\tif (fresh instanceof EntityListSubTreeMarker) {\n\t\t\t\treturn this.mergeEntityListSubTreeMarkers(original, fresh)\n\t\t\t} else {\n\t\t\t\tthrow new BindingError(\n\t\t\t\t\t'MarkerTreeGenerator merging: EntityListSubTreeMarker can only be merged with other list sub trees.',\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tassertNever(original)\n\t}\n\n\tpublic static mergeMarkerTreeRoots(original: MarkerTreeRoot, fresh: MarkerTreeRoot): MarkerTreeRoot {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\treturn new MarkerTreeRoot(\n\t\t\tthis.mergeEntityFields(original.subTrees, fresh.subTrees),\n\t\t\tthis.mergeSubTreePlaceholdersByAliases(original.placeholdersByAliases, fresh.placeholdersByAliases),\n\t\t)\n\t}\n\n\tpublic static mergeSubTreeMarkers(\n\t\toriginal: SubTreeMarkers | undefined,\n\t\tfresh: SubTreeMarkers | undefined,\n\t): SubTreeMarkers | undefined {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tif (original === undefined) {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === undefined) {\n\t\t\treturn original\n\t\t}\n\t\tconst newOriginal = new Map(original)\n\n\t\tfor (const [placeholderName, fromFresh] of fresh) {\n\t\t\tconst fromOriginal = newOriginal.get(placeholderName)\n\n\t\t\tnewOriginal.set(\n\t\t\t\tplaceholderName,\n\t\t\t\tfromOriginal === undefined\n\t\t\t\t\t? fromFresh\n\t\t\t\t\t: fromOriginal instanceof EntityListSubTreeMarker\n\t\t\t\t\t? MarkerMerger.mergeEntityListSubTreeMarkers(fromOriginal, fromFresh as EntityListSubTreeMarker)\n\t\t\t\t\t: MarkerMerger.mergeEntitySubTreeMarkers(fromOriginal, fromFresh as EntitySubTreeMarker),\n\t\t\t)\n\t\t}\n\t\treturn newOriginal\n\t}\n\n\tpublic static mergeSubTreePlaceholdersByAliases(\n\t\toriginal: Map<Alias, PlaceholderName>,\n\t\tfresh: Map<Alias, PlaceholderName>,\n\t) {\n\t\tconst newOriginalAliases = new Map(original)\n\t\tfor (const [alias, placeholder] of fresh) {\n\t\t\tconst fromOriginal = newOriginalAliases.get(alias)\n\t\t\tif (fromOriginal === undefined) {\n\t\t\t\tnewOriginalAliases.set(alias, placeholder)\n\t\t\t} else if (fromOriginal === placeholder) {\n\t\t\t\t// Do nothing\n\t\t\t} else {\n\t\t\t\tthrow new BindingError(`Illegal subTree alias '${alias}' points to distinct subTrees.`)\n\t\t\t}\n\t\t}\n\t\treturn newOriginalAliases\n\t}\n\n\tpublic static mergeEntityFields(original: SubTreeMarkers, fresh: SubTreeMarkers): SubTreeMarkers\n\tpublic static mergeEntityFields(original: EntityFieldMarkers, fresh: EntityFieldMarkers): EntityFieldMarkers\n\tpublic static mergeEntityFields(\n\t\toriginal: Map<PlaceholderName, MeaningfulMarker>,\n\t\tfresh: Map<PlaceholderName, MeaningfulMarker>,\n\t): Map<PlaceholderName, MeaningfulMarker> {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tconst newOriginal: Map<PlaceholderName, MeaningfulMarker> = new Map(original)\n\t\tfor (const [placeholderName, freshMarker] of fresh) {\n\t\t\tconst markerFromOriginal = newOriginal.get(placeholderName)\n\t\t\tnewOriginal.set(\n\t\t\t\tplaceholderName,\n\t\t\t\tmarkerFromOriginal === undefined ? freshMarker : this.mergeMarkers(markerFromOriginal, freshMarker),\n\t\t\t)\n\t\t}\n\t\treturn newOriginal\n\t}\n\n\tpublic static mergeEntityFieldPlaceholders(\n\t\toriginal: EntityFieldPlaceholders,\n\t\tfresh: EntityFieldPlaceholders,\n\t): EntityFieldPlaceholders {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tconst newOriginal: EntityFieldPlaceholders = new Map(original)\n\t\tfor (const [fieldName, freshPlaceholders] of fresh) {\n\t\t\tconst placeholderFromOriginal = newOriginal.get(fieldName)\n\n\t\t\tif (placeholderFromOriginal === undefined) {\n\t\t\t\tnewOriginal.set(fieldName, freshPlaceholders)\n\t\t\t} else if (placeholderFromOriginal instanceof Set) {\n\t\t\t\tconst combinedSet = new Set(placeholderFromOriginal)\n\t\t\t\tif (freshPlaceholders instanceof Set) {\n\t\t\t\t\tfor (const freshPlaceholder of freshPlaceholders) {\n\t\t\t\t\t\tcombinedSet.add(freshPlaceholder)\n\t\t\t\t\t}\n\t\t\t\t} else if (typeof freshPlaceholders === 'string') {\n\t\t\t\t\tcombinedSet.add(freshPlaceholders)\n\t\t\t\t} else {\n\t\t\t\t\tassertNever(freshPlaceholders)\n\t\t\t\t}\n\t\t\t\tnewOriginal.set(fieldName, combinedSet)\n\t\t\t} else if (typeof placeholderFromOriginal === 'string') {\n\t\t\t\tif (typeof freshPlaceholders === 'string') {\n\t\t\t\t\tif (placeholderFromOriginal === freshPlaceholders) {\n\t\t\t\t\t\t// Do nothing\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnewOriginal.set(fieldName, new Set([placeholderFromOriginal, freshPlaceholders]))\n\t\t\t\t\t}\n\t\t\t\t} else if (freshPlaceholders instanceof Set) {\n\t\t\t\t\tif (freshPlaceholders.has(placeholderFromOriginal)) {\n\t\t\t\t\t\tnewOriginal.set(fieldName, freshPlaceholders)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst combinedSet = new Set(freshPlaceholders)\n\t\t\t\t\t\tcombinedSet.add(placeholderFromOriginal)\n\t\t\t\t\t\tnewOriginal.set(fieldName, combinedSet)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tassertNever(freshPlaceholders)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tassertNever(placeholderFromOriginal)\n\t\t\t}\n\t\t}\n\t\treturn newOriginal\n\t}\n\n\tpublic static mergeEntityFieldsContainers(\n\t\toriginal: EntityFieldMarkersContainer,\n\t\tfresh: EntityFieldMarkersContainer,\n\t): EntityFieldMarkersContainer {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\treturn new EntityFieldMarkersContainer(\n\t\t\toriginal.hasAtLeastOneBearingField || fresh.hasAtLeastOneBearingField,\n\t\t\tthis.mergeEntityFields(original.markers, fresh.markers),\n\t\t\tthis.mergeEntityFieldPlaceholders(original.placeholders, fresh.placeholders),\n\t\t)\n\t}\n\n\tpublic static mergeHasOneRelationMarkers(original: HasOneRelationMarker, fresh: HasOneRelationMarker) {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\treturn new HasOneRelationMarker(\n\t\t\tTreeParameterMerger.mergeHasOneRelationsWithSamePlaceholders(original.parameters, fresh.parameters),\n\t\t\tthis.mergeEntityFieldsContainers(original.fields, fresh.fields),\n\t\t\tthis.mergeEnvironments(original.environment, fresh.environment),\n\t\t)\n\t}\n\n\tpublic static mergeHasManyRelationMarkers(original: HasManyRelationMarker, fresh: HasManyRelationMarker) {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\treturn new HasManyRelationMarker(\n\t\t\tTreeParameterMerger.mergeHasManyRelationsWithSamePlaceholders(original.parameters, fresh.parameters),\n\t\t\tthis.mergeEntityFieldsContainers(original.fields, fresh.fields),\n\t\t\tthis.mergeEnvironments(original.environment, fresh.environment),\n\t\t)\n\t}\n\n\tpublic static mergeEntitySubTreeMarkers(original: EntitySubTreeMarker, fresh: EntitySubTreeMarker) {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\treturn new EntitySubTreeMarker(\n\t\t\tTreeParameterMerger.mergeEntitySubTreeParametersWithSamePlaceholders(original.parameters, fresh.parameters),\n\t\t\tthis.mergeEntityFieldsContainers(original.fields, fresh.fields),\n\t\t\tthis.mergeEnvironments(original.environment, fresh.environment),\n\t\t)\n\t}\n\n\tpublic static mergeEntityListSubTreeMarkers(original: EntityListSubTreeMarker, fresh: EntityListSubTreeMarker) {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\treturn new EntityListSubTreeMarker(\n\t\t\tTreeParameterMerger.mergeEntityListSubTreeParametersWithSamePlaceholders(original.parameters, fresh.parameters),\n\t\t\tthis.mergeEntityFieldsContainers(original.fields, fresh.fields),\n\t\t\tthis.mergeEnvironments(original.environment, fresh.environment),\n\t\t)\n\t}\n\n\tpublic static mergeFieldMarkers(original: FieldMarker, fresh: FieldMarker) {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tif (original.defaultValue !== undefined && fresh.defaultValue !== undefined && original.defaultValue !== fresh.defaultValue) {\n\t\t\tthrow new BindingError(`MarkerTreeGenerator merging: multiple fields \"${original.fieldName}\" with different defaultValue found: ${JSON.stringify([original.defaultValue, fresh.defaultValue])}, `)\n\t\t}\n\t\treturn new FieldMarker(\n\t\t\toriginal.fieldName,\n\t\t\toriginal.defaultValue ?? fresh.defaultValue,\n\t\t\toriginal.isNonbearing && fresh.isNonbearing,\n\t\t)\n\t}\n\n\tpublic static mergeInSystemFields(original: EntityFieldMarkersContainer | undefined): EntityFieldMarkersContainer {\n\t\tconst primaryKey = new FieldMarker(PRIMARY_KEY_NAME, undefined, true)\n\t\t// We could potentially share this instance for all fields. Maybe sometime later.\n\t\tconst freshFields = new EntityFieldMarkersContainer(\n\t\t\tfalse,\n\t\t\tnew Map([[primaryKey.placeholderName, primaryKey]]),\n\t\t\tnew Map([[PRIMARY_KEY_NAME, primaryKey.placeholderName]]),\n\t\t)\n\t\treturn original ? this.mergeEntityFieldsContainers(original, freshFields) : freshFields\n\t}\n\n\tpublic static mergeEnvironments(original: Environment, fresh: Environment): Environment {\n\t\treturn original.merge(fresh)\n\t}\n\n\tprivate static rejectRelationScalarCombo(fieldName: FieldName): never {\n\t\tthrow new BindingError(`Cannot combine a relation with a scalar field '${fieldName}'.`)\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAoBO,MAAM,aAAa;AAAA;AAAA,EAEzB,OAAc,aAAa,UAA4B,OAA2C;AACjG,QAAI,aAAa,OAAO;AAChB,aAAA;AAAA,IACR;AACA,QAAI,oBAAoB,aAAa;AACpC,UAAI,iBAAiB,aAAa;AAC1B,eAAA,KAAK,kBAAkB,UAAU,KA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../../../src/core/MarkerMerger.ts"],"sourcesContent":["import { BindingError } from '../BindingError'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport type { Environment } from '../dao'\nimport {\n\tEntityFieldMarkers,\n\tEntityFieldMarkersContainer,\n\tEntityFieldPlaceholders,\n\tEntityListSubTreeMarker,\n\tEntitySubTreeMarker,\n\tFieldMarker,\n\tHasManyRelationMarker,\n\tHasOneRelationMarker,\n\tMarkerTreeRoot,\n\tMeaningfulMarker,\n\tSubTreeMarkers,\n} from '../markers'\nimport type { Alias, FieldName, PlaceholderName } from '../treeParameters'\nimport { assertNever } from '../utils'\nimport { TreeParameterMerger } from './TreeParameterMerger'\n\nexport class MarkerMerger {\n\t// This method assumes their placeholder names are the same\n\tpublic static mergeMarkers(original: MeaningfulMarker, fresh: MeaningfulMarker): MeaningfulMarker {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tif (original instanceof FieldMarker) {\n\t\t\tif (fresh instanceof FieldMarker) {\n\t\t\t\treturn this.mergeFieldMarkers(original, fresh)\n\t\t\t} else if (fresh instanceof HasOneRelationMarker || fresh instanceof HasManyRelationMarker) {\n\t\t\t\treturn this.rejectRelationScalarCombo(original.fieldName)\n\t\t\t} else if (fresh instanceof EntitySubTreeMarker || fresh instanceof EntityListSubTreeMarker) {\n\t\t\t\tthrow new BindingError('Merging fields and sub trees is an undefined operation.')\n\t\t\t}\n\t\t\tassertNever(fresh)\n\t\t} else if (original instanceof HasOneRelationMarker) {\n\t\t\tif (fresh instanceof HasOneRelationMarker) {\n\t\t\t\treturn this.mergeHasOneRelationMarkers(original, fresh)\n\t\t\t} else if (fresh instanceof FieldMarker) {\n\t\t\t\treturn this.rejectRelationScalarCombo(original.parameters.field)\n\t\t\t} else if (fresh instanceof HasManyRelationMarker) {\n\t\t\t\tthrow new BindingError() // TODO not implemented\n\t\t\t} else if (fresh instanceof EntitySubTreeMarker || fresh instanceof EntityListSubTreeMarker) {\n\t\t\t\tthrow new BindingError('MarkerTreeGenerator merging: SubTreeMarkers can only be merged with other sub trees.')\n\t\t\t}\n\t\t\tassertNever(fresh)\n\t\t} else if (original instanceof HasManyRelationMarker) {\n\t\t\tif (fresh instanceof HasManyRelationMarker) {\n\t\t\t\treturn this.mergeHasManyRelationMarkers(original, fresh)\n\t\t\t} else if (fresh instanceof FieldMarker) {\n\t\t\t\treturn this.rejectRelationScalarCombo(original.parameters.field)\n\t\t\t} else if (fresh instanceof HasOneRelationMarker) {\n\t\t\t\tthrow new BindingError() // TODO not implemented\n\t\t\t} else if (fresh instanceof EntitySubTreeMarker || fresh instanceof EntityListSubTreeMarker) {\n\t\t\t\tthrow new BindingError('MarkerTreeGenerator merging: SubTreeMarkers can only be merged with other sub trees.')\n\t\t\t}\n\t\t\tassertNever(fresh)\n\t\t} else if (original instanceof EntitySubTreeMarker) {\n\t\t\tif (fresh instanceof EntitySubTreeMarker) {\n\t\t\t\treturn this.mergeEntitySubTreeMarkers(original, fresh)\n\t\t\t} else {\n\t\t\t\tthrow new BindingError(\n\t\t\t\t\t'MarkerTreeGenerator merging: EntitySubTreeMarker can only be merged with other entity sub trees.',\n\t\t\t\t)\n\t\t\t}\n\t\t} else if (original instanceof EntityListSubTreeMarker) {\n\t\t\tif (fresh instanceof EntityListSubTreeMarker) {\n\t\t\t\treturn this.mergeEntityListSubTreeMarkers(original, fresh)\n\t\t\t} else {\n\t\t\t\tthrow new BindingError(\n\t\t\t\t\t'MarkerTreeGenerator merging: EntityListSubTreeMarker can only be merged with other list sub trees.',\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tassertNever(original)\n\t}\n\n\tpublic static mergeMarkerTreeRoots(original: MarkerTreeRoot, fresh: MarkerTreeRoot): MarkerTreeRoot {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\treturn new MarkerTreeRoot(\n\t\t\tthis.mergeEntityFields(original.subTrees, fresh.subTrees),\n\t\t\tthis.mergeSubTreePlaceholdersByAliases(original.placeholdersByAliases, fresh.placeholdersByAliases),\n\t\t)\n\t}\n\n\tpublic static mergeSubTreeMarkers(\n\t\toriginal: SubTreeMarkers | undefined,\n\t\tfresh: SubTreeMarkers | undefined,\n\t): SubTreeMarkers | undefined {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tif (original === undefined) {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === undefined) {\n\t\t\treturn original\n\t\t}\n\t\tconst newOriginal = new Map(original)\n\n\t\tfor (const [placeholderName, fromFresh] of fresh) {\n\t\t\tconst fromOriginal = newOriginal.get(placeholderName)\n\n\t\t\tnewOriginal.set(\n\t\t\t\tplaceholderName,\n\t\t\t\tfromOriginal === undefined\n\t\t\t\t\t? fromFresh\n\t\t\t\t\t: fromOriginal instanceof EntityListSubTreeMarker\n\t\t\t\t\t? MarkerMerger.mergeEntityListSubTreeMarkers(fromOriginal, fromFresh as EntityListSubTreeMarker)\n\t\t\t\t\t: MarkerMerger.mergeEntitySubTreeMarkers(fromOriginal, fromFresh as EntitySubTreeMarker),\n\t\t\t)\n\t\t}\n\t\treturn newOriginal\n\t}\n\n\tpublic static mergeSubTreePlaceholdersByAliases(\n\t\toriginal: Map<Alias, PlaceholderName>,\n\t\tfresh: Map<Alias, PlaceholderName>,\n\t) {\n\t\tconst newOriginalAliases = new Map(original)\n\t\tfor (const [alias, placeholder] of fresh) {\n\t\t\tconst fromOriginal = newOriginalAliases.get(alias)\n\t\t\tif (fromOriginal === undefined) {\n\t\t\t\tnewOriginalAliases.set(alias, placeholder)\n\t\t\t} else if (fromOriginal === placeholder) {\n\t\t\t\t// Do nothing\n\t\t\t} else {\n\t\t\t\tthrow new BindingError(`Illegal subTree alias '${alias}' points to distinct subTrees.`)\n\t\t\t}\n\t\t}\n\t\treturn newOriginalAliases\n\t}\n\n\tpublic static mergeEntityFields(original: SubTreeMarkers, fresh: SubTreeMarkers): SubTreeMarkers\n\tpublic static mergeEntityFields(original: EntityFieldMarkers, fresh: EntityFieldMarkers): EntityFieldMarkers\n\tpublic static mergeEntityFields(\n\t\toriginal: Map<PlaceholderName, MeaningfulMarker>,\n\t\tfresh: Map<PlaceholderName, MeaningfulMarker>,\n\t): Map<PlaceholderName, MeaningfulMarker> {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tconst newOriginal: Map<PlaceholderName, MeaningfulMarker> = new Map(original)\n\t\tfor (const [placeholderName, freshMarker] of fresh) {\n\t\t\tconst markerFromOriginal = newOriginal.get(placeholderName)\n\t\t\tnewOriginal.set(\n\t\t\t\tplaceholderName,\n\t\t\t\tmarkerFromOriginal === undefined ? freshMarker : this.mergeMarkers(markerFromOriginal, freshMarker),\n\t\t\t)\n\t\t}\n\t\treturn newOriginal\n\t}\n\n\tpublic static mergeEntityFieldPlaceholders(\n\t\toriginal: EntityFieldPlaceholders,\n\t\tfresh: EntityFieldPlaceholders,\n\t): EntityFieldPlaceholders {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tconst newOriginal: EntityFieldPlaceholders = new Map(original)\n\t\tfor (const [fieldName, freshPlaceholders] of fresh) {\n\t\t\tconst placeholderFromOriginal = newOriginal.get(fieldName)\n\n\t\t\tif (placeholderFromOriginal === undefined) {\n\t\t\t\tnewOriginal.set(fieldName, freshPlaceholders)\n\t\t\t} else if (placeholderFromOriginal instanceof Set) {\n\t\t\t\tconst combinedSet = new Set(placeholderFromOriginal)\n\t\t\t\tif (freshPlaceholders instanceof Set) {\n\t\t\t\t\tfor (const freshPlaceholder of freshPlaceholders) {\n\t\t\t\t\t\tcombinedSet.add(freshPlaceholder)\n\t\t\t\t\t}\n\t\t\t\t} else if (typeof freshPlaceholders === 'string') {\n\t\t\t\t\tcombinedSet.add(freshPlaceholders)\n\t\t\t\t} else {\n\t\t\t\t\tassertNever(freshPlaceholders)\n\t\t\t\t}\n\t\t\t\tnewOriginal.set(fieldName, combinedSet)\n\t\t\t} else if (typeof placeholderFromOriginal === 'string') {\n\t\t\t\tif (typeof freshPlaceholders === 'string') {\n\t\t\t\t\tif (placeholderFromOriginal === freshPlaceholders) {\n\t\t\t\t\t\t// Do nothing\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnewOriginal.set(fieldName, new Set([placeholderFromOriginal, freshPlaceholders]))\n\t\t\t\t\t}\n\t\t\t\t} else if (freshPlaceholders instanceof Set) {\n\t\t\t\t\tif (freshPlaceholders.has(placeholderFromOriginal)) {\n\t\t\t\t\t\tnewOriginal.set(fieldName, freshPlaceholders)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst combinedSet = new Set(freshPlaceholders)\n\t\t\t\t\t\tcombinedSet.add(placeholderFromOriginal)\n\t\t\t\t\t\tnewOriginal.set(fieldName, combinedSet)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tassertNever(freshPlaceholders)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tassertNever(placeholderFromOriginal)\n\t\t\t}\n\t\t}\n\t\treturn newOriginal\n\t}\n\n\tpublic static mergeEntityFieldsContainers(\n\t\toriginal: EntityFieldMarkersContainer,\n\t\tfresh: EntityFieldMarkersContainer,\n\t): EntityFieldMarkersContainer {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\treturn new EntityFieldMarkersContainer(\n\t\t\toriginal.hasAtLeastOneBearingField || fresh.hasAtLeastOneBearingField,\n\t\t\tthis.mergeEntityFields(original.markers, fresh.markers),\n\t\t\tthis.mergeEntityFieldPlaceholders(original.placeholders, fresh.placeholders),\n\t\t)\n\t}\n\n\tpublic static mergeHasOneRelationMarkers(original: HasOneRelationMarker, fresh: HasOneRelationMarker) {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\treturn new HasOneRelationMarker(\n\t\t\tTreeParameterMerger.mergeHasOneRelationsWithSamePlaceholders(original.parameters, fresh.parameters),\n\t\t\tthis.mergeEntityFieldsContainers(original.fields, fresh.fields),\n\t\t\tthis.mergeEnvironments(original.environment, fresh.environment),\n\t\t)\n\t}\n\n\tpublic static mergeHasManyRelationMarkers(original: HasManyRelationMarker, fresh: HasManyRelationMarker) {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\treturn new HasManyRelationMarker(\n\t\t\tTreeParameterMerger.mergeHasManyRelationsWithSamePlaceholders(original.parameters, fresh.parameters),\n\t\t\tthis.mergeEntityFieldsContainers(original.fields, fresh.fields),\n\t\t\tthis.mergeEnvironments(original.environment, fresh.environment),\n\t\t)\n\t}\n\n\tpublic static mergeEntitySubTreeMarkers(original: EntitySubTreeMarker, fresh: EntitySubTreeMarker) {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\treturn new EntitySubTreeMarker(\n\t\t\tTreeParameterMerger.mergeEntitySubTreeParametersWithSamePlaceholders(original.parameters, fresh.parameters),\n\t\t\tthis.mergeEntityFieldsContainers(original.fields, fresh.fields),\n\t\t\tthis.mergeEnvironments(original.environment, fresh.environment),\n\t\t)\n\t}\n\n\tpublic static mergeEntityListSubTreeMarkers(original: EntityListSubTreeMarker, fresh: EntityListSubTreeMarker) {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\treturn new EntityListSubTreeMarker(\n\t\t\tTreeParameterMerger.mergeEntityListSubTreeParametersWithSamePlaceholders(original.parameters, fresh.parameters),\n\t\t\tthis.mergeEntityFieldsContainers(original.fields, fresh.fields),\n\t\t\tthis.mergeEnvironments(original.environment, fresh.environment),\n\t\t)\n\t}\n\n\tpublic static mergeFieldMarkers(original: FieldMarker, fresh: FieldMarker) {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tif (original.defaultValue !== undefined && fresh.defaultValue !== undefined && original.defaultValue !== fresh.defaultValue) {\n\t\t\tthrow new BindingError(`MarkerTreeGenerator merging: multiple fields \"${original.fieldName}\" with different defaultValue found: ${JSON.stringify([original.defaultValue, fresh.defaultValue])}, `)\n\t\t}\n\t\treturn new FieldMarker(\n\t\t\toriginal.fieldName,\n\t\t\toriginal.defaultValue ?? fresh.defaultValue,\n\t\t\toriginal.isNonbearing && fresh.isNonbearing,\n\t\t)\n\t}\n\n\tpublic static mergeInSystemFields(original: EntityFieldMarkersContainer | undefined): EntityFieldMarkersContainer {\n\t\tconst primaryKey = new FieldMarker(PRIMARY_KEY_NAME, undefined, true)\n\t\t// We could potentially share this instance for all fields. Maybe sometime later.\n\t\tconst freshFields = new EntityFieldMarkersContainer(\n\t\t\tfalse,\n\t\t\tnew Map([[primaryKey.placeholderName, primaryKey]]),\n\t\t\tnew Map([[PRIMARY_KEY_NAME, primaryKey.placeholderName]]),\n\t\t)\n\t\treturn original ? this.mergeEntityFieldsContainers(original, freshFields) : freshFields\n\t}\n\n\tpublic static mergeEnvironments(original: Environment, fresh: Environment): Environment {\n\t\treturn original.merge(fresh)\n\t}\n\n\tprivate static rejectRelationScalarCombo(fieldName: FieldName): never {\n\t\tthrow new BindingError(`Cannot combine a relation with a scalar field '${fieldName}'.`)\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAoBO,MAAM,aAAa;AAAA;AAAA,EAEzB,OAAc,aAAa,UAA4B,OAA2C;AACjG,QAAI,aAAa,OAAO;AAChB,aAAA;AAAA,IACR;AACA,QAAI,oBAAoB,aAAa;AACpC,UAAI,iBAAiB,aAAa;AAC1B,eAAA,KAAK,kBAAkB,UAAU,KAAK;AAAA,MACnC,WAAA,iBAAiB,wBAAwB,iBAAiB,uBAAuB;AACpF,eAAA,KAAK,0BAA0B,SAAS,SAAS;AAAA,MAC9C,WAAA,iBAAiB,uBAAuB,iBAAiB,yBAAyB;AACtF,cAAA,IAAI,aAAa,yDAAyD;AAAA,MACjF;AACA,kBAAiB;AAAA,IAAA,WACP,oBAAoB,sBAAsB;AACpD,UAAI,iBAAiB,sBAAsB;AACnC,eAAA,KAAK,2BAA2B,UAAU,KAAK;AAAA,MAAA,WAC5C,iBAAiB,aAAa;AACxC,eAAO,KAAK,0BAA0B,SAAS,WAAW,KAAK;AAAA,MAAA,WACrD,iBAAiB,uBAAu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,SAAS,iBAAiB,MAAM,cAAc;AAC5H,YAAM,IAAI,aAAa,iDAAiD,SAAS,SAAS,wCAAwC,KAAK,UAAU,CAAC,SAAS,cAAc,MAAM,YAAY,CAAC,CAAC,IAAI;AAAA,IAClM;AACA,WAAO,IAAI;AAAA,MACV,SAAS;AAAA,MACT,SAAS,gBAAgB,MAAM;AAAA,MAC/B,SAAS,gBAAgB,MAAM;AAAA,IAAA;AAAA,EAEjC;AAAA,EAEA,OAAc,oBAAoB,UAAgF;AACjH,UAAM,aAAa,IAAI,YAAY,kBAAkB,QAAW,IAAI;AAEpE,UAAM,cAAc,IAAI;AAAA,MACvB;AAAA,MACA,oBAAI,IAAI,CAAC,CAAC,WAAW,iBAAiB,UAAU,CAAC,CAAC;AAAA,MAClD,oBAAI,IAAI,CAAC,CAAC,kBAAkB,WAAW,eAAe,CAAC,CAAC;AAAA,IAAA;AAEzD,WAAO,WAAW,KAAK,4BAA4B,UAAU,WAAW,IAAI;AAAA,EAC7E;AAAA,EAEA,OAAc,kBAAkB,UAAuB,OAAiC;AAChF,WAAA,SAAS,MAAM,KAAK;AAAA,EAC5B;AAAA,EAEA,OAAe,0BAA0B,WAA6B;AACrE,UAAM,IAAI,aAAa,kDAAkD,SAAS,IAAI;AAAA,EACvF;AACD;"}
|
|
@@ -250,7 +250,12 @@ class MutationGenerator {
|
|
|
250
250
|
}
|
|
251
251
|
const input = this.getCreateOneRelationInput(processedPlaceholdersByEntity, fieldState, marker);
|
|
252
252
|
if (input !== void 0) {
|
|
253
|
-
result[marker.parameters.field]
|
|
253
|
+
const current = result[marker.parameters.field];
|
|
254
|
+
if (Array.isArray(input) && Array.isArray(current)) {
|
|
255
|
+
current.push(...input);
|
|
256
|
+
} else {
|
|
257
|
+
result[marker.parameters.field] = input;
|
|
258
|
+
}
|
|
254
259
|
}
|
|
255
260
|
break;
|
|
256
261
|
}
|
|
@@ -272,7 +277,12 @@ class MutationGenerator {
|
|
|
272
277
|
}
|
|
273
278
|
const input = this.getCreateManyRelationInput(processedPlaceholdersByEntity, fieldState);
|
|
274
279
|
if (input !== void 0) {
|
|
275
|
-
result[marker.parameters.field]
|
|
280
|
+
const current = result[marker.parameters.field];
|
|
281
|
+
if (Array.isArray(current)) {
|
|
282
|
+
current.push(...input);
|
|
283
|
+
} else {
|
|
284
|
+
result[marker.parameters.field] = input;
|
|
285
|
+
}
|
|
276
286
|
}
|
|
277
287
|
break;
|
|
278
288
|
}
|
|
@@ -298,7 +308,12 @@ class MutationGenerator {
|
|
|
298
308
|
field.marker
|
|
299
309
|
);
|
|
300
310
|
if (input !== void 0) {
|
|
301
|
-
result[field.marker.parameters.field]
|
|
311
|
+
const current = result[field.marker.parameters.field];
|
|
312
|
+
if (Array.isArray(input) && Array.isArray(current)) {
|
|
313
|
+
current.push(...input);
|
|
314
|
+
} else {
|
|
315
|
+
result[field.marker.parameters.field] = input;
|
|
316
|
+
}
|
|
302
317
|
}
|
|
303
318
|
break;
|
|
304
319
|
}
|
|
@@ -308,7 +323,12 @@ class MutationGenerator {
|
|
|
308
323
|
field.fieldState
|
|
309
324
|
);
|
|
310
325
|
if (input !== void 0) {
|
|
311
|
-
result[field.marker.parameters.field]
|
|
326
|
+
const current = result[field.marker.parameters.field];
|
|
327
|
+
if (Array.isArray(current)) {
|
|
328
|
+
current.push(...input);
|
|
329
|
+
} else {
|
|
330
|
+
result[field.marker.parameters.field] = input;
|
|
331
|
+
}
|
|
312
332
|
}
|
|
313
333
|
break;
|
|
314
334
|
}
|
|
@@ -427,7 +447,12 @@ class MutationGenerator {
|
|
|
427
447
|
} else {
|
|
428
448
|
const relationData = this.getUpdateManyRelationForReducedInput(currentState, fieldState, persistedValue, processedPlaceholdersByEntity, placeholderName, reducedBy);
|
|
429
449
|
if (relationData !== void 0) {
|
|
430
|
-
result[marker.parameters.field]
|
|
450
|
+
const current = result[marker.parameters.field];
|
|
451
|
+
if (Array.isArray(current)) {
|
|
452
|
+
current.push(...relationData);
|
|
453
|
+
} else {
|
|
454
|
+
result[marker.parameters.field] = relationData;
|
|
455
|
+
}
|
|
431
456
|
}
|
|
432
457
|
}
|
|
433
458
|
break;
|
|
@@ -446,7 +471,12 @@ class MutationGenerator {
|
|
|
446
471
|
}
|
|
447
472
|
const relationData = this.getUpdateManyRelationInput(fieldState, persistedEntityIds, processedPlaceholdersByEntity);
|
|
448
473
|
if (relationData !== void 0) {
|
|
449
|
-
result[marker.parameters.field]
|
|
474
|
+
const current = result[marker.parameters.field];
|
|
475
|
+
if (Array.isArray(current)) {
|
|
476
|
+
current.push(...relationData);
|
|
477
|
+
} else {
|
|
478
|
+
result[marker.parameters.field] = relationData;
|
|
479
|
+
}
|
|
450
480
|
}
|
|
451
481
|
break;
|
|
452
482
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutationGenerator.cjs","sources":["../../../src/core/MutationGenerator.ts"],"sourcesContent":["import { ContentMutation, ContentQueryBuilder, GraphQlLiteral, Input, replaceGraphQlLiteral } from '@contember/client'\nimport { ClientGeneratedUuid, EntityFieldPersistedData, ReceivedEntityData, ServerId } from '../accessorTree'\nimport { BindingError } from '../BindingError'\nimport { PRIMARY_KEY_NAME, TYPENAME_KEY_NAME } from '../bindingTypes'\nimport { EntityFieldMarkers, FieldMarker, HasManyRelationMarker, HasOneRelationMarker } from '../markers'\nimport type { EntityId, EntityName, PlaceholderName, UniqueWhere } from '../treeParameters'\nimport { assertNever, isEmptyObject } from '../utils'\nimport { QueryGenerator } from './QueryGenerator'\nimport { MutationAlias } from './requestAliases'\nimport { EntityListState, EntityRealmState, EntityRealmStateStub, EntityState, FieldState, getEntityMarker, StateIterator } from './state'\nimport type { TreeStore } from './TreeStore'\n\n\ntype ProcessedPlaceholdersByEntity = Map<EntityState, Set<PlaceholderName>>\n\nexport type SubMutationOperation =\n\t& {\n\t\talias: string,\n\t\tsubTreePlaceholder: PlaceholderName,\n\t\tsubTreeType: 'list' | 'single'\n\t}\n\t& (\n\t\t| { type: 'delete', id: EntityId }\n\t\t| { type: 'update', markers: EntityFieldMarkers, id: EntityId }\n\t\t| { type: 'create', markers: EntityFieldMarkers, id: EntityId }\n\t)\n\nexport type PersistMutationResult = {\n\tmutations: Record<string, ContentMutation<ReceivedEntityData>>\n\toperations: SubMutationOperation[]\n}\n\n// TODO enforce correct expected mutations in dev mode.\nexport class MutationGenerator {\n\n\tprivate aliasCounter = 1\n\n\tpublic constructor(\n\t\tprivate readonly treeStore: TreeStore,\n\t\tprivate readonly qb: ContentQueryBuilder,\n\t) {\n\t}\n\n\tpublic getPersistMutation(): PersistMutationResult | undefined {\n\t\tconst mutations: Record<string, ContentMutation<any>> = {}\n\t\tconst operations: SubMutationOperation[] = []\n\t\tconst processedPlaceholdersByEntity: ProcessedPlaceholdersByEntity = new Map()\n\t\tconst processedDeletes = new Set<string>()\n\n\t\tfor (const [treeRootId, rootStates] of this.treeStore.subTreeStatesByRoot.entries()) {\n\t\t\tfor (const [placeholderName, subTreeState] of Array.from(rootStates.entries()).reverse()) {\n\t\t\t\tif (subTreeState.unpersistedChangesCount <= 0) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (subTreeState.type === 'entityRealm') {\n\t\t\t\t\tif (subTreeState.blueprint.type === 'subTree' && subTreeState.blueprint.marker.parameters.isCreating && subTreeState.blueprint.marker.parameters.isUnpersisted) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst subMutation = this.createMutation(\n\t\t\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\t\t\tplaceholderName,\n\t\t\t\t\t\t'single',\n\t\t\t\t\t\tsubTreeState.entity.id.value,\n\t\t\t\t\t\tsubTreeState,\n\t\t\t\t\t)\n\t\t\t\t\tif (subMutation) {\n\t\t\t\t\t\tmutations[subMutation[1].alias] = subMutation[0]\n\t\t\t\t\t\toperations.push(subMutation[1])\n\t\t\t\t\t}\n\t\t\t\t} else if (subTreeState.type === 'entityList') {\n\t\t\t\t\tif (subTreeState.blueprint.type === 'subTree' && subTreeState.blueprint.marker.parameters.isCreating && subTreeState.blueprint.marker.parameters.isUnpersisted) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tfor (const childState of subTreeState.children.values()) {\n\t\t\t\t\t\tif (childState.type === 'entityRealmStub') {\n\t\t\t\t\t\t\t// TODO there can be a forceCreate somewhere in there that we're hereby ignoring.\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst subMutation = this.createMutation(\n\t\t\t\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\t\t\t\tplaceholderName,\n\t\t\t\t\t\t\t'list',\n\t\t\t\t\t\t\tchildState.entity.id.value,\n\t\t\t\t\t\t\tchildState,\n\t\t\t\t\t\t)\n\t\t\t\t\t\tif (subMutation) {\n\t\t\t\t\t\t\tmutations[subMutation[1].alias] = subMutation[0]\n\t\t\t\t\t\t\toperations.push(subMutation[1])\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (subTreeState.plannedRemovals) {\n\t\t\t\t\t\tfor (const [removedId, removalType] of subTreeState.plannedRemovals) {\n\t\t\t\t\t\t\tif (removalType === 'disconnect') {\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (removalType === 'delete') {\n\t\t\t\t\t\t\t\tconst key = `${subTreeState.entityName}#${removedId}`\n\t\t\t\t\t\t\t\tif (processedDeletes.has(key)) {\n\t\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tprocessedDeletes.add(key)\n\t\t\t\t\t\t\t\tconst alias = this.createAlias()\n\t\t\t\t\t\t\t\tmutations[alias] = this.createDeleteMutation(\n\t\t\t\t\t\t\t\t\tsubTreeState.entityName,\n\t\t\t\t\t\t\t\t\tremovedId,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\toperations.push({ alias, subTreePlaceholder: placeholderName, subTreeType: 'list', type: 'delete', id: removedId })\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tassertNever(removalType)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tassertNever(subTreeState)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { mutations, operations }\n\t}\n\n\tprivate createMutation(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tsubTreePlaceholder: PlaceholderName,\n\t\tsubTreeType: 'list' | 'single',\n\t\tentityId: EntityId,\n\t\trealmState: EntityRealmState,\n\t): [ContentMutation<any>, SubMutationOperation] | undefined {\n\t\tif (realmState.unpersistedChangesCount === 0) {\n\t\t\t// Bail out early\n\t\t\treturn undefined\n\t\t}\n\t\tconst fieldMarkers = getEntityMarker(realmState).fields.markers\n\n\t\tconst alias = this.createAlias()\n\n\t\tif (realmState.entity.isScheduledForDeletion) {\n\t\t\tconst mutation = this.createDeleteMutation(\n\t\t\t\trealmState.entity.entityName,\n\t\t\t\tentityId,\n\t\t\t)\n\t\t\treturn [\n\t\t\t\tmutation,\n\t\t\t\t{\n\t\t\t\t\talias,\n\t\t\t\t\tsubTreePlaceholder,\n\t\t\t\t\tsubTreeType,\n\t\t\t\t\ttype: 'delete',\n\t\t\t\t\tid: entityId,\n\t\t\t\t},\n\t\t\t]\n\t\t} else if (!realmState.entity.id.existsOnServer) {\n\t\t\tconst builder = this.createCreateMutation(\n\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\trealmState,\n\t\t\t\tfieldMarkers,\n\t\t\t)\n\t\t\tif (!builder) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\treturn [\n\t\t\t\tbuilder,\n\t\t\t\t{\n\t\t\t\t\talias,\n\t\t\t\t\tsubTreePlaceholder,\n\t\t\t\t\tsubTreeType,\n\t\t\t\t\ttype: 'create',\n\t\t\t\t\tmarkers: fieldMarkers,\n\t\t\t\t\tid: entityId,\n\t\t\t\t},\n]\n\t\t}\n\t\tconst builder = this.createUpdateMutation(\n\t\t\tprocessedPlaceholdersByEntity,\n\t\t\trealmState,\n\t\t\tfieldMarkers,\n\t\t)\n\t\tif (!builder) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn [\n\t\t\tbuilder,\n\t\t\t{\n\t\t\t\talias,\n\t\t\t\tsubTreePlaceholder,\n\t\t\t\tsubTreeType,\n\t\t\t\ttype: 'update',\n\t\t\t\tid: entityId,\n\t\t\t\tmarkers: fieldMarkers,\n\t\t\t},\n\t\t]\n\t}\n\n\tprivate createDeleteMutation(\n\t\tentityName: EntityName,\n\t\tdeletedId: EntityId,\n\t): ContentMutation<any> {\n\t\treturn this.qb.delete(entityName, {\n\t\t\tby: { [PRIMARY_KEY_NAME]: deletedId },\n\t\t}, it => it.$(PRIMARY_KEY_NAME).$('__typename'))\n\t}\n\n\tprivate createUpdateMutation(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tentityRealm: EntityRealmState,\n\t\tfieldMarkers: EntityFieldMarkers,\n\t): ContentMutation<any> | undefined {\n\t\tconst input = this.getUpdateDataInput(processedPlaceholdersByEntity, entityRealm)\n\n\t\tif (input === undefined) {\n\t\t\treturn undefined\n\t\t}\n\n\t\tconst runtimeId = entityRealm.entity.id\n\n\t\tif (!runtimeId.existsOnServer) {\n\t\t\treturn undefined\n\t\t}\n\n\t\treturn this.qb.update(entityRealm.entity.entityName, {\n\t\t\tby: {\n\t\t\t\t[PRIMARY_KEY_NAME]: runtimeId.value,\n\t\t\t},\n\t\t\tdata: input,\n\t\t}, it => QueryGenerator.registerQueryPart(fieldMarkers, it).$(PRIMARY_KEY_NAME).$('__typename'))\n\t}\n\n\tprivate createCreateMutation(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tentityRealm: EntityRealmState,\n\t\tfieldMarkers: EntityFieldMarkers,\n\t): ContentMutation<any> | undefined {\n\t\tconst input = this.getCreateDataInput(\n\t\t\tprocessedPlaceholdersByEntity,\n\t\t\tentityRealm,\n\t\t)\n\t\tif (input === undefined) {\n\t\t\treturn undefined\n\t\t}\n\n\t\treturn this.qb.create(entityRealm.entity.entityName, {\n\t\t\tdata: input,\n\t\t}, it => QueryGenerator.registerQueryPart(fieldMarkers, it).$(PRIMARY_KEY_NAME).$('__typename'))\n\t}\n\n\tprivate getCreateDataInput(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tcurrentState: EntityRealmState | EntityRealmStateStub,\n\t): Input.CreateDataInput | undefined {\n\t\tlet processedPlaceholders = processedPlaceholdersByEntity.get(currentState.entity)\n\n\t\tif (processedPlaceholders === undefined) {\n\t\t\tprocessedPlaceholdersByEntity.set(currentState.entity, (processedPlaceholders = new Set()))\n\t\t}\n\n\t\tif (currentState.type === 'entityRealmStub') {\n\t\t\t// TODO If there's a forceCreate, this is wrong.\n\t\t\treturn undefined\n\t\t}\n\n\t\tconst result: Input.CreateDataInput = {}\n\t\tfor (const siblingState of StateIterator.eachSiblingRealm(currentState)) {\n\n\t\t\tconst pathBack = this.treeStore.getPathBackToParent(siblingState)\n\n\t\t\tconst nonbearingFields: Array<| { type: 'field'; marker: FieldMarker; fieldState: FieldState }\n\t\t\t\t| { type: 'hasOne'; marker: HasOneRelationMarker; fieldState: EntityRealmState | EntityRealmStateStub }\n\t\t\t\t| { type: 'hasMany'; marker: HasManyRelationMarker; fieldState: EntityListState }> = []\n\n\t\t\tfor (const [placeholderName, fieldState] of siblingState.children) {\n\t\t\t\tif (processedPlaceholders.has(placeholderName)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tprocessedPlaceholders.add(placeholderName)\n\n\t\t\t\tswitch (fieldState.type) {\n\t\t\t\t\tcase 'field': {\n\t\t\t\t\t\tconst marker = fieldState.fieldMarker\n\t\t\t\t\t\tconst placeholderName = marker.placeholderName\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tplaceholderName === TYPENAME_KEY_NAME ||\n\t\t\t\t\t\t\t(placeholderName === PRIMARY_KEY_NAME && !(siblingState.entity.id instanceof ClientGeneratedUuid))\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (marker.isNonbearing) {\n\t\t\t\t\t\t\tnonbearingFields.push({\n\t\t\t\t\t\t\t\ttype: 'field',\n\t\t\t\t\t\t\t\tmarker,\n\t\t\t\t\t\t\t\tfieldState,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst value = fieldState.getAccessor().resolvedValue\n\t\t\t\t\t\tif (value !== undefined && value !== null) {\n\t\t\t\t\t\t\tresult[marker.fieldName] = value\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase 'entityRealmStub':\n\t\t\t\t\tcase 'entityRealm': {\n\t\t\t\t\t\tconst marker = getEntityMarker(fieldState)\n\t\t\t\t\t\tif (!(marker instanceof HasOneRelationMarker)) {\n\t\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (pathBack?.fieldBackToParent === marker.parameters.field) {\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (marker.parameters.isNonbearing) {\n\t\t\t\t\t\t\tnonbearingFields.push({\n\t\t\t\t\t\t\t\ttype: 'hasOne',\n\t\t\t\t\t\t\t\tmarker,\n\t\t\t\t\t\t\t\tfieldState,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst input = this.getCreateOneRelationInput(processedPlaceholdersByEntity, fieldState, marker)\n\t\t\t\t\t\tif (input !== undefined) {\n\t\t\t\t\t\t\tresult[marker.parameters.field] = input\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase 'entityList': {\n\t\t\t\t\t\tconst marker = fieldState.blueprint.marker\n\t\t\t\t\t\tif (!(marker instanceof HasManyRelationMarker)) {\n\t\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (pathBack?.fieldBackToParent === marker.parameters.field) {\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (marker.parameters.isNonbearing) {\n\t\t\t\t\t\t\tnonbearingFields.push({\n\t\t\t\t\t\t\t\ttype: 'hasMany',\n\t\t\t\t\t\t\t\tmarker,\n\t\t\t\t\t\t\t\tfieldState,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst input = this.getCreateManyRelationInput(processedPlaceholdersByEntity, fieldState)\n\t\t\t\t\t\tif (input !== undefined) {\n\t\t\t\t\t\t\tresult[marker.parameters.field] = input\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\treturn assertNever(fieldState)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ((!isEmptyObject(result)) || !getEntityMarker(siblingState).fields.hasAtLeastOneBearingField) {\n\t\t\t\tfor (const field of nonbearingFields) {\n\t\t\t\t\tswitch (field.type) {\n\t\t\t\t\t\tcase 'field': {\n\t\t\t\t\t\t\tconst value = field.fieldState.getAccessor().resolvedValue\n\t\t\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\t\t\tresult[field.marker.fieldName] = value\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase 'hasOne': {\n\t\t\t\t\t\t\tconst input = this.getCreateOneRelationInput(\n\t\t\t\t\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\t\t\t\t\tfield.fieldState,\n\t\t\t\t\t\t\t\tfield.marker,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tif (input !== undefined) {\n\t\t\t\t\t\t\t\tresult[field.marker.parameters.field] = input\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase 'hasMany': {\n\t\t\t\t\t\t\tconst input = this.getCreateManyRelationInput(\n\t\t\t\t\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\t\t\t\t\tfield.fieldState,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tif (input !== undefined) {\n\t\t\t\t\t\t\t\tresult[field.marker.parameters.field] = input\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tassertNever(field)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst setOnCreate = getEntityMarker(siblingState).parameters.setOnCreate\n\t\t\tif (setOnCreate && !isEmptyObject(result)) {\n\t\t\t\tfor (const key in setOnCreate) {\n\t\t\t\t\tconst field = setOnCreate[key]\n\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof field === 'string' ||\n\t\t\t\t\t\ttypeof field === 'number' ||\n\t\t\t\t\t\tfield === null ||\n\t\t\t\t\t\tfield instanceof GraphQlLiteral\n\t\t\t\t\t) {\n\t\t\t\t\t\tresult[key] = field instanceof GraphQlLiteral ? field.value : field\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult[key] = { connect: replaceGraphQlLiteral(field) }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn isEmptyObject(result) ? undefined : result\n\t}\n\n\tprivate getCreateOneRelationInput(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tfieldState: EntityRealmState | EntityRealmStateStub,\n\t\tmarker: HasOneRelationMarker,\n\t): Input.CreateOneRelationInput | Input.CreateManyRelationInput | undefined {\n\t\tconst reducedBy = marker.parameters.reducedBy\n\t\tconst runtimeId = fieldState.entity.id\n\n\t\tif (reducedBy === undefined) {\n\t\t\tif (this.shouldConnectInsteadOfCreate(processedPlaceholdersByEntity, fieldState)) {\n\t\t\t\treturn { connect: { [PRIMARY_KEY_NAME]: runtimeId.value } }\n\t\t\t}\n\n\t\t\tconst createData = this.getCreateDataInput(processedPlaceholdersByEntity, fieldState)\n\t\t\tif (createData === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\treturn { create: createData }\n\t\t}\n\n\t\tconst alias = MutationAlias.encodeEntityId(runtimeId)\n\t\tif (this.shouldConnectInsteadOfCreate(processedPlaceholdersByEntity, fieldState)) {\n\t\t\t// TODO also potentially update\n\t\t\treturn [{ connect: { [PRIMARY_KEY_NAME]: runtimeId.value }, alias }]\n\t\t}\n\t\tconst createData = this.getCreateDataInput(processedPlaceholdersByEntity, fieldState)\n\t\tif (createData === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn [{ create: createData, alias }]\n\t}\n\n\tprivate getCreateManyRelationInput(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tfieldState: EntityListState,\n\t): Input.CreateManyRelationInput | undefined {\n\t\tconst result: Input.CreateManyRelationInput = []\n\t\tfor (const entityRealm of fieldState.children.values()) {\n\t\t\tconst runtimeId = entityRealm.entity.id\n\t\t\tconst alias = MutationAlias.encodeEntityId(runtimeId)\n\t\t\tif (this.shouldConnectInsteadOfCreate(processedPlaceholdersByEntity, entityRealm)) {\n\t\t\t\tresult.push({\n\t\t\t\t\talias,\n\t\t\t\t\tconnect: { [PRIMARY_KEY_NAME]: runtimeId.value },\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tconst createData = this.getCreateDataInput(processedPlaceholdersByEntity, entityRealm)\n\t\t\t\tif (createData === undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tresult.push({\n\t\t\t\t\talias,\n\t\t\t\t\tcreate: createData,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn result.length === 0 ? undefined : result\n\t}\n\n\tprivate shouldConnectInsteadOfCreate(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tcurrentState: EntityRealmState | EntityRealmStateStub,\n\t): boolean {\n\t\tconst runtimeId = currentState.entity.id\n\t\tconst processedPlaceholders = processedPlaceholdersByEntity.get(currentState.entity)\n\n\t\treturn runtimeId.existsOnServer || (runtimeId instanceof ClientGeneratedUuid && (processedPlaceholders?.has(PRIMARY_KEY_NAME) ?? false))\n\t}\n\n\tprivate getUpdateDataInput(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tcurrentState: EntityRealmState,\n\t): Input.UpdateDataInput | undefined {\n\t\tlet processedPlaceholders = processedPlaceholdersByEntity.get(currentState.entity)\n\n\t\tif (processedPlaceholders === undefined) {\n\t\t\tprocessedPlaceholdersByEntity.set(currentState.entity, (processedPlaceholders = new Set()))\n\t\t}\n\n\t\tconst pathBack = this.treeStore.getPathBackToParent(currentState)\n\t\tconst entityData = this.treeStore.persistedEntityData.get(currentState.entity.id.uniqueValue)\n\n\t\tconst result: Input.UpdateDataInput = {}\n\n\t\tfor (const [placeholderName, fieldState] of currentState.children) {\n\t\t\tif (placeholderName === PRIMARY_KEY_NAME || placeholderName === TYPENAME_KEY_NAME) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (processedPlaceholders.has(placeholderName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tprocessedPlaceholders.add(placeholderName)\n\n\t\t\tswitch (fieldState.type) {\n\t\t\t\tcase 'field': {\n\t\t\t\t\tif (fieldState.persistedValue !== undefined) {\n\t\t\t\t\t\tconst resolvedValue = fieldState.getAccessor().resolvedValue\n\t\t\t\t\t\tif (fieldState.persistedValue !== resolvedValue) {\n\t\t\t\t\t\t\tresult[placeholderName] = resolvedValue\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'entityRealmStub':\n\t\t\t\tcase 'entityRealm': {\n\t\t\t\t\tconst marker = getEntityMarker(fieldState)\n\t\t\t\t\tif (!(marker instanceof HasOneRelationMarker)) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\tif (pathBack?.fieldBackToParent === marker.parameters.field) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst reducedBy = marker.parameters.reducedBy\n\n\t\t\t\t\tconst persistedValue = entityData?.get?.(placeholderName)\n\t\t\t\t\tif (reducedBy === undefined) {\n\n\t\t\t\t\t\tconst relationData = this.getUpdateOneRelationInput(currentState, fieldState, persistedValue, processedPlaceholdersByEntity, placeholderName)\n\t\t\t\t\t\tif (relationData !== undefined) {\n\t\t\t\t\t\t\tresult[marker.parameters.field] = relationData\n\t\t\t\t\t\t}\n\n\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst relationData = this.getUpdateManyRelationForReducedInput(currentState, fieldState, persistedValue, processedPlaceholdersByEntity, placeholderName, reducedBy)\n\t\t\t\t\t\tif (relationData !== undefined) {\n\t\t\t\t\t\t\tresult[marker.parameters.field] = relationData\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'entityList': {\n\t\t\t\t\tconst marker = fieldState.blueprint.marker\n\t\t\t\t\tif (!(marker instanceof HasManyRelationMarker)) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\tif (pathBack?.fieldBackToParent === marker.parameters.field) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst persistedEntityIds = entityData?.get?.(placeholderName) ?? new Set()\n\n\t\t\t\t\tif (!(persistedEntityIds instanceof Set)) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst relationData = this.getUpdateManyRelationInput(fieldState, persistedEntityIds, processedPlaceholdersByEntity)\n\t\t\t\t\tif (relationData !== undefined) {\n\t\t\t\t\t\tresult[marker.parameters.field] = relationData\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\treturn assertNever(fieldState)\n\t\t\t}\n\t\t}\n\n\t\treturn isEmptyObject(result) ? undefined : result\n\t}\n\n\tprivate getUpdateOneRelationInput(\n\t\tcurrentState: EntityRealmState,\n\t\tfieldState: EntityRealmState | EntityRealmStateStub,\n\t\tpersistedValue: EntityFieldPersistedData | undefined,\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tplaceholderName: PlaceholderName,\n\t): Input.UpdateOneRelationInput | undefined {\n\t\tconst runtimeId = fieldState.entity.id\n\t\tif (persistedValue instanceof ServerId) {\n\t\t\tif (persistedValue.value === runtimeId.value) {\n\t\t\t\t// The persisted and currently referenced ids match, and so this is an update.\n\t\t\t\tif (fieldState.type === 'entityRealmStub') {\n\t\t\t\t\treturn undefined// …unless we're dealing with a stub. There cannot be any updates there.\n\t\t\t\t}\n\t\t\t\tconst input = this.getUpdateDataInput(processedPlaceholdersByEntity, fieldState)\n\t\t\t\tif (input === undefined) {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tupdate: input,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// There was a referenced entity but currently, there is a different one. Let's investigate:\n\n\t\t\tconst plannedDeletion = currentState.plannedHasOneDeletions?.get(placeholderName)\n\t\t\tif (plannedDeletion !== undefined) {\n\t\t\t\t// It's planned for deletion.\n\t\t\t\t// TODO also potentially do something about the current entity\n\t\t\t\treturn {\n\t\t\t\t\tdelete: true,\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (runtimeId.existsOnServer) {\n\t\t\t\t// This isn't the persisted entity but it does exist on the server. Thus this is a connect.\n\t\t\t\t// TODO also potentially update\n\t\t\t\treturn {\n\t\t\t\t\tconnect: { [PRIMARY_KEY_NAME]: runtimeId.value },\n\t\t\t\t}\n\n\t\t\t}\n\t\t\t// The currently present entity doesn't exist on the server. Try if creating yields anything…\n\t\t\tconst createInput = this.getCreateDataInput(processedPlaceholdersByEntity, fieldState)\n\t\t\tif (createInput !== undefined) {\n\t\t\t\treturn {\n\t\t\t\t\tcreate: createInput,\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// …but if it doesn't, we just disconnect.\n\t\t\t\treturn {\n\t\t\t\t\tdisconnect: true,\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (runtimeId.existsOnServer) {\n\t\t\t// There isn't a linked entity on the server but we're seeing one that exists there.\n\t\t\t// Thus this is a connect.\n\t\t\t// TODO also potentially update\n\t\t\treturn {\n\t\t\t\tconnect: { [PRIMARY_KEY_NAME]: runtimeId.value },\n\t\t\t}\n\t\t} else {\n\t\t\tconst input = this.getCreateDataInput(processedPlaceholdersByEntity, fieldState)\n\t\t\tif (input === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tcreate: input,\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getUpdateManyRelationForReducedInput(\n\t\tcurrentState: EntityRealmState,\n\t\tfieldState: EntityRealmState | EntityRealmStateStub,\n\t\tpersistedValue: EntityFieldPersistedData | undefined,\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tplaceholderName: PlaceholderName,\n\t\treducedBy: UniqueWhere,\n\t): Input.UpdateManyRelationInput | undefined {\n\n\t\tconst runtimeId = fieldState.entity.id\n\t\tconst alias = MutationAlias.encodeEntityId(runtimeId)\n\n\t\tif (persistedValue instanceof ServerId) {\n\t\t\tif (persistedValue.value === runtimeId.value) {\n\t\t\t\tif (fieldState.type === 'entityRealmStub') {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\tconst updateData = this.getUpdateDataInput(processedPlaceholdersByEntity, fieldState)\n\t\t\t\tif (updateData === undefined) {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\treturn [{\n\t\t\t\t\talias,\n\t\t\t\t\tupdate: {\n\t\t\t\t\t\tby: replaceGraphQlLiteral(reducedBy),\n\t\t\t\t\t\tdata: updateData,\n\t\t\t\t\t},\n\t\t\t\t}]\n\t\t\t}\n\t\t\tconst plannedDeletion = currentState.plannedHasOneDeletions?.get(placeholderName)\n\t\t\tif (plannedDeletion !== undefined) {\n\t\t\t\t// TODO also potentially do something about the current entity\n\t\t\t\treturn [{\n\t\t\t\t\talias,\n\t\t\t\t\tdelete: replaceGraphQlLiteral(reducedBy),\n\t\t\t\t}]\n\t\t\t}\n\t\t\tif (runtimeId.existsOnServer) {\n\t\t\t\t// TODO will re-using the alias like this work?\n\t\t\t\t// TODO also potentially update\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\talias,\n\t\t\t\t\t\tdisconnect: replaceGraphQlLiteral(reducedBy),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\talias,\n\t\t\t\t\t\tconnect: { [PRIMARY_KEY_NAME]: runtimeId.value },\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t}\n\t\t\tconst createInput = this.getCreateDataInput(processedPlaceholdersByEntity, fieldState)\n\n\t\t\tif (createInput === undefined) {\n\t\t\t\treturn [{\n\t\t\t\t\talias,\n\t\t\t\t\tdisconnect: replaceGraphQlLiteral(reducedBy),\n\t\t\t\t}]\n\t\t\t}\n\t\t\treturn [{\n\t\t\t\talias,\n\t\t\t\tcreate: createInput,\n\t\t\t}]\n\t\t} else if (runtimeId.existsOnServer) {\n\t\t\treturn [{\n\t\t\t\talias,\n\t\t\t\tconnect: { [PRIMARY_KEY_NAME]: runtimeId.value },\n\t\t\t}]\n\t\t} else {\n\t\t\tconst createInput = this.getCreateDataInput(processedPlaceholdersByEntity, fieldState)\n\t\t\tif (createInput === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\treturn [{\n\t\t\t\talias,\n\t\t\t\tcreate: createInput,\n\t\t\t}]\n\t\t}\n\t}\n\n\tprivate getUpdateManyRelationInput(\n\t\tfieldState: EntityListState,\n\t\tpersistedEntityIds: Set<EntityId>,\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t): Input.UpdateManyRelationInput | undefined {\n\n\t\tconst input: Input.UpdateManyRelationInput = []\n\t\tfor (const childState of fieldState.children.values()) {\n\t\t\tconst runtimeId = childState.entity.id\n\t\t\tconst alias = MutationAlias.encodeEntityId(runtimeId)\n\n\t\t\tif (runtimeId.existsOnServer) {\n\t\t\t\tif (persistedEntityIds.has(runtimeId.value)) {\n\t\t\t\t\tif (childState.type !== 'entityRealmStub') {\n\t\t\t\t\t\tconst dataInput = this.getUpdateDataInput(processedPlaceholdersByEntity, childState)\n\n\t\t\t\t\t\tif (dataInput !== undefined) {\n\t\t\t\t\t\t\tinput.push({\n\t\t\t\t\t\t\t\talias,\n\t\t\t\t\t\t\t\tupdate: {\n\t\t\t\t\t\t\t\t\tby: { [PRIMARY_KEY_NAME]: runtimeId.value },\n\t\t\t\t\t\t\t\t\tdata: dataInput,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tinput.push({\n\t\t\t\t\t\talias,\n\t\t\t\t\t\tconnect: { [PRIMARY_KEY_NAME]: runtimeId.value },\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst dataInput = this.getCreateDataInput(processedPlaceholdersByEntity, childState)\n\t\t\t\tif (dataInput !== undefined) {\n\t\t\t\t\tinput.push({\n\t\t\t\t\t\talias,\n\t\t\t\t\t\tcreate: dataInput,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (fieldState.plannedRemovals) {\n\t\t\tfor (const [removedId, removalType] of fieldState.plannedRemovals) {\n\t\t\t\tconst alias = MutationAlias.encodeEntityId(new ServerId(removedId, fieldState.entityName))\n\t\t\t\tif (removalType === 'delete') {\n\n\t\t\t\t\tinput.push({\n\t\t\t\t\t\talias,\n\t\t\t\t\t\tdelete: { [PRIMARY_KEY_NAME]: removedId },\n\t\t\t\t\t})\n\n\t\t\t\t} else if (removalType === 'disconnect') {\n\t\t\t\t\t// TODO also potentially update\n\n\t\t\t\t\tinput.push({\n\t\t\t\t\t\talias,\n\t\t\t\t\t\tdisconnect: { [PRIMARY_KEY_NAME]: removedId },\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\tassertNever(removalType)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn input.length === 0 ? undefined : input\n\t}\n\n\n\tprivate createAlias(): string {\n\t\treturn `op_${this.aliasCounter++}`\n\t}\n}\n"],"names":["assertNever","getEntityMarker","builder","PRIMARY_KEY_NAME","QueryGenerator","StateIterator","placeholderName","TYPENAME_KEY_NAME","ClientGeneratedUuid","HasOneRelationMarker","BindingError","HasManyRelationMarker","isEmptyObject","GraphQlLiteral","replaceGraphQlLiteral","createData","MutationAlias","ServerId"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiCO,MAAM,kBAAkB;AAAA,EAIvB,YACW,WACA,IAChB;AALM,wCAAe;AAGL,SAAA,YAAA;AACA,SAAA,KAAA;AAAA,EAElB;AAAA,EAEO,qBAAwD;AAC9D,UAAM,YAAkD,CAAA;AACxD,UAAM,aAAqC,CAAA;AACrC,UAAA,oDAAmE;AACnE,UAAA,uCAAuB;AAElB,eAAA,CAAC,YAAY,UAAU,KAAK,KAAK,UAAU,oBAAoB,WAAW;AACzE,iBAAA,CAAC,iBAAiB,YAAY,KAAK,MAAM,KAAK,WAAW,QAAQ,CAAC,EAAE,WAAW;AACrF,YAAA,aAAa,2BAA2B,GAAG;AAC9C;AAAA,QACD;AACI,YAAA,aAAa,SAAS,eAAe;AACxC,cAAI,aAAa,UAAU,SAAS,aAAa,aAAa,UAAU,OAAO,WAAW,cAAc,a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C/B,iBAAW,CAAC,WAAW,WAAW,KAAK,WAAW,iBAAiB;AAC5D,cAAA,QAAQa,4BAAc,eAAe,IAAIC,mBAAS,WAAW,WAAW,UAAU,CAAC;AACzF,YAAI,gBAAgB,UAAU;AAE7B,gBAAM,KAAK;AAAA,YACV;AAAA,YACA,QAAQ,EAAE,CAACd,aAAgB,gBAAA,GAAG,UAAU;AAAA,UAAA,CACxC;AAAA,QAAA,WAES,gBAAgB,cAAc;AAGxC,gBAAM,KAAK;AAAA,YACV;AAAA,YACA,YAAY,EAAE,CAACA,aAAgB,gBAAA,GAAG,UAAU;AAAA,UAAA,CAC5C;AAAA,QAAA,OACK;AACNH,sBAAAA,YAAuB;AAAA,QACxB;AAAA,MACD;AAAA,IACD;AAEO,WAAA,MAAM,WAAW,IAAI,SAAY;AAAA,EACzC;AAAA,EAGQ,cAAsB;AAC7B,WAAO,MAAM,KAAK;AAAA,EACnB;AACD;;"}
|
|
1
|
+
{"version":3,"file":"MutationGenerator.cjs","sources":["../../../src/core/MutationGenerator.ts"],"sourcesContent":["import { ContentMutation, ContentQueryBuilder, GraphQlLiteral, Input, replaceGraphQlLiteral } from '@contember/client'\nimport { ClientGeneratedUuid, EntityFieldPersistedData, ReceivedEntityData, ServerId } from '../accessorTree'\nimport { BindingError } from '../BindingError'\nimport { PRIMARY_KEY_NAME, TYPENAME_KEY_NAME } from '../bindingTypes'\nimport { EntityFieldMarkers, FieldMarker, HasManyRelationMarker, HasOneRelationMarker } from '../markers'\nimport type { EntityId, EntityName, PlaceholderName, UniqueWhere } from '../treeParameters'\nimport { assertNever, isEmptyObject } from '../utils'\nimport { QueryGenerator } from './QueryGenerator'\nimport { MutationAlias } from './requestAliases'\nimport { EntityListState, EntityRealmState, EntityRealmStateStub, EntityState, FieldState, getEntityMarker, StateIterator } from './state'\nimport type { TreeStore } from './TreeStore'\n\n\ntype ProcessedPlaceholdersByEntity = Map<EntityState, Set<PlaceholderName>>\n\nexport type SubMutationOperation =\n\t& {\n\t\talias: string,\n\t\tsubTreePlaceholder: PlaceholderName,\n\t\tsubTreeType: 'list' | 'single'\n\t}\n\t& (\n\t\t| { type: 'delete', id: EntityId }\n\t\t| { type: 'update', markers: EntityFieldMarkers, id: EntityId }\n\t\t| { type: 'create', markers: EntityFieldMarkers, id: EntityId }\n\t)\n\nexport type PersistMutationResult = {\n\tmutations: Record<string, ContentMutation<ReceivedEntityData>>\n\toperations: SubMutationOperation[]\n}\n\n// TODO enforce correct expected mutations in dev mode.\nexport class MutationGenerator {\n\n\tprivate aliasCounter = 1\n\n\tpublic constructor(\n\t\tprivate readonly treeStore: TreeStore,\n\t\tprivate readonly qb: ContentQueryBuilder,\n\t) {\n\t}\n\n\tpublic getPersistMutation(): PersistMutationResult | undefined {\n\t\tconst mutations: Record<string, ContentMutation<any>> = {}\n\t\tconst operations: SubMutationOperation[] = []\n\t\tconst processedPlaceholdersByEntity: ProcessedPlaceholdersByEntity = new Map()\n\t\tconst processedDeletes = new Set<string>()\n\n\t\tfor (const [treeRootId, rootStates] of this.treeStore.subTreeStatesByRoot.entries()) {\n\t\t\tfor (const [placeholderName, subTreeState] of Array.from(rootStates.entries()).reverse()) {\n\t\t\t\tif (subTreeState.unpersistedChangesCount <= 0) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (subTreeState.type === 'entityRealm') {\n\t\t\t\t\tif (subTreeState.blueprint.type === 'subTree' && subTreeState.blueprint.marker.parameters.isCreating && subTreeState.blueprint.marker.parameters.isUnpersisted) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst subMutation = this.createMutation(\n\t\t\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\t\t\tplaceholderName,\n\t\t\t\t\t\t'single',\n\t\t\t\t\t\tsubTreeState.entity.id.value,\n\t\t\t\t\t\tsubTreeState,\n\t\t\t\t\t)\n\t\t\t\t\tif (subMutation) {\n\t\t\t\t\t\tmutations[subMutation[1].alias] = subMutation[0]\n\t\t\t\t\t\toperations.push(subMutation[1])\n\t\t\t\t\t}\n\t\t\t\t} else if (subTreeState.type === 'entityList') {\n\t\t\t\t\tif (subTreeState.blueprint.type === 'subTree' && subTreeState.blueprint.marker.parameters.isCreating && subTreeState.blueprint.marker.parameters.isUnpersisted) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tfor (const childState of subTreeState.children.values()) {\n\t\t\t\t\t\tif (childState.type === 'entityRealmStub') {\n\t\t\t\t\t\t\t// TODO there can be a forceCreate somewhere in there that we're hereby ignoring.\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst subMutation = this.createMutation(\n\t\t\t\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\t\t\t\tplaceholderName,\n\t\t\t\t\t\t\t'list',\n\t\t\t\t\t\t\tchildState.entity.id.value,\n\t\t\t\t\t\t\tchildState,\n\t\t\t\t\t\t)\n\t\t\t\t\t\tif (subMutation) {\n\t\t\t\t\t\t\tmutations[subMutation[1].alias] = subMutation[0]\n\t\t\t\t\t\t\toperations.push(subMutation[1])\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (subTreeState.plannedRemovals) {\n\t\t\t\t\t\tfor (const [removedId, removalType] of subTreeState.plannedRemovals) {\n\t\t\t\t\t\t\tif (removalType === 'disconnect') {\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (removalType === 'delete') {\n\t\t\t\t\t\t\t\tconst key = `${subTreeState.entityName}#${removedId}`\n\t\t\t\t\t\t\t\tif (processedDeletes.has(key)) {\n\t\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tprocessedDeletes.add(key)\n\t\t\t\t\t\t\t\tconst alias = this.createAlias()\n\t\t\t\t\t\t\t\tmutations[alias] = this.createDeleteMutation(\n\t\t\t\t\t\t\t\t\tsubTreeState.entityName,\n\t\t\t\t\t\t\t\t\tremovedId,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\toperations.push({ alias, subTreePlaceholder: placeholderName, subTreeType: 'list', type: 'delete', id: removedId })\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tassertNever(removalType)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tassertNever(subTreeState)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { mutations, operations }\n\t}\n\n\tprivate createMutation(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tsubTreePlaceholder: PlaceholderName,\n\t\tsubTreeType: 'list' | 'single',\n\t\tentityId: EntityId,\n\t\trealmState: EntityRealmState,\n\t): [ContentMutation<any>, SubMutationOperation] | undefined {\n\t\tif (realmState.unpersistedChangesCount === 0) {\n\t\t\t// Bail out early\n\t\t\treturn undefined\n\t\t}\n\t\tconst fieldMarkers = getEntityMarker(realmState).fields.markers\n\n\t\tconst alias = this.createAlias()\n\n\t\tif (realmState.entity.isScheduledForDeletion) {\n\t\t\tconst mutation = this.createDeleteMutation(\n\t\t\t\trealmState.entity.entityName,\n\t\t\t\tentityId,\n\t\t\t)\n\t\t\treturn [\n\t\t\t\tmutation,\n\t\t\t\t{\n\t\t\t\t\talias,\n\t\t\t\t\tsubTreePlaceholder,\n\t\t\t\t\tsubTreeType,\n\t\t\t\t\ttype: 'delete',\n\t\t\t\t\tid: entityId,\n\t\t\t\t},\n\t\t\t]\n\t\t} else if (!realmState.entity.id.existsOnServer) {\n\t\t\tconst builder = this.createCreateMutation(\n\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\trealmState,\n\t\t\t\tfieldMarkers,\n\t\t\t)\n\t\t\tif (!builder) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\treturn [\n\t\t\t\tbuilder,\n\t\t\t\t{\n\t\t\t\t\talias,\n\t\t\t\t\tsubTreePlaceholder,\n\t\t\t\t\tsubTreeType,\n\t\t\t\t\ttype: 'create',\n\t\t\t\t\tmarkers: fieldMarkers,\n\t\t\t\t\tid: entityId,\n\t\t\t\t},\n]\n\t\t}\n\t\tconst builder = this.createUpdateMutation(\n\t\t\tprocessedPlaceholdersByEntity,\n\t\t\trealmState,\n\t\t\tfieldMarkers,\n\t\t)\n\t\tif (!builder) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn [\n\t\t\tbuilder,\n\t\t\t{\n\t\t\t\talias,\n\t\t\t\tsubTreePlaceholder,\n\t\t\t\tsubTreeType,\n\t\t\t\ttype: 'update',\n\t\t\t\tid: entityId,\n\t\t\t\tmarkers: fieldMarkers,\n\t\t\t},\n\t\t]\n\t}\n\n\tprivate createDeleteMutation(\n\t\tentityName: EntityName,\n\t\tdeletedId: EntityId,\n\t): ContentMutation<any> {\n\t\treturn this.qb.delete(entityName, {\n\t\t\tby: { [PRIMARY_KEY_NAME]: deletedId },\n\t\t}, it => it.$(PRIMARY_KEY_NAME).$('__typename'))\n\t}\n\n\tprivate createUpdateMutation(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tentityRealm: EntityRealmState,\n\t\tfieldMarkers: EntityFieldMarkers,\n\t): ContentMutation<any> | undefined {\n\t\tconst input = this.getUpdateDataInput(processedPlaceholdersByEntity, entityRealm)\n\n\t\tif (input === undefined) {\n\t\t\treturn undefined\n\t\t}\n\n\t\tconst runtimeId = entityRealm.entity.id\n\n\t\tif (!runtimeId.existsOnServer) {\n\t\t\treturn undefined\n\t\t}\n\n\t\treturn this.qb.update(entityRealm.entity.entityName, {\n\t\t\tby: {\n\t\t\t\t[PRIMARY_KEY_NAME]: runtimeId.value,\n\t\t\t},\n\t\t\tdata: input,\n\t\t}, it => QueryGenerator.registerQueryPart(fieldMarkers, it).$(PRIMARY_KEY_NAME).$('__typename'))\n\t}\n\n\tprivate createCreateMutation(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tentityRealm: EntityRealmState,\n\t\tfieldMarkers: EntityFieldMarkers,\n\t): ContentMutation<any> | undefined {\n\t\tconst input = this.getCreateDataInput(\n\t\t\tprocessedPlaceholdersByEntity,\n\t\t\tentityRealm,\n\t\t)\n\t\tif (input === undefined) {\n\t\t\treturn undefined\n\t\t}\n\n\t\treturn this.qb.create(entityRealm.entity.entityName, {\n\t\t\tdata: input,\n\t\t}, it => QueryGenerator.registerQueryPart(fieldMarkers, it).$(PRIMARY_KEY_NAME).$('__typename'))\n\t}\n\n\tprivate getCreateDataInput(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tcurrentState: EntityRealmState | EntityRealmStateStub,\n\t): Input.CreateDataInput | undefined {\n\t\tlet processedPlaceholders = processedPlaceholdersByEntity.get(currentState.entity)\n\n\t\tif (processedPlaceholders === undefined) {\n\t\t\tprocessedPlaceholdersByEntity.set(currentState.entity, (processedPlaceholders = new Set()))\n\t\t}\n\n\t\tif (currentState.type === 'entityRealmStub') {\n\t\t\t// TODO If there's a forceCreate, this is wrong.\n\t\t\treturn undefined\n\t\t}\n\n\t\tconst result: Input.CreateDataInput = {}\n\t\tfor (const siblingState of StateIterator.eachSiblingRealm(currentState)) {\n\n\t\t\tconst pathBack = this.treeStore.getPathBackToParent(siblingState)\n\n\t\t\tconst nonbearingFields: Array<| { type: 'field'; marker: FieldMarker; fieldState: FieldState }\n\t\t\t\t| { type: 'hasOne'; marker: HasOneRelationMarker; fieldState: EntityRealmState | EntityRealmStateStub }\n\t\t\t\t| { type: 'hasMany'; marker: HasManyRelationMarker; fieldState: EntityListState }> = []\n\n\t\t\tfor (const [placeholderName, fieldState] of siblingState.children) {\n\t\t\t\tif (processedPlaceholders.has(placeholderName)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tprocessedPlaceholders.add(placeholderName)\n\n\t\t\t\tswitch (fieldState.type) {\n\t\t\t\t\tcase 'field': {\n\t\t\t\t\t\tconst marker = fieldState.fieldMarker\n\t\t\t\t\t\tconst placeholderName = marker.placeholderName\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tplaceholderName === TYPENAME_KEY_NAME ||\n\t\t\t\t\t\t\t(placeholderName === PRIMARY_KEY_NAME && !(siblingState.entity.id instanceof ClientGeneratedUuid))\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (marker.isNonbearing) {\n\t\t\t\t\t\t\tnonbearingFields.push({\n\t\t\t\t\t\t\t\ttype: 'field',\n\t\t\t\t\t\t\t\tmarker,\n\t\t\t\t\t\t\t\tfieldState,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst value = fieldState.getAccessor().resolvedValue\n\t\t\t\t\t\tif (value !== undefined && value !== null) {\n\t\t\t\t\t\t\tresult[marker.fieldName] = value\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase 'entityRealmStub':\n\t\t\t\t\tcase 'entityRealm': {\n\t\t\t\t\t\tconst marker = getEntityMarker(fieldState)\n\t\t\t\t\t\tif (!(marker instanceof HasOneRelationMarker)) {\n\t\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (pathBack?.fieldBackToParent === marker.parameters.field) {\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (marker.parameters.isNonbearing) {\n\t\t\t\t\t\t\tnonbearingFields.push({\n\t\t\t\t\t\t\t\ttype: 'hasOne',\n\t\t\t\t\t\t\t\tmarker,\n\t\t\t\t\t\t\t\tfieldState,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst input = this.getCreateOneRelationInput(processedPlaceholdersByEntity, fieldState, marker)\n\t\t\t\t\t\tif (input !== undefined) {\n\t\t\t\t\t\t\tconst current = result[marker.parameters.field]\n\t\t\t\t\t\t\tif (Array.isArray(input) && Array.isArray(current)) {\n\t\t\t\t\t\t\t\tcurrent.push(...input)\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tresult[marker.parameters.field] = input\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase 'entityList': {\n\t\t\t\t\t\tconst marker = fieldState.blueprint.marker\n\t\t\t\t\t\tif (!(marker instanceof HasManyRelationMarker)) {\n\t\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (pathBack?.fieldBackToParent === marker.parameters.field) {\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (marker.parameters.isNonbearing) {\n\t\t\t\t\t\t\tnonbearingFields.push({\n\t\t\t\t\t\t\t\ttype: 'hasMany',\n\t\t\t\t\t\t\t\tmarker,\n\t\t\t\t\t\t\t\tfieldState,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst input = this.getCreateManyRelationInput(processedPlaceholdersByEntity, fieldState)\n\t\t\t\t\t\tif (input !== undefined) {\n\t\t\t\t\t\t\tconst current = result[marker.parameters.field]\n\t\t\t\t\t\t\tif (Array.isArray(current)) {\n\t\t\t\t\t\t\t\tcurrent.push(...input)\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tresult[marker.parameters.field] = input\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\treturn assertNever(fieldState)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ((!isEmptyObject(result)) || !getEntityMarker(siblingState).fields.hasAtLeastOneBearingField) {\n\t\t\t\tfor (const field of nonbearingFields) {\n\t\t\t\t\tswitch (field.type) {\n\t\t\t\t\t\tcase 'field': {\n\t\t\t\t\t\t\tconst value = field.fieldState.getAccessor().resolvedValue\n\t\t\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\t\t\tresult[field.marker.fieldName] = value\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase 'hasOne': {\n\t\t\t\t\t\t\tconst input = this.getCreateOneRelationInput(\n\t\t\t\t\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\t\t\t\t\tfield.fieldState,\n\t\t\t\t\t\t\t\tfield.marker,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tif (input !== undefined) {\n\t\t\t\t\t\t\t\tconst current = result[field.marker.parameters.field]\n\t\t\t\t\t\t\t\tif (Array.isArray(input) && Array.isArray(current)) {\n\t\t\t\t\t\t\t\t\tcurrent.push(...input)\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tresult[field.marker.parameters.field] = input\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase 'hasMany': {\n\t\t\t\t\t\t\tconst input = this.getCreateManyRelationInput(\n\t\t\t\t\t\t\t\tprocessedPlaceholdersByEntity,\n\t\t\t\t\t\t\t\tfield.fieldState,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tif (input !== undefined) {\n\t\t\t\t\t\t\t\tconst current = result[field.marker.parameters.field]\n\t\t\t\t\t\t\t\tif (Array.isArray(current)) {\n\t\t\t\t\t\t\t\t\tcurrent.push(...input)\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tresult[field.marker.parameters.field] = input\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tassertNever(field)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst setOnCreate = getEntityMarker(siblingState).parameters.setOnCreate\n\t\t\tif (setOnCreate && !isEmptyObject(result)) {\n\t\t\t\tfor (const key in setOnCreate) {\n\t\t\t\t\tconst field = setOnCreate[key]\n\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof field === 'string' ||\n\t\t\t\t\t\ttypeof field === 'number' ||\n\t\t\t\t\t\tfield === null ||\n\t\t\t\t\t\tfield instanceof GraphQlLiteral\n\t\t\t\t\t) {\n\t\t\t\t\t\tresult[key] = field instanceof GraphQlLiteral ? field.value : field\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult[key] = { connect: replaceGraphQlLiteral(field) }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn isEmptyObject(result) ? undefined : result\n\t}\n\n\tprivate getCreateOneRelationInput(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tfieldState: EntityRealmState | EntityRealmStateStub,\n\t\tmarker: HasOneRelationMarker,\n\t): Input.CreateOneRelationInput | Input.CreateManyRelationInput | undefined {\n\t\tconst reducedBy = marker.parameters.reducedBy\n\t\tconst runtimeId = fieldState.entity.id\n\n\t\tif (reducedBy === undefined) {\n\t\t\tif (this.shouldConnectInsteadOfCreate(processedPlaceholdersByEntity, fieldState)) {\n\t\t\t\treturn { connect: { [PRIMARY_KEY_NAME]: runtimeId.value } }\n\t\t\t}\n\n\t\t\tconst createData = this.getCreateDataInput(processedPlaceholdersByEntity, fieldState)\n\t\t\tif (createData === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\treturn { create: createData }\n\t\t}\n\n\t\tconst alias = MutationAlias.encodeEntityId(runtimeId)\n\t\tif (this.shouldConnectInsteadOfCreate(processedPlaceholdersByEntity, fieldState)) {\n\t\t\t// TODO also potentially update\n\t\t\treturn [{ connect: { [PRIMARY_KEY_NAME]: runtimeId.value }, alias }]\n\t\t}\n\t\tconst createData = this.getCreateDataInput(processedPlaceholdersByEntity, fieldState)\n\t\tif (createData === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn [{ create: createData, alias }]\n\t}\n\n\tprivate getCreateManyRelationInput(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tfieldState: EntityListState,\n\t): Input.CreateManyRelationInput | undefined {\n\t\tconst result: Input.CreateManyRelationInput = []\n\t\tfor (const entityRealm of fieldState.children.values()) {\n\t\t\tconst runtimeId = entityRealm.entity.id\n\t\t\tconst alias = MutationAlias.encodeEntityId(runtimeId)\n\t\t\tif (this.shouldConnectInsteadOfCreate(processedPlaceholdersByEntity, entityRealm)) {\n\t\t\t\tresult.push({\n\t\t\t\t\talias,\n\t\t\t\t\tconnect: { [PRIMARY_KEY_NAME]: runtimeId.value },\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tconst createData = this.getCreateDataInput(processedPlaceholdersByEntity, entityRealm)\n\t\t\t\tif (createData === undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tresult.push({\n\t\t\t\t\talias,\n\t\t\t\t\tcreate: createData,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn result.length === 0 ? undefined : result\n\t}\n\n\tprivate shouldConnectInsteadOfCreate(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tcurrentState: EntityRealmState | EntityRealmStateStub,\n\t): boolean {\n\t\tconst runtimeId = currentState.entity.id\n\t\tconst processedPlaceholders = processedPlaceholdersByEntity.get(currentState.entity)\n\n\t\treturn runtimeId.existsOnServer || (runtimeId instanceof ClientGeneratedUuid && (processedPlaceholders?.has(PRIMARY_KEY_NAME) ?? false))\n\t}\n\n\tprivate getUpdateDataInput(\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tcurrentState: EntityRealmState,\n\t): Input.UpdateDataInput | undefined {\n\t\tlet processedPlaceholders = processedPlaceholdersByEntity.get(currentState.entity)\n\n\t\tif (processedPlaceholders === undefined) {\n\t\t\tprocessedPlaceholdersByEntity.set(currentState.entity, (processedPlaceholders = new Set()))\n\t\t}\n\n\t\tconst pathBack = this.treeStore.getPathBackToParent(currentState)\n\t\tconst entityData = this.treeStore.persistedEntityData.get(currentState.entity.id.uniqueValue)\n\n\t\tconst result: Input.UpdateDataInput = {}\n\n\t\tfor (const [placeholderName, fieldState] of currentState.children) {\n\t\t\tif (placeholderName === PRIMARY_KEY_NAME || placeholderName === TYPENAME_KEY_NAME) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (processedPlaceholders.has(placeholderName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tprocessedPlaceholders.add(placeholderName)\n\n\t\t\tswitch (fieldState.type) {\n\t\t\t\tcase 'field': {\n\t\t\t\t\tif (fieldState.persistedValue !== undefined) {\n\t\t\t\t\t\tconst resolvedValue = fieldState.getAccessor().resolvedValue\n\t\t\t\t\t\tif (fieldState.persistedValue !== resolvedValue) {\n\t\t\t\t\t\t\tresult[placeholderName] = resolvedValue\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'entityRealmStub':\n\t\t\t\tcase 'entityRealm': {\n\t\t\t\t\tconst marker = getEntityMarker(fieldState)\n\t\t\t\t\tif (!(marker instanceof HasOneRelationMarker)) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\tif (pathBack?.fieldBackToParent === marker.parameters.field) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst reducedBy = marker.parameters.reducedBy\n\n\t\t\t\t\tconst persistedValue = entityData?.get?.(placeholderName)\n\t\t\t\t\tif (reducedBy === undefined) {\n\n\t\t\t\t\t\tconst relationData = this.getUpdateOneRelationInput(currentState, fieldState, persistedValue, processedPlaceholdersByEntity, placeholderName)\n\t\t\t\t\t\tif (relationData !== undefined) {\n\t\t\t\t\t\t\tresult[marker.parameters.field] = relationData\n\t\t\t\t\t\t}\n\n\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst relationData = this.getUpdateManyRelationForReducedInput(currentState, fieldState, persistedValue, processedPlaceholdersByEntity, placeholderName, reducedBy)\n\t\t\t\t\t\tif (relationData !== undefined) {\n\t\t\t\t\t\t\tconst current = result[marker.parameters.field]\n\t\t\t\t\t\t\tif (Array.isArray(current)) {\n\t\t\t\t\t\t\t\tcurrent.push(...relationData)\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tresult[marker.parameters.field] = relationData\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'entityList': {\n\t\t\t\t\tconst marker = fieldState.blueprint.marker\n\t\t\t\t\tif (!(marker instanceof HasManyRelationMarker)) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\tif (pathBack?.fieldBackToParent === marker.parameters.field) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst persistedEntityIds = entityData?.get?.(placeholderName) ?? new Set()\n\n\t\t\t\t\tif (!(persistedEntityIds instanceof Set)) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst relationData = this.getUpdateManyRelationInput(fieldState, persistedEntityIds, processedPlaceholdersByEntity)\n\t\t\t\t\tif (relationData !== undefined) {\n\t\t\t\t\t\tconst current = result[marker.parameters.field]\n\t\t\t\t\t\tif (Array.isArray(current)) {\n\t\t\t\t\t\t\tcurrent.push(...relationData)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tresult[marker.parameters.field] = relationData\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\treturn assertNever(fieldState)\n\t\t\t}\n\t\t}\n\n\t\treturn isEmptyObject(result) ? undefined : result\n\t}\n\n\tprivate getUpdateOneRelationInput(\n\t\tcurrentState: EntityRealmState,\n\t\tfieldState: EntityRealmState | EntityRealmStateStub,\n\t\tpersistedValue: EntityFieldPersistedData | undefined,\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tplaceholderName: PlaceholderName,\n\t): Input.UpdateOneRelationInput | undefined {\n\t\tconst runtimeId = fieldState.entity.id\n\t\tif (persistedValue instanceof ServerId) {\n\t\t\tif (persistedValue.value === runtimeId.value) {\n\t\t\t\t// The persisted and currently referenced ids match, and so this is an update.\n\t\t\t\tif (fieldState.type === 'entityRealmStub') {\n\t\t\t\t\treturn undefined// …unless we're dealing with a stub. There cannot be any updates there.\n\t\t\t\t}\n\t\t\t\tconst input = this.getUpdateDataInput(processedPlaceholdersByEntity, fieldState)\n\t\t\t\tif (input === undefined) {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tupdate: input,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// There was a referenced entity but currently, there is a different one. Let's investigate:\n\n\t\t\tconst plannedDeletion = currentState.plannedHasOneDeletions?.get(placeholderName)\n\t\t\tif (plannedDeletion !== undefined) {\n\t\t\t\t// It's planned for deletion.\n\t\t\t\t// TODO also potentially do something about the current entity\n\t\t\t\treturn {\n\t\t\t\t\tdelete: true,\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (runtimeId.existsOnServer) {\n\t\t\t\t// This isn't the persisted entity but it does exist on the server. Thus this is a connect.\n\t\t\t\t// TODO also potentially update\n\t\t\t\treturn {\n\t\t\t\t\tconnect: { [PRIMARY_KEY_NAME]: runtimeId.value },\n\t\t\t\t}\n\n\t\t\t}\n\t\t\t// The currently present entity doesn't exist on the server. Try if creating yields anything…\n\t\t\tconst createInput = this.getCreateDataInput(processedPlaceholdersByEntity, fieldState)\n\t\t\tif (createInput !== undefined) {\n\t\t\t\treturn {\n\t\t\t\t\tcreate: createInput,\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// …but if it doesn't, we just disconnect.\n\t\t\t\treturn {\n\t\t\t\t\tdisconnect: true,\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (runtimeId.existsOnServer) {\n\t\t\t// There isn't a linked entity on the server but we're seeing one that exists there.\n\t\t\t// Thus this is a connect.\n\t\t\t// TODO also potentially update\n\t\t\treturn {\n\t\t\t\tconnect: { [PRIMARY_KEY_NAME]: runtimeId.value },\n\t\t\t}\n\t\t} else {\n\t\t\tconst input = this.getCreateDataInput(processedPlaceholdersByEntity, fieldState)\n\t\t\tif (input === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tcreate: input,\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getUpdateManyRelationForReducedInput(\n\t\tcurrentState: EntityRealmState,\n\t\tfieldState: EntityRealmState | EntityRealmStateStub,\n\t\tpersistedValue: EntityFieldPersistedData | undefined,\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t\tplaceholderName: PlaceholderName,\n\t\treducedBy: UniqueWhere,\n\t): Input.UpdateManyRelationInput | undefined {\n\n\t\tconst runtimeId = fieldState.entity.id\n\t\tconst alias = MutationAlias.encodeEntityId(runtimeId)\n\n\t\tif (persistedValue instanceof ServerId) {\n\t\t\tif (persistedValue.value === runtimeId.value) {\n\t\t\t\tif (fieldState.type === 'entityRealmStub') {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\tconst updateData = this.getUpdateDataInput(processedPlaceholdersByEntity, fieldState)\n\t\t\t\tif (updateData === undefined) {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\treturn [{\n\t\t\t\t\talias,\n\t\t\t\t\tupdate: {\n\t\t\t\t\t\tby: replaceGraphQlLiteral(reducedBy),\n\t\t\t\t\t\tdata: updateData,\n\t\t\t\t\t},\n\t\t\t\t}]\n\t\t\t}\n\t\t\tconst plannedDeletion = currentState.plannedHasOneDeletions?.get(placeholderName)\n\t\t\tif (plannedDeletion !== undefined) {\n\t\t\t\t// TODO also potentially do something about the current entity\n\t\t\t\treturn [{\n\t\t\t\t\talias,\n\t\t\t\t\tdelete: replaceGraphQlLiteral(reducedBy),\n\t\t\t\t}]\n\t\t\t}\n\t\t\tif (runtimeId.existsOnServer) {\n\t\t\t\t// TODO will re-using the alias like this work?\n\t\t\t\t// TODO also potentially update\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\talias,\n\t\t\t\t\t\tdisconnect: replaceGraphQlLiteral(reducedBy),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\talias,\n\t\t\t\t\t\tconnect: { [PRIMARY_KEY_NAME]: runtimeId.value },\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t}\n\t\t\tconst createInput = this.getCreateDataInput(processedPlaceholdersByEntity, fieldState)\n\n\t\t\tif (createInput === undefined) {\n\t\t\t\treturn [{\n\t\t\t\t\talias,\n\t\t\t\t\tdisconnect: replaceGraphQlLiteral(reducedBy),\n\t\t\t\t}]\n\t\t\t}\n\t\t\treturn [{\n\t\t\t\talias,\n\t\t\t\tcreate: createInput,\n\t\t\t}]\n\t\t} else if (runtimeId.existsOnServer) {\n\t\t\treturn [{\n\t\t\t\talias,\n\t\t\t\tconnect: { [PRIMARY_KEY_NAME]: runtimeId.value },\n\t\t\t}]\n\t\t} else {\n\t\t\tconst createInput = this.getCreateDataInput(processedPlaceholdersByEntity, fieldState)\n\t\t\tif (createInput === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\treturn [{\n\t\t\t\talias,\n\t\t\t\tcreate: createInput,\n\t\t\t}]\n\t\t}\n\t}\n\n\tprivate getUpdateManyRelationInput(\n\t\tfieldState: EntityListState,\n\t\tpersistedEntityIds: Set<EntityId>,\n\t\tprocessedPlaceholdersByEntity: ProcessedPlaceholdersByEntity,\n\t): Input.UpdateManyRelationInput | undefined {\n\n\t\tconst input: Input.UpdateManyRelationInput = []\n\t\tfor (const childState of fieldState.children.values()) {\n\t\t\tconst runtimeId = childState.entity.id\n\t\t\tconst alias = MutationAlias.encodeEntityId(runtimeId)\n\n\t\t\tif (runtimeId.existsOnServer) {\n\t\t\t\tif (persistedEntityIds.has(runtimeId.value)) {\n\t\t\t\t\tif (childState.type !== 'entityRealmStub') {\n\t\t\t\t\t\tconst dataInput = this.getUpdateDataInput(processedPlaceholdersByEntity, childState)\n\n\t\t\t\t\t\tif (dataInput !== undefined) {\n\t\t\t\t\t\t\tinput.push({\n\t\t\t\t\t\t\t\talias,\n\t\t\t\t\t\t\t\tupdate: {\n\t\t\t\t\t\t\t\t\tby: { [PRIMARY_KEY_NAME]: runtimeId.value },\n\t\t\t\t\t\t\t\t\tdata: dataInput,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tinput.push({\n\t\t\t\t\t\talias,\n\t\t\t\t\t\tconnect: { [PRIMARY_KEY_NAME]: runtimeId.value },\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst dataInput = this.getCreateDataInput(processedPlaceholdersByEntity, childState)\n\t\t\t\tif (dataInput !== undefined) {\n\t\t\t\t\tinput.push({\n\t\t\t\t\t\talias,\n\t\t\t\t\t\tcreate: dataInput,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (fieldState.plannedRemovals) {\n\t\t\tfor (const [removedId, removalType] of fieldState.plannedRemovals) {\n\t\t\t\tconst alias = MutationAlias.encodeEntityId(new ServerId(removedId, fieldState.entityName))\n\t\t\t\tif (removalType === 'delete') {\n\n\t\t\t\t\tinput.push({\n\t\t\t\t\t\talias,\n\t\t\t\t\t\tdelete: { [PRIMARY_KEY_NAME]: removedId },\n\t\t\t\t\t})\n\n\t\t\t\t} else if (removalType === 'disconnect') {\n\t\t\t\t\t// TODO also potentially update\n\n\t\t\t\t\tinput.push({\n\t\t\t\t\t\talias,\n\t\t\t\t\t\tdisconnect: { [PRIMARY_KEY_NAME]: removedId },\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\tassertNever(removalType)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn input.length === 0 ? undefined : input\n\t}\n\n\n\tprivate createAlias(): string {\n\t\treturn `op_${this.aliasCounter++}`\n\t}\n}\n"],"names":["assertNever","getEntityMarker","builder","PRIMARY_KEY_NAME","QueryGenerator","StateIterator","placeholderName","TYPENAME_KEY_NAME","ClientGeneratedUuid","HasOneRelationMarker","BindingError","HasManyRelationMarker","isEmptyObject","GraphQlLiteral","replaceGraphQlLiteral","createData","MutationAlias","ServerId"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiCO,MAAM,kBAAkB;AAAA,EAIvB,YACW,WACA,IAChB;AALM,wCAAe;AAGL,SAAA,YAAA;AACA,SAAA,KAAA;AAAA,EAElB;AAAA,EAEO,qBAAwD;AAC9D,UAAM,YAAkD,CAAA;AACxD,UAAM,aAAqC,CAAA;AACrC,UAAA,oDAAmE;AACnE,UAAA,uCAAuB;AAElB,eAAA,CAAC,YAAY,UAAU,KAAK,KAAK,UAAU,oBAAoB,WAAW;AACzE,iBAAA,CAAC,iBAAiB,YAAY,KAAK,MAAM,KAAK,WAAW,QAAQ,CAAC,EAAE,WAAW;AACrF,YAAA,aAAa,2BAA2B,GAAG;AAC9C;AAAA,QACD;AACI,YAAA,aAAa,SAAS,eAAe;AACxC,cAAI,aAAa,UAAU,SAAS,aAAa,aAAa,UAAU,OAAO,WAAW,cAAc,aAAa,UAAU,OAAO,WAAW,eAAe;AAC/J;AAAA,UACD;AACA,gBAAM,cAAc,KAAK;AAAA,YACxB;AAAA,YACA;AAAA,YACA;AAAA,YACA,aAAa,OAAO,GAAG;AAAA,YACvB;AAAA,UAAA;AAED,cAAI,aAA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AA,MAAM,WAAW,IAAI,SAAY;AAAA,EACzC;AAAA,EAGQ,cAAsB;AACtB,WAAA,MAAM,KAAK,cAAc;AAAA,EACjC;AACD;;"}
|
|
@@ -248,7 +248,12 @@ class MutationGenerator {
|
|
|
248
248
|
}
|
|
249
249
|
const input = this.getCreateOneRelationInput(processedPlaceholdersByEntity, fieldState, marker);
|
|
250
250
|
if (input !== void 0) {
|
|
251
|
-
result[marker.parameters.field]
|
|
251
|
+
const current = result[marker.parameters.field];
|
|
252
|
+
if (Array.isArray(input) && Array.isArray(current)) {
|
|
253
|
+
current.push(...input);
|
|
254
|
+
} else {
|
|
255
|
+
result[marker.parameters.field] = input;
|
|
256
|
+
}
|
|
252
257
|
}
|
|
253
258
|
break;
|
|
254
259
|
}
|
|
@@ -270,7 +275,12 @@ class MutationGenerator {
|
|
|
270
275
|
}
|
|
271
276
|
const input = this.getCreateManyRelationInput(processedPlaceholdersByEntity, fieldState);
|
|
272
277
|
if (input !== void 0) {
|
|
273
|
-
result[marker.parameters.field]
|
|
278
|
+
const current = result[marker.parameters.field];
|
|
279
|
+
if (Array.isArray(current)) {
|
|
280
|
+
current.push(...input);
|
|
281
|
+
} else {
|
|
282
|
+
result[marker.parameters.field] = input;
|
|
283
|
+
}
|
|
274
284
|
}
|
|
275
285
|
break;
|
|
276
286
|
}
|
|
@@ -296,7 +306,12 @@ class MutationGenerator {
|
|
|
296
306
|
field.marker
|
|
297
307
|
);
|
|
298
308
|
if (input !== void 0) {
|
|
299
|
-
result[field.marker.parameters.field]
|
|
309
|
+
const current = result[field.marker.parameters.field];
|
|
310
|
+
if (Array.isArray(input) && Array.isArray(current)) {
|
|
311
|
+
current.push(...input);
|
|
312
|
+
} else {
|
|
313
|
+
result[field.marker.parameters.field] = input;
|
|
314
|
+
}
|
|
300
315
|
}
|
|
301
316
|
break;
|
|
302
317
|
}
|
|
@@ -306,7 +321,12 @@ class MutationGenerator {
|
|
|
306
321
|
field.fieldState
|
|
307
322
|
);
|
|
308
323
|
if (input !== void 0) {
|
|
309
|
-
result[field.marker.parameters.field]
|
|
324
|
+
const current = result[field.marker.parameters.field];
|
|
325
|
+
if (Array.isArray(current)) {
|
|
326
|
+
current.push(...input);
|
|
327
|
+
} else {
|
|
328
|
+
result[field.marker.parameters.field] = input;
|
|
329
|
+
}
|
|
310
330
|
}
|
|
311
331
|
break;
|
|
312
332
|
}
|
|
@@ -425,7 +445,12 @@ class MutationGenerator {
|
|
|
425
445
|
} else {
|
|
426
446
|
const relationData = this.getUpdateManyRelationForReducedInput(currentState, fieldState, persistedValue, processedPlaceholdersByEntity, placeholderName, reducedBy);
|
|
427
447
|
if (relationData !== void 0) {
|
|
428
|
-
result[marker.parameters.field]
|
|
448
|
+
const current = result[marker.parameters.field];
|
|
449
|
+
if (Array.isArray(current)) {
|
|
450
|
+
current.push(...relationData);
|
|
451
|
+
} else {
|
|
452
|
+
result[marker.parameters.field] = relationData;
|
|
453
|
+
}
|
|
429
454
|
}
|
|
430
455
|
}
|
|
431
456
|
break;
|
|
@@ -444,7 +469,12 @@ class MutationGenerator {
|
|
|
444
469
|
}
|
|
445
470
|
const relationData = this.getUpdateManyRelationInput(fieldState, persistedEntityIds, processedPlaceholdersByEntity);
|
|
446
471
|
if (relationData !== void 0) {
|
|
447
|
-
result[marker.parameters.field]
|
|
472
|
+
const current = result[marker.parameters.field];
|
|
473
|
+
if (Array.isArray(current)) {
|
|
474
|
+
current.push(...relationData);
|
|
475
|
+
} else {
|
|
476
|
+
result[marker.parameters.field] = relationData;
|
|
477
|
+
}
|
|
448
478
|
}
|
|
449
479
|
break;
|
|
450
480
|
}
|