@contember/binding 0.8.0-alpha.9 → 1.0.0-alpha.4
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/LICENSE +1 -1
- package/dist/binding.d.ts +26 -56
- package/dist/development/accessors/EntityAccessor.js +2 -1
- package/dist/development/accessors/EntityAccessor.js.map +1 -1
- package/dist/development/accessors/EntityListAccessor.js +3 -1
- package/dist/development/accessors/EntityListAccessor.js.map +1 -1
- package/dist/development/accessors/ErrorAccessor.js +7 -21
- package/dist/development/accessors/ErrorAccessor.js.map +1 -1
- package/dist/development/accessors/FieldAccessor.js +2 -1
- package/dist/development/accessors/FieldAccessor.js.map +1 -1
- package/dist/development/core/AccessorErrorManager.js +7 -4
- package/dist/development/core/AccessorErrorManager.js.map +1 -1
- package/dist/development/core/DataBinding.js +2 -0
- package/dist/development/core/DataBinding.js.map +1 -1
- package/dist/development/core/ErrorsPreprocessor.js +11 -16
- package/dist/development/core/ErrorsPreprocessor.js.map +1 -1
- package/dist/development/core/MutationGenerator.js +1 -1
- package/dist/development/core/MutationGenerator.js.map +1 -1
- package/dist/development/core/operations/EntityOperations.js +1 -1
- package/dist/development/core/operations/EntityOperations.js.map +1 -1
- package/dist/development/core/operations/FieldOperations.js +1 -1
- package/dist/development/core/operations/FieldOperations.js.map +1 -1
- package/dist/development/core/operations/ListOperations.js +1 -1
- package/dist/development/core/operations/ListOperations.js.map +1 -1
- package/dist/development/coreComponents/Entity.js +3 -12
- package/dist/development/coreComponents/Entity.js.map +1 -1
- package/dist/development/coreComponents/EntityList.js +0 -15
- package/dist/development/coreComponents/EntityList.js.map +1 -1
- package/dist/development/coreComponents/EntityListSubTree.js.map +1 -1
- package/dist/development/coreComponents/EntitySubTree.js.map +1 -1
- package/dist/development/coreComponents/HasMany.js.map +1 -1
- package/dist/development/coreComponents/HasOne.js.map +1 -1
- package/dist/production/accessors/EntityAccessor.js +2 -1
- package/dist/production/accessors/EntityAccessor.js.map +1 -1
- package/dist/production/accessors/EntityListAccessor.js +2 -1
- package/dist/production/accessors/EntityListAccessor.js.map +1 -1
- package/dist/production/accessors/ErrorAccessor.js +7 -27
- package/dist/production/accessors/ErrorAccessor.js.map +1 -1
- package/dist/production/accessors/FieldAccessor.js +2 -1
- package/dist/production/accessors/FieldAccessor.js.map +1 -1
- package/dist/production/core/AccessorErrorManager.js +7 -4
- package/dist/production/core/AccessorErrorManager.js.map +1 -1
- package/dist/production/core/DataBinding.js +2 -0
- package/dist/production/core/DataBinding.js.map +1 -1
- package/dist/production/core/ErrorsPreprocessor.js +11 -16
- package/dist/production/core/ErrorsPreprocessor.js.map +1 -1
- package/dist/production/core/MutationGenerator.js +1 -1
- package/dist/production/core/MutationGenerator.js.map +1 -1
- package/dist/production/core/operations/EntityOperations.js +1 -1
- package/dist/production/core/operations/EntityOperations.js.map +1 -1
- package/dist/production/core/operations/FieldOperations.js +1 -1
- package/dist/production/core/operations/FieldOperations.js.map +1 -1
- package/dist/production/core/operations/ListOperations.js +1 -1
- package/dist/production/core/operations/ListOperations.js.map +1 -1
- package/dist/production/coreComponents/Entity.js +3 -12
- package/dist/production/coreComponents/Entity.js.map +1 -1
- package/dist/production/coreComponents/EntityList.js +0 -15
- package/dist/production/coreComponents/EntityList.js.map +1 -1
- package/dist/production/coreComponents/EntityListSubTree.js.map +1 -1
- package/dist/production/coreComponents/EntitySubTree.js.map +1 -1
- package/dist/production/coreComponents/HasMany.js.map +1 -1
- package/dist/production/coreComponents/HasOne.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListOperations.js","sources":["../../../../src/core/operations/ListOperations.ts"],"sourcesContent":["import { validate as uuidValidate } from 'uuid'\nimport type { BatchUpdatesOptions, EntityAccessor, EntityListAccessor, ErrorAccessor } from '../../accessors'\nimport { RuntimeId, UnpersistedEntityDummyId } from '../../accessorTree'\nimport { BindingError } from '../../BindingError'\nimport type { AccessorErrorManager } from '../AccessorErrorManager'\nimport { EventManager } from '../EventManager'\nimport { ErrorLocator, LocalizedBindingError } from '../exceptions'\nimport { MarkerComparator } from '../MarkerComparator'\nimport { RealmKeyGenerator } from '../RealmKeyGenerator'\nimport { EntityListState, getEntityMarker, StateIterator } from '../state'\nimport type { StateInitializer } from '../StateInitializer'\nimport type { TreeStore } from '../TreeStore'\nimport { OperationsHelpers } from './OperationsHelpers'\nimport { EventListenersStore } from '../../treeParameters'\n\nexport class ListOperations {\n\tpublic constructor(\n\t\tprivate readonly accessorErrorManager: AccessorErrorManager,\n\t\tprivate readonly batchUpdatesOptions: BatchUpdatesOptions,\n\t\tprivate readonly eventManager: EventManager,\n\t\tprivate readonly stateInitializer: StateInitializer,\n\t\tprivate readonly treeStore: TreeStore,\n\t) {}\n\n\tpublic addError(listState: EntityListState, error: ErrorAccessor.SugaredValidationError): () => void {\n\t\treturn this.accessorErrorManager.addError(listState, { type: 'validation', error })\n\t}\n\n\tpublic addEventListener<Type extends keyof EntityListAccessor.RuntimeEntityListEventListenerMap>(\n\t\tstate: EntityListState,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityListAccessor.RuntimeEntityListEventListenerMap[Type],\n\t) {\n\t\tif (state.eventListeners === undefined) {\n\t\t\tstate.eventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.eventListeners.add(event, listener)\n\t}\n\n\tpublic addChildEventListener<Type extends keyof EntityAccessor.EntityEventListenerMap>(\n\t\tstate: EntityListState,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t) {\n\t\tif (state.childEventListeners === undefined) {\n\t\t\tstate.childEventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.childEventListeners.add(event, listener)\n\t}\n\n\tpublic batchUpdates(state: EntityListState, performUpdates: EntityListAccessor.BatchUpdatesHandler) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tperformUpdates(state.getAccessor, this.batchUpdatesOptions)\n\t\t})\n\t}\n\n\tpublic connectEntity(outerState: EntityListState, entityToConnect: EntityAccessor) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(outerState)\n\t\t\tconst stateToConnect = OperationsHelpers.resolveAndPrepareEntityToConnect(this.treeStore, entityToConnect)\n\t\t\tconst idToConnect = stateToConnect.entity.id\n\n\t\t\t// TODO disable this at the top-level.\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {\n\t\t\t\tif (state.entityName !== stateToConnect.entity.entityName) {\n\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t`EntityListAccessor.connectEntity: Attempting to connect at an entity of type ` +\n\t\t\t\t\t\t\t`'${stateToConnect.entity.entityName}' but '${state.entityName}' is expected.\\n\\n` +\n\t\t\t\t\t\t\t`Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tMarkerComparator.assertEntityMarkersSubsetOf(\n\t\t\t\t\t\tstate.blueprint.marker.fields,\n\t\t\t\t\t\tgetEntityMarker(stateToConnect).fields,\n\t\t\t\t\t)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof LocalizedBindingError) {\n\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t`Entity list: cannot connect entity with key '${entityToConnect.key}' because its fields are ` +\n\t\t\t\t\t\t\t\t`incompatible with entities found on this list. Make sure both trees are equivalent.\\n\\n` +\n\t\t\t\t\t\t\t\t`${error.message}\\n\\n` +\n\t\t\t\t\t\t\t\t(error.markerPath.length > 1\n\t\t\t\t\t\t\t\t\t? `Incompatibility found at: ${ErrorLocator.locateMarkerPath(error.markerPath)}.\\n\\n`\n\t\t\t\t\t\t\t\t\t: '') +\n\t\t\t\t\t\t\t\t`Entity list located at: ${ErrorLocator.locateInternalState(state)}.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t}\n\n\t\t\t\tif (state.children.has(idToConnect.value)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tthis.stateInitializer.initializeEntityRealm(idToConnect, state.entityName, {\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: state,\n\t\t\t\t}, stateToConnect)\n\n\t\t\t\tstate.plannedRemovals?.delete(idToConnect.value)\n\n\t\t\t\tlet changesDelta = 0\n\n\t\t\t\tif (persistedEntityIds.has(idToConnect.value)) {\n\t\t\t\t\t// It was removed from the list but now we're adding it back.\n\t\t\t\t\tchangesDelta--\n\t\t\t\t} else {\n\t\t\t\t\tchangesDelta++\n\t\t\t\t}\n\t\t\t\tif (stateToConnect.type === 'entityRealm') {\n\t\t\t\t\tchangesDelta += stateToConnect.unpersistedChangesCount\n\t\t\t\t}\n\n\t\t\t\tthis.eventManager.registerJustUpdated(state, changesDelta)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic disconnectEntity(listState: EntityListState, childEntity: EntityAccessor, options: {noPersist?: boolean}) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\t// TODO disable this at the top-level.\n\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(listState)\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, listState)) {\n\t\t\t\tconst disconnectedChildIdValue = childEntity.id\n\t\t\t\tconst disconnectedChildRealm = state.children.get(disconnectedChildIdValue)\n\n\t\t\t\tif (disconnectedChildRealm === undefined) {\n\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t`Entity list doesn't include an entity with id '${disconnectedChildIdValue}' and so it cannot remove it.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tthis.treeStore.disposeOfRealm(disconnectedChildRealm)\n\t\t\t\tlistState.children.delete(disconnectedChildIdValue)\n\n\t\t\t\tlet changesDelta = 0\n\n\t\t\t\tif (persistedEntityIds.has(disconnectedChildIdValue)) {\n\t\t\t\t\tchangesDelta++\n\n\t\t\t\t\tif (state.plannedRemovals === undefined) {\n\t\t\t\t\t\tstate.plannedRemovals = new Map()\n\t\t\t\t\t}\n\t\t\t\t\tif (!options.noPersist) {\n\t\t\t\t\t\tstate.plannedRemovals.set(disconnectedChildIdValue, 'disconnect')\n\t\t\t\t\t}\n\t\t\t\t} else if (disconnectedChildRealm.entity.id.existsOnServer) {\n\t\t\t\t\t// Disconnecting unpersisted entities doesn't constitute a change.\n\n\t\t\t\t\t// It wasn't on the list, then it was, and now we're removing it again.\n\t\t\t\t\tchangesDelta--\n\t\t\t\t}\n\n\t\t\t\tif (disconnectedChildRealm.type === 'entityRealm') {\n\t\t\t\t\t// Undoing whatever changes this child had caused.\n\t\t\t\t\tchangesDelta -= disconnectedChildRealm.unpersistedChangesCount\n\t\t\t\t}\n\n\t\t\t\tthis.eventManager.registerJustUpdated(state, changesDelta)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic createNewEntity(outerState: EntityListState, initialize: EntityAccessor.BatchUpdatesHandler | undefined): RuntimeId {\n\t\treturn this.eventManager.syncOperation((): RuntimeId => {\n\t\t\t// All siblings need to have the same id.\n\t\t\tconst id = new UnpersistedEntityDummyId()\n\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {\n\t\t\t\tconst newEntity = this.stateInitializer.initializeEntityRealm(id, state.entityName, {\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: state,\n\t\t\t\t})\n\n\t\t\t\tthis.stateInitializer.runImmediateUserInitialization(newEntity, initialize)\n\n\t\t\t\t// The act of creating the entity doesn't constitute a change unless there's something inside to persist.\n\t\t\t\t// TODO forceCreate\n\t\t\t\t// TODO defaultValue\n\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t}\n\t\t\treturn id\n\t\t})\n\t}\n\n\tpublic getChildEntityById(state: EntityListState, id: string) {\n\t\tconst realm = state.children.get(id)\n\t\tif (realm === undefined) {\n\t\t\tconst isRuntimeId = uuidValidate(id) || UnpersistedEntityDummyId.matchesDummyId(id)\n\t\t\tif (isRuntimeId) {\n\t\t\t\tthrow new BindingError(`EntityList: cannot retrieve an entity with id '${id}' as it is not on the list.`)\n\t\t\t}\n\t\t\tconst looksLikeKey = this.treeStore.entityRealmStore.has(id) || RealmKeyGenerator.vaguelyAppearsToBeAKey(id)\n\t\t\tthrow new BindingError(\n\t\t\t\t`EntityList: cannot retrieve an entity with id '${id}' because it's not a valid id.` +\n\t\t\t\t\t(looksLikeKey\n\t\t\t\t\t\t? `\\nThe supplied value appears to be an entity *key*, not an *id*. List accessors are indexed by ids ` +\n\t\t\t\t\t\t `and you can use \\`EntityAccessor.id\\` to obtain one. Keys, on the other hand, are globally unique and ` +\n\t\t\t\t\t\t `you can use \\`getEntityByKey\\` to get its EntityAccessor.`\n\t\t\t\t\t\t: ''),\n\t\t\t)\n\t\t}\n\t\treturn realm.getAccessor()\n\t}\n}\n"],"names":["uuidValidate"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"ListOperations.js","sources":["../../../../src/core/operations/ListOperations.ts"],"sourcesContent":["import { validate as uuidValidate } from 'uuid'\nimport type { BatchUpdatesOptions, EntityAccessor, EntityListAccessor, ErrorAccessor } from '../../accessors'\nimport { RuntimeId, UnpersistedEntityDummyId } from '../../accessorTree'\nimport { BindingError } from '../../BindingError'\nimport type { AccessorErrorManager } from '../AccessorErrorManager'\nimport { EventManager } from '../EventManager'\nimport { ErrorLocator, LocalizedBindingError } from '../exceptions'\nimport { MarkerComparator } from '../MarkerComparator'\nimport { RealmKeyGenerator } from '../RealmKeyGenerator'\nimport { EntityListState, getEntityMarker, StateIterator } from '../state'\nimport type { StateInitializer } from '../StateInitializer'\nimport type { TreeStore } from '../TreeStore'\nimport { OperationsHelpers } from './OperationsHelpers'\nimport { EventListenersStore } from '../../treeParameters'\n\nexport class ListOperations {\n\tpublic constructor(\n\t\tprivate readonly accessorErrorManager: AccessorErrorManager,\n\t\tprivate readonly batchUpdatesOptions: BatchUpdatesOptions,\n\t\tprivate readonly eventManager: EventManager,\n\t\tprivate readonly stateInitializer: StateInitializer,\n\t\tprivate readonly treeStore: TreeStore,\n\t) {}\n\n\tpublic addError(listState: EntityListState, error: ErrorAccessor.Error): () => void {\n\t\treturn this.accessorErrorManager.addError(listState, error)\n\t}\n\n\tpublic addEventListener<Type extends keyof EntityListAccessor.RuntimeEntityListEventListenerMap>(\n\t\tstate: EntityListState,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityListAccessor.RuntimeEntityListEventListenerMap[Type],\n\t) {\n\t\tif (state.eventListeners === undefined) {\n\t\t\tstate.eventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.eventListeners.add(event, listener)\n\t}\n\n\tpublic addChildEventListener<Type extends keyof EntityAccessor.EntityEventListenerMap>(\n\t\tstate: EntityListState,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t) {\n\t\tif (state.childEventListeners === undefined) {\n\t\t\tstate.childEventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.childEventListeners.add(event, listener)\n\t}\n\n\tpublic batchUpdates(state: EntityListState, performUpdates: EntityListAccessor.BatchUpdatesHandler) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tperformUpdates(state.getAccessor, this.batchUpdatesOptions)\n\t\t})\n\t}\n\n\tpublic connectEntity(outerState: EntityListState, entityToConnect: EntityAccessor) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(outerState)\n\t\t\tconst stateToConnect = OperationsHelpers.resolveAndPrepareEntityToConnect(this.treeStore, entityToConnect)\n\t\t\tconst idToConnect = stateToConnect.entity.id\n\n\t\t\t// TODO disable this at the top-level.\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {\n\t\t\t\tif (state.entityName !== stateToConnect.entity.entityName) {\n\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t`EntityListAccessor.connectEntity: Attempting to connect at an entity of type ` +\n\t\t\t\t\t\t\t`'${stateToConnect.entity.entityName}' but '${state.entityName}' is expected.\\n\\n` +\n\t\t\t\t\t\t\t`Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tMarkerComparator.assertEntityMarkersSubsetOf(\n\t\t\t\t\t\tstate.blueprint.marker.fields,\n\t\t\t\t\t\tgetEntityMarker(stateToConnect).fields,\n\t\t\t\t\t)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof LocalizedBindingError) {\n\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t`Entity list: cannot connect entity with key '${entityToConnect.key}' because its fields are ` +\n\t\t\t\t\t\t\t\t`incompatible with entities found on this list. Make sure both trees are equivalent.\\n\\n` +\n\t\t\t\t\t\t\t\t`${error.message}\\n\\n` +\n\t\t\t\t\t\t\t\t(error.markerPath.length > 1\n\t\t\t\t\t\t\t\t\t? `Incompatibility found at: ${ErrorLocator.locateMarkerPath(error.markerPath)}.\\n\\n`\n\t\t\t\t\t\t\t\t\t: '') +\n\t\t\t\t\t\t\t\t`Entity list located at: ${ErrorLocator.locateInternalState(state)}.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t}\n\n\t\t\t\tif (state.children.has(idToConnect.value)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tthis.stateInitializer.initializeEntityRealm(idToConnect, state.entityName, {\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: state,\n\t\t\t\t}, stateToConnect)\n\n\t\t\t\tstate.plannedRemovals?.delete(idToConnect.value)\n\n\t\t\t\tlet changesDelta = 0\n\n\t\t\t\tif (persistedEntityIds.has(idToConnect.value)) {\n\t\t\t\t\t// It was removed from the list but now we're adding it back.\n\t\t\t\t\tchangesDelta--\n\t\t\t\t} else {\n\t\t\t\t\tchangesDelta++\n\t\t\t\t}\n\t\t\t\tif (stateToConnect.type === 'entityRealm') {\n\t\t\t\t\tchangesDelta += stateToConnect.unpersistedChangesCount\n\t\t\t\t}\n\n\t\t\t\tthis.eventManager.registerJustUpdated(state, changesDelta)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic disconnectEntity(listState: EntityListState, childEntity: EntityAccessor, options: {noPersist?: boolean}) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\t// TODO disable this at the top-level.\n\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(listState)\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, listState)) {\n\t\t\t\tconst disconnectedChildIdValue = childEntity.id\n\t\t\t\tconst disconnectedChildRealm = state.children.get(disconnectedChildIdValue)\n\n\t\t\t\tif (disconnectedChildRealm === undefined) {\n\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t`Entity list doesn't include an entity with id '${disconnectedChildIdValue}' and so it cannot remove it.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tthis.treeStore.disposeOfRealm(disconnectedChildRealm)\n\t\t\t\tlistState.children.delete(disconnectedChildIdValue)\n\n\t\t\t\tlet changesDelta = 0\n\n\t\t\t\tif (persistedEntityIds.has(disconnectedChildIdValue)) {\n\t\t\t\t\tchangesDelta++\n\n\t\t\t\t\tif (state.plannedRemovals === undefined) {\n\t\t\t\t\t\tstate.plannedRemovals = new Map()\n\t\t\t\t\t}\n\t\t\t\t\tif (!options.noPersist) {\n\t\t\t\t\t\tstate.plannedRemovals.set(disconnectedChildIdValue, 'disconnect')\n\t\t\t\t\t}\n\t\t\t\t} else if (disconnectedChildRealm.entity.id.existsOnServer) {\n\t\t\t\t\t// Disconnecting unpersisted entities doesn't constitute a change.\n\n\t\t\t\t\t// It wasn't on the list, then it was, and now we're removing it again.\n\t\t\t\t\tchangesDelta--\n\t\t\t\t}\n\n\t\t\t\tif (disconnectedChildRealm.type === 'entityRealm') {\n\t\t\t\t\t// Undoing whatever changes this child had caused.\n\t\t\t\t\tchangesDelta -= disconnectedChildRealm.unpersistedChangesCount\n\t\t\t\t}\n\n\t\t\t\tthis.eventManager.registerJustUpdated(state, changesDelta)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic createNewEntity(outerState: EntityListState, initialize: EntityAccessor.BatchUpdatesHandler | undefined): RuntimeId {\n\t\treturn this.eventManager.syncOperation((): RuntimeId => {\n\t\t\t// All siblings need to have the same id.\n\t\t\tconst id = new UnpersistedEntityDummyId()\n\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {\n\t\t\t\tconst newEntity = this.stateInitializer.initializeEntityRealm(id, state.entityName, {\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: state,\n\t\t\t\t})\n\n\t\t\t\tthis.stateInitializer.runImmediateUserInitialization(newEntity, initialize)\n\n\t\t\t\t// The act of creating the entity doesn't constitute a change unless there's something inside to persist.\n\t\t\t\t// TODO forceCreate\n\t\t\t\t// TODO defaultValue\n\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t}\n\t\t\treturn id\n\t\t})\n\t}\n\n\tpublic getChildEntityById(state: EntityListState, id: string) {\n\t\tconst realm = state.children.get(id)\n\t\tif (realm === undefined) {\n\t\t\tconst isRuntimeId = uuidValidate(id) || UnpersistedEntityDummyId.matchesDummyId(id)\n\t\t\tif (isRuntimeId) {\n\t\t\t\tthrow new BindingError(`EntityList: cannot retrieve an entity with id '${id}' as it is not on the list.`)\n\t\t\t}\n\t\t\tconst looksLikeKey = this.treeStore.entityRealmStore.has(id) || RealmKeyGenerator.vaguelyAppearsToBeAKey(id)\n\t\t\tthrow new BindingError(\n\t\t\t\t`EntityList: cannot retrieve an entity with id '${id}' because it's not a valid id.` +\n\t\t\t\t\t(looksLikeKey\n\t\t\t\t\t\t? `\\nThe supplied value appears to be an entity *key*, not an *id*. List accessors are indexed by ids ` +\n\t\t\t\t\t\t `and you can use \\`EntityAccessor.id\\` to obtain one. Keys, on the other hand, are globally unique and ` +\n\t\t\t\t\t\t `you can use \\`getEntityByKey\\` to get its EntityAccessor.`\n\t\t\t\t\t\t: ''),\n\t\t\t)\n\t\t}\n\t\treturn realm.getAccessor()\n\t}\n}\n"],"names":["uuidValidate"],"mappings":"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"}
|
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import { createElement } from "react";
|
|
2
2
|
import { Component } from "./Component.js";
|
|
3
3
|
import { AccessorProvider } from "../accessorPropagation/AccessorProvider.js";
|
|
4
|
-
const Entity = Component((
|
|
5
|
-
let children = props.children;
|
|
6
|
-
if ("entityComponent" in props && props.entityComponent) {
|
|
7
|
-
const EntityComponent = props.entityComponent;
|
|
8
|
-
children = /* @__PURE__ */ createElement(EntityComponent, {
|
|
9
|
-
...props.entityProps,
|
|
10
|
-
accessor: props.accessor,
|
|
11
|
-
key: props.accessor?.key
|
|
12
|
-
}, children);
|
|
13
|
-
}
|
|
4
|
+
const Entity = Component(({ children, accessor }) => {
|
|
14
5
|
return /* @__PURE__ */ createElement(AccessorProvider, {
|
|
15
|
-
accessor
|
|
16
|
-
key:
|
|
6
|
+
accessor,
|
|
7
|
+
key: accessor?.key
|
|
17
8
|
}, children);
|
|
18
9
|
}, "Entity");
|
|
19
10
|
export { Entity };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Entity.js","sources":["../../../src/coreComponents/Entity.tsx"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"Entity.js","sources":["../../../src/coreComponents/Entity.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { AccessorProvider } from '../accessorPropagation'\nimport type { EntityAccessor } from '../accessors'\nimport { Component } from './Component'\n\nexport interface EntityBaseProps {\n\taccessor: EntityAccessor\n\tchildren?: ReactNode\n}\n\nexport type EntityProps = EntityBaseProps\n\nexport const Entity = Component(\n\t({ children, accessor }: EntityProps) => {\n\treturn (\n\t\t// HACK: the ?. is actually important, despite the typings.\n\t\t<AccessorProvider accessor={accessor} key={accessor?.key}>\n\t\t\t{children}\n\t\t</AccessorProvider>\n\t)\n\t},\n\t'Entity',\n)\n"],"names":[],"mappings":";;;MAYa,SAAS,UACrB,CAAC,EAAE,UAAU,eAA4B;uCAGvC,kBAAD;AAAA,IAAkB;AAAA,IAAoB,KAAK,UAAU;AAAA,KACnD;AAAA,GAIH;;"}
|
|
@@ -10,14 +10,6 @@ const EntityList = Component((props) => {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
return /* @__PURE__ */ createElement(Fragment, null, Array.from(props.accessor, (entity) => {
|
|
13
|
-
if ("entityComponent" in props && props.entityComponent) {
|
|
14
|
-
return /* @__PURE__ */ createElement(Entity, {
|
|
15
|
-
key: entity.key,
|
|
16
|
-
accessor: entity,
|
|
17
|
-
entityComponent: props.entityComponent,
|
|
18
|
-
entityProps: props.entityProps
|
|
19
|
-
}, props.children);
|
|
20
|
-
}
|
|
21
13
|
return /* @__PURE__ */ createElement(Entity, {
|
|
22
14
|
key: entity.key,
|
|
23
15
|
accessor: entity
|
|
@@ -31,13 +23,6 @@ const EntityList = Component((props) => {
|
|
|
31
23
|
children: props.children
|
|
32
24
|
});
|
|
33
25
|
}
|
|
34
|
-
if ("entityComponent" in props && props.entityComponent) {
|
|
35
|
-
return /* @__PURE__ */ createElement(Entity, {
|
|
36
|
-
accessor: void 0,
|
|
37
|
-
entityComponent: props.entityComponent,
|
|
38
|
-
entityProps: props.entityProps
|
|
39
|
-
}, props.children);
|
|
40
|
-
}
|
|
41
26
|
return /* @__PURE__ */ createElement(Fragment, null, props.children);
|
|
42
27
|
}, "EntityList");
|
|
43
28
|
export { EntityList };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityList.js","sources":["../../../src/coreComponents/EntityList.tsx"],"sourcesContent":["import { ComponentType, createElement, ReactElement, ReactNode } from 'react'\nimport type { EntityListAccessor } from '../accessors'\nimport { Component } from './Component'\nimport { Entity
|
|
1
|
+
{"version":3,"file":"EntityList.js","sources":["../../../src/coreComponents/EntityList.tsx"],"sourcesContent":["import { ComponentType, createElement, ReactElement, ReactNode } from 'react'\nimport type { EntityListAccessor } from '../accessors'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\n\nexport interface EntityListBaseProps {\n\taccessor: EntityListAccessor\n\tchildren?: ReactNode\n}\n\nexport type EntityListProps<ListProps> = EntityListBaseProps &\n\t(\n\t\t| {}\n\t\t| {\n\t\t\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\t\t\tlistProps?: ListProps\n\t\t }\n\t)\n\nexport const EntityList = Component(\n\t<ListProps extends {}>(props: EntityListProps<ListProps>) => {\n\t\tif ('listComponent' in props && props.listComponent) {\n\t\t\treturn createElement(props.listComponent, {\n\t\t\t\t...props.listProps!,\n\t\t\t\taccessor: props.accessor,\n\t\t\t\tchildren: props.children,\n\t\t\t})\n\t\t}\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{Array.from(props.accessor, entity => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Entity key={entity.key} accessor={entity}>\n\t\t\t\t\t\t\t{props.children}\n\t\t\t\t\t\t</Entity>\n\t\t\t\t\t)\n\t\t\t\t})}\n\t\t\t</>\n\t\t)\n\t},\n\t<ListProps extends {}>(props: EntityListProps<ListProps>) => {\n\t\tif ('listComponent' in props && props.listComponent) {\n\t\t\treturn createElement(props.listComponent, {\n\t\t\t\t...props.listProps!,\n\t\t\t\taccessor: undefined as any,\n\t\t\t\tchildren: props.children,\n\t\t\t})\n\t\t}\n\t\treturn <>{props.children}</>\n\t},\n\t'EntityList',\n) as <ListProps>(props: EntityListProps<ListProps>) => ReactElement\n"],"names":[],"mappings":";;;MAmBa,aAAa,UACzB,CAAuB,UAAsC;MACxD,mBAAmB,SAAS,MAAM,eAAe;WAC7C,cAAc,MAAM,eAAe;AAAA,SACtC,MAAM;AAAA,MACT,UAAU,MAAM;AAAA,MAChB,UAAU,MAAM;AAAA;AAAA;uDAKf,MAAM,KAAK,MAAM,UAAU,YAAU;yCAEnC,QAAD;AAAA,MAAQ,KAAK,OAAO;AAAA,MAAK,UAAU;AAAA,OACjC,MAAM;AAAA;AAAA,GAOb,CAAuB,UAAsC;MACxD,mBAAmB,SAAS,MAAM,eAAe;WAC7C,cAAc,MAAM,eAAe;AAAA,SACtC,MAAM;AAAA,MACT,UAAU;AAAA,MACV,UAAU,MAAM;AAAA;AAAA;uDAGR,MAAM;AAAA,GAEjB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityListSubTree.js","sources":["../../../src/coreComponents/EntityListSubTree.tsx"],"sourcesContent":["import { whereToFilter } from '@contember/client'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { ComponentType, ReactElement, ReactNode, useCallback } from 'react'\nimport {\n\tuseAccessorUpdateSubscription,\n\tuseEntityListSubTreeParameters,\n\tuseGetEntityListSubTree,\n} from '../accessorPropagation'\nimport { NIL_UUID, PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredQualifiedEntityList, SugaredUnconstrainedQualifiedEntityList, TreeRootId } from '../treeParameters'\nimport { Component } from './Component'\nimport
|
|
1
|
+
{"version":3,"file":"EntityListSubTree.js","sources":["../../../src/coreComponents/EntityListSubTree.tsx"],"sourcesContent":["import { whereToFilter } from '@contember/client'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { ComponentType, ReactElement, ReactNode, useCallback } from 'react'\nimport {\n\tuseAccessorUpdateSubscription,\n\tuseEntityListSubTreeParameters,\n\tuseGetEntityListSubTree,\n} from '../accessorPropagation'\nimport { NIL_UUID, PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredQualifiedEntityList, SugaredUnconstrainedQualifiedEntityList, TreeRootId } from '../treeParameters'\nimport { Component } from './Component'\nimport { EntityList, EntityListBaseProps } from './EntityList'\nimport { Field } from './Field'\n\nexport interface EntityListSubTreeAdditionalProps {\n\tvariables?: Environment.DeltaFactory\n}\n\nexport type EntityListSubTreeProps<ListProps, EntityProps> = {\n\ttreeRootId?: TreeRootId\n\tchildren?: ReactNode\n} & EntityListSubTreeAdditionalProps &\n\t(SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList) &\n\t(\n\t\t| {}\n\t\t| {\n\t\t\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\t\t\tlistProps?: ListProps\n\t\t }\n\t)\n\nexport const EntityListSubTree = Component(\n\t<ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntityListSubTree: cannot update isCreating')\n\n\t\tconst getSubTree = useGetEntityListSubTree()\n\t\tconst parameters = useEntityListSubTreeParameters(props)\n\t\tconst getAccessor = useCallback(\n\t\t\t() => getSubTree(parameters, props.treeRootId),\n\t\t\t[getSubTree, parameters, props.treeRootId],\n\t\t)\n\t\tconst accessor = useAccessorUpdateSubscription(getAccessor)\n\n\t\t// TODO revive top level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ?\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne\n\t\t// ) :\n\t\t// \tprops.children\n\t\t// )\n\t\treturn <EntityList {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntityListSubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntityListSubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<EntityList {...props} accessor={0 as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</EntityList>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst newEnvironment =\n\t\t\t\tprops.variables === undefined\n\t\t\t\t\t? oldEnvironment\n\t\t\t\t\t: oldEnvironment.putDelta(Environment.generateDelta(oldEnvironment, props.variables))\n\n\t\t\tif (newEnvironment.hasName('rootWhere') || newEnvironment.hasName('rootWhereAsFilter')) {\n\t\t\t\treturn newEnvironment\n\t\t\t}\n\n\t\t\tconst rootWhere = { id: NIL_UUID } as const\n\t\t\treturn newEnvironment.putDelta({\n\t\t\t\trootWhere,\n\t\t\t\trootWhereAsFilter: whereToFilter(rootWhere),\n\t\t\t})\n\t\t},\n\t},\n\t'EntityListSubTree',\n) as <ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => ReactElement\n"],"names":[],"mappings":";;;;;;;;;;;;MAiCa,oBAAoB,UAChC,CAAyB,UAA0D;4BACxD,MAAM,YAAY;QAEtC,aAAa;QACb,aAAa,+BAA+B;QAC5C,cAAc,YACnB,MAAM,WAAW,YAAY,MAAM,aACnC,CAAC,YAAY,YAAY,MAAM;QAE1B,WAAW,8BAA8B;uCAQvC,YAAD;AAAA,OAAgB;AAAA,IAAO;AAAA;AAAA,GAE/B;AAAA,EACC,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;QACjD,gBAAgB,SAAS,MAAM,YAAY;aACvC,cAAc,2CAA2C,OAAO,QAAQ;AAAA;WAEzE,cAAc,8BAA8B,OAAO,QAAQ;AAAA;AAAA,EAEnE,cAAc,yCACZ,YAAD;AAAA,OAAgB;AAAA,IAAO,UAAU;AAAA,mCAC/B,OAAD;AAAA,IAAO,OAAO;AAAA,MACb,MAAM;AAAA,EAGT,qBAAqB,CAAC,OAAO,mBAAmB;UACzC,iBACL,MAAM,cAAc,SACjB,iBACA,eAAe,SAAS,YAAY,cAAc,gBAAgB,MAAM;QAExE,eAAe,QAAQ,gBAAgB,eAAe,QAAQ,sBAAsB;aAChF;AAAA;UAGF,YAAY,EAAE,IAAI;WACjB,eAAe,SAAS;AAAA,MAC9B;AAAA,MACA,mBAAmB,cAAc;AAAA;AAAA;AAAA,GAIpC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntitySubTree.js","sources":["../../../src/coreComponents/EntitySubTree.tsx"],"sourcesContent":["import { whereToFilter } from '@contember/client'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport {
|
|
1
|
+
{"version":3,"file":"EntitySubTree.js","sources":["../../../src/coreComponents/EntitySubTree.tsx"],"sourcesContent":["import { whereToFilter } from '@contember/client'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback } from 'react'\nimport { useAccessorUpdateSubscription, useEntitySubTreeParameters, useGetEntitySubTree } from '../accessorPropagation'\nimport { SetOrderFieldOnCreate, SetOrderFieldOnCreateOwnProps } from '../accessorSorting'\nimport { NIL_UUID, PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory, QueryLanguage } from '../queryLanguage'\nimport type {\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '../treeParameters'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\n\nexport interface EntitySubTreeAdditionalProps {\n\tvariables?: Environment.DeltaFactory\n}\n\nexport type EntitySubTreeAdditionalCreationProps = {} | SetOrderFieldOnCreateOwnProps\n\nexport type EntitySubTreeProps<EntityProps> = {\n\ttreeRootId?: TreeRootId\n\tchildren?: ReactNode\n} & EntitySubTreeAdditionalProps &\n\t(SugaredQualifiedSingleEntity | (SugaredUnconstrainedQualifiedSingleEntity & EntitySubTreeAdditionalCreationProps))\nexport const EntitySubTree = Component(\n\t<EntityProps extends {}>(props: EntitySubTreeProps<EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntitySubTree: cannot update isCreating')\n\n\t\tconst getSubTree = useGetEntitySubTree()\n\t\tconst parameters = useEntitySubTreeParameters(props)\n\t\tconst getAccessor = useCallback(\n\t\t\t() => getSubTree(parameters, props.treeRootId),\n\t\t\t[getSubTree, parameters, props.treeRootId],\n\t\t)\n\t\tconst accessor = useAccessorUpdateSubscription(getAccessor)\n\n\t\t// TODO revive top-level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ? (\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne>\n\t\t// ) : (\n\t\t// \tprops.children\n\t\t// )}\n\t\treturn <Entity {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntitySubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntitySubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t<Entity {...props} accessor={0 as any}>\n\t\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t\t{props.children}\n\t\t\t\t</Entity>\n\t\t\t\t{props.isCreating && 'orderField' in props && (\n\t\t\t\t\t<SetOrderFieldOnCreate\n\t\t\t\t\t\torderField={props.orderField}\n\t\t\t\t\t\tnewOrderFieldValue={props.newOrderFieldValue}\n\t\t\t\t\t\tentity={props.entity}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst newEnvironment =\n\t\t\t\tprops.variables === undefined\n\t\t\t\t\t? oldEnvironment\n\t\t\t\t\t: oldEnvironment.putDelta(Environment.generateDelta(oldEnvironment, props.variables))\n\n\t\t\tif (newEnvironment.hasName('rootWhere') || newEnvironment.hasName('rootWhereAsFilter')) {\n\t\t\t\treturn newEnvironment\n\t\t\t}\n\n\t\t\tif (props.isCreating) {\n\t\t\t\tconst rootWhere = { id: NIL_UUID } as const\n\t\t\t\treturn newEnvironment.putDelta({\n\t\t\t\t\trootWhere,\n\t\t\t\t\trootWhereAsFilter: whereToFilter(rootWhere),\n\t\t\t\t\trootShouldExists: 'no',\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst qualifiedSingleEntity = QueryLanguage.desugarQualifiedSingleEntity(props, newEnvironment, { missingSetOnCreate: 'fill' })\n\t\t\treturn newEnvironment.putDelta({\n\t\t\t\trootWhere: qualifiedSingleEntity.where,\n\t\t\t\trootWhereAsFilter: whereToFilter(qualifiedSingleEntity.where),\n\t\t\t\trootShouldExists: qualifiedSingleEntity.setOnCreate ? 'maybe' : 'yes',\n\t\t\t})\n\t\t},\n\t},\n\t'EntitySubTree',\n) as <EntityProps>(pros: EntitySubTreeProps<EntityProps>) => ReactElement\n"],"names":[],"mappings":";;;;;;;;;;;;;;MA4Ba,gBAAgB,UAC5B,CAAyB,UAA2C;4BACzC,MAAM,YAAY;QAEtC,aAAa;QACb,aAAa,2BAA2B;QACxC,cAAc,YACnB,MAAM,WAAW,YAAY,MAAM,aACnC,CAAC,YAAY,YAAY,MAAM;QAE1B,WAAW,8BAA8B;uCAQvC,QAAD;AAAA,OAAY;AAAA,IAAO;AAAA;AAAA,GAE3B;AAAA,EACC,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;QACjD,gBAAgB,SAAS,MAAM,YAAY;aACvC,cAAc,uCAAuC,OAAO,QAAQ;AAAA;WAErE,cAAc,0BAA0B,OAAO,QAAQ;AAAA;AAAA,EAE/D,cAAc,uFAEX,QAAD;AAAA,OAAY;AAAA,IAAO,UAAU;AAAA,mCAC3B,OAAD;AAAA,IAAO,OAAO;AAAA,MACb,MAAM,WAEP,MAAM,cAAc,gBAAgB,uCACnC,uBAAD;AAAA,IACC,YAAY,MAAM;AAAA,IAClB,oBAAoB,MAAM;AAAA,IAC1B,QAAQ,MAAM;AAAA;AAAA,EAKlB,qBAAqB,CAAC,OAAO,mBAAmB;UACzC,iBACL,MAAM,cAAc,SACjB,iBACA,eAAe,SAAS,YAAY,cAAc,gBAAgB,MAAM;QAExE,eAAe,QAAQ,gBAAgB,eAAe,QAAQ,sBAAsB;aAChF;AAAA;QAGJ,MAAM,YAAY;YACf,YAAY,EAAE,IAAI;aACjB,eAAe,SAAS;AAAA,QAC9B;AAAA,QACA,mBAAmB,cAAc;AAAA,QACjC,kBAAkB;AAAA;AAAA;UAGd,wBAAwB,cAAc,6BAA6B,OAAO,gBAAgB,EAAE,oBAAoB;WAC/G,eAAe,SAAS;AAAA,MAC9B,WAAW,sBAAsB;AAAA,MACjC,mBAAmB,cAAc,sBAAsB;AAAA,MACvD,kBAAkB,sBAAsB,cAAc,UAAU;AAAA;AAAA;AAAA,GAInE;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasMany.js","sources":["../../../src/coreComponents/HasMany.tsx"],"sourcesContent":["import type { ComponentType, ReactElement, ReactNode } from 'react'\nimport { useEntityList } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredRelativeEntityList } from '../treeParameters'\nimport { Component } from './Component'\nimport type { EntityBaseProps } from './Entity'\nimport { EntityList, EntityListBaseProps } from './EntityList'\nimport { Field } from './Field'\n\nexport type HasManyProps<ListProps = never, EntityProps = never> = SugaredRelativeEntityList & {\n\tchildren?: ReactNode\n\tvariables?: Environment.DeltaFactory\n} & (\n\t\t| {}\n\t\t| {\n\t\t\t\
|
|
1
|
+
{"version":3,"file":"HasMany.js","sources":["../../../src/coreComponents/HasMany.tsx"],"sourcesContent":["import type { ComponentType, ReactElement, ReactNode } from 'react'\nimport { useEntityList } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredRelativeEntityList } from '../treeParameters'\nimport { Component } from './Component'\nimport type { EntityBaseProps } from './Entity'\nimport { EntityList, EntityListBaseProps } from './EntityList'\nimport { Field } from './Field'\n\nexport type HasManyProps<ListProps = never, EntityProps = never> = SugaredRelativeEntityList & {\n\tchildren?: ReactNode\n\tvariables?: Environment.DeltaFactory\n} & (\n\t\t| {}\n\t\t| {\n\t\t\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\t\t\tlistProps?: ListProps\n\t\t }\n\t)\n\nexport const HasMany = Component(\n\t<ListProps, EntityProps>(props: HasManyProps<ListProps, EntityProps>) => {\n\t\tconst entityList = useEntityList(props)\n\n\t\treturn <EntityList {...props} accessor={entityList} />\n\t},\n\t{\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tif (props.variables === undefined) {\n\t\t\t\treturn oldEnvironment\n\t\t\t}\n\t\t\treturn oldEnvironment.putDelta(Environment.generateDelta(oldEnvironment, props.variables))\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<EntityList {...props} accessor={undefined as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</EntityList>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createRelativeEntityListFields(props, environment, fields),\n\t},\n\t'HasMany',\n) as <ListProps, EntityProps>(props: HasManyProps<ListProps, EntityProps>) => ReactElement\n"],"names":[],"mappings":";;;;;;;;MAsBa,UAAU,UACtB,CAAyB,UAAgD;QAClE,aAAa,cAAc;uCAEzB,YAAD;AAAA,OAAgB;AAAA,IAAO,UAAU;AAAA;AAAA,GAEzC;AAAA,EACC,qBAAqB,CAAC,OAAO,mBAAmB;QAC3C,MAAM,cAAc,QAAW;aAC3B;AAAA;WAED,eAAe,SAAS,YAAY,cAAc,gBAAgB,MAAM;AAAA;AAAA,EAEhF,cAAc,yCACZ,YAAD;AAAA,OAAgB;AAAA,IAAO,UAAU;AAAA,mCAC/B,OAAD;AAAA,IAAO,OAAO;AAAA,MACb,MAAM;AAAA,EAGT,sBAAsB,CAAC,OAAO,QAAQ,gBACrC,cAAc,+BAA+B,OAAO,aAAa;AAAA,GAEnE;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasOne.js","sources":["../../../src/coreComponents/HasOne.tsx"],"sourcesContent":["import type { ComponentType, ReactElement, ReactNode } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredRelativeSingleEntity } from '../treeParameters'\nimport { Component } from './Component'\nimport { Entity, EntityBaseProps } from './Entity'\nimport { Field } from './Field'\n\nexport type HasOneProps<EntityProps = never> = SugaredRelativeSingleEntity & {\n\tchildren?: ReactNode\n\tvariables?: Environment.DeltaFactory\n}
|
|
1
|
+
{"version":3,"file":"HasOne.js","sources":["../../../src/coreComponents/HasOne.tsx"],"sourcesContent":["import type { ComponentType, ReactElement, ReactNode } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredRelativeSingleEntity } from '../treeParameters'\nimport { Component } from './Component'\nimport { Entity, EntityBaseProps } from './Entity'\nimport { Field } from './Field'\n\nexport type HasOneProps<EntityProps = never> = SugaredRelativeSingleEntity & {\n\tchildren?: ReactNode\n\tvariables?: Environment.DeltaFactory\n}\n\nexport const HasOne = Component(\n\t<EntityProps extends {}>(props: HasOneProps<EntityProps>) => {\n\t\tconst entity = useEntity(props)\n\n\t\treturn <Entity {...props} accessor={entity} />\n\t},\n\t{\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tif (props.variables === undefined) {\n\t\t\t\treturn oldEnvironment\n\t\t\t}\n\t\t\treturn oldEnvironment.putDelta(Environment.generateDelta(oldEnvironment, props.variables))\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<Entity {...props} accessor={undefined as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</Entity>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createRelativeSingleEntityFields(props, environment, fields),\n\t},\n\t'HasOne',\n) as <EntityProps extends {}>(props: HasOneProps<EntityProps>) => ReactElement\n"],"names":[],"mappings":";;;;;;;;MAea,SAAS,UACrB,CAAyB,UAAoC;QACtD,SAAS,UAAU;uCAEjB,QAAD;AAAA,OAAY;AAAA,IAAO,UAAU;AAAA;AAAA,GAErC;AAAA,EACC,qBAAqB,CAAC,OAAO,mBAAmB;QAC3C,MAAM,cAAc,QAAW;aAC3B;AAAA;WAED,eAAe,SAAS,YAAY,cAAc,gBAAgB,MAAM;AAAA;AAAA,EAEhF,cAAc,yCACZ,QAAD;AAAA,OAAY;AAAA,IAAO,UAAU;AAAA,mCAC3B,OAAD;AAAA,IAAO,OAAO;AAAA,MACb,MAAM;AAAA,EAGT,sBAAsB,CAAC,OAAO,QAAQ,gBACrC,cAAc,iCAAiC,OAAO,aAAa;AAAA,GAErE;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/binding",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.0-alpha.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/production/index.js",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
],
|
|
19
19
|
"typings": "./dist/binding.d.ts",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@contember/client": "0.
|
|
22
|
-
"@contember/react-client": "0.
|
|
23
|
-
"@contember/react-multipass-rendering": "0.
|
|
24
|
-
"@contember/react-utils": "0.
|
|
21
|
+
"@contember/client": "1.0.0-alpha.4",
|
|
22
|
+
"@contember/react-client": "1.0.0-alpha.4",
|
|
23
|
+
"@contember/react-multipass-rendering": "1.0.0-alpha.4",
|
|
24
|
+
"@contember/react-utils": "1.0.0-alpha.4",
|
|
25
25
|
"chevrotain": "6.5.0",
|
|
26
26
|
"js-levenshtein": "1.1.6",
|
|
27
27
|
"uuid": "8.3.2"
|