@contember/binding 1.3.0-alpha.7 → 1.3.0-alpha.8
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.map +1 -1
- package/dist/development/accessors/EntityAccessor.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 +3 -3
- package/dist/development/core/DataBinding.cjs.map +1 -1
- package/dist/development/core/DataBinding.js +3 -3
- 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.map +1 -1
- 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.map +1 -1
- 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/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.map +1 -1
- package/dist/production/accessors/EntityAccessor.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 +3 -3
- package/dist/production/core/DataBinding.cjs.map +1 -1
- package/dist/production/core/DataBinding.js +3 -3
- 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.map +1 -1
- 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.map +1 -1
- 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/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/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateInitializer.js","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":["entity","blueprintListeners"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAwCO,MAAM,iBAAiB;AAAA,EAKtB,YACN,sBACA,qBACiB,cACA,WAChB;AATe;AACA;AACA;AAKC,SAAA,eAAA;AACA,SAAA,YAAA;AAEZ,SAAA,kBAAkB,IAAI,gBAAgB,sBAAsB,KAAK,cAAc,MAAM,KAAK,SAAS;AACnG,SAAA,mBAAmB,IAAI,iBAAiB,sBAAsB,qBAAqB,KAAK,cAAc,MAAM,KAAK,SAAS;AAC1H,SAAA,iBAAiB,IAAI,eAAe,sBAAsB,qBAAqB,KAAK,cAAc,MAAM,KAAK,SAAS;AAAA,EAC5H;AAAA,EAEO,kBAAkB,MAAoE;AACxF,QAAA;AACJ,UAAM,oBAAoB,KAAK,UAAU,qBAAqB,IAAI,KAAK,eAAe;AAEtF,QAAI,gBAAgB,yBAAyB;AAC5C,YAAM,qBAAoC,6BAA6B,MAAM,wCAAwB,IAAI;AACzG,qBAAe,KAAK;AAAA,QACnB,EAAE,MAAM,WAAW,QAAQ,MAAM,QAAQ,OAAU;AAAA,QACnD,KAAK;AAAA,QACL;AAAA,MAAA;AAAA,IACD,OACM;AACN,qBAAe,KAAK;AAAA,QACnB,KAAK;AAAA,UACJ,6BAA6B,WAAW,oBAAoB,IAAI,yBAAyB;AAAA,UACzF,KAAK;AAAA,UACL;AAAA,YACC,MAAM;AAAA,YACN,QAAQ;AAAA,YACR,QAAQ;AAAA,UACT;AAAA,QACD;AAAA,MA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cAAc;AACnG,QAAI,wBAAwB,UAAa,oBAAoB,SAAS,GAAG;AACxE,YAAM,OAAO,kBAAkB;AAAA,IAChC;AAAA,EACD;AAAA,EAEO,mCAAmC,WAAuE;AAC5G,QAAA,UAAU,SAAS,cAAc;AACpC,YAAMC,sBAAqB,UAAU,OAAO,UAAU,OAAO,WAAW;AACxE,YAAM,kBAAkBA,qBAAoB,IAAI,EAAE,MAAM,cAAc;AACtE,YAAM,QAAkC,IAAI,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,WAAA,oBAAoB,gCAAgC,kBAAkB;AAAA,EAC9E;AAAA,EAEQ,uCACP,WAC2C;AACrC,UAAA,qBAAqB,UAAU,OAAO,WAAW;AAEvD,QAAI,uBAAuB,QAAW;AAC9B,aAAA;AAAA,IACR;AACO,WAAA,oBAAoB,8BAA8B,kBAAkB;AAAA,EAC5E;AAAA,EAEQ,4CACP,WACuC;AACjC,UAAA,qBAAqB,UAAU,OAAO,WAAW;AAEvD,QAAI,uBAAuB,QAAW;AAC9B,aAAA;AAAA,IACR;AACO,WAAA,oBAAoB,gCAAgC,kBAAkB;AAAA,EAC9E;AAAA,EAEQ,kCAAkC,QAA0D;AAE5F,WAAA;AAAA,EACR;AACD;"}
|
|
1
|
+
{"version":3,"file":"StateInitializer.js","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":["entity","blueprintListeners"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAwCO,MAAM,iBAAiB;AAAA,EAKtB,YACN,sBACA,qBACiB,cACA,WAChB;AATe;AACA;AACA;AAKC,SAAA,eAAA;AACA,SAAA,YAAA;AAEZ,SAAA,kBAAkB,IAAI,gBAAgB,sBAAsB,KAAK,cAAc,MAAM,KAAK,SAAS;AACnG,SAAA,mBAAmB,IAAI,iBAAiB,sBAAsB,qBAAqB,KAAK,cAAc,MAAM,KAAK,SAAS;AAC1H,SAAA,iBAAiB,IAAI,eAAe,sBAAsB,qBAAqB,KAAK,cAAc,MAAM,KAAK,SAAS;AAAA,EAC5H;AAAA,EAEO,kBAAkB,MAA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E;AAAA,EAEQ,4CACP,WACuC;AACjC,UAAA,qBAAqB,UAAU,OAAO,WAAW;AAEvD,QAAI,uBAAuB,QAAW;AAC9B,aAAA;AAAA,IACR;AACO,WAAA,oBAAoB,gCAAgC,kBAAkB;AAAA,EAC9E;AAAA,EAEQ,kCAAkC,QAA0D;AAE5F,WAAA;AAAA,EACR;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeParameterMerger.cjs","sources":["../../../src/core/TreeParameterMerger.ts"],"sourcesContent":["import { GraphQlBuilder, Writable } from '@contember/client'\nimport { BindingError } from '../BindingError'\nimport type {\n\tAlias,\n\tEntityCreationParameters,\n\tEntityEventListenerStore,\n\tEntityListEventListenerStore,\n\tExpectedQualifiedEntityMutation,\n\tExpectedRelationMutation,\n\tHasManyRelation,\n\tHasOneRelation,\n\tParentEntityParameters,\n\tQualifiedEntityList,\n\tQualifiedSingleEntity,\n\tSetOnCreate,\n\tUnconstrainedQualifiedEntityList,\n\tUnconstrainedQualifiedSingleEntity,\n\tUniqueWhere,\n} from '../treeParameters'\n\nexport class TreeParameterMerger {\n\tpublic static mergeHasOneRelationsWithSamePlaceholders(\n\t\toriginal: HasOneRelation,\n\t\tfresh: HasOneRelation,\n\t): HasOneRelation {\n\t\treturn {\n\t\t\t// Encoded within the placeholder\n\t\t\tfield: original.field,\n\t\t\tfilter: original.filter,\n\t\t\treducedBy: original.reducedBy,\n\n\t\t\t// Not encoded within the placeholder\n\t\t\texpectedMutation: this.mergeExpectedRelationMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\t// forceCreation: original.forceCreation || fresh.forceCreation,\n\t\t\teventListeners: this.mergeSingleEntityEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t}\n\t}\n\n\tpublic static mergeHasManyRelationsWithSamePlaceholders(\n\t\toriginal: HasManyRelation,\n\t\tfresh: HasManyRelation,\n\t): HasManyRelation {\n\t\tif (original.initialEntityCount !== fresh.initialEntityCount) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`Detected hasMany relations on the same field '${original.field}' with different preferred initial ` +\n\t\t\t\t\t`entity counts: '${original.initialEntityCount}' and '${fresh.initialEntityCount}' respectively.`,\n\t\t\t)\n\t\t}\n\t\treturn {\n\t\t\t// Encoded within the placeholder\n\t\t\tfield: original.field,\n\t\t\tfilter: original.filter,\n\t\t\torderBy: original.orderBy,\n\t\t\toffset: original.offset,\n\t\t\tlimit: original.limit,\n\n\t\t\t// Not encoded within the placeholder\n\t\t\texpectedMutation: this.mergeExpectedRelationMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\t// forceCreation: original.forceCreation || fresh.forceCreation,\n\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\tinitialEntityCount: original.initialEntityCount, // Handled above\n\t\t\tchildEventListeners: this.mergeSingleEntityEventListeners(\n\t\t\t\toriginal.childEventListeners,\n\t\t\t\tfresh.childEventListeners,\n\t\t\t),\n\t\t\teventListeners: this.mergeEntityListEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t}\n\t}\n\n\tpublic static mergeEntitySubTreeParametersWithSamePlaceholders(\n\t\toriginal: QualifiedSingleEntity | UnconstrainedQualifiedSingleEntity,\n\t\tfresh: QualifiedSingleEntity | UnconstrainedQualifiedSingleEntity,\n\t): QualifiedSingleEntity | UnconstrainedQualifiedSingleEntity {\n\t\tif (original.isCreating) {\n\t\t\tif (!fresh.isCreating) {\n\t\t\t\tthrow new BindingError()\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t// Encoded within the placeholder\n\t\t\t\tisCreating: original.isCreating,\n\t\t\t\tisUnpersisted: original.isUnpersisted && fresh.isUnpersisted,\n\t\t\t\tentityName: original.entityName,\n\n\t\t\t\t// Not encoded within the placeholder\n\t\t\t\talias: this.mergeSubTreeAliases(original.alias, fresh.alias),\n\t\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\t\t// forceCreation: original.value.forceCreation || fresh.value.forceCreation,\n\t\t\t\texpectedMutation: this.mergeExpectedQualifiedEntityMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\t\thasOneRelationPath: original.hasOneRelationPath, // TODO this is completely wrong.\n\t\t\t\teventListeners: this.mergeSingleEntityEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t// Encoded within the placeholder\n\t\t\tisCreating: original.isCreating,\n\t\t\twhere: original.where,\n\t\t\tentityName: original.entityName,\n\t\t\tfilter: original.filter,\n\n\t\t\t// Not encoded within the placeholder\n\t\t\talias: this.mergeSubTreeAliases(original.alias, fresh.alias),\n\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\t// forceCreation: original.value.forceCreation || fresh.value.forceCreation,\n\t\t\texpectedMutation: this.mergeExpectedQualifiedEntityMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\thasOneRelationPath: original.hasOneRelationPath, // TODO this is completely wrong.\n\t\t\teventListeners: this.mergeSingleEntityEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t}\n\t}\n\n\tpublic static mergeEntityListSubTreeParametersWithSamePlaceholders(\n\t\toriginal: QualifiedEntityList | UnconstrainedQualifiedEntityList,\n\t\tfresh: QualifiedEntityList | UnconstrainedQualifiedEntityList,\n\t): QualifiedEntityList | UnconstrainedQualifiedEntityList {\n\t\tif (original.initialEntityCount !== fresh.initialEntityCount) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`Detected sub trees of the same entity '${original.entityName}' with different preferred initial ` +\n\t\t\t\t\t`entity counts: '${original.initialEntityCount}' and '${fresh.initialEntityCount}' respectively.`,\n\t\t\t)\n\t\t}\n\n\t\tif (original.isCreating) {\n\t\t\tif (!fresh.isCreating) {\n\t\t\t\tthrow new BindingError()\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t// Encoded within the placeholder\n\t\t\t\tisCreating: original.isCreating,\n\t\t\t\tisUnpersisted: original.isUnpersisted && fresh.isUnpersisted,\n\t\t\t\tentityName: original.entityName,\n\n\t\t\t\t// Not encoded within the placeholder\n\t\t\t\talias: this.mergeSubTreeAliases(original.alias, fresh.alias),\n\t\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\t\t// forceCreation: original.value.forceCreation || fresh.value.forceCreation,\n\t\t\t\texpectedMutation: this.mergeExpectedQualifiedEntityMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\t\thasOneRelationPath: original.hasOneRelationPath, // TODO this is completely wrong.\n\t\t\t\tchildEventListeners: this.mergeSingleEntityEventListeners(\n\t\t\t\t\toriginal.childEventListeners,\n\t\t\t\t\tfresh.childEventListeners,\n\t\t\t\t),\n\t\t\t\teventListeners: this.mergeEntityListEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t\t\tinitialEntityCount: original.initialEntityCount, // Handled above\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t// Encoded within the placeholder\n\t\t\tisCreating: original.isCreating,\n\t\t\tentityName: original.entityName,\n\t\t\tfilter: original.filter,\n\t\t\torderBy: original.orderBy,\n\t\t\toffset: original.offset,\n\t\t\tlimit: original.limit,\n\n\t\t\t// Not encoded within the placeholder\n\t\t\talias: this.mergeSubTreeAliases(original.alias, fresh.alias),\n\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\t// forceCreation: original.value.forceCreation || fresh.value.forceCreation,\n\t\t\texpectedMutation: this.mergeExpectedQualifiedEntityMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\thasOneRelationPath: original.hasOneRelationPath, // TODO this is completely wrong.\n\t\t\tchildEventListeners: this.mergeSingleEntityEventListeners(\n\t\t\t\toriginal.childEventListeners,\n\t\t\t\tfresh.childEventListeners,\n\t\t\t),\n\t\t\teventListeners: this.mergeEntityListEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t\tinitialEntityCount: original.initialEntityCount, // Handled above\n\t\t}\n\t}\n\n\tpublic static mergeEntityCreationParameters(\n\t\toriginal: EntityCreationParameters,\n\t\tfresh: EntityCreationParameters,\n\t): EntityCreationParameters {\n\t\treturn {\n\t\t\t// forceCreation: original.forceCreation || fresh.forceCreation,\n\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t}\n\t}\n\n\tpublic static mergeSetOnCreate(original: SetOnCreate, fresh: SetOnCreate): SetOnCreate {\n\t\tif (original === undefined && fresh === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (original === undefined) {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === undefined) {\n\t\t\treturn original\n\t\t}\n\t\tconst originalCopy: Writable<UniqueWhere> = { ...original }\n\n\t\tfor (const field in fresh) {\n\t\t\tif (field in originalCopy) {\n\t\t\t\tconst fromOriginal = originalCopy[field]\n\t\t\t\tconst fromFresh = fresh[field]\n\n\t\t\t\tif (fromOriginal instanceof GraphQlBuilder.GraphQlLiteral) {\n\t\t\t\t\tif (fromFresh instanceof GraphQlBuilder.GraphQlLiteral) {\n\t\t\t\t\t\tif (fromOriginal.value === fromFresh.value) {\n\t\t\t\t\t\t\t// Good, do nothing.\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeof fromOriginal === 'object') {\n\t\t\t\t\tif (fromFresh instanceof GraphQlBuilder.GraphQlLiteral) {\n\t\t\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t\t\t} else if (typeof fromFresh === 'object') {\n\t\t\t\t\t\tconst merged = this.mergeSetOnCreate(fromOriginal, fromFresh)\n\t\t\t\t\t\tif (merged !== undefined) {\n\t\t\t\t\t\t\toriginalCopy[field] = merged\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeof fromFresh === 'string' || typeof fromFresh === 'number') {\n\t\t\t\t\tif (fromOriginal === fromFresh) {\n\t\t\t\t\t\t// Good, do nothing.\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t} else {\n\t\t\t\toriginalCopy[field] = fresh[field]\n\t\t\t}\n\t\t}\n\n\t\treturn originalCopy\n\t}\n\n\tprivate static mergeSets<T>(original: Set<T>, fresh: Set<T>): Set<T> {\n\t\tconst combinedSet = new Set(original)\n\t\tfor (const item of fresh) {\n\t\t\tcombinedSet.add(item)\n\t\t}\n\t\treturn combinedSet\n\t}\n\n\tpublic static mergeParentEntityParameters(\n\t\toriginal: ParentEntityParameters | undefined,\n\t\tfresh: ParentEntityParameters | undefined,\n\t): ParentEntityParameters | undefined {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tif (original === undefined) {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === undefined) {\n\t\t\treturn original\n\t\t}\n\t\treturn {\n\t\t\teventListeners: TreeParameterMerger.mergeSingleEntityEventListeners(\n\t\t\t\toriginal.eventListeners,\n\t\t\t\tfresh.eventListeners,\n\t\t\t),\n\t\t}\n\t}\n\n\tpublic static mergeInParentEntity<\n\t\tOriginal extends Record<Key, EntityEventListenerStore | undefined>,\n\t\tKey extends keyof Original,\n\t>(original: Original, key: Key, parentEntity: ParentEntityParameters | undefined): Original {\n\t\tif (!parentEntity) {\n\t\t\treturn original\n\t\t}\n\n\t\treturn {\n\t\t\t...original,\n\t\t\t[key]: TreeParameterMerger.mergeSingleEntityEventListeners(original[key], parentEntity.eventListeners),\n\t\t}\n\t}\n\n\tpublic static mergeSingleEntityEventListeners(\n\t\toriginal: EntityEventListenerStore | undefined,\n\t\tfresh: EntityEventListenerStore | undefined,\n\t): EntityEventListenerStore | undefined {\n\t\tif (original === undefined) {\n\t\t\tif (fresh === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\treturn this.cloneSingleEntityEventListeners(fresh)\n\t\t}\n\n\t\tif (fresh === undefined) {\n\t\t\treturn this.cloneSingleEntityEventListeners(original)\n\t\t}\n\n\t\tconst store = this.cloneSingleEntityEventListeners(original)\n\t\tstore.append(fresh)\n\t\treturn store\n\t}\n\n\tpublic static mergeEntityListEventListeners(\n\t\toriginal: EntityListEventListenerStore | undefined,\n\t\tfresh: EntityListEventListenerStore | undefined,\n\t): EntityListEventListenerStore | undefined {\n\t\tif (original === undefined) {\n\t\t\tif (fresh === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\treturn this.cloneEntityListEventListeners(fresh)\n\t\t}\n\n\t\tif (fresh === undefined) {\n\t\t\treturn this.cloneEntityListEventListeners(original)\n\t\t}\n\n\t\tconst store = this.cloneEntityListEventListeners(original)\n\t\tstore.append(fresh)\n\t\treturn store\n\t}\n\n\tpublic static cloneSingleEntityEventListeners(store: EntityEventListenerStore): EntityEventListenerStore {\n\t\t// TODO is intentional, that second clone is deep?\n\t\treturn store.clone()\n\t}\n\n\tpublic static cloneEntityListEventListeners(store: EntityListEventListenerStore): EntityListEventListenerStore {\n\t\treturn store.cloneDeep()\n\t}\n\n\tprivate static mergeExpectedRelationMutation(\n\t\toriginal: ExpectedRelationMutation,\n\t\tfresh: ExpectedRelationMutation,\n\t): ExpectedRelationMutation {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tif (original === 'none') {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === 'none') {\n\t\t\treturn original\n\t\t}\n\t\treturn 'anyMutation'\n\t}\n\n\tprivate static mergeExpectedQualifiedEntityMutation(\n\t\toriginal: ExpectedQualifiedEntityMutation,\n\t\tfresh: ExpectedQualifiedEntityMutation,\n\t): ExpectedQualifiedEntityMutation {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tif (original === 'none') {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === 'none') {\n\t\t\treturn original\n\t\t}\n\t\treturn 'anyMutation'\n\t}\n\n\tprivate static mergeSubTreeAliases(\n\t\toriginal: Set<Alias> | undefined,\n\t\tfresh: Set<Alias> | undefined,\n\t): Set<Alias> | undefined {\n\t\tif (original === undefined) {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === undefined) {\n\t\t\treturn original\n\t\t}\n\t\treturn this.mergeSets(original, fresh)\n\t}\n}\n"],"names":["BindingError","GraphQlBuilder"],"mappings":";;;;AAoBO,MAAM,oBAAoB;AAAA,EAChC,OAAc,yCACb,UACA,OACiB;AACV,WAAA;AAAA;AAAA,MAEN,OAAO,SAAS;AAAA,MAChB,QAAQ,SAAS;AAAA,MACjB,WAAW,SAAS;AAAA;AAAA,MAGpB,kBAAkB,KAAK,8BAA8B,SAAS,kBAAkB,MAAM,gBAAgB;AAAA,MACtG,aAAa,KAAK,iBAAiB,SAAS,aAAa,MAAM,WAAW;AAAA,MAC1E,cAAc,SAAS,gBAAgB,MAAM;AAAA;AAAA,MAE7C,gBAAgB,KAAK,gCAAgC,SAAS,gBAAgB,MAAM,cAAc;AAAA,IAAA;AAAA,EAEpG;A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R;AAAA,EAEA,OAAe,qCACd,UACA,OACkC;AAClC,QAAI,aAAa,OAAO;AAChB,aAAA;AAAA,IACR;AACA,QAAI,aAAa,QAAQ;AACjB,aAAA;AAAA,IACR;AACA,QAAI,UAAU,QAAQ;AACd,aAAA;AAAA,IACR;AACO,WAAA;AAAA,EACR;AAAA,EAEA,OAAe,oBACd,UACA,OACyB;AACzB,QAAI,aAAa,QAAW;AACpB,aAAA;AAAA,IACR;AACA,QAAI,UAAU,QAAW;AACjB,aAAA;AAAA,IACR;AACO,WAAA,KAAK,UAAU,UAAU,KAAK;AAAA,EACtC;AACD;;"}
|
|
1
|
+
{"version":3,"file":"TreeParameterMerger.cjs","sources":["../../../src/core/TreeParameterMerger.ts"],"sourcesContent":["import { GraphQlBuilder, Writable } from '@contember/client'\nimport { BindingError } from '../BindingError'\nimport type {\n\tAlias,\n\tEntityCreationParameters,\n\tEntityEventListenerStore,\n\tEntityListEventListenerStore,\n\tExpectedQualifiedEntityMutation,\n\tExpectedRelationMutation,\n\tHasManyRelation,\n\tHasOneRelation,\n\tParentEntityParameters,\n\tQualifiedEntityList,\n\tQualifiedSingleEntity,\n\tSetOnCreate,\n\tUnconstrainedQualifiedEntityList,\n\tUnconstrainedQualifiedSingleEntity,\n\tUniqueWhere,\n} from '../treeParameters'\n\nexport class TreeParameterMerger {\n\tpublic static mergeHasOneRelationsWithSamePlaceholders(\n\t\toriginal: HasOneRelation,\n\t\tfresh: HasOneRelation,\n\t): HasOneRelation {\n\t\treturn {\n\t\t\t// Encoded within the placeholder\n\t\t\tfield: original.field,\n\t\t\tfilter: original.filter,\n\t\t\treducedBy: original.reducedBy,\n\n\t\t\t// Not encoded within the placeholder\n\t\t\texpectedMutation: this.mergeExpectedRelationMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\t// forceCreation: original.forceCreation || fresh.forceCreation,\n\t\t\teventListeners: this.mergeSingleEntityEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t}\n\t}\n\n\tpublic static mergeHasManyRelationsWithSamePlaceholders(\n\t\toriginal: HasManyRelation,\n\t\tfresh: HasManyRelation,\n\t): HasManyRelation {\n\t\tif (original.initialEntityCount !== fresh.initialEntityCount) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`Detected hasMany relations on the same field '${original.field}' with different preferred initial ` +\n\t\t\t\t\t`entity counts: '${original.initialEntityCount}' and '${fresh.initialEntityCount}' respectively.`,\n\t\t\t)\n\t\t}\n\t\treturn {\n\t\t\t// Encoded within the placeholder\n\t\t\tfield: original.field,\n\t\t\tfilter: original.filter,\n\t\t\torderBy: original.orderBy,\n\t\t\toffset: original.offset,\n\t\t\tlimit: original.limit,\n\n\t\t\t// Not encoded within the placeholder\n\t\t\texpectedMutation: this.mergeExpectedRelationMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\t// forceCreation: original.forceCreation || fresh.forceCreation,\n\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\tinitialEntityCount: original.initialEntityCount, // Handled above\n\t\t\tchildEventListeners: this.mergeSingleEntityEventListeners(\n\t\t\t\toriginal.childEventListeners,\n\t\t\t\tfresh.childEventListeners,\n\t\t\t),\n\t\t\teventListeners: this.mergeEntityListEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t}\n\t}\n\n\tpublic static mergeEntitySubTreeParametersWithSamePlaceholders(\n\t\toriginal: QualifiedSingleEntity | UnconstrainedQualifiedSingleEntity,\n\t\tfresh: QualifiedSingleEntity | UnconstrainedQualifiedSingleEntity,\n\t): QualifiedSingleEntity | UnconstrainedQualifiedSingleEntity {\n\t\tif (original.isCreating) {\n\t\t\tif (!fresh.isCreating) {\n\t\t\t\tthrow new BindingError()\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t// Encoded within the placeholder\n\t\t\t\tisCreating: original.isCreating,\n\t\t\t\tisUnpersisted: original.isUnpersisted && fresh.isUnpersisted,\n\t\t\t\tentityName: original.entityName,\n\n\t\t\t\t// Not encoded within the placeholder\n\t\t\t\talias: this.mergeSubTreeAliases(original.alias, fresh.alias),\n\t\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\t\t// forceCreation: original.value.forceCreation || fresh.value.forceCreation,\n\t\t\t\texpectedMutation: this.mergeExpectedQualifiedEntityMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\t\thasOneRelationPath: original.hasOneRelationPath, // TODO this is completely wrong.\n\t\t\t\teventListeners: this.mergeSingleEntityEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t// Encoded within the placeholder\n\t\t\tisCreating: original.isCreating,\n\t\t\twhere: original.where,\n\t\t\tentityName: original.entityName,\n\t\t\tfilter: original.filter,\n\n\t\t\t// Not encoded within the placeholder\n\t\t\talias: this.mergeSubTreeAliases(original.alias, fresh.alias),\n\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\t// forceCreation: original.value.forceCreation || fresh.value.forceCreation,\n\t\t\texpectedMutation: this.mergeExpectedQualifiedEntityMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\thasOneRelationPath: original.hasOneRelationPath, // TODO this is completely wrong.\n\t\t\teventListeners: this.mergeSingleEntityEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t}\n\t}\n\n\tpublic static mergeEntityListSubTreeParametersWithSamePlaceholders(\n\t\toriginal: QualifiedEntityList | UnconstrainedQualifiedEntityList,\n\t\tfresh: QualifiedEntityList | UnconstrainedQualifiedEntityList,\n\t): QualifiedEntityList | UnconstrainedQualifiedEntityList {\n\t\tif (original.initialEntityCount !== fresh.initialEntityCount) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`Detected sub trees of the same entity '${original.entityName}' with different preferred initial ` +\n\t\t\t\t\t`entity counts: '${original.initialEntityCount}' and '${fresh.initialEntityCount}' respectively.`,\n\t\t\t)\n\t\t}\n\n\t\tif (original.isCreating) {\n\t\t\tif (!fresh.isCreating) {\n\t\t\t\tthrow new BindingError()\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t// Encoded within the placeholder\n\t\t\t\tisCreating: original.isCreating,\n\t\t\t\tisUnpersisted: original.isUnpersisted && fresh.isUnpersisted,\n\t\t\t\tentityName: original.entityName,\n\n\t\t\t\t// Not encoded within the placeholder\n\t\t\t\talias: this.mergeSubTreeAliases(original.alias, fresh.alias),\n\t\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\t\t// forceCreation: original.value.forceCreation || fresh.value.forceCreation,\n\t\t\t\texpectedMutation: this.mergeExpectedQualifiedEntityMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\t\thasOneRelationPath: original.hasOneRelationPath, // TODO this is completely wrong.\n\t\t\t\tchildEventListeners: this.mergeSingleEntityEventListeners(\n\t\t\t\t\toriginal.childEventListeners,\n\t\t\t\t\tfresh.childEventListeners,\n\t\t\t\t),\n\t\t\t\teventListeners: this.mergeEntityListEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t\t\tinitialEntityCount: original.initialEntityCount, // Handled above\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t// Encoded within the placeholder\n\t\t\tisCreating: original.isCreating,\n\t\t\tentityName: original.entityName,\n\t\t\tfilter: original.filter,\n\t\t\torderBy: original.orderBy,\n\t\t\toffset: original.offset,\n\t\t\tlimit: original.limit,\n\n\t\t\t// Not encoded within the placeholder\n\t\t\talias: this.mergeSubTreeAliases(original.alias, fresh.alias),\n\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\t// forceCreation: original.value.forceCreation || fresh.value.forceCreation,\n\t\t\texpectedMutation: this.mergeExpectedQualifiedEntityMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\thasOneRelationPath: original.hasOneRelationPath, // TODO this is completely wrong.\n\t\t\tchildEventListeners: this.mergeSingleEntityEventListeners(\n\t\t\t\toriginal.childEventListeners,\n\t\t\t\tfresh.childEventListeners,\n\t\t\t),\n\t\t\teventListeners: this.mergeEntityListEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t\tinitialEntityCount: original.initialEntityCount, // Handled above\n\t\t}\n\t}\n\n\tpublic static mergeEntityCreationParameters(\n\t\toriginal: EntityCreationParameters,\n\t\tfresh: EntityCreationParameters,\n\t): EntityCreationParameters {\n\t\treturn {\n\t\t\t// forceCreation: original.forceCreation || fresh.forceCreation,\n\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t}\n\t}\n\n\tpublic static mergeSetOnCreate(original: SetOnCreate, fresh: SetOnCreate): SetOnCreate {\n\t\tif (original === undefined && fresh === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (original === undefined) {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === undefined) {\n\t\t\treturn original\n\t\t}\n\t\tconst originalCopy: Writable<UniqueWhere> = { ...original }\n\n\t\tfor (const field in fresh) {\n\t\t\tif (field in originalCopy) {\n\t\t\t\tconst fromOriginal = originalCopy[field]\n\t\t\t\tconst fromFresh = fresh[field]\n\n\t\t\t\tif (fromOriginal instanceof GraphQlBuilder.GraphQlLiteral) {\n\t\t\t\t\tif (fromFresh instanceof GraphQlBuilder.GraphQlLiteral) {\n\t\t\t\t\t\tif (fromOriginal.value === fromFresh.value) {\n\t\t\t\t\t\t\t// Good, do nothing.\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeof fromOriginal === 'object') {\n\t\t\t\t\tif (fromFresh instanceof GraphQlBuilder.GraphQlLiteral) {\n\t\t\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t\t\t} else if (typeof fromFresh === 'object') {\n\t\t\t\t\t\tconst merged = this.mergeSetOnCreate(fromOriginal, fromFresh)\n\t\t\t\t\t\tif (merged !== undefined) {\n\t\t\t\t\t\t\toriginalCopy[field] = merged\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeof fromFresh === 'string' || typeof fromFresh === 'number') {\n\t\t\t\t\tif (fromOriginal === fromFresh) {\n\t\t\t\t\t\t// Good, do nothing.\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t} else {\n\t\t\t\toriginalCopy[field] = fresh[field]\n\t\t\t}\n\t\t}\n\n\t\treturn originalCopy\n\t}\n\n\tprivate static mergeSets<T>(original: Set<T>, fresh: Set<T>): Set<T> {\n\t\tconst combinedSet = new Set(original)\n\t\tfor (const item of fresh) {\n\t\t\tcombinedSet.add(item)\n\t\t}\n\t\treturn combinedSet\n\t}\n\n\tpublic static mergeParentEntityParameters(\n\t\toriginal: ParentEntityParameters | undefined,\n\t\tfresh: ParentEntityParameters | undefined,\n\t): ParentEntityParameters | undefined {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tif (original === undefined) {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === undefined) {\n\t\t\treturn original\n\t\t}\n\t\treturn {\n\t\t\teventListeners: TreeParameterMerger.mergeSingleEntityEventListeners(\n\t\t\t\toriginal.eventListeners,\n\t\t\t\tfresh.eventListeners,\n\t\t\t),\n\t\t}\n\t}\n\n\tpublic static mergeInParentEntity<\n\t\tOriginal extends Record<Key, EntityEventListenerStore | undefined>,\n\t\tKey extends keyof Original,\n\t>(original: Original, key: Key, parentEntity: ParentEntityParameters | undefined): Original {\n\t\tif (!parentEntity) {\n\t\t\treturn original\n\t\t}\n\n\t\treturn {\n\t\t\t...original,\n\t\t\t[key]: TreeParameterMerger.mergeSingleEntityEventListeners(original[key], parentEntity.eventListeners),\n\t\t}\n\t}\n\n\tpublic static mergeSingleEntityEventListeners(\n\t\toriginal: EntityEventListenerStore | undefined,\n\t\tfresh: EntityEventListenerStore | undefined,\n\t): EntityEventListenerStore | undefined {\n\t\tif (original === undefined) {\n\t\t\tif (fresh === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\treturn this.cloneSingleEntityEventListeners(fresh)\n\t\t}\n\n\t\tif (fresh === undefined) {\n\t\t\treturn this.cloneSingleEntityEventListeners(original)\n\t\t}\n\n\t\tconst store = this.cloneSingleEntityEventListeners(original)\n\t\tstore.append(fresh)\n\t\treturn store\n\t}\n\n\tpublic static mergeEntityListEventListeners(\n\t\toriginal: EntityListEventListenerStore | undefined,\n\t\tfresh: EntityListEventListenerStore | undefined,\n\t): EntityListEventListenerStore | undefined {\n\t\tif (original === undefined) {\n\t\t\tif (fresh === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\treturn this.cloneEntityListEventListeners(fresh)\n\t\t}\n\n\t\tif (fresh === undefined) {\n\t\t\treturn this.cloneEntityListEventListeners(original)\n\t\t}\n\n\t\tconst store = this.cloneEntityListEventListeners(original)\n\t\tstore.append(fresh)\n\t\treturn store\n\t}\n\n\tpublic static cloneSingleEntityEventListeners(store: EntityEventListenerStore): EntityEventListenerStore {\n\t\t// TODO is intentional, that second clone is deep?\n\t\treturn store.clone()\n\t}\n\n\tpublic static cloneEntityListEventListeners(store: EntityListEventListenerStore): EntityListEventListenerStore {\n\t\treturn store.cloneDeep()\n\t}\n\n\tprivate static mergeExpectedRelationMutation(\n\t\toriginal: ExpectedRelationMutation,\n\t\tfresh: ExpectedRelationMutation,\n\t): ExpectedRelationMutation {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tif (original === 'none') {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === 'none') {\n\t\t\treturn original\n\t\t}\n\t\treturn 'anyMutation'\n\t}\n\n\tprivate static mergeExpectedQualifiedEntityMutation(\n\t\toriginal: ExpectedQualifiedEntityMutation,\n\t\tfresh: ExpectedQualifiedEntityMutation,\n\t): ExpectedQualifiedEntityMutation {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tif (original === 'none') {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === 'none') {\n\t\t\treturn original\n\t\t}\n\t\treturn 'anyMutation'\n\t}\n\n\tprivate static mergeSubTreeAliases(\n\t\toriginal: Set<Alias> | undefined,\n\t\tfresh: Set<Alias> | undefined,\n\t): Set<Alias> | undefined {\n\t\tif (original === undefined) {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === undefined) {\n\t\t\treturn original\n\t\t}\n\t\treturn this.mergeSets(original, fresh)\n\t}\n}\n"],"names":["BindingError","GraphQlBuilder"],"mappings":";;;;AAoBO,MAAM,oBAAoB;AAAA,EAChC,OAAc,yCACb,UACA,OACiB;AACV,WAAA;AAAA;AAAA,MAEN,OAAO,SAAS;AAAA,MAChB,QAAQ,SAAS;AAAA,MACjB,WAAW,SAAS;AAAA;AAAA,MAGpB,kBAAkB,KAAK,8BAA8B,SAAS,kBAAkB,MAAM,gBAAgB;AAAA,MACtG,aAAa,KAAK,iBAAiB,SAAS,aAAa,MAAM,WAAW;AA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,UACA,OAC2B;AAC3B,QAAI,aAAa,OAAO;AAChB,aAAA;AAAA,IACR;AACA,QAAI,aAAa,QAAQ;AACjB,aAAA;AAAA,IACR;AACA,QAAI,UAAU,QAAQ;AACd,aAAA;AAAA,IACR;AACO,WAAA;AAAA,EACR;AAAA,EAEA,OAAe,qCACd,UACA,OACkC;AAClC,QAAI,aAAa,OAAO;AAChB,aAAA;AAAA,IACR;AACA,QAAI,aAAa,QAAQ;AACjB,aAAA;AAAA,IACR;AACA,QAAI,UAAU,QAAQ;AACd,aAAA;AAAA,IACR;AACO,WAAA;AAAA,EACR;AAAA,EAEA,OAAe,oBACd,UACA,OACyB;AACzB,QAAI,aAAa,QAAW;AACpB,aAAA;AAAA,IACR;AACA,QAAI,UAAU,QAAW;AACjB,aAAA;AAAA,IACR;AACO,WAAA,KAAK,UAAU,UAAU,KAAK;AAAA,EACtC;AACD;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeParameterMerger.js","sources":["../../../src/core/TreeParameterMerger.ts"],"sourcesContent":["import { GraphQlBuilder, Writable } from '@contember/client'\nimport { BindingError } from '../BindingError'\nimport type {\n\tAlias,\n\tEntityCreationParameters,\n\tEntityEventListenerStore,\n\tEntityListEventListenerStore,\n\tExpectedQualifiedEntityMutation,\n\tExpectedRelationMutation,\n\tHasManyRelation,\n\tHasOneRelation,\n\tParentEntityParameters,\n\tQualifiedEntityList,\n\tQualifiedSingleEntity,\n\tSetOnCreate,\n\tUnconstrainedQualifiedEntityList,\n\tUnconstrainedQualifiedSingleEntity,\n\tUniqueWhere,\n} from '../treeParameters'\n\nexport class TreeParameterMerger {\n\tpublic static mergeHasOneRelationsWithSamePlaceholders(\n\t\toriginal: HasOneRelation,\n\t\tfresh: HasOneRelation,\n\t): HasOneRelation {\n\t\treturn {\n\t\t\t// Encoded within the placeholder\n\t\t\tfield: original.field,\n\t\t\tfilter: original.filter,\n\t\t\treducedBy: original.reducedBy,\n\n\t\t\t// Not encoded within the placeholder\n\t\t\texpectedMutation: this.mergeExpectedRelationMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\t// forceCreation: original.forceCreation || fresh.forceCreation,\n\t\t\teventListeners: this.mergeSingleEntityEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t}\n\t}\n\n\tpublic static mergeHasManyRelationsWithSamePlaceholders(\n\t\toriginal: HasManyRelation,\n\t\tfresh: HasManyRelation,\n\t): HasManyRelation {\n\t\tif (original.initialEntityCount !== fresh.initialEntityCount) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`Detected hasMany relations on the same field '${original.field}' with different preferred initial ` +\n\t\t\t\t\t`entity counts: '${original.initialEntityCount}' and '${fresh.initialEntityCount}' respectively.`,\n\t\t\t)\n\t\t}\n\t\treturn {\n\t\t\t// Encoded within the placeholder\n\t\t\tfield: original.field,\n\t\t\tfilter: original.filter,\n\t\t\torderBy: original.orderBy,\n\t\t\toffset: original.offset,\n\t\t\tlimit: original.limit,\n\n\t\t\t// Not encoded within the placeholder\n\t\t\texpectedMutation: this.mergeExpectedRelationMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\t// forceCreation: original.forceCreation || fresh.forceCreation,\n\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\tinitialEntityCount: original.initialEntityCount, // Handled above\n\t\t\tchildEventListeners: this.mergeSingleEntityEventListeners(\n\t\t\t\toriginal.childEventListeners,\n\t\t\t\tfresh.childEventListeners,\n\t\t\t),\n\t\t\teventListeners: this.mergeEntityListEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t}\n\t}\n\n\tpublic static mergeEntitySubTreeParametersWithSamePlaceholders(\n\t\toriginal: QualifiedSingleEntity | UnconstrainedQualifiedSingleEntity,\n\t\tfresh: QualifiedSingleEntity | UnconstrainedQualifiedSingleEntity,\n\t): QualifiedSingleEntity | UnconstrainedQualifiedSingleEntity {\n\t\tif (original.isCreating) {\n\t\t\tif (!fresh.isCreating) {\n\t\t\t\tthrow new BindingError()\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t// Encoded within the placeholder\n\t\t\t\tisCreating: original.isCreating,\n\t\t\t\tisUnpersisted: original.isUnpersisted && fresh.isUnpersisted,\n\t\t\t\tentityName: original.entityName,\n\n\t\t\t\t// Not encoded within the placeholder\n\t\t\t\talias: this.mergeSubTreeAliases(original.alias, fresh.alias),\n\t\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\t\t// forceCreation: original.value.forceCreation || fresh.value.forceCreation,\n\t\t\t\texpectedMutation: this.mergeExpectedQualifiedEntityMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\t\thasOneRelationPath: original.hasOneRelationPath, // TODO this is completely wrong.\n\t\t\t\teventListeners: this.mergeSingleEntityEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t// Encoded within the placeholder\n\t\t\tisCreating: original.isCreating,\n\t\t\twhere: original.where,\n\t\t\tentityName: original.entityName,\n\t\t\tfilter: original.filter,\n\n\t\t\t// Not encoded within the placeholder\n\t\t\talias: this.mergeSubTreeAliases(original.alias, fresh.alias),\n\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\t// forceCreation: original.value.forceCreation || fresh.value.forceCreation,\n\t\t\texpectedMutation: this.mergeExpectedQualifiedEntityMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\thasOneRelationPath: original.hasOneRelationPath, // TODO this is completely wrong.\n\t\t\teventListeners: this.mergeSingleEntityEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t}\n\t}\n\n\tpublic static mergeEntityListSubTreeParametersWithSamePlaceholders(\n\t\toriginal: QualifiedEntityList | UnconstrainedQualifiedEntityList,\n\t\tfresh: QualifiedEntityList | UnconstrainedQualifiedEntityList,\n\t): QualifiedEntityList | UnconstrainedQualifiedEntityList {\n\t\tif (original.initialEntityCount !== fresh.initialEntityCount) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`Detected sub trees of the same entity '${original.entityName}' with different preferred initial ` +\n\t\t\t\t\t`entity counts: '${original.initialEntityCount}' and '${fresh.initialEntityCount}' respectively.`,\n\t\t\t)\n\t\t}\n\n\t\tif (original.isCreating) {\n\t\t\tif (!fresh.isCreating) {\n\t\t\t\tthrow new BindingError()\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t// Encoded within the placeholder\n\t\t\t\tisCreating: original.isCreating,\n\t\t\t\tisUnpersisted: original.isUnpersisted && fresh.isUnpersisted,\n\t\t\t\tentityName: original.entityName,\n\n\t\t\t\t// Not encoded within the placeholder\n\t\t\t\talias: this.mergeSubTreeAliases(original.alias, fresh.alias),\n\t\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\t\t// forceCreation: original.value.forceCreation || fresh.value.forceCreation,\n\t\t\t\texpectedMutation: this.mergeExpectedQualifiedEntityMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\t\thasOneRelationPath: original.hasOneRelationPath, // TODO this is completely wrong.\n\t\t\t\tchildEventListeners: this.mergeSingleEntityEventListeners(\n\t\t\t\t\toriginal.childEventListeners,\n\t\t\t\t\tfresh.childEventListeners,\n\t\t\t\t),\n\t\t\t\teventListeners: this.mergeEntityListEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t\t\tinitialEntityCount: original.initialEntityCount, // Handled above\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t// Encoded within the placeholder\n\t\t\tisCreating: original.isCreating,\n\t\t\tentityName: original.entityName,\n\t\t\tfilter: original.filter,\n\t\t\torderBy: original.orderBy,\n\t\t\toffset: original.offset,\n\t\t\tlimit: original.limit,\n\n\t\t\t// Not encoded within the placeholder\n\t\t\talias: this.mergeSubTreeAliases(original.alias, fresh.alias),\n\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\t// forceCreation: original.value.forceCreation || fresh.value.forceCreation,\n\t\t\texpectedMutation: this.mergeExpectedQualifiedEntityMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\thasOneRelationPath: original.hasOneRelationPath, // TODO this is completely wrong.\n\t\t\tchildEventListeners: this.mergeSingleEntityEventListeners(\n\t\t\t\toriginal.childEventListeners,\n\t\t\t\tfresh.childEventListeners,\n\t\t\t),\n\t\t\teventListeners: this.mergeEntityListEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t\tinitialEntityCount: original.initialEntityCount, // Handled above\n\t\t}\n\t}\n\n\tpublic static mergeEntityCreationParameters(\n\t\toriginal: EntityCreationParameters,\n\t\tfresh: EntityCreationParameters,\n\t): EntityCreationParameters {\n\t\treturn {\n\t\t\t// forceCreation: original.forceCreation || fresh.forceCreation,\n\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t}\n\t}\n\n\tpublic static mergeSetOnCreate(original: SetOnCreate, fresh: SetOnCreate): SetOnCreate {\n\t\tif (original === undefined && fresh === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (original === undefined) {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === undefined) {\n\t\t\treturn original\n\t\t}\n\t\tconst originalCopy: Writable<UniqueWhere> = { ...original }\n\n\t\tfor (const field in fresh) {\n\t\t\tif (field in originalCopy) {\n\t\t\t\tconst fromOriginal = originalCopy[field]\n\t\t\t\tconst fromFresh = fresh[field]\n\n\t\t\t\tif (fromOriginal instanceof GraphQlBuilder.GraphQlLiteral) {\n\t\t\t\t\tif (fromFresh instanceof GraphQlBuilder.GraphQlLiteral) {\n\t\t\t\t\t\tif (fromOriginal.value === fromFresh.value) {\n\t\t\t\t\t\t\t// Good, do nothing.\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeof fromOriginal === 'object') {\n\t\t\t\t\tif (fromFresh instanceof GraphQlBuilder.GraphQlLiteral) {\n\t\t\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t\t\t} else if (typeof fromFresh === 'object') {\n\t\t\t\t\t\tconst merged = this.mergeSetOnCreate(fromOriginal, fromFresh)\n\t\t\t\t\t\tif (merged !== undefined) {\n\t\t\t\t\t\t\toriginalCopy[field] = merged\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeof fromFresh === 'string' || typeof fromFresh === 'number') {\n\t\t\t\t\tif (fromOriginal === fromFresh) {\n\t\t\t\t\t\t// Good, do nothing.\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t} else {\n\t\t\t\toriginalCopy[field] = fresh[field]\n\t\t\t}\n\t\t}\n\n\t\treturn originalCopy\n\t}\n\n\tprivate static mergeSets<T>(original: Set<T>, fresh: Set<T>): Set<T> {\n\t\tconst combinedSet = new Set(original)\n\t\tfor (const item of fresh) {\n\t\t\tcombinedSet.add(item)\n\t\t}\n\t\treturn combinedSet\n\t}\n\n\tpublic static mergeParentEntityParameters(\n\t\toriginal: ParentEntityParameters | undefined,\n\t\tfresh: ParentEntityParameters | undefined,\n\t): ParentEntityParameters | undefined {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tif (original === undefined) {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === undefined) {\n\t\t\treturn original\n\t\t}\n\t\treturn {\n\t\t\teventListeners: TreeParameterMerger.mergeSingleEntityEventListeners(\n\t\t\t\toriginal.eventListeners,\n\t\t\t\tfresh.eventListeners,\n\t\t\t),\n\t\t}\n\t}\n\n\tpublic static mergeInParentEntity<\n\t\tOriginal extends Record<Key, EntityEventListenerStore | undefined>,\n\t\tKey extends keyof Original,\n\t>(original: Original, key: Key, parentEntity: ParentEntityParameters | undefined): Original {\n\t\tif (!parentEntity) {\n\t\t\treturn original\n\t\t}\n\n\t\treturn {\n\t\t\t...original,\n\t\t\t[key]: TreeParameterMerger.mergeSingleEntityEventListeners(original[key], parentEntity.eventListeners),\n\t\t}\n\t}\n\n\tpublic static mergeSingleEntityEventListeners(\n\t\toriginal: EntityEventListenerStore | undefined,\n\t\tfresh: EntityEventListenerStore | undefined,\n\t): EntityEventListenerStore | undefined {\n\t\tif (original === undefined) {\n\t\t\tif (fresh === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\treturn this.cloneSingleEntityEventListeners(fresh)\n\t\t}\n\n\t\tif (fresh === undefined) {\n\t\t\treturn this.cloneSingleEntityEventListeners(original)\n\t\t}\n\n\t\tconst store = this.cloneSingleEntityEventListeners(original)\n\t\tstore.append(fresh)\n\t\treturn store\n\t}\n\n\tpublic static mergeEntityListEventListeners(\n\t\toriginal: EntityListEventListenerStore | undefined,\n\t\tfresh: EntityListEventListenerStore | undefined,\n\t): EntityListEventListenerStore | undefined {\n\t\tif (original === undefined) {\n\t\t\tif (fresh === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\treturn this.cloneEntityListEventListeners(fresh)\n\t\t}\n\n\t\tif (fresh === undefined) {\n\t\t\treturn this.cloneEntityListEventListeners(original)\n\t\t}\n\n\t\tconst store = this.cloneEntityListEventListeners(original)\n\t\tstore.append(fresh)\n\t\treturn store\n\t}\n\n\tpublic static cloneSingleEntityEventListeners(store: EntityEventListenerStore): EntityEventListenerStore {\n\t\t// TODO is intentional, that second clone is deep?\n\t\treturn store.clone()\n\t}\n\n\tpublic static cloneEntityListEventListeners(store: EntityListEventListenerStore): EntityListEventListenerStore {\n\t\treturn store.cloneDeep()\n\t}\n\n\tprivate static mergeExpectedRelationMutation(\n\t\toriginal: ExpectedRelationMutation,\n\t\tfresh: ExpectedRelationMutation,\n\t): ExpectedRelationMutation {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tif (original === 'none') {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === 'none') {\n\t\t\treturn original\n\t\t}\n\t\treturn 'anyMutation'\n\t}\n\n\tprivate static mergeExpectedQualifiedEntityMutation(\n\t\toriginal: ExpectedQualifiedEntityMutation,\n\t\tfresh: ExpectedQualifiedEntityMutation,\n\t): ExpectedQualifiedEntityMutation {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tif (original === 'none') {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === 'none') {\n\t\t\treturn original\n\t\t}\n\t\treturn 'anyMutation'\n\t}\n\n\tprivate static mergeSubTreeAliases(\n\t\toriginal: Set<Alias> | undefined,\n\t\tfresh: Set<Alias> | undefined,\n\t): Set<Alias> | undefined {\n\t\tif (original === undefined) {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === undefined) {\n\t\t\treturn original\n\t\t}\n\t\treturn this.mergeSets(original, fresh)\n\t}\n}\n"],"names":[],"mappings":";;AAoBO,MAAM,oBAAoB;AAAA,EAChC,OAAc,yCACb,UACA,OACiB;AACV,WAAA;AAAA;AAAA,MAEN,OAAO,SAAS;AAAA,M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OAAmE;AAC9G,WAAO,MAAM;EACd;AAAA,EAEA,OAAe,8BACd,UACA,OAC2B;AAC3B,QAAI,aAAa,OAAO;AAChB,aAAA;AAAA,IACR;AACA,QAAI,aAAa,QAAQ;AACjB,aAAA;AAAA,IACR;AACA,QAAI,UAAU,QAAQ;AACd,aAAA;AAAA,IACR;AACO,WAAA;AAAA,EACR;AAAA,EAEA,OAAe,qCACd,UACA,OACkC;AAClC,QAAI,aAAa,OAAO;AAChB,aAAA;AAAA,IACR;AACA,QAAI,aAAa,QAAQ;AACjB,aAAA;AAAA,IACR;AACA,QAAI,UAAU,QAAQ;AACd,aAAA;AAAA,IACR;AACO,WAAA;AAAA,EACR;AAAA,EAEA,OAAe,oBACd,UACA,OACyB;AACzB,QAAI,aAAa,QAAW;AACpB,aAAA;AAAA,IACR;AACA,QAAI,UAAU,QAAW;AACjB,aAAA;AAAA,IACR;AACO,WAAA,KAAK,UAAU,UAAU,KAAK;AAAA,EACtC;AACD;"}
|
|
1
|
+
{"version":3,"file":"TreeParameterMerger.js","sources":["../../../src/core/TreeParameterMerger.ts"],"sourcesContent":["import { GraphQlBuilder, Writable } from '@contember/client'\nimport { BindingError } from '../BindingError'\nimport type {\n\tAlias,\n\tEntityCreationParameters,\n\tEntityEventListenerStore,\n\tEntityListEventListenerStore,\n\tExpectedQualifiedEntityMutation,\n\tExpectedRelationMutation,\n\tHasManyRelation,\n\tHasOneRelation,\n\tParentEntityParameters,\n\tQualifiedEntityList,\n\tQualifiedSingleEntity,\n\tSetOnCreate,\n\tUnconstrainedQualifiedEntityList,\n\tUnconstrainedQualifiedSingleEntity,\n\tUniqueWhere,\n} from '../treeParameters'\n\nexport class TreeParameterMerger {\n\tpublic static mergeHasOneRelationsWithSamePlaceholders(\n\t\toriginal: HasOneRelation,\n\t\tfresh: HasOneRelation,\n\t): HasOneRelation {\n\t\treturn {\n\t\t\t// Encoded within the placeholder\n\t\t\tfield: original.field,\n\t\t\tfilter: original.filter,\n\t\t\treducedBy: original.reducedBy,\n\n\t\t\t// Not encoded within the placeholder\n\t\t\texpectedMutation: this.mergeExpectedRelationMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\t// forceCreation: original.forceCreation || fresh.forceCreation,\n\t\t\teventListeners: this.mergeSingleEntityEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t}\n\t}\n\n\tpublic static mergeHasManyRelationsWithSamePlaceholders(\n\t\toriginal: HasManyRelation,\n\t\tfresh: HasManyRelation,\n\t): HasManyRelation {\n\t\tif (original.initialEntityCount !== fresh.initialEntityCount) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`Detected hasMany relations on the same field '${original.field}' with different preferred initial ` +\n\t\t\t\t\t`entity counts: '${original.initialEntityCount}' and '${fresh.initialEntityCount}' respectively.`,\n\t\t\t)\n\t\t}\n\t\treturn {\n\t\t\t// Encoded within the placeholder\n\t\t\tfield: original.field,\n\t\t\tfilter: original.filter,\n\t\t\torderBy: original.orderBy,\n\t\t\toffset: original.offset,\n\t\t\tlimit: original.limit,\n\n\t\t\t// Not encoded within the placeholder\n\t\t\texpectedMutation: this.mergeExpectedRelationMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\t// forceCreation: original.forceCreation || fresh.forceCreation,\n\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\tinitialEntityCount: original.initialEntityCount, // Handled above\n\t\t\tchildEventListeners: this.mergeSingleEntityEventListeners(\n\t\t\t\toriginal.childEventListeners,\n\t\t\t\tfresh.childEventListeners,\n\t\t\t),\n\t\t\teventListeners: this.mergeEntityListEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t}\n\t}\n\n\tpublic static mergeEntitySubTreeParametersWithSamePlaceholders(\n\t\toriginal: QualifiedSingleEntity | UnconstrainedQualifiedSingleEntity,\n\t\tfresh: QualifiedSingleEntity | UnconstrainedQualifiedSingleEntity,\n\t): QualifiedSingleEntity | UnconstrainedQualifiedSingleEntity {\n\t\tif (original.isCreating) {\n\t\t\tif (!fresh.isCreating) {\n\t\t\t\tthrow new BindingError()\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t// Encoded within the placeholder\n\t\t\t\tisCreating: original.isCreating,\n\t\t\t\tisUnpersisted: original.isUnpersisted && fresh.isUnpersisted,\n\t\t\t\tentityName: original.entityName,\n\n\t\t\t\t// Not encoded within the placeholder\n\t\t\t\talias: this.mergeSubTreeAliases(original.alias, fresh.alias),\n\t\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\t\t// forceCreation: original.value.forceCreation || fresh.value.forceCreation,\n\t\t\t\texpectedMutation: this.mergeExpectedQualifiedEntityMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\t\thasOneRelationPath: original.hasOneRelationPath, // TODO this is completely wrong.\n\t\t\t\teventListeners: this.mergeSingleEntityEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t// Encoded within the placeholder\n\t\t\tisCreating: original.isCreating,\n\t\t\twhere: original.where,\n\t\t\tentityName: original.entityName,\n\t\t\tfilter: original.filter,\n\n\t\t\t// Not encoded within the placeholder\n\t\t\talias: this.mergeSubTreeAliases(original.alias, fresh.alias),\n\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\t// forceCreation: original.value.forceCreation || fresh.value.forceCreation,\n\t\t\texpectedMutation: this.mergeExpectedQualifiedEntityMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\thasOneRelationPath: original.hasOneRelationPath, // TODO this is completely wrong.\n\t\t\teventListeners: this.mergeSingleEntityEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t}\n\t}\n\n\tpublic static mergeEntityListSubTreeParametersWithSamePlaceholders(\n\t\toriginal: QualifiedEntityList | UnconstrainedQualifiedEntityList,\n\t\tfresh: QualifiedEntityList | UnconstrainedQualifiedEntityList,\n\t): QualifiedEntityList | UnconstrainedQualifiedEntityList {\n\t\tif (original.initialEntityCount !== fresh.initialEntityCount) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`Detected sub trees of the same entity '${original.entityName}' with different preferred initial ` +\n\t\t\t\t\t`entity counts: '${original.initialEntityCount}' and '${fresh.initialEntityCount}' respectively.`,\n\t\t\t)\n\t\t}\n\n\t\tif (original.isCreating) {\n\t\t\tif (!fresh.isCreating) {\n\t\t\t\tthrow new BindingError()\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t// Encoded within the placeholder\n\t\t\t\tisCreating: original.isCreating,\n\t\t\t\tisUnpersisted: original.isUnpersisted && fresh.isUnpersisted,\n\t\t\t\tentityName: original.entityName,\n\n\t\t\t\t// Not encoded within the placeholder\n\t\t\t\talias: this.mergeSubTreeAliases(original.alias, fresh.alias),\n\t\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\t\t// forceCreation: original.value.forceCreation || fresh.value.forceCreation,\n\t\t\t\texpectedMutation: this.mergeExpectedQualifiedEntityMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\t\thasOneRelationPath: original.hasOneRelationPath, // TODO this is completely wrong.\n\t\t\t\tchildEventListeners: this.mergeSingleEntityEventListeners(\n\t\t\t\t\toriginal.childEventListeners,\n\t\t\t\t\tfresh.childEventListeners,\n\t\t\t\t),\n\t\t\t\teventListeners: this.mergeEntityListEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t\t\tinitialEntityCount: original.initialEntityCount, // Handled above\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t// Encoded within the placeholder\n\t\t\tisCreating: original.isCreating,\n\t\t\tentityName: original.entityName,\n\t\t\tfilter: original.filter,\n\t\t\torderBy: original.orderBy,\n\t\t\toffset: original.offset,\n\t\t\tlimit: original.limit,\n\n\t\t\t// Not encoded within the placeholder\n\t\t\talias: this.mergeSubTreeAliases(original.alias, fresh.alias),\n\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t\t// forceCreation: original.value.forceCreation || fresh.value.forceCreation,\n\t\t\texpectedMutation: this.mergeExpectedQualifiedEntityMutation(original.expectedMutation, fresh.expectedMutation),\n\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\thasOneRelationPath: original.hasOneRelationPath, // TODO this is completely wrong.\n\t\t\tchildEventListeners: this.mergeSingleEntityEventListeners(\n\t\t\t\toriginal.childEventListeners,\n\t\t\t\tfresh.childEventListeners,\n\t\t\t),\n\t\t\teventListeners: this.mergeEntityListEventListeners(original.eventListeners, fresh.eventListeners),\n\t\t\tinitialEntityCount: original.initialEntityCount, // Handled above\n\t\t}\n\t}\n\n\tpublic static mergeEntityCreationParameters(\n\t\toriginal: EntityCreationParameters,\n\t\tfresh: EntityCreationParameters,\n\t): EntityCreationParameters {\n\t\treturn {\n\t\t\t// forceCreation: original.forceCreation || fresh.forceCreation,\n\t\t\tisNonbearing: original.isNonbearing && fresh.isNonbearing,\n\t\t\tsetOnCreate: this.mergeSetOnCreate(original.setOnCreate, fresh.setOnCreate),\n\t\t}\n\t}\n\n\tpublic static mergeSetOnCreate(original: SetOnCreate, fresh: SetOnCreate): SetOnCreate {\n\t\tif (original === undefined && fresh === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (original === undefined) {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === undefined) {\n\t\t\treturn original\n\t\t}\n\t\tconst originalCopy: Writable<UniqueWhere> = { ...original }\n\n\t\tfor (const field in fresh) {\n\t\t\tif (field in originalCopy) {\n\t\t\t\tconst fromOriginal = originalCopy[field]\n\t\t\t\tconst fromFresh = fresh[field]\n\n\t\t\t\tif (fromOriginal instanceof GraphQlBuilder.GraphQlLiteral) {\n\t\t\t\t\tif (fromFresh instanceof GraphQlBuilder.GraphQlLiteral) {\n\t\t\t\t\t\tif (fromOriginal.value === fromFresh.value) {\n\t\t\t\t\t\t\t// Good, do nothing.\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeof fromOriginal === 'object') {\n\t\t\t\t\tif (fromFresh instanceof GraphQlBuilder.GraphQlLiteral) {\n\t\t\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t\t\t} else if (typeof fromFresh === 'object') {\n\t\t\t\t\t\tconst merged = this.mergeSetOnCreate(fromOriginal, fromFresh)\n\t\t\t\t\t\tif (merged !== undefined) {\n\t\t\t\t\t\t\toriginalCopy[field] = merged\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeof fromFresh === 'string' || typeof fromFresh === 'number') {\n\t\t\t\t\tif (fromOriginal === fromFresh) {\n\t\t\t\t\t\t// Good, do nothing.\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow new BindingError() // TODO msg\n\t\t\t} else {\n\t\t\t\toriginalCopy[field] = fresh[field]\n\t\t\t}\n\t\t}\n\n\t\treturn originalCopy\n\t}\n\n\tprivate static mergeSets<T>(original: Set<T>, fresh: Set<T>): Set<T> {\n\t\tconst combinedSet = new Set(original)\n\t\tfor (const item of fresh) {\n\t\t\tcombinedSet.add(item)\n\t\t}\n\t\treturn combinedSet\n\t}\n\n\tpublic static mergeParentEntityParameters(\n\t\toriginal: ParentEntityParameters | undefined,\n\t\tfresh: ParentEntityParameters | undefined,\n\t): ParentEntityParameters | undefined {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tif (original === undefined) {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === undefined) {\n\t\t\treturn original\n\t\t}\n\t\treturn {\n\t\t\teventListeners: TreeParameterMerger.mergeSingleEntityEventListeners(\n\t\t\t\toriginal.eventListeners,\n\t\t\t\tfresh.eventListeners,\n\t\t\t),\n\t\t}\n\t}\n\n\tpublic static mergeInParentEntity<\n\t\tOriginal extends Record<Key, EntityEventListenerStore | undefined>,\n\t\tKey extends keyof Original,\n\t>(original: Original, key: Key, parentEntity: ParentEntityParameters | undefined): Original {\n\t\tif (!parentEntity) {\n\t\t\treturn original\n\t\t}\n\n\t\treturn {\n\t\t\t...original,\n\t\t\t[key]: TreeParameterMerger.mergeSingleEntityEventListeners(original[key], parentEntity.eventListeners),\n\t\t}\n\t}\n\n\tpublic static mergeSingleEntityEventListeners(\n\t\toriginal: EntityEventListenerStore | undefined,\n\t\tfresh: EntityEventListenerStore | undefined,\n\t): EntityEventListenerStore | undefined {\n\t\tif (original === undefined) {\n\t\t\tif (fresh === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\treturn this.cloneSingleEntityEventListeners(fresh)\n\t\t}\n\n\t\tif (fresh === undefined) {\n\t\t\treturn this.cloneSingleEntityEventListeners(original)\n\t\t}\n\n\t\tconst store = this.cloneSingleEntityEventListeners(original)\n\t\tstore.append(fresh)\n\t\treturn store\n\t}\n\n\tpublic static mergeEntityListEventListeners(\n\t\toriginal: EntityListEventListenerStore | undefined,\n\t\tfresh: EntityListEventListenerStore | undefined,\n\t): EntityListEventListenerStore | undefined {\n\t\tif (original === undefined) {\n\t\t\tif (fresh === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\treturn this.cloneEntityListEventListeners(fresh)\n\t\t}\n\n\t\tif (fresh === undefined) {\n\t\t\treturn this.cloneEntityListEventListeners(original)\n\t\t}\n\n\t\tconst store = this.cloneEntityListEventListeners(original)\n\t\tstore.append(fresh)\n\t\treturn store\n\t}\n\n\tpublic static cloneSingleEntityEventListeners(store: EntityEventListenerStore): EntityEventListenerStore {\n\t\t// TODO is intentional, that second clone is deep?\n\t\treturn store.clone()\n\t}\n\n\tpublic static cloneEntityListEventListeners(store: EntityListEventListenerStore): EntityListEventListenerStore {\n\t\treturn store.cloneDeep()\n\t}\n\n\tprivate static mergeExpectedRelationMutation(\n\t\toriginal: ExpectedRelationMutation,\n\t\tfresh: ExpectedRelationMutation,\n\t): ExpectedRelationMutation {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tif (original === 'none') {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === 'none') {\n\t\t\treturn original\n\t\t}\n\t\treturn 'anyMutation'\n\t}\n\n\tprivate static mergeExpectedQualifiedEntityMutation(\n\t\toriginal: ExpectedQualifiedEntityMutation,\n\t\tfresh: ExpectedQualifiedEntityMutation,\n\t): ExpectedQualifiedEntityMutation {\n\t\tif (original === fresh) {\n\t\t\treturn original\n\t\t}\n\t\tif (original === 'none') {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === 'none') {\n\t\t\treturn original\n\t\t}\n\t\treturn 'anyMutation'\n\t}\n\n\tprivate static mergeSubTreeAliases(\n\t\toriginal: Set<Alias> | undefined,\n\t\tfresh: Set<Alias> | undefined,\n\t): Set<Alias> | undefined {\n\t\tif (original === undefined) {\n\t\t\treturn fresh\n\t\t}\n\t\tif (fresh === undefined) {\n\t\t\treturn original\n\t\t}\n\t\treturn this.mergeSets(original, fresh)\n\t}\n}\n"],"names":[],"mappings":";;AAoBO,MAAM,oBAAoB;AAAA,EAChC,OAAc,yCACb,UACA,OACiB;AACV,WAAA;AAAA;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,OAAc,gCAAgC,OAA2D;AAExG,WAAO,MAAM;EACd;AAAA,EAEA,OAAc,8BAA8B,OAAmE;AAC9G,WAAO,MAAM;EACd;AAAA,EAEA,OAAe,8BACd,UACA,OAC2B;AAC3B,QAAI,aAAa,OAAO;AAChB,aAAA;AAAA,IACR;AACA,QAAI,aAAa,QAAQ;AACjB,aAAA;AAAA,IACR;AACA,QAAI,UAAU,QAAQ;AACd,aAAA;AAAA,IACR;AACO,WAAA;AAAA,EACR;AAAA,EAEA,OAAe,qCACd,UACA,OACkC;AAClC,QAAI,aAAa,OAAO;AAChB,aAAA;AAAA,IACR;AACA,QAAI,aAAa,QAAQ;AACjB,aAAA;AAAA,IACR;AACA,QAAI,UAAU,QAAQ;AACd,aAAA;AAAA,IACR;AACO,WAAA;AAAA,EACR;AAAA,EAEA,OAAe,oBACd,UACA,OACyB;AACzB,QAAI,aAAa,QAAW;AACpB,aAAA;AAAA,IACR;AACA,QAAI,UAAU,QAAW;AACjB,aAAA;AAAA,IACR;AACO,WAAA,KAAK,UAAU,UAAU,KAAK;AAAA,EACtC;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeStore.cjs","sources":["../../../src/core/TreeStore.ts"],"sourcesContent":["import {\n\tNormalizedPersistedData,\n\tPersistedEntityDataStore,\n\tReceivedDataTree,\n\tSubTreeDataStore,\n\tUniqueEntityId,\n} from '../accessorTree'\nimport { BindingError } from '../BindingError'\nimport type { Environment } from '../dao'\nimport { MarkerTreeRoot, PlaceholderGenerator } from '../markers'\nimport { QueryLanguage } from '../queryLanguage'\nimport type {\n\tAlias,\n\tEntityId,\n\tEntityName,\n\tEntityRealmKey,\n\tFieldName,\n\tPlaceholderName,\n\tSugaredQualifiedEntityList,\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedEntityList,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '../treeParameters'\nimport { assertNever } from '../utils'\nimport { MarkerComparator } from './MarkerComparator'\nimport { RequestResponseNormalizer } from './RequestResponseNormalizer'\nimport type { Schema } from './schema'\nimport type { EntityListState, EntityRealmState, EntityRealmStateStub, EntityState, RootStateNode } from './state'\nimport { SubMutationOperation } from './MutationGenerator'\n\nconst emptyEntityIdSet: ReadonlySet<EntityId> = new Set()\n\nexport class TreeStore {\n\tpublic readonly entityStore: Map<UniqueEntityId, EntityState> = new Map()\n\tpublic readonly entityRealmStore: Map<EntityRealmKey, EntityRealmState | EntityRealmStateStub> = new Map()\n\n\t// This is tricky. We allow placeholder name duplicates, only the (TreeRootId, PlaceholderName) tuple is unique.\n\t// This is useful when the tree is extended to contain a sub-tree with the same placeholder.\n\tpublic readonly markerTrees: Map<TreeRootId | undefined, MarkerTreeRoot> = new Map()\n\tpublic readonly subTreeStatesByRoot: Map<TreeRootId | undefined, Map<PlaceholderName, RootStateNode>> = new Map()\n\n\tpublic readonly persistedData: NormalizedPersistedData = new NormalizedPersistedData(new Map(), new Map())\n\n\tpublic constructor(\n\t\tprivate readonly _schema: Schema,\n\t) {}\n\n\tpublic mergeInQueryResponse(response: ReceivedDataTree, markerTree: MarkerTreeRoot): void {\n\t\tRequestResponseNormalizer.mergeInQueryResponse(this.persistedData, response, markerTree)\n\t}\n\n\tpublic mergeInMutationResponse(response: ReceivedDataTree, operations: SubMutationOperation[]): void {\n\t\tRequestResponseNormalizer.mergeInMutationResponse(this.persistedData, response, operations)\n\t}\n\n\tpublic get persistedEntityData(): PersistedEntityDataStore {\n\t\treturn this.persistedData.persistedEntityDataStore\n\t}\n\n\tpublic get subTreePersistedData(): SubTreeDataStore {\n\t\treturn this.persistedData.subTreeDataStore\n\t}\n\n\tpublic get schema(): Schema {\n\t\treturn this._schema\n\t}\n\n\tpublic getPathBackToParent(entityRealm: EntityRealmState | EntityRealmStateStub):\n\t\t| {\n\t\t\t\tfieldBackToParent: FieldName\n\t\t\t\tparent: EntityRealmState\n\t\t }\n\t\t| undefined {\n\t\tconst blueprint = entityRealm.blueprint\n\t\tif (blueprint.parent === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tlet parentEntityName: EntityName\n\t\tlet relationFromParent: FieldName\n\t\tlet parent: EntityRealmState\n\n\t\tif (blueprint.type === 'hasOne') {\n\t\t\tparentEntityName = blueprint.parent.entity.entityName\n\t\t\trelationFromParent = blueprint.marker.parameters.field\n\t\t\tparent = blueprint.parent\n\t\t} else if (blueprint.type === 'listEntity') {\n\t\t\tconst grandparentBlueprint = blueprint.parent.blueprint\n\n\t\t\tif (grandparentBlueprint.parent === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tparentEntityName = grandparentBlueprint.parent.entity.entityName\n\t\t\trelationFromParent = grandparentBlueprint.marker.parameters.field\n\t\t\tparent = grandparentBlueprint.parent\n\t\t} else {\n\t\t\treturn assertNever(blueprint)\n\t\t}\n\n\t\tconst relationSchema = this.schema.getEntityRelation(parentEntityName, relationFromParent)\n\t\tconst fieldBack = (relationSchema.ownedBy || relationSchema.inversedBy) ?? null\n\n\t\t// console.log(parentEntityName, relationFromParent, entityRealm.entity.entityName, fieldBack)\n\t\tif (fieldBack === null) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\tparent,\n\t\t\tfieldBackToParent: fieldBack,\n\t\t}\n\t}\n\n\tpublic getSubTreeState(\n\t\tmode: 'entity',\n\t\ttreeRootId: TreeRootId | undefined,\n\t\taliasOrParameters: Alias | SugaredQualifiedSingleEntity | SugaredUnconstrainedQualifiedSingleEntity,\n\t\tenvironment: Environment,\n\t): EntityRealmState\n\tpublic getSubTreeState(\n\t\tmode: 'entityList',\n\t\ttreeRootId: TreeRootId | undefined,\n\t\taliasOrParameters: Alias | SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList,\n\t\tenvironment: Environment,\n\t): EntityListState\n\tpublic getSubTreeState(\n\t\tmode: 'entity' | 'entityList',\n\t\ttreeRootId: TreeRootId | undefined,\n\t\taliasOrParameters:\n\t\t\t| Alias\n\t\t\t| SugaredQualifiedSingleEntity\n\t\t\t| SugaredUnconstrainedQualifiedSingleEntity\n\t\t\t| SugaredQualifiedEntityList\n\t\t\t| SugaredUnconstrainedQualifiedEntityList,\n\t\tenvironment: Environment,\n\t): RootStateNode {\n\t\tconst markerRoot = this.markerTrees.get(treeRootId)\n\t\tconst subTreeStates = this.subTreeStatesByRoot.get(treeRootId)\n\n\t\tif (subTreeStates === undefined || markerRoot === undefined) {\n\t\t\tif (treeRootId) {\n\t\t\t\tthrow new BindingError(\n\t\t\t\t\t`Invalid tree id '${treeRootId}'. Make sure you use the one supplied by the correct extendTree call.`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tthrow new BindingError(`Failed to retrieve a sub tree.`)\n\t\t}\n\n\t\tlet placeholderName: string\n\n\t\tif (typeof aliasOrParameters === 'string') {\n\t\t\tconst placeholderByAlias = markerRoot.placeholdersByAliases.get(aliasOrParameters)\n\n\t\t\tif (placeholderByAlias === undefined) {\n\t\t\t\tthrow new BindingError(`Undefined sub-tree alias '${aliasOrParameters}'.`)\n\t\t\t}\n\t\t\tplaceholderName = placeholderByAlias\n\t\t} else if (mode === 'entityList') {\n\t\t\tplaceholderName = PlaceholderGenerator.getEntityListSubTreePlaceholder(\n\t\t\t\taliasOrParameters.isCreating\n\t\t\t\t\t? QueryLanguage.desugarUnconstrainedQualifiedEntityList(\n\t\t\t\t\t\t\taliasOrParameters as SugaredUnconstrainedQualifiedEntityList,\n\t\t\t\t\t\t\tenvironment,\n\t\t\t\t\t )\n\t\t\t\t\t: QueryLanguage.desugarQualifiedEntityList(aliasOrParameters as SugaredQualifiedEntityList, environment),\n\t\t\t\tenvironment,\n\t\t\t)\n\t\t} else if (mode === 'entity') {\n\t\t\tplaceholderName = PlaceholderGenerator.getEntitySubTreePlaceholder(\n\t\t\t\taliasOrParameters.isCreating\n\t\t\t\t\t? QueryLanguage.desugarUnconstrainedQualifiedSingleEntity(\n\t\t\t\t\t\t\taliasOrParameters as SugaredUnconstrainedQualifiedSingleEntity,\n\t\t\t\t\t\t\tenvironment,\n\t\t\t\t\t )\n\t\t\t\t\t: QueryLanguage.desugarQualifiedSingleEntity(aliasOrParameters as SugaredQualifiedSingleEntity, environment),\n\t\t\t\tenvironment,\n\t\t\t)\n\t\t} else {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\tconst subTreeState = subTreeStates.get(placeholderName)\n\n\t\tif (subTreeState === undefined) {\n\t\t\tthrow new BindingError(`Trying to retrieve a non-existent sub-tree '${placeholderName}'.`)\n\t\t}\n\t\treturn subTreeState\n\t}\n\n\tpublic getEntityListPersistedIds(state: EntityListState): ReadonlySet<EntityId> {\n\t\tconst blueprint = state.blueprint\n\n\t\tif (blueprint.parent) {\n\t\t\tconst entityData = this.persistedEntityData.get(blueprint.parent.entity.id.uniqueValue)\n\t\t\treturn (entityData?.get(blueprint.marker.placeholderName) as Set<string> | undefined) ?? emptyEntityIdSet\n\t\t} else {\n\t\t\treturn (this.subTreePersistedData.get(blueprint.marker.placeholderName) as Set<string>) ?? emptyEntityIdSet\n\t\t}\n\t}\n\n\tpublic disposeOfRealm(realmToDisposeOf: EntityRealmState | EntityRealmStateStub) {\n\t\tthis.entityRealmStore.delete(realmToDisposeOf.realmKey)\n\t\trealmToDisposeOf.entity.realms.delete(realmToDisposeOf.realmKey)\n\n\t\tif (realmToDisposeOf.type === 'entityRealm') {\n\t\t\trealmToDisposeOf.blueprint.parent?.childrenWithPendingUpdates?.delete(realmToDisposeOf)\n\n\t\t\tfor (const child of realmToDisposeOf.children.values()) {\n\t\t\t\tswitch (child.type) {\n\t\t\t\t\tcase 'field':\n\t\t\t\t\t\tcontinue\n\t\t\t\t\tcase 'entityRealm':\n\t\t\t\t\tcase 'entityRealmStub': {\n\t\t\t\t\t\tthis.disposeOfRealm(child)\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\tfor (const listChild of child.children.values()) {\n\t\t\t\t\t\t\tthis.disposeOfRealm(listChild)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst entity = realmToDisposeOf.entity\n\t\tif (entity.realms.size === 0) {\n\t\t\tthis.disposeOfEntity(entity)\n\t\t}\n\t}\n\n\tpublic disposeOfEntity(entity: EntityState) {\n\t\tfor (const realm of entity.realms.values()) {\n\t\t\tthis.disposeOfRealm(realm)\n\t\t}\n\t\tthis.entityStore.delete(entity.id.uniqueValue)\n\t\tthis.persistedEntityData.delete(entity.id.uniqueValue)\n\t}\n\n\tpublic effectivelyHasTreeRoot(candidateRoot: MarkerTreeRoot): boolean {\n\t\tcandidateRoots: for (const candidateSubTree of candidateRoot.subTrees.values()) {\n\t\t\tif (candidateSubTree.parameters.isCreating) {\n\t\t\t\t// This, by definition, won't trigger a query.\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor (const root of this.markerTrees.values()) {\n\t\t\t\tfor (const alreadyPresentSubTree of root.subTrees.values()) {\n\t\t\t\t\tconst isSubset = MarkerComparator.isSubTreeSubsetOf(candidateSubTree, alreadyPresentSubTree)\n\t\t\t\t\tif (isSubset) {\n\t\t\t\t\t\tcontinue candidateRoots\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\t\treturn true\n\t}\n}\n"],"names":["NormalizedPersistedData","RequestResponseNormalizer","assertNever","BindingError","PlaceholderGenerator","QueryLanguage","MarkerComparator"],"mappings":";;;;;;;;;;;;;;;AA+BA,MAAM,uCAA8C;AAE7C,MAAM,UAAU;AAAA,EAWf,YACW,SAChB;AAZc,2DAAoD;AACpD,gEAAqF;AAIrF;AAAA;AAAA,2DAA+D;AAC/D,mEAA4F;AAE5F,yCAAyC,IAAIA,wBAAAA,wBAAwB,oBAAI,OAAO,oBAAI,KAAK;AAGvF,SAAA,UAAA;AAAA,EACf;AAAA,EAEI,qBAAqB,UAA4B,YAAkC;AACzFC,8BAAA,0BAA0B,qBAAqB,K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;AACD;;"}
|
|
1
|
+
{"version":3,"file":"TreeStore.cjs","sources":["../../../src/core/TreeStore.ts"],"sourcesContent":["import {\n\tNormalizedPersistedData,\n\tPersistedEntityDataStore,\n\tReceivedDataTree,\n\tSubTreeDataStore,\n\tUniqueEntityId,\n} from '../accessorTree'\nimport { BindingError } from '../BindingError'\nimport type { Environment } from '../dao'\nimport { MarkerTreeRoot, PlaceholderGenerator } from '../markers'\nimport { QueryLanguage } from '../queryLanguage'\nimport type {\n\tAlias,\n\tEntityId,\n\tEntityName,\n\tEntityRealmKey,\n\tFieldName,\n\tPlaceholderName,\n\tSugaredQualifiedEntityList,\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedEntityList,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '../treeParameters'\nimport { assertNever } from '../utils'\nimport { MarkerComparator } from './MarkerComparator'\nimport { RequestResponseNormalizer } from './RequestResponseNormalizer'\nimport type { Schema } from './schema'\nimport type { EntityListState, EntityRealmState, EntityRealmStateStub, EntityState, RootStateNode } from './state'\nimport { SubMutationOperation } from './MutationGenerator'\n\nconst emptyEntityIdSet: ReadonlySet<EntityId> = new Set()\n\nexport class TreeStore {\n\tpublic readonly entityStore: Map<UniqueEntityId, EntityState> = new Map()\n\tpublic readonly entityRealmStore: Map<EntityRealmKey, EntityRealmState | EntityRealmStateStub> = new Map()\n\n\t// This is tricky. We allow placeholder name duplicates, only the (TreeRootId, PlaceholderName) tuple is unique.\n\t// This is useful when the tree is extended to contain a sub-tree with the same placeholder.\n\tpublic readonly markerTrees: Map<TreeRootId | undefined, MarkerTreeRoot> = new Map()\n\tpublic readonly subTreeStatesByRoot: Map<TreeRootId | undefined, Map<PlaceholderName, RootStateNode>> = new Map()\n\n\tpublic readonly persistedData: NormalizedPersistedData = new NormalizedPersistedData(new Map(), new Map())\n\n\tpublic constructor(\n\t\tprivate readonly _schema: Schema,\n\t) {}\n\n\tpublic mergeInQueryResponse(response: ReceivedDataTree, markerTree: MarkerTreeRoot): void {\n\t\tRequestResponseNormalizer.mergeInQueryResponse(this.persistedData, response, markerTree)\n\t}\n\n\tpublic mergeInMutationResponse(response: ReceivedDataTree, operations: SubMutationOperation[]): void {\n\t\tRequestResponseNormalizer.mergeInMutationResponse(this.persistedData, response, operations)\n\t}\n\n\tpublic get persistedEntityData(): PersistedEntityDataStore {\n\t\treturn this.persistedData.persistedEntityDataStore\n\t}\n\n\tpublic get subTreePersistedData(): SubTreeDataStore {\n\t\treturn this.persistedData.subTreeDataStore\n\t}\n\n\tpublic get schema(): Schema {\n\t\treturn this._schema\n\t}\n\n\tpublic getPathBackToParent(entityRealm: EntityRealmState | EntityRealmStateStub):\n\t\t| {\n\t\t\t\tfieldBackToParent: FieldName\n\t\t\t\tparent: EntityRealmState\n\t\t }\n\t\t| undefined {\n\t\tconst blueprint = entityRealm.blueprint\n\t\tif (blueprint.parent === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tlet parentEntityName: EntityName\n\t\tlet relationFromParent: FieldName\n\t\tlet parent: EntityRealmState\n\n\t\tif (blueprint.type === 'hasOne') {\n\t\t\tparentEntityName = blueprint.parent.entity.entityName\n\t\t\trelationFromParent = blueprint.marker.parameters.field\n\t\t\tparent = blueprint.parent\n\t\t} else if (blueprint.type === 'listEntity') {\n\t\t\tconst grandparentBlueprint = blueprint.parent.blueprint\n\n\t\t\tif (grandparentBlueprint.parent === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tparentEntityName = grandparentBlueprint.parent.entity.entityName\n\t\t\trelationFromParent = grandparentBlueprint.marker.parameters.field\n\t\t\tparent = grandparentBlueprint.parent\n\t\t} else {\n\t\t\treturn assertNever(blueprint)\n\t\t}\n\n\t\tconst relationSchema = this.schema.getEntityRelation(parentEntityName, relationFromParent)\n\t\tconst fieldBack = (relationSchema.ownedBy || relationSchema.inversedBy) ?? null\n\n\t\t// console.log(parentEntityName, relationFromParent, entityRealm.entity.entityName, fieldBack)\n\t\tif (fieldBack === null) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\tparent,\n\t\t\tfieldBackToParent: fieldBack,\n\t\t}\n\t}\n\n\tpublic getSubTreeState(\n\t\tmode: 'entity',\n\t\ttreeRootId: TreeRootId | undefined,\n\t\taliasOrParameters: Alias | SugaredQualifiedSingleEntity | SugaredUnconstrainedQualifiedSingleEntity,\n\t\tenvironment: Environment,\n\t): EntityRealmState\n\tpublic getSubTreeState(\n\t\tmode: 'entityList',\n\t\ttreeRootId: TreeRootId | undefined,\n\t\taliasOrParameters: Alias | SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList,\n\t\tenvironment: Environment,\n\t): EntityListState\n\tpublic getSubTreeState(\n\t\tmode: 'entity' | 'entityList',\n\t\ttreeRootId: TreeRootId | undefined,\n\t\taliasOrParameters:\n\t\t\t| Alias\n\t\t\t| SugaredQualifiedSingleEntity\n\t\t\t| SugaredUnconstrainedQualifiedSingleEntity\n\t\t\t| SugaredQualifiedEntityList\n\t\t\t| SugaredUnconstrainedQualifiedEntityList,\n\t\tenvironment: Environment,\n\t): RootStateNode {\n\t\tconst markerRoot = this.markerTrees.get(treeRootId)\n\t\tconst subTreeStates = this.subTreeStatesByRoot.get(treeRootId)\n\n\t\tif (subTreeStates === undefined || markerRoot === undefined) {\n\t\t\tif (treeRootId) {\n\t\t\t\tthrow new BindingError(\n\t\t\t\t\t`Invalid tree id '${treeRootId}'. Make sure you use the one supplied by the correct extendTree call.`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tthrow new BindingError(`Failed to retrieve a sub tree.`)\n\t\t}\n\n\t\tlet placeholderName: string\n\n\t\tif (typeof aliasOrParameters === 'string') {\n\t\t\tconst placeholderByAlias = markerRoot.placeholdersByAliases.get(aliasOrParameters)\n\n\t\t\tif (placeholderByAlias === undefined) {\n\t\t\t\tthrow new BindingError(`Undefined sub-tree alias '${aliasOrParameters}'.`)\n\t\t\t}\n\t\t\tplaceholderName = placeholderByAlias\n\t\t} else if (mode === 'entityList') {\n\t\t\tplaceholderName = PlaceholderGenerator.getEntityListSubTreePlaceholder(\n\t\t\t\taliasOrParameters.isCreating\n\t\t\t\t\t? QueryLanguage.desugarUnconstrainedQualifiedEntityList(\n\t\t\t\t\t\t\taliasOrParameters as SugaredUnconstrainedQualifiedEntityList,\n\t\t\t\t\t\t\tenvironment,\n\t\t\t\t\t )\n\t\t\t\t\t: QueryLanguage.desugarQualifiedEntityList(aliasOrParameters as SugaredQualifiedEntityList, environment),\n\t\t\t\tenvironment,\n\t\t\t)\n\t\t} else if (mode === 'entity') {\n\t\t\tplaceholderName = PlaceholderGenerator.getEntitySubTreePlaceholder(\n\t\t\t\taliasOrParameters.isCreating\n\t\t\t\t\t? QueryLanguage.desugarUnconstrainedQualifiedSingleEntity(\n\t\t\t\t\t\t\taliasOrParameters as SugaredUnconstrainedQualifiedSingleEntity,\n\t\t\t\t\t\t\tenvironment,\n\t\t\t\t\t )\n\t\t\t\t\t: QueryLanguage.desugarQualifiedSingleEntity(aliasOrParameters as SugaredQualifiedSingleEntity, environment),\n\t\t\t\tenvironment,\n\t\t\t)\n\t\t} else {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\tconst subTreeState = subTreeStates.get(placeholderName)\n\n\t\tif (subTreeState === undefined) {\n\t\t\tthrow new BindingError(`Trying to retrieve a non-existent sub-tree '${placeholderName}'.`)\n\t\t}\n\t\treturn subTreeState\n\t}\n\n\tpublic getEntityListPersistedIds(state: EntityListState): ReadonlySet<EntityId> {\n\t\tconst blueprint = state.blueprint\n\n\t\tif (blueprint.parent) {\n\t\t\tconst entityData = this.persistedEntityData.get(blueprint.parent.entity.id.uniqueValue)\n\t\t\treturn (entityData?.get(blueprint.marker.placeholderName) as Set<string> | undefined) ?? emptyEntityIdSet\n\t\t} else {\n\t\t\treturn (this.subTreePersistedData.get(blueprint.marker.placeholderName) as Set<string>) ?? emptyEntityIdSet\n\t\t}\n\t}\n\n\tpublic disposeOfRealm(realmToDisposeOf: EntityRealmState | EntityRealmStateStub) {\n\t\tthis.entityRealmStore.delete(realmToDisposeOf.realmKey)\n\t\trealmToDisposeOf.entity.realms.delete(realmToDisposeOf.realmKey)\n\n\t\tif (realmToDisposeOf.type === 'entityRealm') {\n\t\t\trealmToDisposeOf.blueprint.parent?.childrenWithPendingUpdates?.delete(realmToDisposeOf)\n\n\t\t\tfor (const child of realmToDisposeOf.children.values()) {\n\t\t\t\tswitch (child.type) {\n\t\t\t\t\tcase 'field':\n\t\t\t\t\t\tcontinue\n\t\t\t\t\tcase 'entityRealm':\n\t\t\t\t\tcase 'entityRealmStub': {\n\t\t\t\t\t\tthis.disposeOfRealm(child)\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\tfor (const listChild of child.children.values()) {\n\t\t\t\t\t\t\tthis.disposeOfRealm(listChild)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst entity = realmToDisposeOf.entity\n\t\tif (entity.realms.size === 0) {\n\t\t\tthis.disposeOfEntity(entity)\n\t\t}\n\t}\n\n\tpublic disposeOfEntity(entity: EntityState) {\n\t\tfor (const realm of entity.realms.values()) {\n\t\t\tthis.disposeOfRealm(realm)\n\t\t}\n\t\tthis.entityStore.delete(entity.id.uniqueValue)\n\t\tthis.persistedEntityData.delete(entity.id.uniqueValue)\n\t}\n\n\tpublic effectivelyHasTreeRoot(candidateRoot: MarkerTreeRoot): boolean {\n\t\tcandidateRoots: for (const candidateSubTree of candidateRoot.subTrees.values()) {\n\t\t\tif (candidateSubTree.parameters.isCreating) {\n\t\t\t\t// This, by definition, won't trigger a query.\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor (const root of this.markerTrees.values()) {\n\t\t\t\tfor (const alreadyPresentSubTree of root.subTrees.values()) {\n\t\t\t\t\tconst isSubset = MarkerComparator.isSubTreeSubsetOf(candidateSubTree, alreadyPresentSubTree)\n\t\t\t\t\tif (isSubset) {\n\t\t\t\t\t\tcontinue candidateRoots\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\t\treturn true\n\t}\n}\n"],"names":["NormalizedPersistedData","RequestResponseNormalizer","assertNever","BindingError","PlaceholderGenerator","QueryLanguage","MarkerComparator"],"mappings":";;;;;;;;;;;;;;;AA+BA,MAAM,uCAA8C;AAE7C,MAAM,UAAU;AAAA,EAWf,YACW,SAChB;AAZc,2DAAoD;AACpD,gEAAqF;AAIrF;AAAA;AAAA,2DAA+D;AAC/D,mEAA4F;AAE5F,yCAAyC,IAAIA,wBAAAA,wBAAwB,oBAAI,OAAO,oBAAI,KAAK;AAGvF,SAAA,UAAA;AAAA,EACf;AAAA,EAEI,qBAAqB,UAA4B,YAAkC;AACzFC,8BAAA,0BAA0B,qBAAqB,KAAK,eAAe,UAAU,UAAU;AAAA,EACxF;AAAA,EAEO,wBAAwB,UAA4B,YAA0C;AACpGA,8BAAA,0BAA0B,wBAAwB,KAAK,eAAe,UAAU,UAAU;AAAA,EAC3F;AAAA,EAEA,IAAW,sBAAgD;AAC1D,WAAO,KAAK,cAAc;AAAA,EAC3B;AAAA,EAEA,IAAW,uBAAyC;AACnD,WAAO,KAAK,cAAc;AAAA,EAC3B;AAAA,EAEA,IAAW,SAAiB;AAC3B,WAAO,KAAK;AAAA,EACb;AAAA,EAEO,oBAAoB,aAKd;AACZ,UAAM,YAAY,YAAY;AAC1B,QAAA,UAAU,WAAW,QAAW;AAC5B,aAAA;AAAA,IACR;AACI,QAAA;AACA,QAAA;AACA,QAAA;AAEA,QAAA,UAAU,SAAS,UAAU;AACb,yBAAA,UAAU,OAAO,OAAO;AACtB,2BAAA,UAAU,OAAO,WAAW;AACjD,eAAS,UAAU;AAAA,IAAA,WACT,UAAU,SAAS,cAAc;AACrC,YAAA,uBAAuB,UAAU,OAAO;AAE1C,UAAA,qBAAqB,WAAW,QAAW;AACvC,eAAA;AAAA,MAC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,OAAO,OAAO,OAAA,GAAU;AAC3C,WAAK,eAAe,KAAK;AAAA,IAC1B;AACA,SAAK,YAAY,OAAO,OAAO,GAAG,WAAW;AAC7C,SAAK,oBAAoB,OAAO,OAAO,GAAG,WAAW;AAAA,EACtD;AAAA,EAEO,uBAAuB,eAAwC;AACrE;AAAgB,iBAAW,oBAAoB,cAAc,SAAS,OAAA,GAAU;AAC3E,YAAA,iBAAiB,WAAW,YAAY;AAE3C;AAAA,QACD;AACA,mBAAW,QAAQ,KAAK,YAAY,OAAA,GAAU;AAC7C,qBAAW,yBAAyB,KAAK,SAAS,OAAA,GAAU;AAC3D,kBAAM,WAAWG,iBAAA,iBAAiB,kBAAkB,kBAAkB,qBAAqB;AAC3F,gBAAI,UAAU;AACJ,uBAAA;AAAA,YACV;AAAA,UACD;AAAA,QACD;AACO,eAAA;AAAA,MACR;AACO,WAAA;AAAA,EACR;AACD;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeStore.js","sources":["../../../src/core/TreeStore.ts"],"sourcesContent":["import {\n\tNormalizedPersistedData,\n\tPersistedEntityDataStore,\n\tReceivedDataTree,\n\tSubTreeDataStore,\n\tUniqueEntityId,\n} from '../accessorTree'\nimport { BindingError } from '../BindingError'\nimport type { Environment } from '../dao'\nimport { MarkerTreeRoot, PlaceholderGenerator } from '../markers'\nimport { QueryLanguage } from '../queryLanguage'\nimport type {\n\tAlias,\n\tEntityId,\n\tEntityName,\n\tEntityRealmKey,\n\tFieldName,\n\tPlaceholderName,\n\tSugaredQualifiedEntityList,\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedEntityList,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '../treeParameters'\nimport { assertNever } from '../utils'\nimport { MarkerComparator } from './MarkerComparator'\nimport { RequestResponseNormalizer } from './RequestResponseNormalizer'\nimport type { Schema } from './schema'\nimport type { EntityListState, EntityRealmState, EntityRealmStateStub, EntityState, RootStateNode } from './state'\nimport { SubMutationOperation } from './MutationGenerator'\n\nconst emptyEntityIdSet: ReadonlySet<EntityId> = new Set()\n\nexport class TreeStore {\n\tpublic readonly entityStore: Map<UniqueEntityId, EntityState> = new Map()\n\tpublic readonly entityRealmStore: Map<EntityRealmKey, EntityRealmState | EntityRealmStateStub> = new Map()\n\n\t// This is tricky. We allow placeholder name duplicates, only the (TreeRootId, PlaceholderName) tuple is unique.\n\t// This is useful when the tree is extended to contain a sub-tree with the same placeholder.\n\tpublic readonly markerTrees: Map<TreeRootId | undefined, MarkerTreeRoot> = new Map()\n\tpublic readonly subTreeStatesByRoot: Map<TreeRootId | undefined, Map<PlaceholderName, RootStateNode>> = new Map()\n\n\tpublic readonly persistedData: NormalizedPersistedData = new NormalizedPersistedData(new Map(), new Map())\n\n\tpublic constructor(\n\t\tprivate readonly _schema: Schema,\n\t) {}\n\n\tpublic mergeInQueryResponse(response: ReceivedDataTree, markerTree: MarkerTreeRoot): void {\n\t\tRequestResponseNormalizer.mergeInQueryResponse(this.persistedData, response, markerTree)\n\t}\n\n\tpublic mergeInMutationResponse(response: ReceivedDataTree, operations: SubMutationOperation[]): void {\n\t\tRequestResponseNormalizer.mergeInMutationResponse(this.persistedData, response, operations)\n\t}\n\n\tpublic get persistedEntityData(): PersistedEntityDataStore {\n\t\treturn this.persistedData.persistedEntityDataStore\n\t}\n\n\tpublic get subTreePersistedData(): SubTreeDataStore {\n\t\treturn this.persistedData.subTreeDataStore\n\t}\n\n\tpublic get schema(): Schema {\n\t\treturn this._schema\n\t}\n\n\tpublic getPathBackToParent(entityRealm: EntityRealmState | EntityRealmStateStub):\n\t\t| {\n\t\t\t\tfieldBackToParent: FieldName\n\t\t\t\tparent: EntityRealmState\n\t\t }\n\t\t| undefined {\n\t\tconst blueprint = entityRealm.blueprint\n\t\tif (blueprint.parent === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tlet parentEntityName: EntityName\n\t\tlet relationFromParent: FieldName\n\t\tlet parent: EntityRealmState\n\n\t\tif (blueprint.type === 'hasOne') {\n\t\t\tparentEntityName = blueprint.parent.entity.entityName\n\t\t\trelationFromParent = blueprint.marker.parameters.field\n\t\t\tparent = blueprint.parent\n\t\t} else if (blueprint.type === 'listEntity') {\n\t\t\tconst grandparentBlueprint = blueprint.parent.blueprint\n\n\t\t\tif (grandparentBlueprint.parent === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tparentEntityName = grandparentBlueprint.parent.entity.entityName\n\t\t\trelationFromParent = grandparentBlueprint.marker.parameters.field\n\t\t\tparent = grandparentBlueprint.parent\n\t\t} else {\n\t\t\treturn assertNever(blueprint)\n\t\t}\n\n\t\tconst relationSchema = this.schema.getEntityRelation(parentEntityName, relationFromParent)\n\t\tconst fieldBack = (relationSchema.ownedBy || relationSchema.inversedBy) ?? null\n\n\t\t// console.log(parentEntityName, relationFromParent, entityRealm.entity.entityName, fieldBack)\n\t\tif (fieldBack === null) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\tparent,\n\t\t\tfieldBackToParent: fieldBack,\n\t\t}\n\t}\n\n\tpublic getSubTreeState(\n\t\tmode: 'entity',\n\t\ttreeRootId: TreeRootId | undefined,\n\t\taliasOrParameters: Alias | SugaredQualifiedSingleEntity | SugaredUnconstrainedQualifiedSingleEntity,\n\t\tenvironment: Environment,\n\t): EntityRealmState\n\tpublic getSubTreeState(\n\t\tmode: 'entityList',\n\t\ttreeRootId: TreeRootId | undefined,\n\t\taliasOrParameters: Alias | SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList,\n\t\tenvironment: Environment,\n\t): EntityListState\n\tpublic getSubTreeState(\n\t\tmode: 'entity' | 'entityList',\n\t\ttreeRootId: TreeRootId | undefined,\n\t\taliasOrParameters:\n\t\t\t| Alias\n\t\t\t| SugaredQualifiedSingleEntity\n\t\t\t| SugaredUnconstrainedQualifiedSingleEntity\n\t\t\t| SugaredQualifiedEntityList\n\t\t\t| SugaredUnconstrainedQualifiedEntityList,\n\t\tenvironment: Environment,\n\t): RootStateNode {\n\t\tconst markerRoot = this.markerTrees.get(treeRootId)\n\t\tconst subTreeStates = this.subTreeStatesByRoot.get(treeRootId)\n\n\t\tif (subTreeStates === undefined || markerRoot === undefined) {\n\t\t\tif (treeRootId) {\n\t\t\t\tthrow new BindingError(\n\t\t\t\t\t`Invalid tree id '${treeRootId}'. Make sure you use the one supplied by the correct extendTree call.`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tthrow new BindingError(`Failed to retrieve a sub tree.`)\n\t\t}\n\n\t\tlet placeholderName: string\n\n\t\tif (typeof aliasOrParameters === 'string') {\n\t\t\tconst placeholderByAlias = markerRoot.placeholdersByAliases.get(aliasOrParameters)\n\n\t\t\tif (placeholderByAlias === undefined) {\n\t\t\t\tthrow new BindingError(`Undefined sub-tree alias '${aliasOrParameters}'.`)\n\t\t\t}\n\t\t\tplaceholderName = placeholderByAlias\n\t\t} else if (mode === 'entityList') {\n\t\t\tplaceholderName = PlaceholderGenerator.getEntityListSubTreePlaceholder(\n\t\t\t\taliasOrParameters.isCreating\n\t\t\t\t\t? QueryLanguage.desugarUnconstrainedQualifiedEntityList(\n\t\t\t\t\t\t\taliasOrParameters as SugaredUnconstrainedQualifiedEntityList,\n\t\t\t\t\t\t\tenvironment,\n\t\t\t\t\t )\n\t\t\t\t\t: QueryLanguage.desugarQualifiedEntityList(aliasOrParameters as SugaredQualifiedEntityList, environment),\n\t\t\t\tenvironment,\n\t\t\t)\n\t\t} else if (mode === 'entity') {\n\t\t\tplaceholderName = PlaceholderGenerator.getEntitySubTreePlaceholder(\n\t\t\t\taliasOrParameters.isCreating\n\t\t\t\t\t? QueryLanguage.desugarUnconstrainedQualifiedSingleEntity(\n\t\t\t\t\t\t\taliasOrParameters as SugaredUnconstrainedQualifiedSingleEntity,\n\t\t\t\t\t\t\tenvironment,\n\t\t\t\t\t )\n\t\t\t\t\t: QueryLanguage.desugarQualifiedSingleEntity(aliasOrParameters as SugaredQualifiedSingleEntity, environment),\n\t\t\t\tenvironment,\n\t\t\t)\n\t\t} else {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\tconst subTreeState = subTreeStates.get(placeholderName)\n\n\t\tif (subTreeState === undefined) {\n\t\t\tthrow new BindingError(`Trying to retrieve a non-existent sub-tree '${placeholderName}'.`)\n\t\t}\n\t\treturn subTreeState\n\t}\n\n\tpublic getEntityListPersistedIds(state: EntityListState): ReadonlySet<EntityId> {\n\t\tconst blueprint = state.blueprint\n\n\t\tif (blueprint.parent) {\n\t\t\tconst entityData = this.persistedEntityData.get(blueprint.parent.entity.id.uniqueValue)\n\t\t\treturn (entityData?.get(blueprint.marker.placeholderName) as Set<string> | undefined) ?? emptyEntityIdSet\n\t\t} else {\n\t\t\treturn (this.subTreePersistedData.get(blueprint.marker.placeholderName) as Set<string>) ?? emptyEntityIdSet\n\t\t}\n\t}\n\n\tpublic disposeOfRealm(realmToDisposeOf: EntityRealmState | EntityRealmStateStub) {\n\t\tthis.entityRealmStore.delete(realmToDisposeOf.realmKey)\n\t\trealmToDisposeOf.entity.realms.delete(realmToDisposeOf.realmKey)\n\n\t\tif (realmToDisposeOf.type === 'entityRealm') {\n\t\t\trealmToDisposeOf.blueprint.parent?.childrenWithPendingUpdates?.delete(realmToDisposeOf)\n\n\t\t\tfor (const child of realmToDisposeOf.children.values()) {\n\t\t\t\tswitch (child.type) {\n\t\t\t\t\tcase 'field':\n\t\t\t\t\t\tcontinue\n\t\t\t\t\tcase 'entityRealm':\n\t\t\t\t\tcase 'entityRealmStub': {\n\t\t\t\t\t\tthis.disposeOfRealm(child)\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\tfor (const listChild of child.children.values()) {\n\t\t\t\t\t\t\tthis.disposeOfRealm(listChild)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst entity = realmToDisposeOf.entity\n\t\tif (entity.realms.size === 0) {\n\t\t\tthis.disposeOfEntity(entity)\n\t\t}\n\t}\n\n\tpublic disposeOfEntity(entity: EntityState) {\n\t\tfor (const realm of entity.realms.values()) {\n\t\t\tthis.disposeOfRealm(realm)\n\t\t}\n\t\tthis.entityStore.delete(entity.id.uniqueValue)\n\t\tthis.persistedEntityData.delete(entity.id.uniqueValue)\n\t}\n\n\tpublic effectivelyHasTreeRoot(candidateRoot: MarkerTreeRoot): boolean {\n\t\tcandidateRoots: for (const candidateSubTree of candidateRoot.subTrees.values()) {\n\t\t\tif (candidateSubTree.parameters.isCreating) {\n\t\t\t\t// This, by definition, won't trigger a query.\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor (const root of this.markerTrees.values()) {\n\t\t\t\tfor (const alreadyPresentSubTree of root.subTrees.values()) {\n\t\t\t\t\tconst isSubset = MarkerComparator.isSubTreeSubsetOf(candidateSubTree, alreadyPresentSubTree)\n\t\t\t\t\tif (isSubset) {\n\t\t\t\t\t\tcontinue candidateRoots\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\t\treturn true\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AA+BA,MAAM,uCAA8C;AAE7C,MAAM,UAAU;AAAA,EAWf,YACW,SAChB;AAZc,2DAAoD;AACpD,gEAAqF;AAIrF;AAAA;AAAA,2DAA+D;AAC/D,mEAA4F;AAE5F,yCAAyC,IAAI,wBAAwB,oBAAI,OAAO,oBAAI,KAAK;AAGvF,SAAA,UAAA;AAAA,EACf;AAAA,EAEI,qBAAqB,UAA4B,YAAkC;AACzF,8BAA0B,qBAAqB,KAAK,eAAe,UAAU,UAAU;AAAA,EACxF;AAAA,EAEO,wBAAwB,UAA4B,YAA0C;AACpG,8BAA0B,wBAAwB,KAAK,eAAe,UAAU,UAAU;AAAA,EAC3F;AAAA,EAEA,IAAW,sBAAgD;AAC1D,WAAO,KAAK,cAAc;AAAA,EAC3B;AAAA,EAEA,IA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AK;AAAA,UACL,KAAK,mBAAmB;AACvB,iBAAK,eAAe,KAAK;AACzB;AAAA,UACD;AAAA,UACA,KAAK,cAAc;AAClB,uBAAW,aAAa,MAAM,SAAS,OAAA,GAAU;AAChD,mBAAK,eAAe,SAAS;AAAA,YAC9B;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAEA,UAAM,SAAS,iBAAiB;AAC5B,QAAA,OAAO,OAAO,SAAS,GAAG;AAC7B,WAAK,gBAAgB,MAAM;AAAA,IAC5B;AAAA,EACD;AAAA,EAEO,gBAAgB,QAAqB;AAC3C,eAAW,SAAS,OAAO,OAAO,OAAA,GAAU;AAC3C,WAAK,eAAe,KAAK;AAAA,IAC1B;AACA,SAAK,YAAY,OAAO,OAAO,GAAG,WAAW;AAC7C,SAAK,oBAAoB,OAAO,OAAO,GAAG,WAAW;AAAA,EACtD;AAAA,EAEO,uBAAuB,eAAwC;AACrE;AAAgB,iBAAW,oBAAoB,cAAc,SAAS,OAAA,GAAU;AAC3E,YAAA,iBAAiB,WAAW,YAAY;AAE3C;AAAA,QACD;AACA,mBAAW,QAAQ,KAAK,YAAY,OAAA,GAAU;AAC7C,qBAAW,yBAAyB,KAAK,SAAS,OAAA,GAAU;AAC3D,kBAAM,WAAW,iBAAiB,kBAAkB,kBAAkB,qBAAqB;AAC3F,gBAAI,UAAU;AACJ,uBAAA;AAAA,YACV;AAAA,UACD;AAAA,QACD;AACO,eAAA;AAAA,MACR;AACO,WAAA;AAAA,EACR;AACD;"}
|
|
1
|
+
{"version":3,"file":"TreeStore.js","sources":["../../../src/core/TreeStore.ts"],"sourcesContent":["import {\n\tNormalizedPersistedData,\n\tPersistedEntityDataStore,\n\tReceivedDataTree,\n\tSubTreeDataStore,\n\tUniqueEntityId,\n} from '../accessorTree'\nimport { BindingError } from '../BindingError'\nimport type { Environment } from '../dao'\nimport { MarkerTreeRoot, PlaceholderGenerator } from '../markers'\nimport { QueryLanguage } from '../queryLanguage'\nimport type {\n\tAlias,\n\tEntityId,\n\tEntityName,\n\tEntityRealmKey,\n\tFieldName,\n\tPlaceholderName,\n\tSugaredQualifiedEntityList,\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedEntityList,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '../treeParameters'\nimport { assertNever } from '../utils'\nimport { MarkerComparator } from './MarkerComparator'\nimport { RequestResponseNormalizer } from './RequestResponseNormalizer'\nimport type { Schema } from './schema'\nimport type { EntityListState, EntityRealmState, EntityRealmStateStub, EntityState, RootStateNode } from './state'\nimport { SubMutationOperation } from './MutationGenerator'\n\nconst emptyEntityIdSet: ReadonlySet<EntityId> = new Set()\n\nexport class TreeStore {\n\tpublic readonly entityStore: Map<UniqueEntityId, EntityState> = new Map()\n\tpublic readonly entityRealmStore: Map<EntityRealmKey, EntityRealmState | EntityRealmStateStub> = new Map()\n\n\t// This is tricky. We allow placeholder name duplicates, only the (TreeRootId, PlaceholderName) tuple is unique.\n\t// This is useful when the tree is extended to contain a sub-tree with the same placeholder.\n\tpublic readonly markerTrees: Map<TreeRootId | undefined, MarkerTreeRoot> = new Map()\n\tpublic readonly subTreeStatesByRoot: Map<TreeRootId | undefined, Map<PlaceholderName, RootStateNode>> = new Map()\n\n\tpublic readonly persistedData: NormalizedPersistedData = new NormalizedPersistedData(new Map(), new Map())\n\n\tpublic constructor(\n\t\tprivate readonly _schema: Schema,\n\t) {}\n\n\tpublic mergeInQueryResponse(response: ReceivedDataTree, markerTree: MarkerTreeRoot): void {\n\t\tRequestResponseNormalizer.mergeInQueryResponse(this.persistedData, response, markerTree)\n\t}\n\n\tpublic mergeInMutationResponse(response: ReceivedDataTree, operations: SubMutationOperation[]): void {\n\t\tRequestResponseNormalizer.mergeInMutationResponse(this.persistedData, response, operations)\n\t}\n\n\tpublic get persistedEntityData(): PersistedEntityDataStore {\n\t\treturn this.persistedData.persistedEntityDataStore\n\t}\n\n\tpublic get subTreePersistedData(): SubTreeDataStore {\n\t\treturn this.persistedData.subTreeDataStore\n\t}\n\n\tpublic get schema(): Schema {\n\t\treturn this._schema\n\t}\n\n\tpublic getPathBackToParent(entityRealm: EntityRealmState | EntityRealmStateStub):\n\t\t| {\n\t\t\t\tfieldBackToParent: FieldName\n\t\t\t\tparent: EntityRealmState\n\t\t }\n\t\t| undefined {\n\t\tconst blueprint = entityRealm.blueprint\n\t\tif (blueprint.parent === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tlet parentEntityName: EntityName\n\t\tlet relationFromParent: FieldName\n\t\tlet parent: EntityRealmState\n\n\t\tif (blueprint.type === 'hasOne') {\n\t\t\tparentEntityName = blueprint.parent.entity.entityName\n\t\t\trelationFromParent = blueprint.marker.parameters.field\n\t\t\tparent = blueprint.parent\n\t\t} else if (blueprint.type === 'listEntity') {\n\t\t\tconst grandparentBlueprint = blueprint.parent.blueprint\n\n\t\t\tif (grandparentBlueprint.parent === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tparentEntityName = grandparentBlueprint.parent.entity.entityName\n\t\t\trelationFromParent = grandparentBlueprint.marker.parameters.field\n\t\t\tparent = grandparentBlueprint.parent\n\t\t} else {\n\t\t\treturn assertNever(blueprint)\n\t\t}\n\n\t\tconst relationSchema = this.schema.getEntityRelation(parentEntityName, relationFromParent)\n\t\tconst fieldBack = (relationSchema.ownedBy || relationSchema.inversedBy) ?? null\n\n\t\t// console.log(parentEntityName, relationFromParent, entityRealm.entity.entityName, fieldBack)\n\t\tif (fieldBack === null) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\tparent,\n\t\t\tfieldBackToParent: fieldBack,\n\t\t}\n\t}\n\n\tpublic getSubTreeState(\n\t\tmode: 'entity',\n\t\ttreeRootId: TreeRootId | undefined,\n\t\taliasOrParameters: Alias | SugaredQualifiedSingleEntity | SugaredUnconstrainedQualifiedSingleEntity,\n\t\tenvironment: Environment,\n\t): EntityRealmState\n\tpublic getSubTreeState(\n\t\tmode: 'entityList',\n\t\ttreeRootId: TreeRootId | undefined,\n\t\taliasOrParameters: Alias | SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList,\n\t\tenvironment: Environment,\n\t): EntityListState\n\tpublic getSubTreeState(\n\t\tmode: 'entity' | 'entityList',\n\t\ttreeRootId: TreeRootId | undefined,\n\t\taliasOrParameters:\n\t\t\t| Alias\n\t\t\t| SugaredQualifiedSingleEntity\n\t\t\t| SugaredUnconstrainedQualifiedSingleEntity\n\t\t\t| SugaredQualifiedEntityList\n\t\t\t| SugaredUnconstrainedQualifiedEntityList,\n\t\tenvironment: Environment,\n\t): RootStateNode {\n\t\tconst markerRoot = this.markerTrees.get(treeRootId)\n\t\tconst subTreeStates = this.subTreeStatesByRoot.get(treeRootId)\n\n\t\tif (subTreeStates === undefined || markerRoot === undefined) {\n\t\t\tif (treeRootId) {\n\t\t\t\tthrow new BindingError(\n\t\t\t\t\t`Invalid tree id '${treeRootId}'. Make sure you use the one supplied by the correct extendTree call.`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tthrow new BindingError(`Failed to retrieve a sub tree.`)\n\t\t}\n\n\t\tlet placeholderName: string\n\n\t\tif (typeof aliasOrParameters === 'string') {\n\t\t\tconst placeholderByAlias = markerRoot.placeholdersByAliases.get(aliasOrParameters)\n\n\t\t\tif (placeholderByAlias === undefined) {\n\t\t\t\tthrow new BindingError(`Undefined sub-tree alias '${aliasOrParameters}'.`)\n\t\t\t}\n\t\t\tplaceholderName = placeholderByAlias\n\t\t} else if (mode === 'entityList') {\n\t\t\tplaceholderName = PlaceholderGenerator.getEntityListSubTreePlaceholder(\n\t\t\t\taliasOrParameters.isCreating\n\t\t\t\t\t? QueryLanguage.desugarUnconstrainedQualifiedEntityList(\n\t\t\t\t\t\t\taliasOrParameters as SugaredUnconstrainedQualifiedEntityList,\n\t\t\t\t\t\t\tenvironment,\n\t\t\t\t\t )\n\t\t\t\t\t: QueryLanguage.desugarQualifiedEntityList(aliasOrParameters as SugaredQualifiedEntityList, environment),\n\t\t\t\tenvironment,\n\t\t\t)\n\t\t} else if (mode === 'entity') {\n\t\t\tplaceholderName = PlaceholderGenerator.getEntitySubTreePlaceholder(\n\t\t\t\taliasOrParameters.isCreating\n\t\t\t\t\t? QueryLanguage.desugarUnconstrainedQualifiedSingleEntity(\n\t\t\t\t\t\t\taliasOrParameters as SugaredUnconstrainedQualifiedSingleEntity,\n\t\t\t\t\t\t\tenvironment,\n\t\t\t\t\t )\n\t\t\t\t\t: QueryLanguage.desugarQualifiedSingleEntity(aliasOrParameters as SugaredQualifiedSingleEntity, environment),\n\t\t\t\tenvironment,\n\t\t\t)\n\t\t} else {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\tconst subTreeState = subTreeStates.get(placeholderName)\n\n\t\tif (subTreeState === undefined) {\n\t\t\tthrow new BindingError(`Trying to retrieve a non-existent sub-tree '${placeholderName}'.`)\n\t\t}\n\t\treturn subTreeState\n\t}\n\n\tpublic getEntityListPersistedIds(state: EntityListState): ReadonlySet<EntityId> {\n\t\tconst blueprint = state.blueprint\n\n\t\tif (blueprint.parent) {\n\t\t\tconst entityData = this.persistedEntityData.get(blueprint.parent.entity.id.uniqueValue)\n\t\t\treturn (entityData?.get(blueprint.marker.placeholderName) as Set<string> | undefined) ?? emptyEntityIdSet\n\t\t} else {\n\t\t\treturn (this.subTreePersistedData.get(blueprint.marker.placeholderName) as Set<string>) ?? emptyEntityIdSet\n\t\t}\n\t}\n\n\tpublic disposeOfRealm(realmToDisposeOf: EntityRealmState | EntityRealmStateStub) {\n\t\tthis.entityRealmStore.delete(realmToDisposeOf.realmKey)\n\t\trealmToDisposeOf.entity.realms.delete(realmToDisposeOf.realmKey)\n\n\t\tif (realmToDisposeOf.type === 'entityRealm') {\n\t\t\trealmToDisposeOf.blueprint.parent?.childrenWithPendingUpdates?.delete(realmToDisposeOf)\n\n\t\t\tfor (const child of realmToDisposeOf.children.values()) {\n\t\t\t\tswitch (child.type) {\n\t\t\t\t\tcase 'field':\n\t\t\t\t\t\tcontinue\n\t\t\t\t\tcase 'entityRealm':\n\t\t\t\t\tcase 'entityRealmStub': {\n\t\t\t\t\t\tthis.disposeOfRealm(child)\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\tfor (const listChild of child.children.values()) {\n\t\t\t\t\t\t\tthis.disposeOfRealm(listChild)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst entity = realmToDisposeOf.entity\n\t\tif (entity.realms.size === 0) {\n\t\t\tthis.disposeOfEntity(entity)\n\t\t}\n\t}\n\n\tpublic disposeOfEntity(entity: EntityState) {\n\t\tfor (const realm of entity.realms.values()) {\n\t\t\tthis.disposeOfRealm(realm)\n\t\t}\n\t\tthis.entityStore.delete(entity.id.uniqueValue)\n\t\tthis.persistedEntityData.delete(entity.id.uniqueValue)\n\t}\n\n\tpublic effectivelyHasTreeRoot(candidateRoot: MarkerTreeRoot): boolean {\n\t\tcandidateRoots: for (const candidateSubTree of candidateRoot.subTrees.values()) {\n\t\t\tif (candidateSubTree.parameters.isCreating) {\n\t\t\t\t// This, by definition, won't trigger a query.\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor (const root of this.markerTrees.values()) {\n\t\t\t\tfor (const alreadyPresentSubTree of root.subTrees.values()) {\n\t\t\t\t\tconst isSubset = MarkerComparator.isSubTreeSubsetOf(candidateSubTree, alreadyPresentSubTree)\n\t\t\t\t\tif (isSubset) {\n\t\t\t\t\t\tcontinue candidateRoots\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\t\treturn true\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AA+BA,MAAM,uCAA8C;AAE7C,MAAM,UAAU;AAAA,EAWf,YACW,SAChB;AAZc,2DAAoD;AACpD,gEAAqF;AAIrF;AAAA;AAAA,2DAA+D;AAC/D,mEAA4F;AAE5F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A,UACD;AAAA,QACD;AACO,eAAA;AAAA,MACR;AACO,WAAA;AAAA,EACR;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VariableInputTransformer.cjs","sources":["../../../src/core/VariableInputTransformer.ts"],"sourcesContent":["import { BindingError } from '../BindingError'\nimport { Environment, VariableFieldValue } from '../dao'\nimport type { FieldValue, OptionallyVariableFieldValue } from '../treeParameters'\n\nexport class VariableInputTransformer {\n\tpublic static transformValue(value: OptionallyVariableFieldValue, environment: Environment): FieldValue {\n\t\tif (value instanceof VariableFieldValue) {\n\t\t\treturn VariableInputTransformer.transformVariableFieldValue(value, environment)\n\t\t}\n\t\treturn value\n\t}\n\n\tpublic static transformVariableFieldValue(variableFieldValue: VariableFieldValue, environment: Environment): FieldValue {\n\t\tconst value = environment.getVariableOrElse(variableFieldValue.variableName, undefined)\n\t\t\t?? environment.getParameterOrElse(variableFieldValue.variableName, undefined)\n\n\t\tif (value === undefined) {\n\t\t\tthrow new BindingError(`Variable '${variableFieldValue.variableName}' not found.`)\n\t\t}\n\n\t\tif (typeof value !== 'string' && typeof value !== 'boolean' && typeof value !== 'number' && value !== null) {\n\t\t\tthrow new BindingError(`The value of the '${variableFieldValue.variableName}' must be a scalar or null, not '${typeof value}'.`)\n\t\t}\n\t\treturn value\n\t}\n}\n"],"names":["VariableFieldValue","BindingError"],"mappings":";;;;AAIO,MAAM,yBAAyB;AAAA,EACrC,OAAc,eAAe,OAAqC,aAAsC;AACvG,QAAI,iBAAiBA,mBAAAA,oBAAoB;AACjC,aAAA,yBAAyB,4BAA4B,OAAO,WAAW;AAAA,IAC/E;AACO,WAAA;AAAA,EACR;AAAA,EAEA,OAAc,4BAA4B,oBAAwC,aAAsC;AACjH,UAAA,QAAQ,YAAY,kBAAkB,mBAAmB,cAAc,MAAS,KAClF,YAAY,mBAAmB,mBAAmB,cAAc,MAAS;AAE7E,QAAI,UAAU,QAAW;AACxB,YAAM,IAAIC,aAAA,aAAa,aAAa,mBAAmB,
|
|
1
|
+
{"version":3,"file":"VariableInputTransformer.cjs","sources":["../../../src/core/VariableInputTransformer.ts"],"sourcesContent":["import { BindingError } from '../BindingError'\nimport { Environment, VariableFieldValue } from '../dao'\nimport type { FieldValue, OptionallyVariableFieldValue } from '../treeParameters'\n\nexport class VariableInputTransformer {\n\tpublic static transformValue(value: OptionallyVariableFieldValue, environment: Environment): FieldValue {\n\t\tif (value instanceof VariableFieldValue) {\n\t\t\treturn VariableInputTransformer.transformVariableFieldValue(value, environment)\n\t\t}\n\t\treturn value\n\t}\n\n\tpublic static transformVariableFieldValue(variableFieldValue: VariableFieldValue, environment: Environment): FieldValue {\n\t\tconst value = environment.getVariableOrElse(variableFieldValue.variableName, undefined)\n\t\t\t?? environment.getParameterOrElse(variableFieldValue.variableName, undefined)\n\n\t\tif (value === undefined) {\n\t\t\tthrow new BindingError(`Variable '${variableFieldValue.variableName}' not found.`)\n\t\t}\n\n\t\tif (typeof value !== 'string' && typeof value !== 'boolean' && typeof value !== 'number' && value !== null) {\n\t\t\tthrow new BindingError(`The value of the '${variableFieldValue.variableName}' must be a scalar or null, not '${typeof value}'.`)\n\t\t}\n\t\treturn value\n\t}\n}\n"],"names":["VariableFieldValue","BindingError"],"mappings":";;;;AAIO,MAAM,yBAAyB;AAAA,EACrC,OAAc,eAAe,OAAqC,aAAsC;AACvG,QAAI,iBAAiBA,mBAAAA,oBAAoB;AACjC,aAAA,yBAAyB,4BAA4B,OAAO,WAAW;AAAA,IAC/E;AACO,WAAA;AAAA,EACR;AAAA,EAEA,OAAc,4BAA4B,oBAAwC,aAAsC;AACjH,UAAA,QAAQ,YAAY,kBAAkB,mBAAmB,cAAc,MAAS,KAClF,YAAY,mBAAmB,mBAAmB,cAAc,MAAS;AAE7E,QAAI,UAAU,QAAW;AACxB,YAAM,IAAIC,aAAA,aAAa,aAAa,mBAAmB,YAAY,cAAc;AAAA,IAClF;AAEI,QAAA,OAAO,UAAU,YAAY,OAAO,UAAU,aAAa,OAAO,UAAU,YAAY,UAAU,MAAM;AACrG,YAAA,IAAIA,aAAAA,aAAa,qBAAqB,mBAAmB,YAAY,oCAAoC,OAAO,KAAK,IAAI;AAAA,IAChI;AACO,WAAA;AAAA,EACR;AACD;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VariableInputTransformer.js","sources":["../../../src/core/VariableInputTransformer.ts"],"sourcesContent":["import { BindingError } from '../BindingError'\nimport { Environment, VariableFieldValue } from '../dao'\nimport type { FieldValue, OptionallyVariableFieldValue } from '../treeParameters'\n\nexport class VariableInputTransformer {\n\tpublic static transformValue(value: OptionallyVariableFieldValue, environment: Environment): FieldValue {\n\t\tif (value instanceof VariableFieldValue) {\n\t\t\treturn VariableInputTransformer.transformVariableFieldValue(value, environment)\n\t\t}\n\t\treturn value\n\t}\n\n\tpublic static transformVariableFieldValue(variableFieldValue: VariableFieldValue, environment: Environment): FieldValue {\n\t\tconst value = environment.getVariableOrElse(variableFieldValue.variableName, undefined)\n\t\t\t?? environment.getParameterOrElse(variableFieldValue.variableName, undefined)\n\n\t\tif (value === undefined) {\n\t\t\tthrow new BindingError(`Variable '${variableFieldValue.variableName}' not found.`)\n\t\t}\n\n\t\tif (typeof value !== 'string' && typeof value !== 'boolean' && typeof value !== 'number' && value !== null) {\n\t\t\tthrow new BindingError(`The value of the '${variableFieldValue.variableName}' must be a scalar or null, not '${typeof value}'.`)\n\t\t}\n\t\treturn value\n\t}\n}\n"],"names":[],"mappings":";;AAIO,MAAM,yBAAyB;AAAA,EACrC,OAAc,eAAe,OAAqC,aAAsC;AACvG,QAAI,iBAAiB,oBAAoB;AACjC,aAAA,yBAAyB,4BAA4B,OAAO,WAAW;AAAA,IAC/E;AACO,WAAA;AAAA,EACR;AAAA,EAEA,OAAc,4BAA4B,oBAAwC,aAAsC;AACjH,UAAA,QAAQ,YAAY,kBAAkB,mBAAmB,cAAc,MAAS,KAClF,YAAY,mBAAmB,mBAAmB,cAAc,MAAS;AAE7E,QAAI,UAAU,QAAW;AACxB,YAAM,IAAI,aAAa,aAAa,mBAAmB,
|
|
1
|
+
{"version":3,"file":"VariableInputTransformer.js","sources":["../../../src/core/VariableInputTransformer.ts"],"sourcesContent":["import { BindingError } from '../BindingError'\nimport { Environment, VariableFieldValue } from '../dao'\nimport type { FieldValue, OptionallyVariableFieldValue } from '../treeParameters'\n\nexport class VariableInputTransformer {\n\tpublic static transformValue(value: OptionallyVariableFieldValue, environment: Environment): FieldValue {\n\t\tif (value instanceof VariableFieldValue) {\n\t\t\treturn VariableInputTransformer.transformVariableFieldValue(value, environment)\n\t\t}\n\t\treturn value\n\t}\n\n\tpublic static transformVariableFieldValue(variableFieldValue: VariableFieldValue, environment: Environment): FieldValue {\n\t\tconst value = environment.getVariableOrElse(variableFieldValue.variableName, undefined)\n\t\t\t?? environment.getParameterOrElse(variableFieldValue.variableName, undefined)\n\n\t\tif (value === undefined) {\n\t\t\tthrow new BindingError(`Variable '${variableFieldValue.variableName}' not found.`)\n\t\t}\n\n\t\tif (typeof value !== 'string' && typeof value !== 'boolean' && typeof value !== 'number' && value !== null) {\n\t\t\tthrow new BindingError(`The value of the '${variableFieldValue.variableName}' must be a scalar or null, not '${typeof value}'.`)\n\t\t}\n\t\treturn value\n\t}\n}\n"],"names":[],"mappings":";;AAIO,MAAM,yBAAyB;AAAA,EACrC,OAAc,eAAe,OAAqC,aAAsC;AACvG,QAAI,iBAAiB,oBAAoB;AACjC,aAAA,yBAAyB,4BAA4B,OAAO,WAAW;AAAA,IAC/E;AACO,WAAA;AAAA,EACR;AAAA,EAEA,OAAc,4BAA4B,oBAAwC,aAAsC;AACjH,UAAA,QAAQ,YAAY,kBAAkB,mBAAmB,cAAc,MAAS,KAClF,YAAY,mBAAmB,mBAAmB,cAAc,MAAS;AAE7E,QAAI,UAAU,QAAW;AACxB,YAAM,IAAI,aAAa,aAAa,mBAAmB,YAAY,cAAc;AAAA,IAClF;AAEI,QAAA,OAAO,UAAU,YAAY,OAAO,UAAU,aAAa,OAAO,UAAU,YAAY,UAAU,MAAM;AACrG,YAAA,IAAI,aAAa,qBAAqB,mBAAmB,YAAY,oCAAoC,OAAO,KAAK,IAAI;AAAA,IAChI;AACO,WAAA;AAAA,EACR;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeParameterSugarer.cjs","sources":["../../../../src/core/exceptions/TreeParameterSugarer.ts"],"sourcesContent":["import type { EntityName, FieldName, Filter, UniqueWhere } from '../../treeParameters'\n\nexport class TreeParameterSugarer {\n\tpublic static sugarField(fieldName: FieldName) {\n\t\treturn fieldName\n\t}\n\n\tpublic static sugarHasOneRelation(\n\t\tfieldName: FieldName,\n\t\treducedBy: UniqueWhere | undefined,\n\t\tfilter: Filter | undefined,\n\t) {\n\t\treturn `${fieldName}${this.sugarUniqueWhere(reducedBy)}${this.sugarFilter(filter)}`\n\t}\n\n\tpublic static sugarHasManyRelation(fieldName: FieldName, filter: Filter | undefined) {\n\t\treturn `${fieldName}${this.sugarFilter(filter)}`\n\t}\n\n\tpublic static sugarRootEntity(entityName: EntityName, where: UniqueWhere | undefined) {\n\t\treturn `${entityName}${this.sugarUniqueWhere(where)}`\n\t}\n\n\tpublic static sugarRootEntityList(entityName: EntityName, filter: Filter | undefined) {\n\t\treturn `${entityName}${this.sugarFilter(filter)}`\n\t}\n\n\tpublic static sugarUniqueWhere(where: UniqueWhere | undefined): string {\n\t\tif (where === undefined) {\n\t\t\treturn ''\n\t\t}\n\t\treturn `(…)` // TODO\n\t}\n\n\tpublic static sugarFilter(filter: Filter | undefined): string {\n\t\tif (filter === undefined) {\n\t\t\treturn ''\n\t\t}\n\t\treturn `[…]` // TODO\n\t}\n}\n"],"names":[],"mappings":";;AAEO,MAAM,qBAAqB;AAAA,EACjC,OAAc,WAAW,WAAsB;AACvC,WAAA;AAAA,EACR;AAAA,EAEA,OAAc,oBACb,WACA,WACA,QACC;AACM,WAAA,GAAG,
|
|
1
|
+
{"version":3,"file":"TreeParameterSugarer.cjs","sources":["../../../../src/core/exceptions/TreeParameterSugarer.ts"],"sourcesContent":["import type { EntityName, FieldName, Filter, UniqueWhere } from '../../treeParameters'\n\nexport class TreeParameterSugarer {\n\tpublic static sugarField(fieldName: FieldName) {\n\t\treturn fieldName\n\t}\n\n\tpublic static sugarHasOneRelation(\n\t\tfieldName: FieldName,\n\t\treducedBy: UniqueWhere | undefined,\n\t\tfilter: Filter | undefined,\n\t) {\n\t\treturn `${fieldName}${this.sugarUniqueWhere(reducedBy)}${this.sugarFilter(filter)}`\n\t}\n\n\tpublic static sugarHasManyRelation(fieldName: FieldName, filter: Filter | undefined) {\n\t\treturn `${fieldName}${this.sugarFilter(filter)}`\n\t}\n\n\tpublic static sugarRootEntity(entityName: EntityName, where: UniqueWhere | undefined) {\n\t\treturn `${entityName}${this.sugarUniqueWhere(where)}`\n\t}\n\n\tpublic static sugarRootEntityList(entityName: EntityName, filter: Filter | undefined) {\n\t\treturn `${entityName}${this.sugarFilter(filter)}`\n\t}\n\n\tpublic static sugarUniqueWhere(where: UniqueWhere | undefined): string {\n\t\tif (where === undefined) {\n\t\t\treturn ''\n\t\t}\n\t\treturn `(…)` // TODO\n\t}\n\n\tpublic static sugarFilter(filter: Filter | undefined): string {\n\t\tif (filter === undefined) {\n\t\t\treturn ''\n\t\t}\n\t\treturn `[…]` // TODO\n\t}\n}\n"],"names":[],"mappings":";;AAEO,MAAM,qBAAqB;AAAA,EACjC,OAAc,WAAW,WAAsB;AACvC,WAAA;AAAA,EACR;AAAA,EAEA,OAAc,oBACb,WACA,WACA,QACC;AACM,WAAA,GAAG,SAAS,GAAG,KAAK,iBAAiB,SAAS,CAAC,GAAG,KAAK,YAAY,MAAM,CAAC;AAAA,EAClF;AAAA,EAEA,OAAc,qBAAqB,WAAsB,QAA4B;AACpF,WAAO,GAAG,SAAS,GAAG,KAAK,YAAY,MAAM,CAAC;AAAA,EAC/C;AAAA,EAEA,OAAc,gBAAgB,YAAwB,OAAgC;AACrF,WAAO,GAAG,UAAU,GAAG,KAAK,iBAAiB,KAAK,CAAC;AAAA,EACpD;AAAA,EAEA,OAAc,oBAAoB,YAAwB,QAA4B;AACrF,WAAO,GAAG,UAAU,GAAG,KAAK,YAAY,MAAM,CAAC;AAAA,EAChD;AAAA,EAEA,OAAc,iBAAiB,OAAwC;AACtE,QAAI,UAAU,QAAW;AACjB,aAAA;AAAA,IACR;AACO,WAAA;AAAA,EACR;AAAA,EAEA,OAAc,YAAY,QAAoC;AAC7D,QAAI,WAAW,QAAW;AAClB,aAAA;AAAA,IACR;AACO,WAAA;AAAA,EACR;AACD;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeParameterSugarer.js","sources":["../../../../src/core/exceptions/TreeParameterSugarer.ts"],"sourcesContent":["import type { EntityName, FieldName, Filter, UniqueWhere } from '../../treeParameters'\n\nexport class TreeParameterSugarer {\n\tpublic static sugarField(fieldName: FieldName) {\n\t\treturn fieldName\n\t}\n\n\tpublic static sugarHasOneRelation(\n\t\tfieldName: FieldName,\n\t\treducedBy: UniqueWhere | undefined,\n\t\tfilter: Filter | undefined,\n\t) {\n\t\treturn `${fieldName}${this.sugarUniqueWhere(reducedBy)}${this.sugarFilter(filter)}`\n\t}\n\n\tpublic static sugarHasManyRelation(fieldName: FieldName, filter: Filter | undefined) {\n\t\treturn `${fieldName}${this.sugarFilter(filter)}`\n\t}\n\n\tpublic static sugarRootEntity(entityName: EntityName, where: UniqueWhere | undefined) {\n\t\treturn `${entityName}${this.sugarUniqueWhere(where)}`\n\t}\n\n\tpublic static sugarRootEntityList(entityName: EntityName, filter: Filter | undefined) {\n\t\treturn `${entityName}${this.sugarFilter(filter)}`\n\t}\n\n\tpublic static sugarUniqueWhere(where: UniqueWhere | undefined): string {\n\t\tif (where === undefined) {\n\t\t\treturn ''\n\t\t}\n\t\treturn `(…)` // TODO\n\t}\n\n\tpublic static sugarFilter(filter: Filter | undefined): string {\n\t\tif (filter === undefined) {\n\t\t\treturn ''\n\t\t}\n\t\treturn `[…]` // TODO\n\t}\n}\n"],"names":[],"mappings":"AAEO,MAAM,qBAAqB;AAAA,EACjC,OAAc,WAAW,WAAsB;AACvC,WAAA;AAAA,EACR;AAAA,EAEA,OAAc,oBACb,WACA,WACA,QACC;AACM,WAAA,GAAG,
|
|
1
|
+
{"version":3,"file":"TreeParameterSugarer.js","sources":["../../../../src/core/exceptions/TreeParameterSugarer.ts"],"sourcesContent":["import type { EntityName, FieldName, Filter, UniqueWhere } from '../../treeParameters'\n\nexport class TreeParameterSugarer {\n\tpublic static sugarField(fieldName: FieldName) {\n\t\treturn fieldName\n\t}\n\n\tpublic static sugarHasOneRelation(\n\t\tfieldName: FieldName,\n\t\treducedBy: UniqueWhere | undefined,\n\t\tfilter: Filter | undefined,\n\t) {\n\t\treturn `${fieldName}${this.sugarUniqueWhere(reducedBy)}${this.sugarFilter(filter)}`\n\t}\n\n\tpublic static sugarHasManyRelation(fieldName: FieldName, filter: Filter | undefined) {\n\t\treturn `${fieldName}${this.sugarFilter(filter)}`\n\t}\n\n\tpublic static sugarRootEntity(entityName: EntityName, where: UniqueWhere | undefined) {\n\t\treturn `${entityName}${this.sugarUniqueWhere(where)}`\n\t}\n\n\tpublic static sugarRootEntityList(entityName: EntityName, filter: Filter | undefined) {\n\t\treturn `${entityName}${this.sugarFilter(filter)}`\n\t}\n\n\tpublic static sugarUniqueWhere(where: UniqueWhere | undefined): string {\n\t\tif (where === undefined) {\n\t\t\treturn ''\n\t\t}\n\t\treturn `(…)` // TODO\n\t}\n\n\tpublic static sugarFilter(filter: Filter | undefined): string {\n\t\tif (filter === undefined) {\n\t\t\treturn ''\n\t\t}\n\t\treturn `[…]` // TODO\n\t}\n}\n"],"names":[],"mappings":"AAEO,MAAM,qBAAqB;AAAA,EACjC,OAAc,WAAW,WAAsB;AACvC,WAAA;AAAA,EACR;AAAA,EAEA,OAAc,oBACb,WACA,WACA,QACC;AACM,WAAA,GAAG,SAAS,GAAG,KAAK,iBAAiB,SAAS,CAAC,GAAG,KAAK,YAAY,MAAM,CAAC;AAAA,EAClF;AAAA,EAEA,OAAc,qBAAqB,WAAsB,QAA4B;AACpF,WAAO,GAAG,SAAS,GAAG,KAAK,YAAY,MAAM,CAAC;AAAA,EAC/C;AAAA,EAEA,OAAc,gBAAgB,YAAwB,OAAgC;AACrF,WAAO,GAAG,UAAU,GAAG,KAAK,iBAAiB,KAAK,CAAC;AAAA,EACpD;AAAA,EAEA,OAAc,oBAAoB,YAAwB,QAA4B;AACrF,WAAO,GAAG,UAAU,GAAG,KAAK,YAAY,MAAM,CAAC;AAAA,EAChD;AAAA,EAEA,OAAc,iBAAiB,OAAwC;AACtE,QAAI,UAAU,QAAW;AACjB,aAAA;AAAA,IACR;AACO,WAAA;AAAA,EACR;AAAA,EAEA,OAAc,YAAY,QAAoC;AAC7D,QAAI,WAAW,QAAW;AAClB,aAAA;AAAA,IACR;AACO,WAAA;AAAA,EACR;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBatchUpdatesOptions.cjs","sources":["../../../../src/core/factories/createBatchUpdatesOptions.ts"],"sourcesContent":["import type { BatchUpdatesOptions, EntityAccessor, EntityListAccessor } from '../../accessors'\nimport { BindingError } from '../../BindingError'\nimport type { Environment } from '../../dao'\nimport type {\n\tAlias,\n\tSugaredQualifiedEntityList,\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedEntityList,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '../../treeParameters'\nimport type { TreeStore } from '../TreeStore'\n\nexport const createBatchUpdatesOptions = (rootEnvironment: Environment, treeStore: TreeStore): BatchUpdatesOptions =>\n\tObject.freeze({\n\t\tgetEntityByKey: (key: string) => {\n\t\t\tconst realm = treeStore.entityRealmStore.get(key)\n\n\t\t\tif (realm === undefined) {\n\t\t\t\tthrow new BindingError(`Trying to retrieve a non-existent entity: key '${key}' was not found.`)\n\t\t\t}\n\t\t\treturn realm.getAccessor()\n\t\t},\n\t\tgetEntityListSubTree: (\n\t\t\taliasOrParameters: Alias | SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList,\n\t\t\ttreeId: TreeRootId | undefined,\n\t\t\tenvironment = rootEnvironment,\n\t\t): EntityListAccessor => {\n\t\t\treturn treeStore.getSubTreeState('entityList', treeId, aliasOrParameters, environment).getAccessor()\n\t\t},\n\t\tgetEntitySubTree: (\n\t\t\taliasOrParameters: Alias | SugaredQualifiedSingleEntity | SugaredUnconstrainedQualifiedSingleEntity,\n\t\t\ttreeId: TreeRootId | undefined,\n\t\t\tenvironment = rootEnvironment,\n\t\t): EntityAccessor => {\n\t\t\treturn treeStore.getSubTreeState('entity', treeId, aliasOrParameters, environment).getAccessor()\n\t\t},\n\t})\n"],"names":["BindingError"],"mappings":";;;AAaO,MAAM,4BAA4B,CAAC,iBAA8B,cACvE,OAAO,OAAO;AAAA,EACb,gBAAgB,CAAC,QAAgB;AAChC,UAAM,QAAQ,UAAU,iBAAiB,IAAI,GAAG;AAEhD,QAAI,UAAU,QAAW;
|
|
1
|
+
{"version":3,"file":"createBatchUpdatesOptions.cjs","sources":["../../../../src/core/factories/createBatchUpdatesOptions.ts"],"sourcesContent":["import type { BatchUpdatesOptions, EntityAccessor, EntityListAccessor } from '../../accessors'\nimport { BindingError } from '../../BindingError'\nimport type { Environment } from '../../dao'\nimport type {\n\tAlias,\n\tSugaredQualifiedEntityList,\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedEntityList,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '../../treeParameters'\nimport type { TreeStore } from '../TreeStore'\n\nexport const createBatchUpdatesOptions = (rootEnvironment: Environment, treeStore: TreeStore): BatchUpdatesOptions =>\n\tObject.freeze({\n\t\tgetEntityByKey: (key: string) => {\n\t\t\tconst realm = treeStore.entityRealmStore.get(key)\n\n\t\t\tif (realm === undefined) {\n\t\t\t\tthrow new BindingError(`Trying to retrieve a non-existent entity: key '${key}' was not found.`)\n\t\t\t}\n\t\t\treturn realm.getAccessor()\n\t\t},\n\t\tgetEntityListSubTree: (\n\t\t\taliasOrParameters: Alias | SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList,\n\t\t\ttreeId: TreeRootId | undefined,\n\t\t\tenvironment = rootEnvironment,\n\t\t): EntityListAccessor => {\n\t\t\treturn treeStore.getSubTreeState('entityList', treeId, aliasOrParameters, environment).getAccessor()\n\t\t},\n\t\tgetEntitySubTree: (\n\t\t\taliasOrParameters: Alias | SugaredQualifiedSingleEntity | SugaredUnconstrainedQualifiedSingleEntity,\n\t\t\ttreeId: TreeRootId | undefined,\n\t\t\tenvironment = rootEnvironment,\n\t\t): EntityAccessor => {\n\t\t\treturn treeStore.getSubTreeState('entity', treeId, aliasOrParameters, environment).getAccessor()\n\t\t},\n\t})\n"],"names":["BindingError"],"mappings":";;;AAaO,MAAM,4BAA4B,CAAC,iBAA8B,cACvE,OAAO,OAAO;AAAA,EACb,gBAAgB,CAAC,QAAgB;AAChC,UAAM,QAAQ,UAAU,iBAAiB,IAAI,GAAG;AAEhD,QAAI,UAAU,QAAW;AACxB,YAAM,IAAIA,aAAA,aAAa,kDAAkD,GAAG,kBAAkB;AAAA,IAC/F;AACA,WAAO,MAAM;EACd;AAAA,EACA,sBAAsB,CACrB,mBACA,QACA,cAAc,oBACU;AACxB,WAAO,UAAU,gBAAgB,cAAc,QAAQ,mBAAmB,WAAW,EAAE;EACxF;AAAA,EACA,kBAAkB,CACjB,mBACA,QACA,cAAc,oBACM;AACpB,WAAO,UAAU,gBAAgB,UAAU,QAAQ,mBAAmB,WAAW,EAAE;EACpF;AACD,CAAC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBatchUpdatesOptions.js","sources":["../../../../src/core/factories/createBatchUpdatesOptions.ts"],"sourcesContent":["import type { BatchUpdatesOptions, EntityAccessor, EntityListAccessor } from '../../accessors'\nimport { BindingError } from '../../BindingError'\nimport type { Environment } from '../../dao'\nimport type {\n\tAlias,\n\tSugaredQualifiedEntityList,\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedEntityList,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '../../treeParameters'\nimport type { TreeStore } from '../TreeStore'\n\nexport const createBatchUpdatesOptions = (rootEnvironment: Environment, treeStore: TreeStore): BatchUpdatesOptions =>\n\tObject.freeze({\n\t\tgetEntityByKey: (key: string) => {\n\t\t\tconst realm = treeStore.entityRealmStore.get(key)\n\n\t\t\tif (realm === undefined) {\n\t\t\t\tthrow new BindingError(`Trying to retrieve a non-existent entity: key '${key}' was not found.`)\n\t\t\t}\n\t\t\treturn realm.getAccessor()\n\t\t},\n\t\tgetEntityListSubTree: (\n\t\t\taliasOrParameters: Alias | SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList,\n\t\t\ttreeId: TreeRootId | undefined,\n\t\t\tenvironment = rootEnvironment,\n\t\t): EntityListAccessor => {\n\t\t\treturn treeStore.getSubTreeState('entityList', treeId, aliasOrParameters, environment).getAccessor()\n\t\t},\n\t\tgetEntitySubTree: (\n\t\t\taliasOrParameters: Alias | SugaredQualifiedSingleEntity | SugaredUnconstrainedQualifiedSingleEntity,\n\t\t\ttreeId: TreeRootId | undefined,\n\t\t\tenvironment = rootEnvironment,\n\t\t): EntityAccessor => {\n\t\t\treturn treeStore.getSubTreeState('entity', treeId, aliasOrParameters, environment).getAccessor()\n\t\t},\n\t})\n"],"names":[],"mappings":";AAaO,MAAM,4BAA4B,CAAC,iBAA8B,cACvE,OAAO,OAAO;AAAA,EACb,gBAAgB,CAAC,QAAgB;AAChC,UAAM,QAAQ,UAAU,iBAAiB,IAAI,GAAG;AAEhD,QAAI,UAAU,QAAW;
|
|
1
|
+
{"version":3,"file":"createBatchUpdatesOptions.js","sources":["../../../../src/core/factories/createBatchUpdatesOptions.ts"],"sourcesContent":["import type { BatchUpdatesOptions, EntityAccessor, EntityListAccessor } from '../../accessors'\nimport { BindingError } from '../../BindingError'\nimport type { Environment } from '../../dao'\nimport type {\n\tAlias,\n\tSugaredQualifiedEntityList,\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedEntityList,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '../../treeParameters'\nimport type { TreeStore } from '../TreeStore'\n\nexport const createBatchUpdatesOptions = (rootEnvironment: Environment, treeStore: TreeStore): BatchUpdatesOptions =>\n\tObject.freeze({\n\t\tgetEntityByKey: (key: string) => {\n\t\t\tconst realm = treeStore.entityRealmStore.get(key)\n\n\t\t\tif (realm === undefined) {\n\t\t\t\tthrow new BindingError(`Trying to retrieve a non-existent entity: key '${key}' was not found.`)\n\t\t\t}\n\t\t\treturn realm.getAccessor()\n\t\t},\n\t\tgetEntityListSubTree: (\n\t\t\taliasOrParameters: Alias | SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList,\n\t\t\ttreeId: TreeRootId | undefined,\n\t\t\tenvironment = rootEnvironment,\n\t\t): EntityListAccessor => {\n\t\t\treturn treeStore.getSubTreeState('entityList', treeId, aliasOrParameters, environment).getAccessor()\n\t\t},\n\t\tgetEntitySubTree: (\n\t\t\taliasOrParameters: Alias | SugaredQualifiedSingleEntity | SugaredUnconstrainedQualifiedSingleEntity,\n\t\t\ttreeId: TreeRootId | undefined,\n\t\t\tenvironment = rootEnvironment,\n\t\t): EntityAccessor => {\n\t\t\treturn treeStore.getSubTreeState('entity', treeId, aliasOrParameters, environment).getAccessor()\n\t\t},\n\t})\n"],"names":[],"mappings":";AAaO,MAAM,4BAA4B,CAAC,iBAA8B,cACvE,OAAO,OAAO;AAAA,EACb,gBAAgB,CAAC,QAAgB;AAChC,UAAM,QAAQ,UAAU,iBAAiB,IAAI,GAAG;AAEhD,QAAI,UAAU,QAAW;AACxB,YAAM,IAAI,aAAa,kDAAkD,GAAG,kBAAkB;AAAA,IAC/F;AACA,WAAO,MAAM;EACd;AAAA,EACA,sBAAsB,CACrB,mBACA,QACA,cAAc,oBACU;AACxB,WAAO,UAAU,gBAAgB,cAAc,QAAQ,mBAAmB,WAAW,EAAE;EACxF;AAAA,EACA,kBAAkB,CACjB,mBACA,QACA,cAAc,oBACM;AACpB,WAAO,UAAU,gBAAgB,UAAU,QAAQ,mBAAmB,WAAW,EAAE;EACpF;AACD,CAAC;"}
|