@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":"MutationGenerator.js","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":["builder","placeholderName","createData"],"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,aAAa;AAChB,sBAAU,YAAY,CAAC,EAAE,KAAK,IAAI,YAAY,CAAC;AACpC,uBAAA,KAAK,YAAY,CAAC,CAAC;AAAA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","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":["builder","placeholderName","createData"],"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,Y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GAAG,UAAU;AAAA,UAAA,CAC5C;AAAA,QAAA,OACK;AACN,sBAAuB;AAAA,QACxB;AAAA,MACD;AAAA,IACD;AAEO,WAAA,MAAM,WAAW,IAAI,SAAY;AAAA,EACzC;AAAA,EAGQ,cAAsB;AACtB,WAAA,MAAM,KAAK,cAAc;AAAA,EACjC;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryGenerator.cjs","sources":["../../../src/core/QueryGenerator.ts"],"sourcesContent":["import { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport {\n\tEntityFieldMarkers,\n\tEntityListSubTreeMarker,\n\tEntitySubTreeMarker,\n\tFieldMarker,\n\tHasManyRelationMarker,\n\tHasOneRelationMarker,\n\tMarkerTreeRoot,\n} from '../markers'\nimport { assertNever, ucfirst } from '../utils'\nimport { ContentEntitySelection, ContentQuery, ContentQueryBuilder, replaceGraphQlLiteral } from '@contember/client'\nimport { Filter } from '../treeParameters'\n\n\nexport class QueryGenerator {\n\tconstructor(\n\t\tprivate tree: MarkerTreeRoot,\n\t\tprivate qb: ContentQueryBuilder,\n\t) {}\n\n\tpublic getReadQuery(): Record<string, ContentQuery<any>> {\n\t\tconst result: Record<string, ContentQuery<any>> = {}\n\t\tfor (const [, subTreeMarker] of this.tree.subTrees) {\n\t\t\tif (subTreeMarker.parameters.isCreating) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (subTreeMarker instanceof EntitySubTreeMarker) {\n\t\t\t\tresult[subTreeMarker.placeholderName] = this.addGetQuery(subTreeMarker)\n\t\t\t} else if (subTreeMarker instanceof EntityListSubTreeMarker) {\n\t\t\t\tresult[subTreeMarker.placeholderName] = this.createListQuery(subTreeMarker)\n\t\t\t}\n\t\t}\n\t\treturn result\n\t}\n\n\tprivate addGetQuery(subTree: EntitySubTreeMarker): ContentQuery<any> {\n\t\tif (subTree.parameters.isCreating) {\n\t\t\tthrow new Error()\n\t\t}\n\n\t\treturn this.qb.get(\n\t\t\tsubTree.entityName,\n\t\t\t{\n\t\t\t\tby: replaceGraphQlLiteral(subTree.parameters.where),\n\t\t\t\tfilter: resolveFilter(subTree.parameters.filter),\n\t\t\t},\n\t\t\tit => QueryGenerator.registerQueryPart(subTree.fields.markers, it),\n\t\t)\n\t}\n\n\tprivate createListQuery(subTree: EntityListSubTreeMarker): ContentQuery<any> {\n\t\tif (subTree.parameters.isCreating) {\n\t\t\tthrow new Error()\n\t\t}\n\t\treturn this.qb.list(\n\t\t\tsubTree.entityName,\n\t\t\t{\n\t\t\t\tfilter: resolveFilter(subTree.parameters.filter),\n\t\t\t\torderBy: replaceGraphQlLiteral(subTree.parameters.orderBy),\n\t\t\t\toffset: subTree.parameters.offset,\n\t\t\t\tlimit: subTree.parameters.limit,\n\t\t\t},\n\t\t\tit => QueryGenerator.registerQueryPart(subTree.fields.markers, it),\n\t\t)\n\t}\n\n\tpublic static registerQueryPart(fields: EntityFieldMarkers, selection: ContentEntitySelection): ContentEntitySelection {\n\t\tselection = selection.$(PRIMARY_KEY_NAME).$('__typename')\n\n\t\tfor (const [, fieldValue] of fields) {\n\t\t\tif (fieldValue instanceof FieldMarker) {\n\t\t\t\tif (fieldValue.fieldName !== PRIMARY_KEY_NAME) {\n\t\t\t\t\tselection = selection.$(fieldValue.fieldName)\n\t\t\t\t}\n\t\t\t} else if (fieldValue instanceof HasOneRelationMarker) {\n\t\t\t\tconst relation = fieldValue.parameters\n\n\t\t\t\tif (relation.reducedBy) {\n\t\t\t\t\t// Assuming there's exactly one reducer field as enforced by MarkerTreeGenerator\n\t\t\t\t\tconst relationField = `${relation.field}By${ucfirst(Object.keys(relation.reducedBy)[0])}`\n\t\t\t\t\tselection = selection.$(\n\t\t\t\t\t\trelationField,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tby: replaceGraphQlLiteral(relation.reducedBy),\n\t\t\t\t\t\t\tfilter: resolveFilter(relation.filter),\n\t\t\t\t\t\t\tas: fieldValue.placeholderName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tit => QueryGenerator.registerQueryPart(fieldValue.fields.markers, it),\n\t\t\t\t\t)\n\t\t\t\t} else {\n\t\t\t\t\tselection = selection.$(\n\t\t\t\t\t\trelation.field,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfilter: resolveFilter(relation.filter),\n\t\t\t\t\t\t\tas: fieldValue.placeholderName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tit => QueryGenerator.registerQueryPart(fieldValue.fields.markers, it),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} else if (fieldValue instanceof HasManyRelationMarker) {\n\t\t\t\tconst relation = fieldValue.parameters\n\n\n\t\t\t\tselection = selection.$(\n\t\t\t\t\trelation.field,\n\t\t\t\t\t{\n\t\t\t\t\t\tas: fieldValue.placeholderName,\n\t\t\t\t\t\tfilter: resolveFilter(relation.filter),\n\t\t\t\t\t\torderBy: replaceGraphQlLiteral(relation.orderBy),\n\t\t\t\t\t\toffset: relation.offset,\n\t\t\t\t\t\tlimit: relation.limit,\n\t\t\t\t\t},\n\t\t\t\t\tit => QueryGenerator.registerQueryPart(fieldValue.fields.markers, it),\n\t\t\t\t)\n\t\t\t} else {\n\t\t\t\tassertNever(fieldValue)\n\t\t\t}\n\t\t}\n\n\t\treturn selection\n\t}\n}\n\nconst resolveFilter = (input?: Filter): Filter<never> => {\n\treturn replaceGraphQlLiteral<unknown>(input) as Filter<never>\n}\n"],"names":["EntitySubTreeMarker","EntityListSubTreeMarker","replaceGraphQlLiteral","PRIMARY_KEY_NAME","FieldMarker","HasOneRelationMarker","ucfirst","HasManyRelationMarker","assertNever"],"mappings":";;;;;;;;;;;AAeO,MAAM,eAAe;AAAA,EAC3B,YACS,MACA,IACP;AAFO,SAAA,OAAA;AACA,SAAA,KAAA;AAAA,EACN;AAAA,EAEI,eAAkD;AACxD,UAAM,SAA4C,CAAA;AAClD,eAAW,CAAA,EAAG,aAAa,KAAK,KAAK,KAAK,UAAU;AAC/C,UAAA,cAAc,WAAW,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;AAAA,QAC7C;AAAA,MAAA,WACU,sBAAsBE,2CAAsB;AACtD,cAAM,WAAW,WAAW;AAE5B,YAAI,SAAS,WAAW;
|
|
1
|
+
{"version":3,"file":"QueryGenerator.cjs","sources":["../../../src/core/QueryGenerator.ts"],"sourcesContent":["import { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport {\n\tEntityFieldMarkers,\n\tEntityListSubTreeMarker,\n\tEntitySubTreeMarker,\n\tFieldMarker,\n\tHasManyRelationMarker,\n\tHasOneRelationMarker,\n\tMarkerTreeRoot,\n} from '../markers'\nimport { assertNever, ucfirst } from '../utils'\nimport { ContentEntitySelection, ContentQuery, ContentQueryBuilder, replaceGraphQlLiteral } from '@contember/client'\nimport { Filter } from '../treeParameters'\n\n\nexport class QueryGenerator {\n\tconstructor(\n\t\tprivate tree: MarkerTreeRoot,\n\t\tprivate qb: ContentQueryBuilder,\n\t) {}\n\n\tpublic getReadQuery(): Record<string, ContentQuery<any>> {\n\t\tconst result: Record<string, ContentQuery<any>> = {}\n\t\tfor (const [, subTreeMarker] of this.tree.subTrees) {\n\t\t\tif (subTreeMarker.parameters.isCreating) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (subTreeMarker instanceof EntitySubTreeMarker) {\n\t\t\t\tresult[subTreeMarker.placeholderName] = this.addGetQuery(subTreeMarker)\n\t\t\t} else if (subTreeMarker instanceof EntityListSubTreeMarker) {\n\t\t\t\tresult[subTreeMarker.placeholderName] = this.createListQuery(subTreeMarker)\n\t\t\t}\n\t\t}\n\t\treturn result\n\t}\n\n\tprivate addGetQuery(subTree: EntitySubTreeMarker): ContentQuery<any> {\n\t\tif (subTree.parameters.isCreating) {\n\t\t\tthrow new Error()\n\t\t}\n\n\t\treturn this.qb.get(\n\t\t\tsubTree.entityName,\n\t\t\t{\n\t\t\t\tby: replaceGraphQlLiteral(subTree.parameters.where),\n\t\t\t\tfilter: resolveFilter(subTree.parameters.filter),\n\t\t\t},\n\t\t\tit => QueryGenerator.registerQueryPart(subTree.fields.markers, it),\n\t\t)\n\t}\n\n\tprivate createListQuery(subTree: EntityListSubTreeMarker): ContentQuery<any> {\n\t\tif (subTree.parameters.isCreating) {\n\t\t\tthrow new Error()\n\t\t}\n\t\treturn this.qb.list(\n\t\t\tsubTree.entityName,\n\t\t\t{\n\t\t\t\tfilter: resolveFilter(subTree.parameters.filter),\n\t\t\t\torderBy: replaceGraphQlLiteral(subTree.parameters.orderBy),\n\t\t\t\toffset: subTree.parameters.offset,\n\t\t\t\tlimit: subTree.parameters.limit,\n\t\t\t},\n\t\t\tit => QueryGenerator.registerQueryPart(subTree.fields.markers, it),\n\t\t)\n\t}\n\n\tpublic static registerQueryPart(fields: EntityFieldMarkers, selection: ContentEntitySelection): ContentEntitySelection {\n\t\tselection = selection.$(PRIMARY_KEY_NAME).$('__typename')\n\n\t\tfor (const [, fieldValue] of fields) {\n\t\t\tif (fieldValue instanceof FieldMarker) {\n\t\t\t\tif (fieldValue.fieldName !== PRIMARY_KEY_NAME) {\n\t\t\t\t\tselection = selection.$(fieldValue.fieldName)\n\t\t\t\t}\n\t\t\t} else if (fieldValue instanceof HasOneRelationMarker) {\n\t\t\t\tconst relation = fieldValue.parameters\n\n\t\t\t\tif (relation.reducedBy) {\n\t\t\t\t\t// Assuming there's exactly one reducer field as enforced by MarkerTreeGenerator\n\t\t\t\t\tconst relationField = `${relation.field}By${ucfirst(Object.keys(relation.reducedBy)[0])}`\n\t\t\t\t\tselection = selection.$(\n\t\t\t\t\t\trelationField,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tby: replaceGraphQlLiteral(relation.reducedBy),\n\t\t\t\t\t\t\tfilter: resolveFilter(relation.filter),\n\t\t\t\t\t\t\tas: fieldValue.placeholderName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tit => QueryGenerator.registerQueryPart(fieldValue.fields.markers, it),\n\t\t\t\t\t)\n\t\t\t\t} else {\n\t\t\t\t\tselection = selection.$(\n\t\t\t\t\t\trelation.field,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfilter: resolveFilter(relation.filter),\n\t\t\t\t\t\t\tas: fieldValue.placeholderName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tit => QueryGenerator.registerQueryPart(fieldValue.fields.markers, it),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} else if (fieldValue instanceof HasManyRelationMarker) {\n\t\t\t\tconst relation = fieldValue.parameters\n\n\n\t\t\t\tselection = selection.$(\n\t\t\t\t\trelation.field,\n\t\t\t\t\t{\n\t\t\t\t\t\tas: fieldValue.placeholderName,\n\t\t\t\t\t\tfilter: resolveFilter(relation.filter),\n\t\t\t\t\t\torderBy: replaceGraphQlLiteral(relation.orderBy),\n\t\t\t\t\t\toffset: relation.offset,\n\t\t\t\t\t\tlimit: relation.limit,\n\t\t\t\t\t},\n\t\t\t\t\tit => QueryGenerator.registerQueryPart(fieldValue.fields.markers, it),\n\t\t\t\t)\n\t\t\t} else {\n\t\t\t\tassertNever(fieldValue)\n\t\t\t}\n\t\t}\n\n\t\treturn selection\n\t}\n}\n\nconst resolveFilter = (input?: Filter): Filter<never> => {\n\treturn replaceGraphQlLiteral<unknown>(input) as Filter<never>\n}\n"],"names":["EntitySubTreeMarker","EntityListSubTreeMarker","replaceGraphQlLiteral","PRIMARY_KEY_NAME","FieldMarker","HasOneRelationMarker","ucfirst","HasManyRelationMarker","assertNever"],"mappings":";;;;;;;;;;;AAeO,MAAM,eAAe;AAAA,EAC3B,YACS,MACA,IACP;AAFO,SAAA,OAAA;AACA,SAAA,KAAA;AAAA,EACN;AAAA,EAEI,eAAkD;AACxD,UAAM,SAA4C,CAAA;AAClD,eAAW,CAAA,EAAG,aAAa,KAAK,KAAK,KAAK,UAAU;AAC/C,UAAA,cAAc,WAAW,YAAY;AACxC;AAAA,MACD;AACA,UAAI,yBAAyBA,oBAAAA,qBAAqB;AACjD,eAAO,cAAc,eAAe,IAAI,KAAK,YAAY,aAAa;AAAA,MAAA,WAC5D,yBAAyBC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AK,KAAKC,QAAA,QAAQ,OAAO,KAAK,SAAS,SAAS,EAAE,CAAC,CAAC,CAAC;AACvF,sBAAY,UAAU;AAAA,YACrB;AAAA,YACA;AAAA,cACC,IAAIJ,OAAAA,sBAAsB,SAAS,SAAS;AAAA,cAC5C,QAAQ,cAAc,SAAS,MAAM;AAAA,cACrC,IAAI,WAAW;AAAA,YAChB;AAAA,YACA,QAAM,eAAe,kBAAkB,WAAW,OAAO,SAAS,EAAE;AAAA,UAAA;AAAA,QACrE,OACM;AACN,sBAAY,UAAU;AAAA,YACrB,SAAS;AAAA,YACT;AAAA,cACC,QAAQ,cAAc,SAAS,MAAM;AAAA,cACrC,IAAI,WAAW;AAAA,YAChB;AAAA,YACA,QAAM,eAAe,kBAAkB,WAAW,OAAO,SAAS,EAAE;AAAA,UAAA;AAAA,QAEtE;AAAA,MAAA,WACU,sBAAsBK,6CAAuB;AACvD,cAAM,WAAW,WAAW;AAG5B,oBAAY,UAAU;AAAA,UACrB,SAAS;AAAA,UACT;AAAA,YACC,IAAI,WAAW;AAAA,YACf,QAAQ,cAAc,SAAS,MAAM;AAAA,YACrC,SAASL,OAAAA,sBAAsB,SAAS,OAAO;AAAA,YAC/C,QAAQ,SAAS;AAAA,YACjB,OAAO,SAAS;AAAA,UACjB;AAAA,UACA,QAAM,eAAe,kBAAkB,WAAW,OAAO,SAAS,EAAE;AAAA,QAAA;AAAA,MACrE,OACM;AACNM,oBAAAA,YAAsB;AAAA,MACvB;AAAA,IACD;AAEO,WAAA;AAAA,EACR;AACD;AAEA,MAAM,gBAAgB,CAAC,UAAkC;AACxD,SAAON,OAAAA,sBAA+B,KAAK;AAC5C;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryGenerator.js","sources":["../../../src/core/QueryGenerator.ts"],"sourcesContent":["import { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport {\n\tEntityFieldMarkers,\n\tEntityListSubTreeMarker,\n\tEntitySubTreeMarker,\n\tFieldMarker,\n\tHasManyRelationMarker,\n\tHasOneRelationMarker,\n\tMarkerTreeRoot,\n} from '../markers'\nimport { assertNever, ucfirst } from '../utils'\nimport { ContentEntitySelection, ContentQuery, ContentQueryBuilder, replaceGraphQlLiteral } from '@contember/client'\nimport { Filter } from '../treeParameters'\n\n\nexport class QueryGenerator {\n\tconstructor(\n\t\tprivate tree: MarkerTreeRoot,\n\t\tprivate qb: ContentQueryBuilder,\n\t) {}\n\n\tpublic getReadQuery(): Record<string, ContentQuery<any>> {\n\t\tconst result: Record<string, ContentQuery<any>> = {}\n\t\tfor (const [, subTreeMarker] of this.tree.subTrees) {\n\t\t\tif (subTreeMarker.parameters.isCreating) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (subTreeMarker instanceof EntitySubTreeMarker) {\n\t\t\t\tresult[subTreeMarker.placeholderName] = this.addGetQuery(subTreeMarker)\n\t\t\t} else if (subTreeMarker instanceof EntityListSubTreeMarker) {\n\t\t\t\tresult[subTreeMarker.placeholderName] = this.createListQuery(subTreeMarker)\n\t\t\t}\n\t\t}\n\t\treturn result\n\t}\n\n\tprivate addGetQuery(subTree: EntitySubTreeMarker): ContentQuery<any> {\n\t\tif (subTree.parameters.isCreating) {\n\t\t\tthrow new Error()\n\t\t}\n\n\t\treturn this.qb.get(\n\t\t\tsubTree.entityName,\n\t\t\t{\n\t\t\t\tby: replaceGraphQlLiteral(subTree.parameters.where),\n\t\t\t\tfilter: resolveFilter(subTree.parameters.filter),\n\t\t\t},\n\t\t\tit => QueryGenerator.registerQueryPart(subTree.fields.markers, it),\n\t\t)\n\t}\n\n\tprivate createListQuery(subTree: EntityListSubTreeMarker): ContentQuery<any> {\n\t\tif (subTree.parameters.isCreating) {\n\t\t\tthrow new Error()\n\t\t}\n\t\treturn this.qb.list(\n\t\t\tsubTree.entityName,\n\t\t\t{\n\t\t\t\tfilter: resolveFilter(subTree.parameters.filter),\n\t\t\t\torderBy: replaceGraphQlLiteral(subTree.parameters.orderBy),\n\t\t\t\toffset: subTree.parameters.offset,\n\t\t\t\tlimit: subTree.parameters.limit,\n\t\t\t},\n\t\t\tit => QueryGenerator.registerQueryPart(subTree.fields.markers, it),\n\t\t)\n\t}\n\n\tpublic static registerQueryPart(fields: EntityFieldMarkers, selection: ContentEntitySelection): ContentEntitySelection {\n\t\tselection = selection.$(PRIMARY_KEY_NAME).$('__typename')\n\n\t\tfor (const [, fieldValue] of fields) {\n\t\t\tif (fieldValue instanceof FieldMarker) {\n\t\t\t\tif (fieldValue.fieldName !== PRIMARY_KEY_NAME) {\n\t\t\t\t\tselection = selection.$(fieldValue.fieldName)\n\t\t\t\t}\n\t\t\t} else if (fieldValue instanceof HasOneRelationMarker) {\n\t\t\t\tconst relation = fieldValue.parameters\n\n\t\t\t\tif (relation.reducedBy) {\n\t\t\t\t\t// Assuming there's exactly one reducer field as enforced by MarkerTreeGenerator\n\t\t\t\t\tconst relationField = `${relation.field}By${ucfirst(Object.keys(relation.reducedBy)[0])}`\n\t\t\t\t\tselection = selection.$(\n\t\t\t\t\t\trelationField,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tby: replaceGraphQlLiteral(relation.reducedBy),\n\t\t\t\t\t\t\tfilter: resolveFilter(relation.filter),\n\t\t\t\t\t\t\tas: fieldValue.placeholderName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tit => QueryGenerator.registerQueryPart(fieldValue.fields.markers, it),\n\t\t\t\t\t)\n\t\t\t\t} else {\n\t\t\t\t\tselection = selection.$(\n\t\t\t\t\t\trelation.field,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfilter: resolveFilter(relation.filter),\n\t\t\t\t\t\t\tas: fieldValue.placeholderName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tit => QueryGenerator.registerQueryPart(fieldValue.fields.markers, it),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} else if (fieldValue instanceof HasManyRelationMarker) {\n\t\t\t\tconst relation = fieldValue.parameters\n\n\n\t\t\t\tselection = selection.$(\n\t\t\t\t\trelation.field,\n\t\t\t\t\t{\n\t\t\t\t\t\tas: fieldValue.placeholderName,\n\t\t\t\t\t\tfilter: resolveFilter(relation.filter),\n\t\t\t\t\t\torderBy: replaceGraphQlLiteral(relation.orderBy),\n\t\t\t\t\t\toffset: relation.offset,\n\t\t\t\t\t\tlimit: relation.limit,\n\t\t\t\t\t},\n\t\t\t\t\tit => QueryGenerator.registerQueryPart(fieldValue.fields.markers, it),\n\t\t\t\t)\n\t\t\t} else {\n\t\t\t\tassertNever(fieldValue)\n\t\t\t}\n\t\t}\n\n\t\treturn selection\n\t}\n}\n\nconst resolveFilter = (input?: Filter): Filter<never> => {\n\treturn replaceGraphQlLiteral<unknown>(input) as Filter<never>\n}\n"],"names":[],"mappings":";;;;;;;;;AAeO,MAAM,eAAe;AAAA,EAC3B,YACS,MACA,IACP;AAFO,SAAA,OAAA;AACA,SAAA,KAAA;AAAA,EACN;AAAA,EAEI,eAAkD;AACxD,UAAM,SAA4C,CAAA;AAClD,eAAW,CAAA,EAAG,aAAa,KAAK,KAAK,KAAK,UAAU;AAC/C,UAAA,cAAc,WAAW,YAAY;AACxC;AAAA,MACD;AACA,UAAI,yBAAyB,qBAAqB;AACjD,eAAO,cAAc,eAAe,IAAI,KAAK,YAAY,aAAa;AAAA,MAAA,WAC5D,yBAAyB,yBAAyB;AAC5D,eAAO,cAAc,eAAe,IAAI,KAAK,gBAAgB,aAAa;AAAA,MAC3E;AAAA,IACD;AACO,WAAA;AAAA,EACR;AAAA,EAEQ,YAAY,SAAiD;AAChE,QAAA,QAAQ,WAAW,YAAY;AAClC,YAAM,IAAI,MAAM;AAAA,IACjB;AAEA,WAAO,KAAK,GAAG;AAAA,MACd,QAAQ;AAAA,MACR;AAAA,QACC,IAAI,sBAAsB,QAAQ,WAAW,KAAK;AAAA,QAClD,QAAQ,cAAc,QAAQ,WAAW,MAAM;AAAA,MAChD;AAAA,MACA,QAAO,eAAe,kBAAkB,QAAQ,OAAO,SAAS,EAAE;AAAA,IAAA;AAAA,EAEpE;AAAA,EAEQ,gBAAgB,SAAqD;AACxE,QAAA,QAAQ,WAAW,YAAY;AAClC,YAAM,IAAI,MAAM;AAAA,IACjB;AACA,WAAO,KAAK,GAAG;AAAA,MACd,QAAQ;AAAA,MACR;AAAA,QACC,QAAQ,cAAc,QAAQ,WAAW,MAAM;AAAA,QAC/C,SAAS,sBAAsB,QAAQ,WAAW,OAAO;AAAA,QACzD,QAAQ,QAAQ,WAAW;AAAA,QAC3B,OAAO,QAAQ,WAAW;AAAA,MAC3B;AAAA,MACA,QAAO,eAAe,kBAAkB,QAAQ,OAAO,SAAS,EAAE;AAAA,IAAA;AAAA,EAEpE;AAAA,EAEA,OAAc,kBAAkB,QAA4B,WAA2D;AACtH,gBAAY,UAAU,EAAE,gBAAgB,EAAE,EAAE,YAAY;AAExD,eAAW,CAAA,EAAG,UAAU,KAAK,QAAQ;AACpC,UAAI,sBAAsB,aAAa;AAClC,YAAA,WAAW,cAAc,kBAAkB;AAClC,sBAAA,UAAU,EAAE,WAAW,SAAS;AAAA,QAC7C;AAAA,MAAA,WACU,sBAAsB,sBAAsB;AACtD,cAAM,WAAW,WAAW;AAE5B,YAAI,SAAS,WAAW;
|
|
1
|
+
{"version":3,"file":"QueryGenerator.js","sources":["../../../src/core/QueryGenerator.ts"],"sourcesContent":["import { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport {\n\tEntityFieldMarkers,\n\tEntityListSubTreeMarker,\n\tEntitySubTreeMarker,\n\tFieldMarker,\n\tHasManyRelationMarker,\n\tHasOneRelationMarker,\n\tMarkerTreeRoot,\n} from '../markers'\nimport { assertNever, ucfirst } from '../utils'\nimport { ContentEntitySelection, ContentQuery, ContentQueryBuilder, replaceGraphQlLiteral } from '@contember/client'\nimport { Filter } from '../treeParameters'\n\n\nexport class QueryGenerator {\n\tconstructor(\n\t\tprivate tree: MarkerTreeRoot,\n\t\tprivate qb: ContentQueryBuilder,\n\t) {}\n\n\tpublic getReadQuery(): Record<string, ContentQuery<any>> {\n\t\tconst result: Record<string, ContentQuery<any>> = {}\n\t\tfor (const [, subTreeMarker] of this.tree.subTrees) {\n\t\t\tif (subTreeMarker.parameters.isCreating) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (subTreeMarker instanceof EntitySubTreeMarker) {\n\t\t\t\tresult[subTreeMarker.placeholderName] = this.addGetQuery(subTreeMarker)\n\t\t\t} else if (subTreeMarker instanceof EntityListSubTreeMarker) {\n\t\t\t\tresult[subTreeMarker.placeholderName] = this.createListQuery(subTreeMarker)\n\t\t\t}\n\t\t}\n\t\treturn result\n\t}\n\n\tprivate addGetQuery(subTree: EntitySubTreeMarker): ContentQuery<any> {\n\t\tif (subTree.parameters.isCreating) {\n\t\t\tthrow new Error()\n\t\t}\n\n\t\treturn this.qb.get(\n\t\t\tsubTree.entityName,\n\t\t\t{\n\t\t\t\tby: replaceGraphQlLiteral(subTree.parameters.where),\n\t\t\t\tfilter: resolveFilter(subTree.parameters.filter),\n\t\t\t},\n\t\t\tit => QueryGenerator.registerQueryPart(subTree.fields.markers, it),\n\t\t)\n\t}\n\n\tprivate createListQuery(subTree: EntityListSubTreeMarker): ContentQuery<any> {\n\t\tif (subTree.parameters.isCreating) {\n\t\t\tthrow new Error()\n\t\t}\n\t\treturn this.qb.list(\n\t\t\tsubTree.entityName,\n\t\t\t{\n\t\t\t\tfilter: resolveFilter(subTree.parameters.filter),\n\t\t\t\torderBy: replaceGraphQlLiteral(subTree.parameters.orderBy),\n\t\t\t\toffset: subTree.parameters.offset,\n\t\t\t\tlimit: subTree.parameters.limit,\n\t\t\t},\n\t\t\tit => QueryGenerator.registerQueryPart(subTree.fields.markers, it),\n\t\t)\n\t}\n\n\tpublic static registerQueryPart(fields: EntityFieldMarkers, selection: ContentEntitySelection): ContentEntitySelection {\n\t\tselection = selection.$(PRIMARY_KEY_NAME).$('__typename')\n\n\t\tfor (const [, fieldValue] of fields) {\n\t\t\tif (fieldValue instanceof FieldMarker) {\n\t\t\t\tif (fieldValue.fieldName !== PRIMARY_KEY_NAME) {\n\t\t\t\t\tselection = selection.$(fieldValue.fieldName)\n\t\t\t\t}\n\t\t\t} else if (fieldValue instanceof HasOneRelationMarker) {\n\t\t\t\tconst relation = fieldValue.parameters\n\n\t\t\t\tif (relation.reducedBy) {\n\t\t\t\t\t// Assuming there's exactly one reducer field as enforced by MarkerTreeGenerator\n\t\t\t\t\tconst relationField = `${relation.field}By${ucfirst(Object.keys(relation.reducedBy)[0])}`\n\t\t\t\t\tselection = selection.$(\n\t\t\t\t\t\trelationField,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tby: replaceGraphQlLiteral(relation.reducedBy),\n\t\t\t\t\t\t\tfilter: resolveFilter(relation.filter),\n\t\t\t\t\t\t\tas: fieldValue.placeholderName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tit => QueryGenerator.registerQueryPart(fieldValue.fields.markers, it),\n\t\t\t\t\t)\n\t\t\t\t} else {\n\t\t\t\t\tselection = selection.$(\n\t\t\t\t\t\trelation.field,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfilter: resolveFilter(relation.filter),\n\t\t\t\t\t\t\tas: fieldValue.placeholderName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tit => QueryGenerator.registerQueryPart(fieldValue.fields.markers, it),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} else if (fieldValue instanceof HasManyRelationMarker) {\n\t\t\t\tconst relation = fieldValue.parameters\n\n\n\t\t\t\tselection = selection.$(\n\t\t\t\t\trelation.field,\n\t\t\t\t\t{\n\t\t\t\t\t\tas: fieldValue.placeholderName,\n\t\t\t\t\t\tfilter: resolveFilter(relation.filter),\n\t\t\t\t\t\torderBy: replaceGraphQlLiteral(relation.orderBy),\n\t\t\t\t\t\toffset: relation.offset,\n\t\t\t\t\t\tlimit: relation.limit,\n\t\t\t\t\t},\n\t\t\t\t\tit => QueryGenerator.registerQueryPart(fieldValue.fields.markers, it),\n\t\t\t\t)\n\t\t\t} else {\n\t\t\t\tassertNever(fieldValue)\n\t\t\t}\n\t\t}\n\n\t\treturn selection\n\t}\n}\n\nconst resolveFilter = (input?: Filter): Filter<never> => {\n\treturn replaceGraphQlLiteral<unknown>(input) as Filter<never>\n}\n"],"names":[],"mappings":";;;;;;;;;AAeO,MAAM,eAAe;AAAA,EAC3B,YACS,MACA,IACP;AAFO,SAAA,OAAA;AACA,SAAA,KAAA;AAAA,EACN;AAAA,EAEI,eAAkD;AACxD,UAAM,SAA4C,CAAA;AAClD,eAAW,CAAA,EAAG,aAAa,KAAK,KAAK,KAAK,UAAU;AAC/C,UAAA,cAAc,WAAW,YAAY;AACxC;AAAA,MACD;AACA,UAAI,yBAAyB,qBAAqB;AACjD,eAAO,cAAc,eAAe,IAAI,KAAK,YAAY,aAAa;AAAA,MAAA,WAC5D,yBAAyB,yBAAyB;AAC5D,eAAO,cAAc,eAAe,IAAI,KAAK,gBAAgB,aAAa;AAAA,MAC3E;AAAA,IACD;AACO,WAAA;AAAA,EACR;AAAA,EAEQ,YAAY,SAAiD;AAChE,QAAA,QAAQ,WAAW,YAAY;AAClC,YAAM,IAAI,MAAM;AAAA,IACjB;AAEA,WAAO,KAAK,GAAG;AAAA,MACd,QAAQ;AAAA,MACR;AAAA,QACC,IAAI,sBAAsB,QAAQ,WAAW,KAAK;AAAA,QAClD,QAAQ,cAAc,QAAQ,WAAW,MAAM;AAAA,MAChD;AAAA,MACA,QAAO,eAAe,kBAAkB,QAAQ,OAAO,SAAS,EAAE;AAAA,IAAA;AAAA,EAEpE;AAAA,EAEQ,gBAAgB,SAAqD;AACxE,QAAA,QAAQ,WAAW,YAAY;AAClC,YAAM,IAAI,MAAM;AAAA,IACjB;AACA,WAAO,KAAK,GAAG;AAAA,MACd,QAAQ;AAAA,MACR;AAAA,QACC,QAAQ,cAAc,QAAQ,WAAW,MAAM;AAAA,QAC/C,SAAS,sBAAsB,QAAQ,WAAW,OAAO;AAAA,QACzD,QAAQ,QAAQ,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;AAAA,YACjB,OAAO,SAAS;AAAA,UACjB;AAAA,UACA,QAAM,eAAe,kBAAkB,WAAW,OAAO,SAAS,EAAE;AAAA,QAAA;AAAA,MACrE,OACM;AACN,oBAAsB;AAAA,MACvB;AAAA,IACD;AAEO,WAAA;AAAA,EACR;AACD;AAEA,MAAM,gBAAgB,CAAC,UAAkC;AACxD,SAAO,sBAA+B,KAAK;AAC5C;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealmKeyGenerator.cjs","sources":["../../../src/core/RealmKeyGenerator.ts"],"sourcesContent":["import type { RuntimeId } from '../accessorTree'\nimport type { EntityFieldMarkersContainer } from '../markers'\nimport type { EntityId, EntityRealmKey, PlaceholderName } from '../treeParameters'\nimport { assertNever } from '../utils'\nimport type { EntityListState, EntityRealmBlueprint, EntityRealmState } from './state'\nimport { WeakIdCache } from '../structures'\n\nconst GLUE = '--'\nconst keyEndRegex = new RegExp(`${GLUE}\\\\d+$`)\n\nexport class RealmKeyGenerator {\n\t// We're using this id, and not, well, the entity id, because it *SIGNIFICANTLY* reduces the complexity of\n\t// entity id changes.\n\tprivate static parentStateIdCache = new WeakIdCache<EntityRealmState | EntityListState>()\n\tprivate static markerIdCache = new WeakIdCache<EntityFieldMarkersContainer>()\n\n\tpublic static vaguelyAppearsToBeAKey(candidate: string): boolean {\n\t\t// This is just for error messages. No need to be super precise.\n\t\treturn candidate.startsWith(`key${GLUE}`) && keyEndRegex.test(candidate)\n\t}\n\n\tprivate static generateKey(\n\t\tparent: EntityRealmState | EntityListState | undefined,\n\t\tplaceholderName: PlaceholderName,\n\t\tid: EntityId,\n\t\tcontainer: EntityFieldMarkersContainer,\n\t): EntityRealmKey {\n\t\t// The static prefix serves to really emphasize that this is *NOT* just a uuid\n\t\treturn `key${GLUE}${this.parentStateIdCache.getOptionalKeyId(\n\t\t\tparent,\n\t\t)}${GLUE}${placeholderName}${id}${GLUE}${this.markerIdCache.getId(container)}`\n\t}\n\n\tpublic static getRealmKey(id: RuntimeId, blueprint: EntityRealmBlueprint): EntityRealmKey {\n\t\tconst parent = blueprint.parent\n\t\tlet placeholderName: PlaceholderName\n\n\t\tif (blueprint.type === 'subTree') {\n\t\t\tplaceholderName = blueprint.marker.placeholderName\n\t\t} else if (blueprint.type === 'listEntity') {\n\t\t\tplaceholderName = blueprint.parent.blueprint.marker.placeholderName\n\t\t} else if (blueprint.type === 'hasOne') {\n\t\t\tplaceholderName = blueprint.marker.placeholderName\n\t\t} else {\n\t\t\treturn assertNever(blueprint)\n\t\t}\n\t\treturn this.generateKey(\n\t\t\tparent,\n\t\t\tplaceholderName,\n\t\t\tid.value,\n\t\t\tblueprint.type === 'listEntity' ? blueprint.parent.blueprint.marker.fields : blueprint.marker.fields,\n\t\t)\n\t}\n}\n"],"names":["assertNever","WeakIdCache"],"mappings":";;;;;;;;;;AAOA,MAAM,OAAO;AACb,MAAM,cAAc,IAAI,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"RealmKeyGenerator.cjs","sources":["../../../src/core/RealmKeyGenerator.ts"],"sourcesContent":["import type { RuntimeId } from '../accessorTree'\nimport type { EntityFieldMarkersContainer } from '../markers'\nimport type { EntityId, EntityRealmKey, PlaceholderName } from '../treeParameters'\nimport { assertNever } from '../utils'\nimport type { EntityListState, EntityRealmBlueprint, EntityRealmState } from './state'\nimport { WeakIdCache } from '../structures'\n\nconst GLUE = '--'\nconst keyEndRegex = new RegExp(`${GLUE}\\\\d+$`)\n\nexport class RealmKeyGenerator {\n\t// We're using this id, and not, well, the entity id, because it *SIGNIFICANTLY* reduces the complexity of\n\t// entity id changes.\n\tprivate static parentStateIdCache = new WeakIdCache<EntityRealmState | EntityListState>()\n\tprivate static markerIdCache = new WeakIdCache<EntityFieldMarkersContainer>()\n\n\tpublic static vaguelyAppearsToBeAKey(candidate: string): boolean {\n\t\t// This is just for error messages. No need to be super precise.\n\t\treturn candidate.startsWith(`key${GLUE}`) && keyEndRegex.test(candidate)\n\t}\n\n\tprivate static generateKey(\n\t\tparent: EntityRealmState | EntityListState | undefined,\n\t\tplaceholderName: PlaceholderName,\n\t\tid: EntityId,\n\t\tcontainer: EntityFieldMarkersContainer,\n\t): EntityRealmKey {\n\t\t// The static prefix serves to really emphasize that this is *NOT* just a uuid\n\t\treturn `key${GLUE}${this.parentStateIdCache.getOptionalKeyId(\n\t\t\tparent,\n\t\t)}${GLUE}${placeholderName}${id}${GLUE}${this.markerIdCache.getId(container)}`\n\t}\n\n\tpublic static getRealmKey(id: RuntimeId, blueprint: EntityRealmBlueprint): EntityRealmKey {\n\t\tconst parent = blueprint.parent\n\t\tlet placeholderName: PlaceholderName\n\n\t\tif (blueprint.type === 'subTree') {\n\t\t\tplaceholderName = blueprint.marker.placeholderName\n\t\t} else if (blueprint.type === 'listEntity') {\n\t\t\tplaceholderName = blueprint.parent.blueprint.marker.placeholderName\n\t\t} else if (blueprint.type === 'hasOne') {\n\t\t\tplaceholderName = blueprint.marker.placeholderName\n\t\t} else {\n\t\t\treturn assertNever(blueprint)\n\t\t}\n\t\treturn this.generateKey(\n\t\t\tparent,\n\t\t\tplaceholderName,\n\t\t\tid.value,\n\t\t\tblueprint.type === 'listEntity' ? blueprint.parent.blueprint.marker.fields : blueprint.marker.fields,\n\t\t)\n\t}\n}\n"],"names":["assertNever","WeakIdCache"],"mappings":";;;;;;;;;;AAOA,MAAM,OAAO;AACb,MAAM,cAAc,IAAI,OAAO,GAAG,IAAI,OAAO;AAEtC,MAAM,kBAAkB;AAAA,EAM9B,OAAc,uBAAuB,WAA4B;AAEzD,WAAA,UAAU,WAAW,MAAM,IAAI,EAAE,KAAK,YAAY,KAAK,SAAS;AAAA,EACxE;AAAA,EAEA,OAAe,YACd,QACA,iBACA,IACA,WACiB;AAEjB,WAAO,MAAM,IAAI,GAAG,KAAK,mBAAmB;AAAA,MAC3C;AAAA,IACA,CAAA,GAAG,IAAI,GAAG,eAAe,GAAG,EAAE,GAAG,IAAI,GAAG,KAAK,cAAc,MAAM,SAAS,CAAC;AAAA,EAC7E;AAAA,EAEA,OAAc,YAAY,IAAe,WAAiD;AACzF,UAAM,SAAS,UAAU;AACrB,QAAA;AAEA,QAAA,UAAU,SAAS,WAAW;AACjC,wBAAkB,UAAU,OAAO;AAAA,IAAA,WACzB,UAAU,SAAS,cAAc;AACzB,wBAAA,UAAU,OAAO,UAAU,OAAO;AAAA,IAAA,WAC1C,UAAU,SAAS,UAAU;AACvC,wBAAkB,UAAU,OAAO;AAAA,IAAA,OAC7B;AACN,aAAOA,YAAAA,YAAqB;AAAA,IAC7B;AACA,WAAO,KAAK;AAAA,MACX;AAAA,MACA;AAAA,MACA,GAAG;AAAA,MACH,UAAU,SAAS,eAAe,UAAU,OAAO,UAAU,OAAO,SAAS,UAAU,OAAO;AAAA,IAAA;AAAA,EAEhG;AACD;AAAA;AAAA;AAxCC,cAHY,mBAGG,sBAAqB,IAAIC,YAAAA;AACxC,cAJY,mBAIG,iBAAgB,IAAIA,YAAAA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealmKeyGenerator.js","sources":["../../../src/core/RealmKeyGenerator.ts"],"sourcesContent":["import type { RuntimeId } from '../accessorTree'\nimport type { EntityFieldMarkersContainer } from '../markers'\nimport type { EntityId, EntityRealmKey, PlaceholderName } from '../treeParameters'\nimport { assertNever } from '../utils'\nimport type { EntityListState, EntityRealmBlueprint, EntityRealmState } from './state'\nimport { WeakIdCache } from '../structures'\n\nconst GLUE = '--'\nconst keyEndRegex = new RegExp(`${GLUE}\\\\d+$`)\n\nexport class RealmKeyGenerator {\n\t// We're using this id, and not, well, the entity id, because it *SIGNIFICANTLY* reduces the complexity of\n\t// entity id changes.\n\tprivate static parentStateIdCache = new WeakIdCache<EntityRealmState | EntityListState>()\n\tprivate static markerIdCache = new WeakIdCache<EntityFieldMarkersContainer>()\n\n\tpublic static vaguelyAppearsToBeAKey(candidate: string): boolean {\n\t\t// This is just for error messages. No need to be super precise.\n\t\treturn candidate.startsWith(`key${GLUE}`) && keyEndRegex.test(candidate)\n\t}\n\n\tprivate static generateKey(\n\t\tparent: EntityRealmState | EntityListState | undefined,\n\t\tplaceholderName: PlaceholderName,\n\t\tid: EntityId,\n\t\tcontainer: EntityFieldMarkersContainer,\n\t): EntityRealmKey {\n\t\t// The static prefix serves to really emphasize that this is *NOT* just a uuid\n\t\treturn `key${GLUE}${this.parentStateIdCache.getOptionalKeyId(\n\t\t\tparent,\n\t\t)}${GLUE}${placeholderName}${id}${GLUE}${this.markerIdCache.getId(container)}`\n\t}\n\n\tpublic static getRealmKey(id: RuntimeId, blueprint: EntityRealmBlueprint): EntityRealmKey {\n\t\tconst parent = blueprint.parent\n\t\tlet placeholderName: PlaceholderName\n\n\t\tif (blueprint.type === 'subTree') {\n\t\t\tplaceholderName = blueprint.marker.placeholderName\n\t\t} else if (blueprint.type === 'listEntity') {\n\t\t\tplaceholderName = blueprint.parent.blueprint.marker.placeholderName\n\t\t} else if (blueprint.type === 'hasOne') {\n\t\t\tplaceholderName = blueprint.marker.placeholderName\n\t\t} else {\n\t\t\treturn assertNever(blueprint)\n\t\t}\n\t\treturn this.generateKey(\n\t\t\tparent,\n\t\t\tplaceholderName,\n\t\t\tid.value,\n\t\t\tblueprint.type === 'listEntity' ? blueprint.parent.blueprint.marker.fields : blueprint.marker.fields,\n\t\t)\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;AAOA,MAAM,OAAO;AACb,MAAM,cAAc,IAAI,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"RealmKeyGenerator.js","sources":["../../../src/core/RealmKeyGenerator.ts"],"sourcesContent":["import type { RuntimeId } from '../accessorTree'\nimport type { EntityFieldMarkersContainer } from '../markers'\nimport type { EntityId, EntityRealmKey, PlaceholderName } from '../treeParameters'\nimport { assertNever } from '../utils'\nimport type { EntityListState, EntityRealmBlueprint, EntityRealmState } from './state'\nimport { WeakIdCache } from '../structures'\n\nconst GLUE = '--'\nconst keyEndRegex = new RegExp(`${GLUE}\\\\d+$`)\n\nexport class RealmKeyGenerator {\n\t// We're using this id, and not, well, the entity id, because it *SIGNIFICANTLY* reduces the complexity of\n\t// entity id changes.\n\tprivate static parentStateIdCache = new WeakIdCache<EntityRealmState | EntityListState>()\n\tprivate static markerIdCache = new WeakIdCache<EntityFieldMarkersContainer>()\n\n\tpublic static vaguelyAppearsToBeAKey(candidate: string): boolean {\n\t\t// This is just for error messages. No need to be super precise.\n\t\treturn candidate.startsWith(`key${GLUE}`) && keyEndRegex.test(candidate)\n\t}\n\n\tprivate static generateKey(\n\t\tparent: EntityRealmState | EntityListState | undefined,\n\t\tplaceholderName: PlaceholderName,\n\t\tid: EntityId,\n\t\tcontainer: EntityFieldMarkersContainer,\n\t): EntityRealmKey {\n\t\t// The static prefix serves to really emphasize that this is *NOT* just a uuid\n\t\treturn `key${GLUE}${this.parentStateIdCache.getOptionalKeyId(\n\t\t\tparent,\n\t\t)}${GLUE}${placeholderName}${id}${GLUE}${this.markerIdCache.getId(container)}`\n\t}\n\n\tpublic static getRealmKey(id: RuntimeId, blueprint: EntityRealmBlueprint): EntityRealmKey {\n\t\tconst parent = blueprint.parent\n\t\tlet placeholderName: PlaceholderName\n\n\t\tif (blueprint.type === 'subTree') {\n\t\t\tplaceholderName = blueprint.marker.placeholderName\n\t\t} else if (blueprint.type === 'listEntity') {\n\t\t\tplaceholderName = blueprint.parent.blueprint.marker.placeholderName\n\t\t} else if (blueprint.type === 'hasOne') {\n\t\t\tplaceholderName = blueprint.marker.placeholderName\n\t\t} else {\n\t\t\treturn assertNever(blueprint)\n\t\t}\n\t\treturn this.generateKey(\n\t\t\tparent,\n\t\t\tplaceholderName,\n\t\t\tid.value,\n\t\t\tblueprint.type === 'listEntity' ? blueprint.parent.blueprint.marker.fields : blueprint.marker.fields,\n\t\t)\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;AAOA,MAAM,OAAO;AACb,MAAM,cAAc,IAAI,OAAO,GAAG,IAAI,OAAO;AAEtC,MAAM,kBAAkB;AAAA,EAM9B,OAAc,uBAAuB,WAA4B;AAEzD,WAAA,UAAU,WAAW,MAAM,IAAI,EAAE,KAAK,YAAY,KAAK,SAAS;AAAA,EACxE;AAAA,EAEA,OAAe,YACd,QACA,iBACA,IACA,WACiB;AAEjB,WAAO,MAAM,IAAI,GAAG,KAAK,mBAAmB;AAAA,MAC3C;AAAA,IACA,CAAA,GAAG,IAAI,GAAG,eAAe,GAAG,EAAE,GAAG,IAAI,GAAG,KAAK,cAAc,MAAM,SAAS,CAAC;AAAA,EAC7E;AAAA,EAEA,OAAc,YAAY,IAAe,WAAiD;AACzF,UAAM,SAAS,UAAU;AACrB,QAAA;AAEA,QAAA,UAAU,SAAS,WAAW;AACjC,wBAAkB,UAAU,OAAO;AAAA,IAAA,WACzB,UAAU,SAAS,cAAc;AACzB,wBAAA,UAAU,OAAO,UAAU,OAAO;AAAA,IAAA,WAC1C,UAAU,SAAS,UAAU;AACvC,wBAAkB,UAAU,OAAO;AAAA,IAAA,OAC7B;AACN,aAAO,YAAqB;AAAA,IAC7B;AACA,WAAO,KAAK;AAAA,MACX;AAAA,MACA;AAAA,MACA,GAAG;AAAA,MACH,UAAU,SAAS,eAAe,UAAU,OAAO,UAAU,OAAO,SAAS,UAAU,OAAO;AAAA,IAAA;AAAA,EAEhG;AACD;AAAA;AAAA;AAxCC,cAHY,mBAGG,sBAAqB,IAAI;AACxC,cAJY,mBAIG,iBAAgB,IAAI;"}
|
|
@@ -238,6 +238,7 @@ class StateInitializer {
|
|
|
238
238
|
entityListState.accessor = new EntityListAccessor.EntityListAccessor(
|
|
239
239
|
entityListState,
|
|
240
240
|
this.listOperations,
|
|
241
|
+
entityListState.entityName,
|
|
241
242
|
entityListState.children,
|
|
242
243
|
persistedEntityIds,
|
|
243
244
|
entityListState.unpersistedChangesCount !== 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateInitializer.cjs","sources":["../../../src/core/StateInitializer.ts"],"sourcesContent":["import { BatchUpdatesOptions, EntityAccessor, EntityListAccessor, FieldAccessor } from '../accessors'\nimport { EntityFieldPersistedData, RuntimeId, ServerId, UnpersistedEntityDummyId } from '../accessorTree'\nimport { BindingError } from '../BindingError'\nimport {\n\tEntityListSubTreeMarker,\n\tEntitySubTreeMarker,\n\tFieldMarker,\n\tHasManyRelationMarker,\n\tHasOneRelationMarker,\n} from '../markers'\nimport { BijectiveIndexedMap } from '../structures'\nimport type {\n\tEntityEventListenerStore,\n\tEntityId,\n\tEntityListEventListenerStore,\n\tEntityName,\n\tFieldEventListenerStore,\n\tFieldName,\n\tFieldValue,\n} from '../treeParameters'\nimport { EventListenersStore } from '../treeParameters'\nimport { assertNever } from '../utils'\nimport type { AccessorErrorManager } from './AccessorErrorManager'\nimport type { EventManager } from './EventManager'\nimport { EntityOperations, FieldOperations, ListOperations } from './operations'\nimport { RealmKeyGenerator } from './RealmKeyGenerator'\nimport {\n\tEntityListBlueprint,\n\tEntityListState,\n\tEntityRealmBlueprint,\n\tEntityRealmState,\n\tEntityRealmStateStub,\n\tEntityState,\n\tFieldState,\n\tgetEntityMarker,\n\tRootStateNode,\n} from './state'\nimport { TreeParameterMerger } from './TreeParameterMerger'\nimport type { TreeStore } from './TreeStore'\n\nexport class StateInitializer {\n\tprivate readonly fieldOperations: FieldOperations\n\tprivate readonly entityOperations: EntityOperations\n\tprivate readonly listOperations: ListOperations\n\n\tpublic constructor(\n\t\taccessorErrorManager: AccessorErrorManager,\n\t\tbatchUpdatesOptions: BatchUpdatesOptions,\n\t\tprivate readonly eventManager: EventManager,\n\t\tprivate readonly treeStore: TreeStore,\n\t) {\n\t\tthis.fieldOperations = new FieldOperations(accessorErrorManager, this.eventManager, this, this.treeStore)\n\t\tthis.entityOperations = new EntityOperations(accessorErrorManager, batchUpdatesOptions, this.eventManager, this, this.treeStore)\n\t\tthis.listOperations = new ListOperations(accessorErrorManager, batchUpdatesOptions, this.eventManager, this, this.treeStore)\n\t}\n\n\tpublic initializeSubTree(tree: EntitySubTreeMarker | EntityListSubTreeMarker): RootStateNode {\n\t\tlet subTreeState: RootStateNode\n\t\tconst persistedRootData = this.treeStore.subTreePersistedData.get(tree.placeholderName)\n\n\t\tif (tree instanceof EntityListSubTreeMarker) {\n\t\t\tconst persistedEntityIds: Set<EntityId> = persistedRootData instanceof Set ? persistedRootData : new Set()\n\t\t\tsubTreeState = this.initializeEntityListState(\n\t\t\t\t{ type: 'subTree', marker: tree, parent: undefined },\n\t\t\t\ttree.entityName,\n\t\t\t\tpersistedEntityIds,\n\t\t\t)\n\t\t} else {\n\t\t\tsubTreeState = this.materializeEntityRealm(\n\t\t\t\tthis.initializeEntityRealm(\n\t\t\t\t\tpersistedRootData instanceof ServerId ? persistedRootData : new UnpersistedEntityDummyId(),\n\t\t\t\t\ttree.entityName,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'subTree',\n\t\t\t\t\t\tmarker: tree,\n\t\t\t\t\t\tparent: undefined,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\n\t\treturn subTreeState\n\t}\n\n\tpublic initializeEntityRealm(\n\t\tid: RuntimeId,\n\t\tentityName: EntityName,\n\t\tblueprint: EntityRealmBlueprint,\n\t\tcopyFrom?: EntityRealmState | EntityRealmStateStub,\n\t): EntityRealmState | EntityRealmStateStub {\n\t\t// This is counter-intuitive a bit. The method can also return an EntityRealmState, not just a stub.\n\t\t// The reason is so that each call-site can just default to trying to initialize a stub without having to keep\n\t\t// in mind that the realm might have already been initialized.\n\n\t\tconst entity = this.initializeEntityState(id, entityName)\n\t\tconst realmKey = RealmKeyGenerator.getRealmKey(id, blueprint)\n\n\t\tconst existing = this.treeStore.entityRealmStore.get(realmKey)\n\t\tif (existing !== undefined) {\n\t\t\treturn existing\n\t\t}\n\n\t\tif (!copyFrom || copyFrom.type !== 'entityRealm') {\n\t\t\tconst stub: EntityRealmStateStub = {\n\t\t\t\ttype: 'entityRealmStub',\n\n\t\t\t\tblueprint,\n\t\t\t\tentity,\n\t\t\t\trealmKey,\n\t\t\t\tgetAccessor: () => this.materializeEntityRealm(stub).getAccessor(),\n\t\t\t}\n\t\t\tthis.registerEntityRealm(stub)\n\n\t\t\treturn stub\n\t\t}\n\t\tconst realm = this.createEntityRealm(blueprint, realmKey, entity, copyFrom)\n\n\t\tthis.registerEntityRealm(realm)\n\n\t\tconst marker = getEntityMarker(realm)\n\t\tconst pathBack = this.treeStore.getPathBackToParent(realm)\n\n\t\tfor (const [placeholderName, field] of marker.fields.markers) {\n\t\t\tif (field instanceof FieldMarker) {\n\t\t\t\tconst value = copyFrom.children.get(placeholderName)\n\t\t\t\tif (!value || value.type !== 'field') {\n\t\t\t\t\tthrow new BindingError()\n\t\t\t\t}\n\t\t\t\tthis.initializeFromFieldMarker(realm, field, undefined, value)\n\t\t\t} else if (field instanceof HasManyRelationMarker) {\n\t\t\t\tconst value = copyFrom.children.get(placeholderName)\n\t\t\t\tif (!value || value.type !== 'entityList') {\n\t\t\t\t\tthrow new BindingError()\n\t\t\t\t}\n\t\t\t\tthis.initializeFromHasManyRelationMarker(realm, field, new Set(value.children.keys()))\n\t\t\t} else if (field instanceof HasOneRelationMarker) {\n\t\t\t\tlet runtimeId: RuntimeId\n\t\t\t\tlet subCopyFrom: EntityRealmState | undefined = undefined\n\t\t\t\tif (pathBack?.fieldBackToParent === field.parameters.field) {\n\t\t\t\t\truntimeId = pathBack.parent.entity.id\n\t\t\t\t} else {\n\t\t\t\t\tconst value = copyFrom.children.get(placeholderName)\n\t\t\t\t\tif (!value || (value.type !== 'entityRealm' && value.type !== 'entityRealmStub')) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\truntimeId = !(value.entity.id instanceof UnpersistedEntityDummyId) ? value.entity.id : new UnpersistedEntityDummyId()\n\t\t\t\t\tif (value.type === 'entityRealm') {\n\t\t\t\t\t\tsubCopyFrom = value\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.initializeFromHasOneRelationMarker(realm, field, runtimeId, subCopyFrom)\n\t\t\t} else {\n\t\t\t\tassertNever(field)\n\t\t\t}\n\t\t}\n\n\t\tthis.eventManager.registerNewlyInitialized(realm)\n\t\treturn realm\n\t}\n\n\tprivate createEntityRealm(\n\t\tblueprint: EntityRealmBlueprint,\n\t\trealmKey: string,\n\t\tentity: EntityState,\n\t\tcopyFrom?: EntityRealmState,\n\t): EntityRealmState {\n\t\tconst entityRealm: EntityRealmState = {\n\t\t\ttype: 'entityRealm',\n\n\t\t\tblueprint,\n\t\t\trealmKey,\n\t\t\tentity,\n\n\t\t\taccessor: undefined,\n\t\t\tchildren: new Map(),\n\t\t\tchildrenWithPendingUpdates: undefined,\n\t\t\terrors: undefined,\n\t\t\teventListeners: this.initializeEntityEventListenerStore(blueprint),\n\t\t\tfieldsWithPendingConnectionUpdates: undefined,\n\t\t\tplannedHasOneDeletions: undefined,\n\t\t\tunpersistedChangesCount: copyFrom?.unpersistedChangesCount ?? 0,\n\t\t\tgetAccessor: () => {\n\t\t\t\tif (entityRealm.accessor === undefined) {\n\t\t\t\t\tconst entity = entityRealm.entity\n\t\t\t\t\tentityRealm.accessor = new EntityAccessor(\n\t\t\t\t\t\tentityRealm,\n\t\t\t\t\t\tthis.entityOperations,\n\t\t\t\t\t\tentity.id,\n\t\t\t\t\t\tentityRealm.realmKey,\n\t\t\t\t\t\tentity.entityName,\n\n\t\t\t\t\t\t// We're technically exposing more info in runtime than we'd like but that way we don't have to allocate and\n\t\t\t\t\t\t// keep in sync two copies of the same data. TS hides the extra info anyway.\n\t\t\t\t\t\tentityRealm.children,\n\t\t\t\t\t\tthis.treeStore.persistedEntityData.get(entity.id.uniqueValue),\n\t\t\t\t\t\tentityRealm.unpersistedChangesCount !== 0,\n\t\t\t\t\t\tentityRealm.errors,\n\t\t\t\t\t\tgetEntityMarker(entityRealm).environment,\n\t\t\t\t\t\tentityRealm.getAccessor,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn entityRealm.accessor\n\t\t\t},\n\t\t}\n\t\treturn entityRealm\n\t}\n\n\tprivate materializeEntityRealm(state: EntityRealmState | EntityRealmStateStub): EntityRealmState {\n\t\tif (state.type === 'entityRealm') {\n\t\t\treturn state\n\t\t}\n\t\tconst { realmKey, entity, blueprint } = state\n\n\t\tconst existing = this.treeStore.entityRealmStore.get(realmKey)\n\t\tif (existing !== undefined && existing.type === 'entityRealm') {\n\t\t\treturn existing\n\t\t}\n\n\t\tconst entityRealm = this.createEntityRealm(blueprint, realmKey, entity)\n\n\t\tthis.registerEntityRealm(entityRealm)\n\n\t\t// if (blueprint.creationParameters.forceCreation && !entity.id.existsOnServer) {\n\t\t// \tentityRealm.unpersistedChangesCount += 1\n\t\t// }\n\n\t\tconst persistedData = this.treeStore.persistedEntityData.get(entity.id.uniqueValue)\n\n\t\tconst marker = getEntityMarker(state)\n\t\tconst pathBack = this.treeStore.getPathBackToParent(entityRealm)\n\n\t\tfor (const [placeholderName, field] of marker.fields.markers) {\n\t\t\tconst fieldDatum = persistedData?.get(placeholderName)\n\n\t\t\tif (field instanceof FieldMarker) {\n\t\t\t\tthis.initializeFromFieldMarker(entityRealm, field, fieldDatum)\n\t\t\t} else if (field instanceof HasManyRelationMarker) {\n\t\t\t\t// if (pathBack?.fieldBackToParent === field.parameters.field) {\n\t\t\t\t// \t// TODO this is probably wrong?\n\t\t\t\t// \tconst ids = pathBack.parent.children.get(field.placeholderName)\n\t\t\t\t// \tconst newData = this.treeStore.persistedEntityData.get(pathBack.parent.entity.id.value)\n\t\t\t\t// \tconsole.log('many?', pathBack, field, entityRealm, fieldDatum, ids)\n\t\t\t\t// }\n\t\t\t\tthis.initializeFromHasManyRelationMarker(entityRealm, field, fieldDatum instanceof Set ? fieldDatum : new Set())\n\t\t\t} else if (field instanceof HasOneRelationMarker) {\n\t\t\t\tlet runtimeId: RuntimeId\n\t\t\t\tif (pathBack?.fieldBackToParent === field.parameters.field) {\n\t\t\t\t\truntimeId = pathBack.parent.entity.id\n\t\t\t\t} else {\n\t\t\t\t\truntimeId = fieldDatum instanceof ServerId ? fieldDatum : new UnpersistedEntityDummyId()\n\t\t\t\t}\n\t\t\t\tthis.initializeFromHasOneRelationMarker(entityRealm, field, runtimeId)\n\t\t\t} else {\n\t\t\t\tassertNever(field)\n\t\t\t}\n\t\t}\n\n\t\tthis.eventManager.registerNewlyInitialized(entityRealm)\n\n\t\treturn entityRealm\n\t}\n\n\tprivate registerEntityRealm(entityRealm: EntityRealmState | EntityRealmStateStub) {\n\t\tconst { realmKey, blueprint, entity } = entityRealm\n\n\t\tthis.treeStore.entityRealmStore.set(entityRealm.realmKey, entityRealm)\n\n\t\tif (blueprint.type === 'listEntity') {\n\t\t\tblueprint.parent.children.set(entity.id.value, entityRealm)\n\t\t} else if (blueprint.type === 'hasOne') {\n\t\t\tblueprint.parent.children.set(blueprint.marker.placeholderName, entityRealm)\n\t\t}\n\t\tentity.realms.set(realmKey, entityRealm)\n\t}\n\n\tpublic initializeEntityState(id: RuntimeId, entityName: EntityName): EntityState {\n\t\tconst entityId = id.uniqueValue\n\n\t\tconst existing = this.treeStore.entityStore.get(entityId)\n\t\tif (existing !== undefined) {\n\t\t\treturn existing\n\t\t}\n\n\t\tconst entityState: EntityState = {\n\t\t\tentityName,\n\t\t\thasIdSetInStone: id instanceof ServerId,\n\t\t\tid,\n\t\t\tisScheduledForDeletion: false,\n\t\t\tmaidenId: id instanceof UnpersistedEntityDummyId ? id : undefined,\n\t\t\trealms: new Map(),\n\t\t}\n\t\tthis.treeStore.entityStore.set(entityId, entityState)\n\n\t\treturn entityState\n\t}\n\n\tprivate initializeEntityListState(\n\t\tblueprint: EntityListBlueprint,\n\t\tentityName: EntityName,\n\t\tinitialEntityIds: Set<EntityId>,\n\t): EntityListState {\n\t\tconst entityListState: EntityListState = {\n\t\t\ttype: 'entityList',\n\t\t\taccessor: undefined,\n\t\t\tblueprint,\n\t\t\tchildren: new BijectiveIndexedMap(realm => realm.entity.id.value),\n\t\t\tchildrenWithPendingUpdates: undefined,\n\t\t\tentityName,\n\t\t\teventListeners: this.initializeEntityListEventListenerStore(blueprint),\n\t\t\tchildEventListeners: this.initializeEntityListChildEventListenerStore(blueprint),\n\t\t\terrors: undefined,\n\t\t\tplannedRemovals: undefined,\n\t\t\tunpersistedChangesCount: 0, // TODO force creation?\n\t\t\tgetAccessor: () => {\n\t\t\t\tif (entityListState.accessor === undefined) {\n\t\t\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(entityListState)\n\t\t\t\t\tentityListState.accessor = new EntityListAccessor(\n\t\t\t\t\t\tentityListState,\n\t\t\t\t\t\tthis.listOperations,\n\t\t\t\t\t\tentityListState.children,\n\t\t\t\t\t\tpersistedEntityIds,\n\t\t\t\t\t\tentityListState.unpersistedChangesCount !== 0,\n\t\t\t\t\t\tentityListState.errors,\n\t\t\t\t\t\tentityListState.blueprint.marker.environment,\n\t\t\t\t\t\tentityListState.getAccessor,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn entityListState.accessor\n\t\t\t},\n\t\t}\n\n\t\tconst initialData: Iterable<EntityId | undefined> =\n\t\t\tinitialEntityIds.size === 0\n\t\t\t\t? Array.from({ length: blueprint.marker.parameters.initialEntityCount })\n\t\t\t\t: initialEntityIds\n\t\tfor (const entityId of initialData) {\n\t\t\tthis.initializeEntityRealm(\n\t\t\t\tentityId ? new ServerId(entityId, entityName) : new UnpersistedEntityDummyId(),\n\t\t\t\tentityListState.entityName,\n\t\t\t\t{\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: entityListState,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\n\t\tthis.eventManager.registerNewlyInitialized(entityListState)\n\n\t\treturn entityListState\n\t}\n\n\tprivate initializeFieldState(\n\t\tparent: EntityRealmState,\n\t\tplaceholderName: FieldName,\n\t\tfieldMarker: FieldMarker,\n\t\tpersistedValue: FieldValue | undefined,\n\t\tcopyFromState: FieldState | undefined,\n\t): FieldState {\n\t\tconst resolvedFieldValue = copyFromState ? copyFromState.value : (persistedValue ?? fieldMarker.defaultValue ?? null)\n\n\t\tconst fieldState: FieldState = {\n\t\t\ttype: 'field',\n\t\t\taccessor: undefined,\n\t\t\tfieldMarker,\n\t\t\tplaceholderName,\n\t\t\tpersistedValue,\n\t\t\tparent,\n\t\t\tvalue: resolvedFieldValue,\n\t\t\teventListeners: this.initializeFieldEventListenerStore(fieldMarker),\n\t\t\terrors: undefined,\n\t\t\ttouchLog: undefined,\n\t\t\thasUnpersistedChanges: copyFromState?.hasUnpersistedChanges ?? false,\n\n\t\t\tgetAccessor: () => {\n\t\t\t\tif (fieldState.accessor === undefined) {\n\t\t\t\t\tconst fieldSchema = this.treeStore.schema.getEntityColumn(parent.entity.entityName, fieldMarker.fieldName)\n\n\t\t\t\t\tfieldState.accessor = new FieldAccessor(\n\t\t\t\t\t\tfieldState,\n\t\t\t\t\t\tthis.fieldOperations,\n\t\t\t\t\t\tfieldState.placeholderName,\n\t\t\t\t\t\tfieldState.value,\n\t\t\t\t\t\tfieldState.persistedValue === undefined ? null : fieldState.persistedValue,\n\t\t\t\t\t\tfieldState.fieldMarker.defaultValue,\n\t\t\t\t\t\tfieldState.errors,\n\t\t\t\t\t\tfieldState.hasUnpersistedChanges,\n\t\t\t\t\t\tfieldState.touchLog,\n\t\t\t\t\t\tfieldState.getAccessor,\n\t\t\t\t\t\tfieldSchema,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn fieldState.accessor\n\t\t\t},\n\t\t}\n\n\t\tthis.eventManager.registerNewlyInitialized(fieldState)\n\t\treturn fieldState\n\t}\n\n\tprivate initializeFromFieldMarker(\n\t\tparent: EntityRealmState,\n\t\tfield: FieldMarker,\n\t\tpersistedValue: EntityFieldPersistedData | undefined,\n\t\tcopyFromState?: FieldState,\n\t) {\n\t\tif (persistedValue instanceof Set) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`Received a collection of referenced entities where a single '${field.fieldName}' field was expected. ` +\n\t\t\t\t\t`Perhaps you wanted to use a <Repeater />?`,\n\t\t\t)\n\t\t}\n\t\tif (persistedValue instanceof ServerId) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`Received a referenced entity where a single '${field.fieldName}' field was expected. ` +\n\t\t\t\t\t`Perhaps you wanted to use <HasOne />?`,\n\t\t\t)\n\t\t}\n\t\tparent.children.set(\n\t\t\tfield.placeholderName,\n\t\t\tthis.initializeFieldState(parent, field.placeholderName, field, persistedValue, copyFromState),\n\t\t)\n\t}\n\n\tprivate initializeFromHasOneRelationMarker(\n\t\tparent: EntityRealmState,\n\t\tfield: HasOneRelationMarker,\n\t\tentityId: RuntimeId,\n\t\tcopyFrom?: EntityRealmState | EntityRealmStateStub,\n\t) {\n\t\tparent.children.set(\n\t\t\tfield.placeholderName,\n\t\t\tthis.initializeEntityRealm(entityId, this.getRelationTargetEntityName(parent, field), {\n\t\t\t\ttype: 'hasOne',\n\t\t\t\tparent,\n\t\t\t\tmarker: field,\n\t\t\t}, copyFrom),\n\t\t)\n\t\t// if (fieldDatum instanceof ServerGeneratedUuid || fieldDatum === null || fieldDatum === undefined) {\n\t\t// \tconst entityId = fieldDatum instanceof ServerGeneratedUuid ? fieldDatum : new UnpersistedEntityDummyId()\n\t\t//\n\t\t//\n\t\t// } else if (fieldDatum instanceof Set) {\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Received a collection of entities for field '${relation.field}' where a single entity was expected. ` +\n\t\t// \t\t\t`Perhaps you wanted to use a <Repeater />?`,\n\t\t// \t)\n\t\t// } else {\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Received a scalar value for field '${relation.field}' where a single entity was expected.` +\n\t\t// \t\t\t`Perhaps you meant to use a variant of <Field />?`,\n\t\t// \t)\n\t\t// }\n\t}\n\n\tprivate initializeFromHasManyRelationMarker(\n\t\tparent: EntityRealmState,\n\t\tfield: HasManyRelationMarker,\n\t\tpersistedEntityIds: Set<EntityId>,\n\t) {\n\t\tparent.children.set(\n\t\t\tfield.placeholderName,\n\t\t\tthis.initializeEntityListState(\n\t\t\t\t{ type: 'hasMany', marker: field, parent },\n\t\t\t\tthis.getRelationTargetEntityName(parent, field),\n\t\t\t\tpersistedEntityIds,\n\t\t\t),\n\t\t)\n\t\t// const relation = field.parameters\n\t\t//\n\t\t// if (fieldDatum === undefined || fieldDatum instanceof Set) {\n\t\t//\n\t\t// } else if (typeof fieldDatum === 'object') {\n\t\t// \t// Intentionally allowing `fieldDatum === null` here as well since this should only happen when a *hasOne\n\t\t// \t// relation is unlinked, e.g. a Person does not have a linked Nationality.\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Received a referenced entity for field '${relation.field}' where a collection of entities was expected.` +\n\t\t// \t\t\t`Perhaps you wanted to use a <HasOne />?`,\n\t\t// \t)\n\t\t// } else {\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Received a scalar value for field '${relation.field}' where a collection of entities was expected.` +\n\t\t// \t\t\t`Perhaps you meant to use a variant of <Field />?`,\n\t\t// \t)\n\t\t// }\n\t}\n\n\tprivate getRelationTargetEntityName(\n\t\tentityRealm: EntityRealmState,\n\t\tfield: HasOneRelationMarker | HasManyRelationMarker,\n\t): EntityName {\n\t\tconst targetField = this.treeStore.schema.getEntityRelation(entityRealm.entity.entityName, field.parameters.field)\n\t\treturn targetField.targetEntity\n\t}\n\n\tpublic runImmediateUserInitialization(\n\t\trealm: EntityRealmState | EntityRealmStateStub,\n\t\tinitialize: EntityAccessor.BatchUpdatesHandler | undefined,\n\t) {\n\t\tif (initialize === undefined) {\n\t\t\treturn\n\t\t}\n\t\tconst entityRealm = this.materializeEntityRealm(realm)\n\n\t\trealm.getAccessor().batchUpdates(initialize)\n\n\t\tconst initializeListeners = this.eventManager.getEventListeners(entityRealm, { type: 'initialize' })\n\t\tif (initializeListeners === undefined || initializeListeners.size === 0) {\n\t\t\trealm.entity.hasIdSetInStone = true\n\t\t}\n\t}\n\n\tpublic initializeEntityEventListenerStore(blueprint: EntityRealmBlueprint): EntityEventListenerStore | undefined {\n\t\tif (blueprint.type === 'listEntity') {\n\t\t\tconst blueprintListeners = blueprint.parent.blueprint.marker.parameters.childEventListeners\n\t\t\tconst childInitialize = blueprintListeners?.get({ type: 'initialize' })\n\t\t\tconst store: EntityEventListenerStore = new EventListenersStore(() => blueprint.parent.childEventListeners)\n\n\t\t\tif (childInitialize !== undefined) {\n\t\t\t\tstore.set({ type: 'initialize' }, childInitialize)\n\t\t\t}\n\t\t\treturn store\n\t\t}\n\n\t\tconst blueprintListeners = blueprint.marker.parameters.eventListeners\n\t\tif (blueprintListeners === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn TreeParameterMerger.cloneSingleEntityEventListeners(blueprintListeners)\n\t}\n\n\tprivate initializeEntityListEventListenerStore(\n\t\tblueprint: EntityListBlueprint,\n\t): EntityListEventListenerStore | undefined {\n\t\tconst blueprintListeners = blueprint.marker.parameters.eventListeners\n\n\t\tif (blueprintListeners === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn TreeParameterMerger.cloneEntityListEventListeners(blueprintListeners)\n\t}\n\n\tprivate initializeEntityListChildEventListenerStore(\n\t\tblueprint: EntityListBlueprint,\n\t): EntityEventListenerStore | undefined {\n\t\tconst blueprintListeners = blueprint.marker.parameters.childEventListeners\n\n\t\tif (blueprintListeners === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn TreeParameterMerger.cloneSingleEntityEventListeners(blueprintListeners)\n\t}\n\n\tprivate initializeFieldEventListenerStore(marker: FieldMarker): FieldEventListenerStore | undefined {\n\t\t// TODO !!!\n\t\treturn undefined\n\t}\n}\n"],"names":["FieldOperations","EntityOperations","ListOperations","EntityListSubTreeMarker","ServerId","UnpersistedEntityDummyId","RealmKeyGenerator","getEntityMarker","FieldMarker","BindingError","HasManyRelationMarker","HasOneRelationMarker","assertNever","entity","EntityAccessor","BijectiveIndexedMap","EntityListAccessor","FieldAccessor","blueprintListeners","EventListenersStore","TreeParameterMerger"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAwCO,MAAM,i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,UAAU,SAAS,cAAc;AACpC,YAAMS,sBAAqB,UAAU,OAAO,UAAU,OAAO,WAAW;AACxE,YAAM,kBAAkBA,qBAAoB,IAAI,EAAE,MAAM,cAAc;AACtE,YAAM,QAAkC,IAAIC,oBAAA,oBAAoB,MAAM,UAAU,OAAO,mBAAmB;AAE1G,UAAI,oBAAoB,QAAW;AAClC,cAAM,IAAI,EAAE,MAAM,gBAAgB,eAAe;AAAA,MAClD;AACO,aAAA;AAAA,IACR;AAEM,UAAA,qBAAqB,UAAU,OAAO,WAAW;AACvD,QAAI,uBAAuB,QAAW;AAC9B,aAAA;AAAA,IACR;AACO,WAAAC,oBAAA,oBAAoB,gCAAgC,kBAAkB;AAAA,EAC9E;AAAA,EAEQ,uCACP,WAC2C;AACrC,UAAA,qBAAqB,UAAU,OAAO,WAAW;AAEvD,QAAI,uBAAuB,QAAW;AAC9B,aAAA;AAAA,IACR;AACO,WAAAA,oBAAA,oBAAoB,8BAA8B,kBAAkB;AAAA,EAC5E;AAAA,EAEQ,4CACP,WACuC;AACjC,UAAA,qBAAqB,UAAU,OAAO,WAAW;AAEvD,QAAI,uBAAuB,QAAW;AAC9B,aAAA;AAAA,IACR;AACO,WAAAA,oBAAA,oBAAoB,gCAAgC,kBAAkB;AAAA,EAC9E;AAAA,EAEQ,kCAAkC,QAA0D;AAE5F,WAAA;AAAA,EACR;AACD;;"}
|
|
1
|
+
{"version":3,"file":"StateInitializer.cjs","sources":["../../../src/core/StateInitializer.ts"],"sourcesContent":["import { BatchUpdatesOptions, EntityAccessor, EntityListAccessor, FieldAccessor } from '../accessors'\nimport { EntityFieldPersistedData, RuntimeId, ServerId, UnpersistedEntityDummyId } from '../accessorTree'\nimport { BindingError } from '../BindingError'\nimport {\n\tEntityListSubTreeMarker,\n\tEntitySubTreeMarker,\n\tFieldMarker,\n\tHasManyRelationMarker,\n\tHasOneRelationMarker,\n} from '../markers'\nimport { BijectiveIndexedMap } from '../structures'\nimport type {\n\tEntityEventListenerStore,\n\tEntityId,\n\tEntityListEventListenerStore,\n\tEntityName,\n\tFieldEventListenerStore,\n\tFieldName,\n\tFieldValue,\n} from '../treeParameters'\nimport { EventListenersStore } from '../treeParameters'\nimport { assertNever } from '../utils'\nimport type { AccessorErrorManager } from './AccessorErrorManager'\nimport type { EventManager } from './EventManager'\nimport { EntityOperations, FieldOperations, ListOperations } from './operations'\nimport { RealmKeyGenerator } from './RealmKeyGenerator'\nimport {\n\tEntityListBlueprint,\n\tEntityListState,\n\tEntityRealmBlueprint,\n\tEntityRealmState,\n\tEntityRealmStateStub,\n\tEntityState,\n\tFieldState,\n\tgetEntityMarker,\n\tRootStateNode,\n} from './state'\nimport { TreeParameterMerger } from './TreeParameterMerger'\nimport type { TreeStore } from './TreeStore'\n\nexport class StateInitializer {\n\tprivate readonly fieldOperations: FieldOperations\n\tprivate readonly entityOperations: EntityOperations\n\tprivate readonly listOperations: ListOperations\n\n\tpublic constructor(\n\t\taccessorErrorManager: AccessorErrorManager,\n\t\tbatchUpdatesOptions: BatchUpdatesOptions,\n\t\tprivate readonly eventManager: EventManager,\n\t\tprivate readonly treeStore: TreeStore,\n\t) {\n\t\tthis.fieldOperations = new FieldOperations(accessorErrorManager, this.eventManager, this, this.treeStore)\n\t\tthis.entityOperations = new EntityOperations(accessorErrorManager, batchUpdatesOptions, this.eventManager, this, this.treeStore)\n\t\tthis.listOperations = new ListOperations(accessorErrorManager, batchUpdatesOptions, this.eventManager, this, this.treeStore)\n\t}\n\n\tpublic initializeSubTree(tree: EntitySubTreeMarker | EntityListSubTreeMarker): RootStateNode {\n\t\tlet subTreeState: RootStateNode\n\t\tconst persistedRootData = this.treeStore.subTreePersistedData.get(tree.placeholderName)\n\n\t\tif (tree instanceof EntityListSubTreeMarker) {\n\t\t\tconst persistedEntityIds: Set<EntityId> = persistedRootData instanceof Set ? persistedRootData : new Set()\n\t\t\tsubTreeState = this.initializeEntityListState(\n\t\t\t\t{ type: 'subTree', marker: tree, parent: undefined },\n\t\t\t\ttree.entityName,\n\t\t\t\tpersistedEntityIds,\n\t\t\t)\n\t\t} else {\n\t\t\tsubTreeState = this.materializeEntityRealm(\n\t\t\t\tthis.initializeEntityRealm(\n\t\t\t\t\tpersistedRootData instanceof ServerId ? persistedRootData : new UnpersistedEntityDummyId(),\n\t\t\t\t\ttree.entityName,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'subTree',\n\t\t\t\t\t\tmarker: tree,\n\t\t\t\t\t\tparent: undefined,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\n\t\treturn subTreeState\n\t}\n\n\tpublic initializeEntityRealm(\n\t\tid: RuntimeId,\n\t\tentityName: EntityName,\n\t\tblueprint: EntityRealmBlueprint,\n\t\tcopyFrom?: EntityRealmState | EntityRealmStateStub,\n\t): EntityRealmState | EntityRealmStateStub {\n\t\t// This is counter-intuitive a bit. The method can also return an EntityRealmState, not just a stub.\n\t\t// The reason is so that each call-site can just default to trying to initialize a stub without having to keep\n\t\t// in mind that the realm might have already been initialized.\n\n\t\tconst entity = this.initializeEntityState(id, entityName)\n\t\tconst realmKey = RealmKeyGenerator.getRealmKey(id, blueprint)\n\n\t\tconst existing = this.treeStore.entityRealmStore.get(realmKey)\n\t\tif (existing !== undefined) {\n\t\t\treturn existing\n\t\t}\n\n\t\tif (!copyFrom || copyFrom.type !== 'entityRealm') {\n\t\t\tconst stub: EntityRealmStateStub = {\n\t\t\t\ttype: 'entityRealmStub',\n\n\t\t\t\tblueprint,\n\t\t\t\tentity,\n\t\t\t\trealmKey,\n\t\t\t\tgetAccessor: () => this.materializeEntityRealm(stub).getAccessor(),\n\t\t\t}\n\t\t\tthis.registerEntityRealm(stub)\n\n\t\t\treturn stub\n\t\t}\n\t\tconst realm = this.createEntityRealm(blueprint, realmKey, entity, copyFrom)\n\n\t\tthis.registerEntityRealm(realm)\n\n\t\tconst marker = getEntityMarker(realm)\n\t\tconst pathBack = this.treeStore.getPathBackToParent(realm)\n\n\t\tfor (const [placeholderName, field] of marker.fields.markers) {\n\t\t\tif (field instanceof FieldMarker) {\n\t\t\t\tconst value = copyFrom.children.get(placeholderName)\n\t\t\t\tif (!value || value.type !== 'field') {\n\t\t\t\t\tthrow new BindingError()\n\t\t\t\t}\n\t\t\t\tthis.initializeFromFieldMarker(realm, field, undefined, value)\n\t\t\t} else if (field instanceof HasManyRelationMarker) {\n\t\t\t\tconst value = copyFrom.children.get(placeholderName)\n\t\t\t\tif (!value || value.type !== 'entityList') {\n\t\t\t\t\tthrow new BindingError()\n\t\t\t\t}\n\t\t\t\tthis.initializeFromHasManyRelationMarker(realm, field, new Set(value.children.keys()))\n\t\t\t} else if (field instanceof HasOneRelationMarker) {\n\t\t\t\tlet runtimeId: RuntimeId\n\t\t\t\tlet subCopyFrom: EntityRealmState | undefined = undefined\n\t\t\t\tif (pathBack?.fieldBackToParent === field.parameters.field) {\n\t\t\t\t\truntimeId = pathBack.parent.entity.id\n\t\t\t\t} else {\n\t\t\t\t\tconst value = copyFrom.children.get(placeholderName)\n\t\t\t\t\tif (!value || (value.type !== 'entityRealm' && value.type !== 'entityRealmStub')) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\truntimeId = !(value.entity.id instanceof UnpersistedEntityDummyId) ? value.entity.id : new UnpersistedEntityDummyId()\n\t\t\t\t\tif (value.type === 'entityRealm') {\n\t\t\t\t\t\tsubCopyFrom = value\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.initializeFromHasOneRelationMarker(realm, field, runtimeId, subCopyFrom)\n\t\t\t} else {\n\t\t\t\tassertNever(field)\n\t\t\t}\n\t\t}\n\n\t\tthis.eventManager.registerNewlyInitialized(realm)\n\t\treturn realm\n\t}\n\n\tprivate createEntityRealm(\n\t\tblueprint: EntityRealmBlueprint,\n\t\trealmKey: string,\n\t\tentity: EntityState,\n\t\tcopyFrom?: EntityRealmState,\n\t): EntityRealmState {\n\t\tconst entityRealm: EntityRealmState = {\n\t\t\ttype: 'entityRealm',\n\n\t\t\tblueprint,\n\t\t\trealmKey,\n\t\t\tentity,\n\n\t\t\taccessor: undefined,\n\t\t\tchildren: new Map(),\n\t\t\tchildrenWithPendingUpdates: undefined,\n\t\t\terrors: undefined,\n\t\t\teventListeners: this.initializeEntityEventListenerStore(blueprint),\n\t\t\tfieldsWithPendingConnectionUpdates: undefined,\n\t\t\tplannedHasOneDeletions: undefined,\n\t\t\tunpersistedChangesCount: copyFrom?.unpersistedChangesCount ?? 0,\n\t\t\tgetAccessor: () => {\n\t\t\t\tif (entityRealm.accessor === undefined) {\n\t\t\t\t\tconst entity = entityRealm.entity\n\t\t\t\t\tentityRealm.accessor = new EntityAccessor(\n\t\t\t\t\t\tentityRealm,\n\t\t\t\t\t\tthis.entityOperations,\n\t\t\t\t\t\tentity.id,\n\t\t\t\t\t\tentityRealm.realmKey,\n\t\t\t\t\t\tentity.entityName,\n\n\t\t\t\t\t\t// We're technically exposing more info in runtime than we'd like but that way we don't have to allocate and\n\t\t\t\t\t\t// keep in sync two copies of the same data. TS hides the extra info anyway.\n\t\t\t\t\t\tentityRealm.children,\n\t\t\t\t\t\tthis.treeStore.persistedEntityData.get(entity.id.uniqueValue),\n\t\t\t\t\t\tentityRealm.unpersistedChangesCount !== 0,\n\t\t\t\t\t\tentityRealm.errors,\n\t\t\t\t\t\tgetEntityMarker(entityRealm).environment,\n\t\t\t\t\t\tentityRealm.getAccessor,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn entityRealm.accessor\n\t\t\t},\n\t\t}\n\t\treturn entityRealm\n\t}\n\n\tprivate materializeEntityRealm(state: EntityRealmState | EntityRealmStateStub): EntityRealmState {\n\t\tif (state.type === 'entityRealm') {\n\t\t\treturn state\n\t\t}\n\t\tconst { realmKey, entity, blueprint } = state\n\n\t\tconst existing = this.treeStore.entityRealmStore.get(realmKey)\n\t\tif (existing !== undefined && existing.type === 'entityRealm') {\n\t\t\treturn existing\n\t\t}\n\n\t\tconst entityRealm = this.createEntityRealm(blueprint, realmKey, entity)\n\n\t\tthis.registerEntityRealm(entityRealm)\n\n\t\t// if (blueprint.creationParameters.forceCreation && !entity.id.existsOnServer) {\n\t\t// \tentityRealm.unpersistedChangesCount += 1\n\t\t// }\n\n\t\tconst persistedData = this.treeStore.persistedEntityData.get(entity.id.uniqueValue)\n\n\t\tconst marker = getEntityMarker(state)\n\t\tconst pathBack = this.treeStore.getPathBackToParent(entityRealm)\n\n\t\tfor (const [placeholderName, field] of marker.fields.markers) {\n\t\t\tconst fieldDatum = persistedData?.get(placeholderName)\n\n\t\t\tif (field instanceof FieldMarker) {\n\t\t\t\tthis.initializeFromFieldMarker(entityRealm, field, fieldDatum)\n\t\t\t} else if (field instanceof HasManyRelationMarker) {\n\t\t\t\t// if (pathBack?.fieldBackToParent === field.parameters.field) {\n\t\t\t\t// \t// TODO this is probably wrong?\n\t\t\t\t// \tconst ids = pathBack.parent.children.get(field.placeholderName)\n\t\t\t\t// \tconst newData = this.treeStore.persistedEntityData.get(pathBack.parent.entity.id.value)\n\t\t\t\t// \tconsole.log('many?', pathBack, field, entityRealm, fieldDatum, ids)\n\t\t\t\t// }\n\t\t\t\tthis.initializeFromHasManyRelationMarker(entityRealm, field, fieldDatum instanceof Set ? fieldDatum : new Set())\n\t\t\t} else if (field instanceof HasOneRelationMarker) {\n\t\t\t\tlet runtimeId: RuntimeId\n\t\t\t\tif (pathBack?.fieldBackToParent === field.parameters.field) {\n\t\t\t\t\truntimeId = pathBack.parent.entity.id\n\t\t\t\t} else {\n\t\t\t\t\truntimeId = fieldDatum instanceof ServerId ? fieldDatum : new UnpersistedEntityDummyId()\n\t\t\t\t}\n\t\t\t\tthis.initializeFromHasOneRelationMarker(entityRealm, field, runtimeId)\n\t\t\t} else {\n\t\t\t\tassertNever(field)\n\t\t\t}\n\t\t}\n\n\t\tthis.eventManager.registerNewlyInitialized(entityRealm)\n\n\t\treturn entityRealm\n\t}\n\n\tprivate registerEntityRealm(entityRealm: EntityRealmState | EntityRealmStateStub) {\n\t\tconst { realmKey, blueprint, entity } = entityRealm\n\n\t\tthis.treeStore.entityRealmStore.set(entityRealm.realmKey, entityRealm)\n\n\t\tif (blueprint.type === 'listEntity') {\n\t\t\tblueprint.parent.children.set(entity.id.value, entityRealm)\n\t\t} else if (blueprint.type === 'hasOne') {\n\t\t\tblueprint.parent.children.set(blueprint.marker.placeholderName, entityRealm)\n\t\t}\n\t\tentity.realms.set(realmKey, entityRealm)\n\t}\n\n\tpublic initializeEntityState(id: RuntimeId, entityName: EntityName): EntityState {\n\t\tconst entityId = id.uniqueValue\n\n\t\tconst existing = this.treeStore.entityStore.get(entityId)\n\t\tif (existing !== undefined) {\n\t\t\treturn existing\n\t\t}\n\n\t\tconst entityState: EntityState = {\n\t\t\tentityName,\n\t\t\thasIdSetInStone: id instanceof ServerId,\n\t\t\tid,\n\t\t\tisScheduledForDeletion: false,\n\t\t\tmaidenId: id instanceof UnpersistedEntityDummyId ? id : undefined,\n\t\t\trealms: new Map(),\n\t\t}\n\t\tthis.treeStore.entityStore.set(entityId, entityState)\n\n\t\treturn entityState\n\t}\n\n\tprivate initializeEntityListState(\n\t\tblueprint: EntityListBlueprint,\n\t\tentityName: EntityName,\n\t\tinitialEntityIds: Set<EntityId>,\n\t): EntityListState {\n\t\tconst entityListState: EntityListState = {\n\t\t\ttype: 'entityList',\n\t\t\taccessor: undefined,\n\t\t\tblueprint,\n\t\t\tchildren: new BijectiveIndexedMap(realm => realm.entity.id.value),\n\t\t\tchildrenWithPendingUpdates: undefined,\n\t\t\tentityName,\n\t\t\teventListeners: this.initializeEntityListEventListenerStore(blueprint),\n\t\t\tchildEventListeners: this.initializeEntityListChildEventListenerStore(blueprint),\n\t\t\terrors: undefined,\n\t\t\tplannedRemovals: undefined,\n\t\t\tunpersistedChangesCount: 0, // TODO force creation?\n\t\t\tgetAccessor: () => {\n\t\t\t\tif (entityListState.accessor === undefined) {\n\t\t\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(entityListState)\n\t\t\t\t\tentityListState.accessor = new EntityListAccessor(\n\t\t\t\t\t\tentityListState,\n\t\t\t\t\t\tthis.listOperations,\n\t\t\t\t\t\tentityListState.entityName,\n\t\t\t\t\t\tentityListState.children,\n\t\t\t\t\t\tpersistedEntityIds,\n\t\t\t\t\t\tentityListState.unpersistedChangesCount !== 0,\n\t\t\t\t\t\tentityListState.errors,\n\t\t\t\t\t\tentityListState.blueprint.marker.environment,\n\t\t\t\t\t\tentityListState.getAccessor,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn entityListState.accessor\n\t\t\t},\n\t\t}\n\n\t\tconst initialData: Iterable<EntityId | undefined> =\n\t\t\tinitialEntityIds.size === 0\n\t\t\t\t? Array.from({ length: blueprint.marker.parameters.initialEntityCount })\n\t\t\t\t: initialEntityIds\n\t\tfor (const entityId of initialData) {\n\t\t\tthis.initializeEntityRealm(\n\t\t\t\tentityId ? new ServerId(entityId, entityName) : new UnpersistedEntityDummyId(),\n\t\t\t\tentityListState.entityName,\n\t\t\t\t{\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: entityListState,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\n\t\tthis.eventManager.registerNewlyInitialized(entityListState)\n\n\t\treturn entityListState\n\t}\n\n\tprivate initializeFieldState(\n\t\tparent: EntityRealmState,\n\t\tplaceholderName: FieldName,\n\t\tfieldMarker: FieldMarker,\n\t\tpersistedValue: FieldValue | undefined,\n\t\tcopyFromState: FieldState | undefined,\n\t): FieldState {\n\t\tconst resolvedFieldValue = copyFromState ? copyFromState.value : (persistedValue ?? fieldMarker.defaultValue ?? null)\n\n\t\tconst fieldState: FieldState = {\n\t\t\ttype: 'field',\n\t\t\taccessor: undefined,\n\t\t\tfieldMarker,\n\t\t\tplaceholderName,\n\t\t\tpersistedValue,\n\t\t\tparent,\n\t\t\tvalue: resolvedFieldValue,\n\t\t\teventListeners: this.initializeFieldEventListenerStore(fieldMarker),\n\t\t\terrors: undefined,\n\t\t\ttouchLog: undefined,\n\t\t\thasUnpersistedChanges: copyFromState?.hasUnpersistedChanges ?? false,\n\n\t\t\tgetAccessor: () => {\n\t\t\t\tif (fieldState.accessor === undefined) {\n\t\t\t\t\tconst fieldSchema = this.treeStore.schema.getEntityColumn(parent.entity.entityName, fieldMarker.fieldName)\n\n\t\t\t\t\tfieldState.accessor = new FieldAccessor(\n\t\t\t\t\t\tfieldState,\n\t\t\t\t\t\tthis.fieldOperations,\n\t\t\t\t\t\tfieldState.placeholderName,\n\t\t\t\t\t\tfieldState.value,\n\t\t\t\t\t\tfieldState.persistedValue === undefined ? null : fieldState.persistedValue,\n\t\t\t\t\t\tfieldState.fieldMarker.defaultValue,\n\t\t\t\t\t\tfieldState.errors,\n\t\t\t\t\t\tfieldState.hasUnpersistedChanges,\n\t\t\t\t\t\tfieldState.touchLog,\n\t\t\t\t\t\tfieldState.getAccessor,\n\t\t\t\t\t\tfieldSchema,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn fieldState.accessor\n\t\t\t},\n\t\t}\n\n\t\tthis.eventManager.registerNewlyInitialized(fieldState)\n\t\treturn fieldState\n\t}\n\n\tprivate initializeFromFieldMarker(\n\t\tparent: EntityRealmState,\n\t\tfield: FieldMarker,\n\t\tpersistedValue: EntityFieldPersistedData | undefined,\n\t\tcopyFromState?: FieldState,\n\t) {\n\t\tif (persistedValue instanceof Set) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`Received a collection of referenced entities where a single '${field.fieldName}' field was expected. ` +\n\t\t\t\t\t`Perhaps you wanted to use a <Repeater />?`,\n\t\t\t)\n\t\t}\n\t\tif (persistedValue instanceof ServerId) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`Received a referenced entity where a single '${field.fieldName}' field was expected. ` +\n\t\t\t\t\t`Perhaps you wanted to use <HasOne />?`,\n\t\t\t)\n\t\t}\n\t\tparent.children.set(\n\t\t\tfield.placeholderName,\n\t\t\tthis.initializeFieldState(parent, field.placeholderName, field, persistedValue, copyFromState),\n\t\t)\n\t}\n\n\tprivate initializeFromHasOneRelationMarker(\n\t\tparent: EntityRealmState,\n\t\tfield: HasOneRelationMarker,\n\t\tentityId: RuntimeId,\n\t\tcopyFrom?: EntityRealmState | EntityRealmStateStub,\n\t) {\n\t\tparent.children.set(\n\t\t\tfield.placeholderName,\n\t\t\tthis.initializeEntityRealm(entityId, this.getRelationTargetEntityName(parent, field), {\n\t\t\t\ttype: 'hasOne',\n\t\t\t\tparent,\n\t\t\t\tmarker: field,\n\t\t\t}, copyFrom),\n\t\t)\n\t\t// if (fieldDatum instanceof ServerGeneratedUuid || fieldDatum === null || fieldDatum === undefined) {\n\t\t// \tconst entityId = fieldDatum instanceof ServerGeneratedUuid ? fieldDatum : new UnpersistedEntityDummyId()\n\t\t//\n\t\t//\n\t\t// } else if (fieldDatum instanceof Set) {\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Received a collection of entities for field '${relation.field}' where a single entity was expected. ` +\n\t\t// \t\t\t`Perhaps you wanted to use a <Repeater />?`,\n\t\t// \t)\n\t\t// } else {\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Received a scalar value for field '${relation.field}' where a single entity was expected.` +\n\t\t// \t\t\t`Perhaps you meant to use a variant of <Field />?`,\n\t\t// \t)\n\t\t// }\n\t}\n\n\tprivate initializeFromHasManyRelationMarker(\n\t\tparent: EntityRealmState,\n\t\tfield: HasManyRelationMarker,\n\t\tpersistedEntityIds: Set<EntityId>,\n\t) {\n\t\tparent.children.set(\n\t\t\tfield.placeholderName,\n\t\t\tthis.initializeEntityListState(\n\t\t\t\t{ type: 'hasMany', marker: field, parent },\n\t\t\t\tthis.getRelationTargetEntityName(parent, field),\n\t\t\t\tpersistedEntityIds,\n\t\t\t),\n\t\t)\n\t\t// const relation = field.parameters\n\t\t//\n\t\t// if (fieldDatum === undefined || fieldDatum instanceof Set) {\n\t\t//\n\t\t// } else if (typeof fieldDatum === 'object') {\n\t\t// \t// Intentionally allowing `fieldDatum === null` here as well since this should only happen when a *hasOne\n\t\t// \t// relation is unlinked, e.g. a Person does not have a linked Nationality.\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Received a referenced entity for field '${relation.field}' where a collection of entities was expected.` +\n\t\t// \t\t\t`Perhaps you wanted to use a <HasOne />?`,\n\t\t// \t)\n\t\t// } else {\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Received a scalar value for field '${relation.field}' where a collection of entities was expected.` +\n\t\t// \t\t\t`Perhaps you meant to use a variant of <Field />?`,\n\t\t// \t)\n\t\t// }\n\t}\n\n\tprivate getRelationTargetEntityName(\n\t\tentityRealm: EntityRealmState,\n\t\tfield: HasOneRelationMarker | HasManyRelationMarker,\n\t): EntityName {\n\t\tconst targetField = this.treeStore.schema.getEntityRelation(entityRealm.entity.entityName, field.parameters.field)\n\t\treturn targetField.targetEntity\n\t}\n\n\tpublic runImmediateUserInitialization(\n\t\trealm: EntityRealmState | EntityRealmStateStub,\n\t\tinitialize: EntityAccessor.BatchUpdatesHandler | undefined,\n\t) {\n\t\tif (initialize === undefined) {\n\t\t\treturn\n\t\t}\n\t\tconst entityRealm = this.materializeEntityRealm(realm)\n\n\t\trealm.getAccessor().batchUpdates(initialize)\n\n\t\tconst initializeListeners = this.eventManager.getEventListeners(entityRealm, { type: 'initialize' })\n\t\tif (initializeListeners === undefined || initializeListeners.size === 0) {\n\t\t\trealm.entity.hasIdSetInStone = true\n\t\t}\n\t}\n\n\tpublic initializeEntityEventListenerStore(blueprint: EntityRealmBlueprint): EntityEventListenerStore | undefined {\n\t\tif (blueprint.type === 'listEntity') {\n\t\t\tconst blueprintListeners = blueprint.parent.blueprint.marker.parameters.childEventListeners\n\t\t\tconst childInitialize = blueprintListeners?.get({ type: 'initialize' })\n\t\t\tconst store: EntityEventListenerStore = new EventListenersStore(() => blueprint.parent.childEventListeners)\n\n\t\t\tif (childInitialize !== undefined) {\n\t\t\t\tstore.set({ type: 'initialize' }, childInitialize)\n\t\t\t}\n\t\t\treturn store\n\t\t}\n\n\t\tconst blueprintListeners = blueprint.marker.parameters.eventListeners\n\t\tif (blueprintListeners === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn TreeParameterMerger.cloneSingleEntityEventListeners(blueprintListeners)\n\t}\n\n\tprivate initializeEntityListEventListenerStore(\n\t\tblueprint: EntityListBlueprint,\n\t): EntityListEventListenerStore | undefined {\n\t\tconst blueprintListeners = blueprint.marker.parameters.eventListeners\n\n\t\tif (blueprintListeners === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn TreeParameterMerger.cloneEntityListEventListeners(blueprintListeners)\n\t}\n\n\tprivate initializeEntityListChildEventListenerStore(\n\t\tblueprint: EntityListBlueprint,\n\t): EntityEventListenerStore | undefined {\n\t\tconst blueprintListeners = blueprint.marker.parameters.childEventListeners\n\n\t\tif (blueprintListeners === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn TreeParameterMerger.cloneSingleEntityEventListeners(blueprintListeners)\n\t}\n\n\tprivate initializeFieldEventListenerStore(marker: FieldMarker): FieldEventListenerStore | undefined {\n\t\t// TODO !!!\n\t\treturn undefined\n\t}\n}\n"],"names":["FieldOperations","EntityOperations","ListOperations","EntityListSubTreeMarker","ServerId","UnpersistedEntityDummyId","RealmKeyGenerator","getEntityMarker","FieldMarker","BindingError","HasManyRelationMarker","HasOneRelationMarker","assertNever","entity","EntityAccessor","BijectiveIndexedMap","EntityListAccessor","FieldAccessor","blueprintListeners","EventListenersStore","TreeParameterMerger"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAwCO,MAAM,iBAAiB;AAAA,EAKtB,YACN,sBACA,qBACiB,cACA,WAChB;AATe;AACA;AACA;AAKC,SAAA,eAAA;AACA,SAAA,YAAA;AAEZ,SAAA,kBAAkB,IAAIA,gBAAAA,gBAAgB,sBAAsB,KAAK,cAAc,MAAM,KAAK,SAAS;AACnG,SAAA,mBAAmB,IAAIC,iBAAiB,iBAAA,sBAAsB,qBAAqB,KAAK,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AAW;AAClC,cAAM,IAAI,EAAE,MAAM,gBAAgB,eAAe;AAAA,MAClD;AACO,aAAA;AAAA,IACR;AAEM,UAAA,qBAAqB,UAAU,OAAO,WAAW;AACvD,QAAI,uBAAuB,QAAW;AAC9B,aAAA;AAAA,IACR;AACO,WAAAC,oBAAA,oBAAoB,gCAAgC,kBAAkB;AAAA,EAC9E;AAAA,EAEQ,uCACP,WAC2C;AACrC,UAAA,qBAAqB,UAAU,OAAO,WAAW;AAEvD,QAAI,uBAAuB,QAAW;AAC9B,aAAA;AAAA,IACR;AACO,WAAAA,oBAAA,oBAAoB,8BAA8B,kBAAkB;AAAA,EAC5E;AAAA,EAEQ,4CACP,WACuC;AACjC,UAAA,qBAAqB,UAAU,OAAO,WAAW;AAEvD,QAAI,uBAAuB,QAAW;AAC9B,aAAA;AAAA,IACR;AACO,WAAAA,oBAAA,oBAAoB,gCAAgC,kBAAkB;AAAA,EAC9E;AAAA,EAEQ,kCAAkC,QAA0D;AAE5F,WAAA;AAAA,EACR;AACD;;"}
|
|
@@ -236,6 +236,7 @@ class StateInitializer {
|
|
|
236
236
|
entityListState.accessor = new EntityListAccessor(
|
|
237
237
|
entityListState,
|
|
238
238
|
this.listOperations,
|
|
239
|
+
entityListState.entityName,
|
|
239
240
|
entityListState.children,
|
|
240
241
|
persistedEntityIds,
|
|
241
242
|
entityListState.unpersistedChangesCount !== 0,
|