@contember/binding 1.0.0-rc.13 → 1.0.0-rc.16

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.
@@ -178,7 +178,7 @@ class DataBinding {
178
178
  pendingExtensions = /* @__PURE__ */ new Set();
179
179
  async extendTree(newFragment, options = {}) {
180
180
  if (options.signal?.aborted) {
181
- return Promise.reject();
181
+ return Promise.reject(DataBindingExtendAborted);
182
182
  }
183
183
  const markerTreeRoot = new MarkerTreeGenerator(newFragment, options.environment ?? this.environment).generate();
184
184
  if (this.treeStore.effectivelyHasTreeRoot(markerTreeRoot)) {
@@ -199,7 +199,7 @@ class DataBinding {
199
199
  newFragment,
200
200
  newTreeRootId: this.getNewTreeRootId(),
201
201
  options,
202
- reject,
202
+ reject: () => reject(DataBindingExtendAborted),
203
203
  resolve
204
204
  });
205
205
  const pendingExtensionsCount = this.pendingExtensions.size;
@@ -324,6 +324,7 @@ class DataBinding {
324
324
  return this.treeStore.markerTrees.size === 0 ? void 0 : `${generateEnumerabilityPreventingEntropy()}-${DataBinding.getNextTreeRootIdSeed()}`;
325
325
  }
326
326
  }
327
+ const DataBindingExtendAborted = Symbol("aborted");
327
328
 
328
- export { DataBinding };
329
+ export { DataBinding, DataBindingExtendAborted };
329
330
  //# sourceMappingURL=DataBinding.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DataBinding.js","sources":["../../../src/core/DataBinding.ts"],"sourcesContent":["import type { GraphQlClient, GraphQlClientFailedRequestMetadata, TreeFilter } from '@contember/client'\nimport type { ReactNode } from 'react'\nimport {\n\tAsyncBatchUpdatesOptions,\n\tBatchUpdatesOptions,\n\tBindingOperations,\n\tExtendTreeOptions,\n\tPersistErrorOptions,\n\tPersistSuccessOptions,\n\tTreeRootAccessor,\n} from '../accessors'\nimport {\n\tmetadataToRequestError,\n\tMutationRequestResponse,\n\tQueryRequestResponse,\n\tRequestError,\n\tSuccessfulPersistResult,\n} from '../accessorTree'\nimport type { Environment } from '../dao'\nimport type { MarkerTreeRoot } from '../markers'\nimport type { TreeRootId } from '../treeParameters'\nimport { assertNever, generateEnumerabilityPreventingEntropy } from '../utils'\nimport { AccessorErrorManager } from './AccessorErrorManager'\nimport { Config } from './Config'\nimport { DirtinessTracker } from './DirtinessTracker'\nimport { EventManager } from './EventManager'\nimport { createBatchUpdatesOptions } from './factories'\nimport { MarkerMerger } from './MarkerMerger'\nimport { MarkerTreeGenerator } from './MarkerTreeGenerator'\nimport { MutationGenerator } from './MutationGenerator'\nimport { QueryGenerator } from './QueryGenerator'\nimport { Schema, SchemaLoader, SchemaValidator } from './schema'\nimport { StateIterator } from './state'\nimport { StateInitializer } from './StateInitializer'\nimport { TreeAugmenter } from './TreeAugmenter'\nimport { TreeFilterGenerator } from './TreeFilterGenerator'\nimport { TreeStore } from './TreeStore'\nimport type { UpdateMetadata } from './UpdateMetadata'\nimport { getCombinedSignal } from './utils'\n\nexport class DataBinding {\n\tprivate static readonly schemaLoadCache: Map<string, Schema | Promise<Schema>> = new Map()\n\n\tprivate readonly accessorErrorManager: AccessorErrorManager\n\tprivate readonly batchUpdatesOptions: BatchUpdatesOptions\n\tprivate readonly asyncBatchUpdatesOptions: AsyncBatchUpdatesOptions\n\tprivate readonly bindingOperations: BindingOperations\n\tprivate readonly config: Config\n\tprivate readonly dirtinessTracker: DirtinessTracker\n\tprivate readonly eventManager: EventManager\n\tprivate readonly stateInitializer: StateInitializer\n\tprivate readonly treeAugmenter: TreeAugmenter\n\tprivate readonly treeStore: TreeStore\n\n\t// private treeRootListeners: {\n\t// \teventListeners: {}\n\t// } = {\n\t// \teventListeners: {},\n\t// }\n\n\tpublic constructor(\n\t\tprivate readonly contentApiClient: GraphQlClient,\n\t\tprivate readonly systemApiClient: GraphQlClient,\n\t\tprivate readonly tenantApiClient: GraphQlClient,\n\t\tprivate readonly environment: Environment,\n\t\tprivate readonly onUpdate: (newData: TreeRootAccessor) => void,\n\t\tprivate readonly onError: (error: RequestError) => void,\n\t\tprivate readonly onPersistSuccess: (result: SuccessfulPersistResult) => void,\n\t) {\n\t\tthis.config = new Config()\n\t\tthis.treeStore = new TreeStore()\n\t\tthis.batchUpdatesOptions = createBatchUpdatesOptions(environment, this.treeStore)\n\t\tthis.asyncBatchUpdatesOptions = {\n\t\t\t...this.batchUpdatesOptions,\n\t\t\tcontentClient: contentApiClient,\n\t\t\tsystemClient: systemApiClient,\n\t\t\ttenantClient: tenantApiClient,\n\t\t}\n\t\tthis.dirtinessTracker = new DirtinessTracker()\n\t\tthis.eventManager = new EventManager(\n\t\t\tthis.asyncBatchUpdatesOptions,\n\t\t\tthis.batchUpdatesOptions,\n\t\t\tthis.config,\n\t\t\tthis.dirtinessTracker,\n\t\t\tthis.resolvedOnUpdate,\n\t\t\tthis.treeStore,\n\t\t)\n\t\tthis.accessorErrorManager = new AccessorErrorManager(this.eventManager, this.treeStore)\n\t\tthis.stateInitializer = new StateInitializer(\n\t\t\tthis.accessorErrorManager,\n\t\t\tthis.batchUpdatesOptions,\n\t\t\tthis.config,\n\t\t\tthis.eventManager,\n\t\t\tthis.treeStore,\n\t\t)\n\t\tthis.treeAugmenter = new TreeAugmenter(this.eventManager, this.stateInitializer, this.treeStore)\n\n\t\t// TODO move this elsewhere\n\t\tthis.bindingOperations = Object.freeze<BindingOperations>({\n\t\t\t...this.asyncBatchUpdatesOptions,\n\t\t\tgetTreeFilters: (): TreeFilter[] => {\n\t\t\t\tconst generator = new TreeFilterGenerator(this.treeStore)\n\t\t\t\treturn generator.generateTreeFilter()\n\t\t\t},\n\t\t\tbatchDeferredUpdates: performUpdates => {\n\t\t\t\tthis.eventManager.syncTransaction(() => performUpdates(this.bindingOperations))\n\t\t\t},\n\t\t\textendTree: async (...args) => await this.extendTree(...args),\n\t\t\tpersist: async ({ signal, onPersistSuccess, onPersistError } = {}) =>\n\t\t\t\tawait this.eventManager.persistOperation(async () => {\n\t\t\t\t\tfor (let attemptNumber = 1; attemptNumber <= this.config.getValue('maxPersistAttempts'); attemptNumber++) {\n\t\t\t\t\t\t// TODO if the tree is in an inconsistent state, wait for lock releases\n\n\t\t\t\t\t\tthis.eventManager.syncTransaction(() => {\n\t\t\t\t\t\t\tthis.accessorErrorManager.clearErrors()\n\t\t\t\t\t\t})\n\t\t\t\t\t\tawait this.eventManager.triggerOnBeforePersist()\n\n\t\t\t\t\t\tlet shouldTryAgain = false\n\t\t\t\t\t\tconst proposedBackOffs: number[] = []\n\t\t\t\t\t\tconst persistErrorOptions: PersistErrorOptions = {\n\t\t\t\t\t\t\t...this.bindingOperations,\n\t\t\t\t\t\t\ttryAgain: options => {\n\t\t\t\t\t\t\t\tshouldTryAgain = true\n\t\t\t\t\t\t\t\tif (options?.proposedBackoff !== undefined && options.proposedBackoff > 0) {\n\t\t\t\t\t\t\t\t\tproposedBackOffs.push(options.proposedBackoff)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tattemptNumber,\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (this.accessorErrorManager.hasErrors()) {\n\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistError(persistErrorOptions)\n\t\t\t\t\t\t\tawait onPersistError?.(persistErrorOptions)\n\n\t\t\t\t\t\t\tif (shouldTryAgain) {\n\t\t\t\t\t\t\t\tcontinue // Trying again immediately\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tthrow {\n\t\t\t\t\t\t\t\terrors: this.accessorErrorManager.getErrors(),\n\t\t\t\t\t\t\t\ttype: 'invalidInput',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst generator = new MutationGenerator(this.treeStore)\n\t\t\t\t\t\tconst mutation = generator.getPersistMutation()\n\n\t\t\t\t\t\tif (mutation === undefined) {\n\t\t\t\t\t\t\tthis.dirtinessTracker.reset() // TODO This ideally shouldn't be necessary but given the current limitations, this makes for better UX.\n\t\t\t\t\t\t\tconst persistSuccessOptions: PersistSuccessOptions = {\n\t\t\t\t\t\t\t\t...this.bindingOperations,\n\t\t\t\t\t\t\t\tsuccessType: 'nothingToPersist',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistSuccess(persistSuccessOptions)\n\t\t\t\t\t\t\tawait onPersistSuccess?.(persistSuccessOptions)\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\ttype: 'nothingToPersist',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst mutationResponse: MutationRequestResponse = await this.contentApiClient.sendRequest(mutation, {\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tconst mutationData = mutationResponse.data?.transaction ?? {}\n\t\t\t\t\t\tconst aliases = Object.keys(mutationData)\n\t\t\t\t\t\tif (!mutationResponse.data) {\n\t\t\t\t\t\t\tthrow {\n\t\t\t\t\t\t\t\terrors: mutationData.errors,\n\t\t\t\t\t\t\t\ttype: 'invalidResponse',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (aliases.every(item => mutationData[item].ok)) {\n\t\t\t\t\t\t\tconst persistedEntityIds = aliases.map(alias => mutationData[alias].node?.id).filter(id => id !== undefined)\n\t\t\t\t\t\t\tconst result: SuccessfulPersistResult = {\n\t\t\t\t\t\t\t\ttype: 'justSuccess',\n\t\t\t\t\t\t\t\tpersistedEntityIds,\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tawait this.eventManager.asyncTransaction(async () => {\n\t\t\t\t\t\t\t\t\tthis.resetTreeAfterSuccessfulPersist()\n\t\t\t\t\t\t\t\t\tthis.treeAugmenter.updatePersistedData(\n\t\t\t\t\t\t\t\t\t\tObject.fromEntries(\n\t\t\t\t\t\t\t\t\t\t\tObject.entries(mutationData).map(([placeholderName, subTreeResponse]) => [\n\t\t\t\t\t\t\t\t\t\t\t\tplaceholderName,\n\t\t\t\t\t\t\t\t\t\t\t\tsubTreeResponse.node,\n\t\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tconst persistSuccessOptions: PersistSuccessOptions = {\n\t\t\t\t\t\t\t\t\t\t...this.bindingOperations,\n\t\t\t\t\t\t\t\t\t\tsuccessType: result.type,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistSuccess(persistSuccessOptions)\n\t\t\t\t\t\t\t\t\tawait onPersistSuccess?.(persistSuccessOptions)\n\n\t\t\t\t\t\t\t\t\tthis.treeAugmenter.resetCreatingSubTrees()\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t\tconsole.error(e)\n\t\t\t\t\t\t\t\tconst resultWithError = {\n\t\t\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\t\t\tafterPersistError: e,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tthis.onPersistSuccess(resultWithError)\n\t\t\t\t\t\t\t\treturn resultWithError\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.onPersistSuccess(result)\n\t\t\t\t\t\t\treturn result\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.eventManager.syncTransaction(() => this.accessorErrorManager.replaceErrors(mutationData))\n\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistError(persistErrorOptions)\n\t\t\t\t\t\t\tawait onPersistError?.(persistErrorOptions)\n\t\t\t\t\t\t\tif (shouldTryAgain) {\n\t\t\t\t\t\t\t\tif (proposedBackOffs.length) {\n\t\t\t\t\t\t\t\t\tconst geometricMean = Math.round(\n\t\t\t\t\t\t\t\t\t\tMath.pow(\n\t\t\t\t\t\t\t\t\t\t\tproposedBackOffs.reduce((a, b) => a * b, 1),\n\t\t\t\t\t\t\t\t\t\t\t1 / proposedBackOffs.length,\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, geometricMean))\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthrow {\n\t\t\t\t\t\t\t\terrors: this.accessorErrorManager.getErrors(),\n\t\t\t\t\t\t\t\ttype: 'invalidInput',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Max attempts exceeded\n\t\t\t\t\t// TODO fire persist error\n\t\t\t\t\tthrow {\n\t\t\t\t\t\ttype: 'givenUp',\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t})\n\t}\n\n\tprivate resolvedOnUpdate = ({ isMutating }: UpdateMetadata) => {\n\t\tthis.onUpdate(new TreeRootAccessor(this.dirtinessTracker.hasChanges(), isMutating, this.bindingOperations))\n\t}\n\n\t// This is currently useless but potentially future-compatible\n\t// private readonly addTreeRootEventListener: TreeRootAccessor.AddTreeRootEventListener = this.getAddEventListener(\n\t// \tthis.treeRootListeners,\n\t// )\n\n\tprivate pendingExtensions: Set<{\n\t\tmarkerTreeRoot: MarkerTreeRoot\n\t\tnewFragment: ReactNode\n\t\tnewTreeRootId: TreeRootId | undefined\n\t\toptions: ExtendTreeOptions\n\t\treject: () => void\n\t\tresolve: (newRootId: TreeRootId | undefined) => void\n\t}> = new Set()\n\n\tpublic async extendTree(newFragment: ReactNode, options: ExtendTreeOptions = {}): Promise<TreeRootId | undefined> {\n\t\tif (options.signal?.aborted) {\n\t\t\treturn Promise.reject()\n\t\t}\n\t\tconst markerTreeRoot = new MarkerTreeGenerator(newFragment, options.environment ?? this.environment).generate()\n\n\t\tif (this.treeStore.effectivelyHasTreeRoot(markerTreeRoot)) {\n\t\t\t// This isn't perfectly accurate as theoretically, we could already have all the data necessary but this\n\t\t\t// could still be false.\n\n\t\t\tconst schema = await this.getOrLoadSchema()\n\t\t\tthis.treeStore.setSchema(schema)\n\t\t\tif (import.meta.env.DEV) {\n\t\t\t\t// For most trees, checking this against the schema should be unnecessary since if we already effectively\n\t\t\t\t// have this tree root, then assuming everything we already have is valid, this should match the schema as well.\n\t\t\t\t// However, we might be dealing with an isCreating tree root which is completely new. Also, we can just lean\n\t\t\t\t// towards the safe side since developer machines can generally handle the potentially unnecessary check anyway.\n\t\t\t\tSchemaValidator.assertTreeValid(schema, markerTreeRoot)\n\t\t\t}\n\n\t\t\treturn this.eventManager.syncOperation(() => {\n\t\t\t\tconst newTreeRootId = this.getNewTreeRootId()\n\t\t\t\tthis.treeAugmenter.extendTreeStates(newTreeRootId, markerTreeRoot)\n\t\t\t\treturn newTreeRootId\n\t\t\t})\n\t\t}\n\n\t\treturn await new Promise((resolve, reject) => {\n\t\t\tthis.pendingExtensions.add({\n\t\t\t\tmarkerTreeRoot,\n\t\t\t\tnewFragment,\n\t\t\t\tnewTreeRootId: this.getNewTreeRootId(),\n\t\t\t\toptions,\n\t\t\t\treject,\n\t\t\t\tresolve,\n\t\t\t})\n\t\t\tconst pendingExtensionsCount = this.pendingExtensions.size\n\n\t\t\tPromise.resolve().then(() => {\n\t\t\t\tif (pendingExtensionsCount < this.pendingExtensions.size) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.flushBatchedTreeExtensions()\n\t\t\t})\n\t\t})\n\t}\n\n\tprivate async flushBatchedTreeExtensions() {\n\t\t// This is an async operation so we just take whatever pendingExtensions there are now and let any new ones\n\t\t// accumulate in an empty set.\n\t\tconst pendingExtensions = Array.from(this.pendingExtensions).filter(extension => {\n\t\t\tif (extension.options.signal?.aborted) {\n\t\t\t\textension.reject()\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn true\n\t\t})\n\t\tthis.pendingExtensions.clear()\n\n\t\tconst aggregateMarkerTreeRoot = pendingExtensions.reduce<MarkerTreeRoot | undefined>(\n\t\t\t(previousValue, currentValue) => {\n\t\t\t\tif (previousValue === undefined) {\n\t\t\t\t\treturn currentValue.markerTreeRoot\n\t\t\t\t}\n\t\t\t\treturn MarkerMerger.mergeMarkerTreeRoots(previousValue, currentValue.markerTreeRoot)\n\t\t\t},\n\t\t\tundefined,\n\t\t)\n\n\t\tif (aggregateMarkerTreeRoot === undefined) {\n\t\t\treturn\n\t\t}\n\n\t\tconst aggregateSignal = getCombinedSignal(pendingExtensions.map(extension => extension.options.signal))\n\n\t\t// Even if we don't have a schema yet, we'll still optimistically fire the request so as to prevent a waterfall\n\t\t// in the most likely case that things will go fine and the query does match the schema. If it doesn't, then we\n\t\t// just get a \"400 Bad Request\" but that's not enough to make us delay the happy path.\n\t\tconst [aggregatePersistedData, schema] = await Promise.all([\n\t\t\tthis.fetchPersistedData(aggregateMarkerTreeRoot, aggregateSignal),\n\t\t\tthis.getOrLoadSchema(),\n\t\t])\n\t\tthis.treeStore.setSchema(schema)\n\n\t\tif (import.meta.env.DEV) {\n\t\t\tfor (const extension of pendingExtensions) {\n\t\t\t\tSchemaValidator.assertTreeValid(schema, extension.markerTreeRoot)\n\t\t\t}\n\t\t}\n\n\t\tif (aggregateSignal?.aborted) {\n\t\t\treturn\n\t\t}\n\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tthis.treeAugmenter.extendPersistedData(aggregatePersistedData?.data ?? {})\n\n\t\t\tfor (const extension of pendingExtensions) {\n\t\t\t\tthis.treeAugmenter.extendTreeStates(extension.newTreeRootId, extension.markerTreeRoot)\n\t\t\t\textension.resolve(extension.newTreeRootId)\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate async fetchPersistedData(\n\t\ttree: MarkerTreeRoot,\n\t\tsignal?: AbortSignal,\n\t): Promise<QueryRequestResponse | undefined> {\n\t\tconst queryGenerator = new QueryGenerator(tree)\n\t\tconst query = queryGenerator.getReadQuery()\n\n\t\tlet queryResponse: QueryRequestResponse | undefined = undefined\n\n\t\ttry {\n\t\t\tqueryResponse =\n\t\t\t\tquery === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: await this.contentApiClient.sendRequest(query, {\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t })\n\t\t} catch (metadata) {\n\t\t\tif (metadata.name === 'AbortError') {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.onError(metadataToRequestError(metadata as GraphQlClientFailedRequestMetadata))\n\t\t}\n\t\treturn queryResponse\n\t}\n\n\tprivate resetTreeAfterSuccessfulPersist() {\n\t\tthis.eventManager.syncTransaction(() => {\n\t\t\tthis.accessorErrorManager.clearErrors()\n\t\t\tthis.dirtinessTracker.reset()\n\n\t\t\tfor (const [, rootState] of StateIterator.eachRootState(this.treeStore)) {\n\t\t\t\tfor (const state of StateIterator.depthFirstAllNodes(rootState)) {\n\t\t\t\t\tswitch (state.type) {\n\t\t\t\t\t\tcase 'field': {\n\t\t\t\t\t\t\tif (state.hasUnpersistedChanges || state.touchLog?.size) {\n\t\t\t\t\t\t\t\tstate.touchLog?.clear()\n\t\t\t\t\t\t\t\tstate.hasUnpersistedChanges = false\n\t\t\t\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase 'entityList':\n\t\t\t\t\t\t\tif (state.unpersistedChangesCount > 0 || state.plannedRemovals?.size) {\n\t\t\t\t\t\t\t\tstate.unpersistedChangesCount = 0\n\t\t\t\t\t\t\t\tstate.plannedRemovals?.clear()\n\t\t\t\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase 'entityRealm': {\n\t\t\t\t\t\t\tif (state.unpersistedChangesCount > 0 || state.plannedHasOneDeletions?.size) {\n\t\t\t\t\t\t\t\tstate.unpersistedChangesCount = 0\n\t\t\t\t\t\t\t\tstate.plannedHasOneDeletions?.clear()\n\t\t\t\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tassertNever(state)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate getOrLoadSchema(): Schema | Promise<Schema> {\n\t\tconst existing = DataBinding.schemaLoadCache.get(this.contentApiClient.apiUrl)\n\t\tif (existing !== undefined) {\n\t\t\treturn existing\n\t\t}\n\n\t\tconst schemaPromise = SchemaLoader.loadSchema(this.contentApiClient, this.config.getValue('maxSchemaLoadAttempts'))\n\t\tschemaPromise.then(schema => {\n\t\t\tDataBinding.schemaLoadCache.set(this.contentApiClient.apiUrl, schema)\n\t\t})\n\t\tDataBinding.schemaLoadCache.set(this.contentApiClient.apiUrl, schemaPromise)\n\t\treturn schemaPromise\n\t}\n\n\tprivate static getNextTreeRootIdSeed = (() => {\n\t\tlet seed = 1\n\t\treturn () => seed++\n\t})()\n\n\tprivate getNewTreeRootId() {\n\t\t// TODO this is an awful, awful hack.\n\t\t// TODO the particular shape of the alias is relied on in MutationAlias. If you change this, change it there too.\n\t\treturn this.treeStore.markerTrees.size === 0\n\t\t\t? undefined\n\t\t\t: `${generateEnumerabilityPreventingEntropy()}-${DataBinding.getNextTreeRootIdSeed()}`\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;kBAwCyB;AAAA,EAoBjB,YACW,kBACA,iBACA,iBACA,aACA,UACA,SACA,kBAChB;AAPgB;AACA;AACA;AACA;AACA;AACA;AACA;AAEjB,SAAK,SAAS,IAAI;AAClB,SAAK,YAAY,IAAI;AACrB,SAAK,sBAAsB,0BAA0B,aAAa,KAAK;AACvE,SAAK,2BAA2B;AAAA,SAC5B,KAAK;AAAA,MACR,eAAe;AAAA,MACf,cAAc;AAAA,MACd,cAAc;AAAA;AAEf,SAAK,mBAAmB,IA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1F,kBAAc,KAAK,YAAU;AAC5B,kBAAY,gBAAgB,IAAI,KAAK,iBAAiB,QAAQ;AAAA;AAE/D,gBAAY,gBAAgB,IAAI,KAAK,iBAAiB,QAAQ;AAC9D,WAAO;AAAA;AAAA,SAGO,wBAAyB,OAAM;AAC7C,QAAI,OAAO;AACX,WAAO,MAAM;AAAA;AAAA,EAGN,mBAAmB;AAG1B,WAAO,KAAK,UAAU,YAAY,SAAS,IACxC,SACA,GAAG,4CAA4C,YAAY;AAAA;AAAA;;;;"}
1
+ {"version":3,"file":"DataBinding.js","sources":["../../../src/core/DataBinding.ts"],"sourcesContent":["import type { GraphQlClient, GraphQlClientFailedRequestMetadata, TreeFilter } from '@contember/client'\nimport type { ReactNode } from 'react'\nimport {\n\tAsyncBatchUpdatesOptions,\n\tBatchUpdatesOptions,\n\tBindingOperations,\n\tExtendTreeOptions,\n\tPersistErrorOptions,\n\tPersistSuccessOptions,\n\tTreeRootAccessor,\n} from '../accessors'\nimport {\n\tmetadataToRequestError,\n\tMutationRequestResponse,\n\tQueryRequestResponse,\n\tRequestError,\n\tSuccessfulPersistResult,\n} from '../accessorTree'\nimport type { Environment } from '../dao'\nimport type { MarkerTreeRoot } from '../markers'\nimport type { TreeRootId } from '../treeParameters'\nimport { assertNever, generateEnumerabilityPreventingEntropy } from '../utils'\nimport { AccessorErrorManager } from './AccessorErrorManager'\nimport { Config } from './Config'\nimport { DirtinessTracker } from './DirtinessTracker'\nimport { EventManager } from './EventManager'\nimport { createBatchUpdatesOptions } from './factories'\nimport { MarkerMerger } from './MarkerMerger'\nimport { MarkerTreeGenerator } from './MarkerTreeGenerator'\nimport { MutationGenerator } from './MutationGenerator'\nimport { QueryGenerator } from './QueryGenerator'\nimport { Schema, SchemaLoader, SchemaValidator } from './schema'\nimport { StateIterator } from './state'\nimport { StateInitializer } from './StateInitializer'\nimport { TreeAugmenter } from './TreeAugmenter'\nimport { TreeFilterGenerator } from './TreeFilterGenerator'\nimport { TreeStore } from './TreeStore'\nimport type { UpdateMetadata } from './UpdateMetadata'\nimport { getCombinedSignal } from './utils'\n\nexport class DataBinding {\n\tprivate static readonly schemaLoadCache: Map<string, Schema | Promise<Schema>> = new Map()\n\n\tprivate readonly accessorErrorManager: AccessorErrorManager\n\tprivate readonly batchUpdatesOptions: BatchUpdatesOptions\n\tprivate readonly asyncBatchUpdatesOptions: AsyncBatchUpdatesOptions\n\tprivate readonly bindingOperations: BindingOperations\n\tprivate readonly config: Config\n\tprivate readonly dirtinessTracker: DirtinessTracker\n\tprivate readonly eventManager: EventManager\n\tprivate readonly stateInitializer: StateInitializer\n\tprivate readonly treeAugmenter: TreeAugmenter\n\tprivate readonly treeStore: TreeStore\n\n\t// private treeRootListeners: {\n\t// \teventListeners: {}\n\t// } = {\n\t// \teventListeners: {},\n\t// }\n\n\tpublic constructor(\n\t\tprivate readonly contentApiClient: GraphQlClient,\n\t\tprivate readonly systemApiClient: GraphQlClient,\n\t\tprivate readonly tenantApiClient: GraphQlClient,\n\t\tprivate readonly environment: Environment,\n\t\tprivate readonly onUpdate: (newData: TreeRootAccessor) => void,\n\t\tprivate readonly onError: (error: RequestError) => void,\n\t\tprivate readonly onPersistSuccess: (result: SuccessfulPersistResult) => void,\n\t) {\n\t\tthis.config = new Config()\n\t\tthis.treeStore = new TreeStore()\n\t\tthis.batchUpdatesOptions = createBatchUpdatesOptions(environment, this.treeStore)\n\t\tthis.asyncBatchUpdatesOptions = {\n\t\t\t...this.batchUpdatesOptions,\n\t\t\tcontentClient: contentApiClient,\n\t\t\tsystemClient: systemApiClient,\n\t\t\ttenantClient: tenantApiClient,\n\t\t}\n\t\tthis.dirtinessTracker = new DirtinessTracker()\n\t\tthis.eventManager = new EventManager(\n\t\t\tthis.asyncBatchUpdatesOptions,\n\t\t\tthis.batchUpdatesOptions,\n\t\t\tthis.config,\n\t\t\tthis.dirtinessTracker,\n\t\t\tthis.resolvedOnUpdate,\n\t\t\tthis.treeStore,\n\t\t)\n\t\tthis.accessorErrorManager = new AccessorErrorManager(this.eventManager, this.treeStore)\n\t\tthis.stateInitializer = new StateInitializer(\n\t\t\tthis.accessorErrorManager,\n\t\t\tthis.batchUpdatesOptions,\n\t\t\tthis.config,\n\t\t\tthis.eventManager,\n\t\t\tthis.treeStore,\n\t\t)\n\t\tthis.treeAugmenter = new TreeAugmenter(this.eventManager, this.stateInitializer, this.treeStore)\n\n\t\t// TODO move this elsewhere\n\t\tthis.bindingOperations = Object.freeze<BindingOperations>({\n\t\t\t...this.asyncBatchUpdatesOptions,\n\t\t\tgetTreeFilters: (): TreeFilter[] => {\n\t\t\t\tconst generator = new TreeFilterGenerator(this.treeStore)\n\t\t\t\treturn generator.generateTreeFilter()\n\t\t\t},\n\t\t\tbatchDeferredUpdates: performUpdates => {\n\t\t\t\tthis.eventManager.syncTransaction(() => performUpdates(this.bindingOperations))\n\t\t\t},\n\t\t\textendTree: async (...args) => await this.extendTree(...args),\n\t\t\tpersist: async ({ signal, onPersistSuccess, onPersistError } = {}) =>\n\t\t\t\tawait this.eventManager.persistOperation(async () => {\n\t\t\t\t\tfor (let attemptNumber = 1; attemptNumber <= this.config.getValue('maxPersistAttempts'); attemptNumber++) {\n\t\t\t\t\t\t// TODO if the tree is in an inconsistent state, wait for lock releases\n\n\t\t\t\t\t\tthis.eventManager.syncTransaction(() => {\n\t\t\t\t\t\t\tthis.accessorErrorManager.clearErrors()\n\t\t\t\t\t\t})\n\t\t\t\t\t\tawait this.eventManager.triggerOnBeforePersist()\n\n\t\t\t\t\t\tlet shouldTryAgain = false\n\t\t\t\t\t\tconst proposedBackOffs: number[] = []\n\t\t\t\t\t\tconst persistErrorOptions: PersistErrorOptions = {\n\t\t\t\t\t\t\t...this.bindingOperations,\n\t\t\t\t\t\t\ttryAgain: options => {\n\t\t\t\t\t\t\t\tshouldTryAgain = true\n\t\t\t\t\t\t\t\tif (options?.proposedBackoff !== undefined && options.proposedBackoff > 0) {\n\t\t\t\t\t\t\t\t\tproposedBackOffs.push(options.proposedBackoff)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tattemptNumber,\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (this.accessorErrorManager.hasErrors()) {\n\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistError(persistErrorOptions)\n\t\t\t\t\t\t\tawait onPersistError?.(persistErrorOptions)\n\n\t\t\t\t\t\t\tif (shouldTryAgain) {\n\t\t\t\t\t\t\t\tcontinue // Trying again immediately\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tthrow {\n\t\t\t\t\t\t\t\terrors: this.accessorErrorManager.getErrors(),\n\t\t\t\t\t\t\t\ttype: 'invalidInput',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst generator = new MutationGenerator(this.treeStore)\n\t\t\t\t\t\tconst mutation = generator.getPersistMutation()\n\n\t\t\t\t\t\tif (mutation === undefined) {\n\t\t\t\t\t\t\tthis.dirtinessTracker.reset() // TODO This ideally shouldn't be necessary but given the current limitations, this makes for better UX.\n\t\t\t\t\t\t\tconst persistSuccessOptions: PersistSuccessOptions = {\n\t\t\t\t\t\t\t\t...this.bindingOperations,\n\t\t\t\t\t\t\t\tsuccessType: 'nothingToPersist',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistSuccess(persistSuccessOptions)\n\t\t\t\t\t\t\tawait onPersistSuccess?.(persistSuccessOptions)\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\ttype: 'nothingToPersist',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst mutationResponse: MutationRequestResponse = await this.contentApiClient.sendRequest(mutation, {\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tconst mutationData = mutationResponse.data?.transaction ?? {}\n\t\t\t\t\t\tconst aliases = Object.keys(mutationData)\n\t\t\t\t\t\tif (!mutationResponse.data) {\n\t\t\t\t\t\t\tthrow {\n\t\t\t\t\t\t\t\terrors: mutationData.errors,\n\t\t\t\t\t\t\t\ttype: 'invalidResponse',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (aliases.every(item => mutationData[item].ok)) {\n\t\t\t\t\t\t\tconst persistedEntityIds = aliases.map(alias => mutationData[alias].node?.id).filter(id => id !== undefined)\n\t\t\t\t\t\t\tconst result: SuccessfulPersistResult = {\n\t\t\t\t\t\t\t\ttype: 'justSuccess',\n\t\t\t\t\t\t\t\tpersistedEntityIds,\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tawait this.eventManager.asyncTransaction(async () => {\n\t\t\t\t\t\t\t\t\tthis.resetTreeAfterSuccessfulPersist()\n\t\t\t\t\t\t\t\t\tthis.treeAugmenter.updatePersistedData(\n\t\t\t\t\t\t\t\t\t\tObject.fromEntries(\n\t\t\t\t\t\t\t\t\t\t\tObject.entries(mutationData).map(([placeholderName, subTreeResponse]) => [\n\t\t\t\t\t\t\t\t\t\t\t\tplaceholderName,\n\t\t\t\t\t\t\t\t\t\t\t\tsubTreeResponse.node,\n\t\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tconst persistSuccessOptions: PersistSuccessOptions = {\n\t\t\t\t\t\t\t\t\t\t...this.bindingOperations,\n\t\t\t\t\t\t\t\t\t\tsuccessType: result.type,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistSuccess(persistSuccessOptions)\n\t\t\t\t\t\t\t\t\tawait onPersistSuccess?.(persistSuccessOptions)\n\n\t\t\t\t\t\t\t\t\tthis.treeAugmenter.resetCreatingSubTrees()\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t\tconsole.error(e)\n\t\t\t\t\t\t\t\tconst resultWithError = {\n\t\t\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\t\t\tafterPersistError: e,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tthis.onPersistSuccess(resultWithError)\n\t\t\t\t\t\t\t\treturn resultWithError\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.onPersistSuccess(result)\n\t\t\t\t\t\t\treturn result\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.eventManager.syncTransaction(() => this.accessorErrorManager.replaceErrors(mutationData))\n\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistError(persistErrorOptions)\n\t\t\t\t\t\t\tawait onPersistError?.(persistErrorOptions)\n\t\t\t\t\t\t\tif (shouldTryAgain) {\n\t\t\t\t\t\t\t\tif (proposedBackOffs.length) {\n\t\t\t\t\t\t\t\t\tconst geometricMean = Math.round(\n\t\t\t\t\t\t\t\t\t\tMath.pow(\n\t\t\t\t\t\t\t\t\t\t\tproposedBackOffs.reduce((a, b) => a * b, 1),\n\t\t\t\t\t\t\t\t\t\t\t1 / proposedBackOffs.length,\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, geometricMean))\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthrow {\n\t\t\t\t\t\t\t\terrors: this.accessorErrorManager.getErrors(),\n\t\t\t\t\t\t\t\ttype: 'invalidInput',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Max attempts exceeded\n\t\t\t\t\t// TODO fire persist error\n\t\t\t\t\tthrow {\n\t\t\t\t\t\ttype: 'givenUp',\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t})\n\t}\n\n\tprivate resolvedOnUpdate = ({ isMutating }: UpdateMetadata) => {\n\t\tthis.onUpdate(new TreeRootAccessor(this.dirtinessTracker.hasChanges(), isMutating, this.bindingOperations))\n\t}\n\n\t// This is currently useless but potentially future-compatible\n\t// private readonly addTreeRootEventListener: TreeRootAccessor.AddTreeRootEventListener = this.getAddEventListener(\n\t// \tthis.treeRootListeners,\n\t// )\n\n\tprivate pendingExtensions: Set<{\n\t\tmarkerTreeRoot: MarkerTreeRoot\n\t\tnewFragment: ReactNode\n\t\tnewTreeRootId: TreeRootId | undefined\n\t\toptions: ExtendTreeOptions\n\t\treject: () => void\n\t\tresolve: (newRootId: TreeRootId | undefined) => void\n\t}> = new Set()\n\n\tpublic async extendTree(newFragment: ReactNode, options: ExtendTreeOptions = {}): Promise<TreeRootId | undefined> {\n\t\tif (options.signal?.aborted) {\n\t\t\treturn Promise.reject(DataBindingExtendAborted)\n\t\t}\n\t\tconst markerTreeRoot = new MarkerTreeGenerator(newFragment, options.environment ?? this.environment).generate()\n\n\t\tif (this.treeStore.effectivelyHasTreeRoot(markerTreeRoot)) {\n\t\t\t// This isn't perfectly accurate as theoretically, we could already have all the data necessary but this\n\t\t\t// could still be false.\n\n\t\t\tconst schema = await this.getOrLoadSchema()\n\t\t\tthis.treeStore.setSchema(schema)\n\t\t\tif (import.meta.env.DEV) {\n\t\t\t\t// For most trees, checking this against the schema should be unnecessary since if we already effectively\n\t\t\t\t// have this tree root, then assuming everything we already have is valid, this should match the schema as well.\n\t\t\t\t// However, we might be dealing with an isCreating tree root which is completely new. Also, we can just lean\n\t\t\t\t// towards the safe side since developer machines can generally handle the potentially unnecessary check anyway.\n\t\t\t\tSchemaValidator.assertTreeValid(schema, markerTreeRoot)\n\t\t\t}\n\n\t\t\treturn this.eventManager.syncOperation(() => {\n\t\t\t\tconst newTreeRootId = this.getNewTreeRootId()\n\t\t\t\tthis.treeAugmenter.extendTreeStates(newTreeRootId, markerTreeRoot)\n\t\t\t\treturn newTreeRootId\n\t\t\t})\n\t\t}\n\n\t\treturn await new Promise((resolve, reject) => {\n\t\t\tthis.pendingExtensions.add({\n\t\t\t\tmarkerTreeRoot,\n\t\t\t\tnewFragment,\n\t\t\t\tnewTreeRootId: this.getNewTreeRootId(),\n\t\t\t\toptions,\n\t\t\t\treject: () => reject(DataBindingExtendAborted),\n\t\t\t\tresolve,\n\t\t\t})\n\t\t\tconst pendingExtensionsCount = this.pendingExtensions.size\n\n\t\t\tPromise.resolve().then(() => {\n\t\t\t\tif (pendingExtensionsCount < this.pendingExtensions.size) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.flushBatchedTreeExtensions()\n\t\t\t})\n\t\t})\n\t}\n\n\tprivate async flushBatchedTreeExtensions() {\n\t\t// This is an async operation so we just take whatever pendingExtensions there are now and let any new ones\n\t\t// accumulate in an empty set.\n\t\tconst pendingExtensions = Array.from(this.pendingExtensions).filter(extension => {\n\t\t\tif (extension.options.signal?.aborted) {\n\t\t\t\textension.reject()\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn true\n\t\t})\n\t\tthis.pendingExtensions.clear()\n\n\t\tconst aggregateMarkerTreeRoot = pendingExtensions.reduce<MarkerTreeRoot | undefined>(\n\t\t\t(previousValue, currentValue) => {\n\t\t\t\tif (previousValue === undefined) {\n\t\t\t\t\treturn currentValue.markerTreeRoot\n\t\t\t\t}\n\t\t\t\treturn MarkerMerger.mergeMarkerTreeRoots(previousValue, currentValue.markerTreeRoot)\n\t\t\t},\n\t\t\tundefined,\n\t\t)\n\n\t\tif (aggregateMarkerTreeRoot === undefined) {\n\t\t\treturn\n\t\t}\n\n\t\tconst aggregateSignal = getCombinedSignal(pendingExtensions.map(extension => extension.options.signal))\n\n\t\t// Even if we don't have a schema yet, we'll still optimistically fire the request so as to prevent a waterfall\n\t\t// in the most likely case that things will go fine and the query does match the schema. If it doesn't, then we\n\t\t// just get a \"400 Bad Request\" but that's not enough to make us delay the happy path.\n\t\tconst [aggregatePersistedData, schema] = await Promise.all([\n\t\t\tthis.fetchPersistedData(aggregateMarkerTreeRoot, aggregateSignal),\n\t\t\tthis.getOrLoadSchema(),\n\t\t])\n\t\tthis.treeStore.setSchema(schema)\n\n\t\tif (import.meta.env.DEV) {\n\t\t\tfor (const extension of pendingExtensions) {\n\t\t\t\tSchemaValidator.assertTreeValid(schema, extension.markerTreeRoot)\n\t\t\t}\n\t\t}\n\n\t\tif (aggregateSignal?.aborted) {\n\t\t\treturn\n\t\t}\n\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tthis.treeAugmenter.extendPersistedData(aggregatePersistedData?.data ?? {})\n\n\t\t\tfor (const extension of pendingExtensions) {\n\t\t\t\tthis.treeAugmenter.extendTreeStates(extension.newTreeRootId, extension.markerTreeRoot)\n\t\t\t\textension.resolve(extension.newTreeRootId)\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate async fetchPersistedData(\n\t\ttree: MarkerTreeRoot,\n\t\tsignal?: AbortSignal,\n\t): Promise<QueryRequestResponse | undefined> {\n\t\tconst queryGenerator = new QueryGenerator(tree)\n\t\tconst query = queryGenerator.getReadQuery()\n\n\t\tlet queryResponse: QueryRequestResponse | undefined = undefined\n\n\t\ttry {\n\t\t\tqueryResponse =\n\t\t\t\tquery === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: await this.contentApiClient.sendRequest(query, {\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t })\n\t\t} catch (metadata) {\n\t\t\tif (metadata.name === 'AbortError') {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.onError(metadataToRequestError(metadata as GraphQlClientFailedRequestMetadata))\n\t\t}\n\t\treturn queryResponse\n\t}\n\n\tprivate resetTreeAfterSuccessfulPersist() {\n\t\tthis.eventManager.syncTransaction(() => {\n\t\t\tthis.accessorErrorManager.clearErrors()\n\t\t\tthis.dirtinessTracker.reset()\n\n\t\t\tfor (const [, rootState] of StateIterator.eachRootState(this.treeStore)) {\n\t\t\t\tfor (const state of StateIterator.depthFirstAllNodes(rootState)) {\n\t\t\t\t\tswitch (state.type) {\n\t\t\t\t\t\tcase 'field': {\n\t\t\t\t\t\t\tif (state.hasUnpersistedChanges || state.touchLog?.size) {\n\t\t\t\t\t\t\t\tstate.touchLog?.clear()\n\t\t\t\t\t\t\t\tstate.hasUnpersistedChanges = false\n\t\t\t\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase 'entityList':\n\t\t\t\t\t\t\tif (state.unpersistedChangesCount > 0 || state.plannedRemovals?.size) {\n\t\t\t\t\t\t\t\tstate.unpersistedChangesCount = 0\n\t\t\t\t\t\t\t\tstate.plannedRemovals?.clear()\n\t\t\t\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase 'entityRealm': {\n\t\t\t\t\t\t\tif (state.unpersistedChangesCount > 0 || state.plannedHasOneDeletions?.size) {\n\t\t\t\t\t\t\t\tstate.unpersistedChangesCount = 0\n\t\t\t\t\t\t\t\tstate.plannedHasOneDeletions?.clear()\n\t\t\t\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tassertNever(state)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate getOrLoadSchema(): Schema | Promise<Schema> {\n\t\tconst existing = DataBinding.schemaLoadCache.get(this.contentApiClient.apiUrl)\n\t\tif (existing !== undefined) {\n\t\t\treturn existing\n\t\t}\n\n\t\tconst schemaPromise = SchemaLoader.loadSchema(this.contentApiClient, this.config.getValue('maxSchemaLoadAttempts'))\n\t\tschemaPromise.then(schema => {\n\t\t\tDataBinding.schemaLoadCache.set(this.contentApiClient.apiUrl, schema)\n\t\t})\n\t\tDataBinding.schemaLoadCache.set(this.contentApiClient.apiUrl, schemaPromise)\n\t\treturn schemaPromise\n\t}\n\n\tprivate static getNextTreeRootIdSeed = (() => {\n\t\tlet seed = 1\n\t\treturn () => seed++\n\t})()\n\n\tprivate getNewTreeRootId() {\n\t\t// TODO this is an awful, awful hack.\n\t\t// TODO the particular shape of the alias is relied on in MutationAlias. If you change this, change it there too.\n\t\treturn this.treeStore.markerTrees.size === 0\n\t\t\t? undefined\n\t\t\t: `${generateEnumerabilityPreventingEntropy()}-${DataBinding.getNextTreeRootIdSeed()}`\n\t}\n}\n\nexport const DataBindingExtendAborted = Symbol('aborted')\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;kBAwCyB;AAAA,EAoBjB,YACW,kBACA,iBACA,iBACA,aACA,UACA,SACA,kBAChB;AAPgB;AACA;AACA;AACA;AACA;AACA;AACA;AAEjB,SAAK,SAAS,IAAI;AAClB,SAAK,YAAY,IAAI;AACrB,SAAK,sBAAsB,0BAA0B,aAAa,KAAK;AACvE,SAAK,2BAA2B;AAAA,SAC5B,KAAK;AAAA,MACR,eAAe;AAAA,MACf,cAAc;AAAA,MACd,cAAc;AAAA;AAEf,SAAK,mBAAmB,IAAI;AAC5B,SAAK,eAAe,IAAI,aACvB,KAAK,0BACL,KAAK,qBACL,KAAK,QACL,KAAK,kBACL,KAAK,kBACL,KAAK;AAEN,SAAK,uBAAuB,IAAI,qBAAqB,KAAK,cAAc,KAAK;AAC7E,SAAK,mBAAmB,IAAI,iBAC3B,KAAK,sBACL,KAAK,qBACL,KAAK,QACL,KAAK,cACL,KAAK;AAEN,SAAK,gBAAgB,IAAI,cAAc,KAAK,cAAc,KAAK,kBAAkB,KAAK;AAGtF,SAAK,oBAAoB,OAAO,OAA0B;AAAA,SACtD,KAAK;AAAA,MACR,gBAAgB,MAAoB;AACnC,cAAM,YAAY,IAAI,oBAAoB,KAAK;AAC/C,eAAO,UAAU;AAA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48
  export { useDataBinding } from './accessorTree/useDataBinding.js';
49
49
  export { useDirtinessState } from './accessorTree/useDirtinessState.js';
50
50
  export { useMutationState } from './accessorTree/useMutationState.js';
51
- export { DataBinding } from './core/DataBinding.js';
51
+ export { DataBinding, DataBindingExtendAborted } from './core/DataBinding.js';
52
52
  export { MarkerMerger } from './core/MarkerMerger.js';
53
53
  export { MarkerTreeGenerator } from './core/MarkerTreeGenerator.js';
54
54
  export { TreeParameterMerger } from './core/TreeParameterMerger.js';
@@ -407,7 +407,7 @@ class Parser extends EmbeddedActionsParser {
407
407
  return order;
408
408
  });
409
409
  taggedMap = this.RULE("taggedMap", () => {
410
- const name = this.SUBRULE(this.identifier);
410
+ const name = this.SUBRULE(this.pageName);
411
411
  return {
412
412
  name,
413
413
  entries: this.OPTION(() => this.SUBRULE(this.taggedMapEntries)) ?? []
@@ -507,6 +507,14 @@ class Parser extends EmbeddedActionsParser {
507
507
  }
508
508
  ]);
509
509
  });
510
+ pageName = this.RULE("pageName", () => {
511
+ const parts = [];
512
+ this.AT_LEAST_ONE_SEP({
513
+ SEP: tokens.Slash,
514
+ DEF: () => parts.push(this.CONSUME(tokens.Identifier).image)
515
+ });
516
+ return parts.join("/");
517
+ });
510
518
  entityIdentifier = this.RULE("entityIdentifier", () => {
511
519
  return this.OR([
512
520
  {
@@ -1 +1 @@
1
- {"version":3,"file":"Parser.js","sources":["../../../src/queryLanguage/Parser.ts"],"sourcesContent":["import { CrudQueryBuilder, GraphQlBuilder, GraphQlLiteral, Input } from '@contember/client'\nimport { EmbeddedActionsParser, Lexer } from 'chevrotain'\nimport { Environment } from '../dao'\nimport type { EntityName, FieldName, Filter, OrderBy, UniqueWhere } from '../treeParameters'\nimport type {\n\tParsedTaggedMap,\n\tParsedTaggedMapVariableValue,\n\tParsedTaggedMapLiteralValue,\n\tParsedTaggedMapEntry,\n\tParsedHasManyRelation,\n\tParsedHasOneRelation,\n\tParsedQualifiedEntityList,\n\tParsedQualifiedFieldList,\n\tParsedQualifiedSingleEntity,\n\tParsedRelativeEntityList,\n\tParsedRelativeSingleEntity,\n\tParsedRelativeSingleField,\n\tParsedUnconstrainedQualifiedEntityList,\n\tParsedUnconstrainedQualifiedSingleEntity,\n} from './ParserResults'\nimport { CacheStore } from './CacheStore'\nimport { QueryLanguageError } from './QueryLanguageError'\nimport { tokenList, TokenRegExps, tokens } from './tokenList'\n\n/**\n * TODO:\n * \t- double quoted strings\n * \t- collections (objects & lists)\n * \t- collection operators (e.g. 'in', 'notIn', etc.)\n * \t- filtering toOne\n */\nclass Parser extends EmbeddedActionsParser {\n\tprivate static rawInput: string = ''\n\tprivate static lexer = new Lexer(tokenList)\n\tprivate static parser = new Parser()\n\tprivate static environment: Environment = new Environment()\n\tprivate static cacheStore: CacheStore = new CacheStore()\n\n\tprivate qualifiedEntityList = this.RULE<ParsedQualifiedEntityList>('qualifiedEntityList', () => {\n\t\tconst entityName = this.SUBRULE(this.entityIdentifier)\n\t\tconst filter = this.OPTION(() => this.SUBRULE(this.nonUniqueWhere))\n\n\t\tconst relativeSingleEntity = this.OPTION1(() => {\n\t\t\tthis.CONSUME(tokens.Dot)\n\t\t\treturn this.SUBRULE(this.relativeSingleEntity)\n\t\t})\n\t\tconst hasOneRelationPath = this.ACTION(() =>\n\t\t\trelativeSingleEntity === undefined ? [] : relativeSingleEntity.hasOneRelationPath,\n\t\t)\n\n\t\treturn {\n\t\t\tentityName,\n\t\t\tfilter,\n\t\t\thasOneRelationPath,\n\t\t}\n\t})\n\n\tprivate qualifiedFieldList = this.RULE<ParsedQualifiedFieldList>('qualifiedFieldList', () => {\n\t\tconst entityName = this.SUBRULE(this.entityIdentifier)\n\t\tconst filter = this.OPTION(() => this.SUBRULE(this.nonUniqueWhere))\n\n\t\tthis.CONSUME(tokens.Dot)\n\n\t\tconst { hasOneRelationPath, field } = this.SUBRULE(this.relativeSingleField)\n\n\t\treturn {\n\t\t\tentityName,\n\t\t\tfield,\n\t\t\tfilter,\n\t\t\thasOneRelationPath,\n\t\t}\n\t})\n\n\tprivate qualifiedSingleEntity = this.RULE<ParsedQualifiedSingleEntity>('qualifiedSingleEntity', () => {\n\t\tconst entityName = this.SUBRULE(this.entityIdentifier)\n\n\t\t// TODO this will probably go away once we support singleton entities\n\t\tconst where = this.SUBRULE(this.uniqueWhere)\n\t\tconst filter = this.OPTION(() => this.SUBRULE(this.nonUniqueWhere))\n\t\tconst relativeSingleEntity = this.OPTION1(() => {\n\t\t\tthis.CONSUME(tokens.Dot)\n\t\t\treturn this.SUBRULE(this.relativeSingleEntity)\n\t\t})\n\n\t\tconst hasOneRelationPath = this.ACTION(() =>\n\t\t\trelativeSingleEntity === undefined ? [] : relativeSingleEntity.hasOneRelationPath,\n\t\t)\n\n\t\treturn {\n\t\t\tentityName,\n\t\t\twhere,\n\t\t\thasOneRelationPath,\n\t\t\tfilter,\n\t\t}\n\t})\n\n\tprivate unconstrainedQualifiedEntityList = this.RULE<ParsedUnconstrainedQualifiedEntityList>(\n\t\t'unconstrainedQualifiedEntityList',\n\t\t() => {\n\t\t\tconst entityName = this.SUBRULE(this.entityIdentifier)\n\t\t\tconst relativeSingleEntity = this.OPTION(() => {\n\t\t\t\tthis.CONSUME(tokens.Dot)\n\t\t\t\treturn this.SUBRULE(this.relativeSingleEntity)\n\t\t\t})\n\n\t\t\tconst hasOneRelationPath = this.ACTION(() =>\n\t\t\t\trelativeSingleEntity === undefined ? [] : relativeSingleEntity.hasOneRelationPath,\n\t\t\t)\n\n\t\t\treturn {\n\t\t\t\tentityName,\n\t\t\t\thasOneRelationPath,\n\t\t\t}\n\t\t},\n\t)\n\n\tprivate unconstrainedQualifiedSingleEntity = this.RULE<ParsedUnconstrainedQualifiedSingleEntity>(\n\t\t'unconstrainedQualifiedSingleEntity',\n\t\t() => {\n\t\t\tconst entityName = this.SUBRULE(this.entityIdentifier)\n\t\t\tconst relativeSingleEntity = this.OPTION1(() => {\n\t\t\t\tthis.CONSUME(tokens.Dot)\n\t\t\t\treturn this.SUBRULE(this.relativeSingleEntity)\n\t\t\t})\n\n\t\t\tconst hasOneRelationPath = this.ACTION(() =>\n\t\t\t\trelativeSingleEntity === undefined ? [] : relativeSingleEntity.hasOneRelationPath,\n\t\t\t)\n\n\t\t\treturn {\n\t\t\t\tentityName,\n\t\t\t\thasOneRelationPath,\n\t\t\t}\n\t\t},\n\t)\n\n\tprivate relativeSingleField = this.RULE<ParsedRelativeSingleField>('relativeSingleField', () => {\n\t\tlet { hasOneRelationPath } = this.SUBRULE(this.relativeSingleEntity)\n\n\t\tconst last = this.ACTION(() => hasOneRelationPath.pop()!)\n\n\t\tthis.ACTION(() => {\n\t\t\tif (last.reducedBy !== undefined || last.filter !== undefined) {\n\t\t\t\tthrow new QueryLanguageError(\n\t\t\t\t\t`Cannot parse '${Parser.rawInput}': the last field '${last.field}' is being reduced or filtered, which, grammatically, makes it a relation but a single field is expected.`,\n\t\t\t\t)\n\t\t\t}\n\t\t})\n\n\t\tconst field = this.ACTION(() => last.field)\n\n\t\treturn {\n\t\t\thasOneRelationPath,\n\t\t\tfield,\n\t\t}\n\t})\n\n\tprivate relativeSingleEntity = this.RULE<ParsedRelativeSingleEntity>('relativeSingleEntity', () => {\n\t\tconst hasOneRelationPath: ParsedHasOneRelation[] = []\n\n\t\tthis.AT_LEAST_ONE_SEP({\n\t\t\tSEP: tokens.Dot,\n\t\t\tDEF: () => {\n\t\t\t\thasOneRelationPath.push(this.SUBRULE(this.hasOneRelation))\n\t\t\t},\n\t\t})\n\n\t\treturn {\n\t\t\thasOneRelationPath,\n\t\t}\n\t})\n\n\tprivate relativeEntityList = this.RULE<ParsedRelativeEntityList>('relativeEntityList', () => {\n\t\tlet { hasOneRelationPath } = this.SUBRULE(this.relativeSingleEntity)\n\n\t\tconst last = this.ACTION(() => hasOneRelationPath.pop()!)\n\n\t\tthis.ACTION(() => {\n\t\t\tif (last.reducedBy !== undefined) {\n\t\t\t\tthrow new QueryLanguageError(\n\t\t\t\t\t`Cannot parse '${Parser.rawInput}': the last field '${last.field}' is being reduced, which, grammatically, makes it a has-one relation but a has-many relation is expected.`,\n\t\t\t\t)\n\t\t\t}\n\t\t})\n\n\t\tconst hasManyRelation = this.ACTION(\n\t\t\t(): ParsedHasManyRelation => ({\n\t\t\t\tfield: last.field,\n\t\t\t\tfilter: last.filter,\n\t\t\t}),\n\t\t)\n\n\t\treturn {\n\t\t\thasOneRelationPath,\n\t\t\thasManyRelation,\n\t\t}\n\t})\n\n\tprivate hasOneRelation = this.RULE<ParsedHasOneRelation>('hasOneRelation', () => {\n\t\tconst fieldName = this.SUBRULE(this.fieldName)\n\t\tconst reducedBy = this.OPTION(() => this.SUBRULE(this.uniqueWhere))\n\t\tconst filter = this.OPTION1(() => this.SUBRULE(this.nonUniqueWhere))\n\t\tconst hasOneRelation: ParsedHasOneRelation = {\n\t\t\tfield: fieldName,\n\t\t\tfilter,\n\t\t\treducedBy,\n\t\t}\n\n\t\treturn hasOneRelation\n\t})\n\n\tprivate nonUniqueWhere: () => Filter = this.RULE('nonUniqueWhere', () => {\n\t\tconst cnfWhere: Filter[] = []\n\n\t\tthis.AT_LEAST_ONE(() => {\n\t\t\tthis.CONSUME(tokens.LeftBracket)\n\n\t\t\tcnfWhere.push(this.SUBRULE(this.disjunction))\n\n\t\t\tthis.CONSUME(tokens.RightBracket)\n\t\t})\n\t\tif (cnfWhere.length === 1) {\n\t\t\treturn cnfWhere[0]\n\t\t}\n\t\treturn {\n\t\t\tand: cnfWhere,\n\t\t}\n\t})\n\n\tprivate disjunction: () => Filter = this.RULE('disjunction', () => {\n\t\tconst conjunctions: Filter[] = []\n\n\t\tthis.AT_LEAST_ONE_SEP({\n\t\t\tSEP: tokens.Or,\n\t\t\tDEF: () => {\n\t\t\t\tconjunctions.push(this.SUBRULE(this.conjunction))\n\t\t\t},\n\t\t})\n\t\tif (conjunctions.length === 1) {\n\t\t\treturn conjunctions[0]\n\t\t}\n\t\treturn {\n\t\t\tor: conjunctions,\n\t\t}\n\t})\n\n\tprivate conjunction: () => Filter = this.RULE('conjunction', () => {\n\t\tconst negations: Filter[] = []\n\n\t\tthis.AT_LEAST_ONE_SEP({\n\t\t\tSEP: tokens.And,\n\t\t\tDEF: () => {\n\t\t\t\tnegations.push(this.SUBRULE(this.negation))\n\t\t\t},\n\t\t})\n\t\tif (negations.length === 1) {\n\t\t\treturn negations[0]\n\t\t}\n\t\treturn {\n\t\t\tand: negations,\n\t\t}\n\t})\n\n\t// TODO this is to naïve and needs rewriting\n\tprivate negation: () => Filter = this.RULE('negation', () => {\n\t\treturn this.OR([\n\t\t\t{\n\t\t\t\tALT: () => {\n\t\t\t\t\tthis.CONSUME(tokens.Not)\n\t\t\t\t\treturn {\n\t\t\t\t\t\tnot: this.SUBRULE(this.filterGroup),\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => {\n\t\t\t\t\treturn this.SUBRULE1(this.filterGroup)\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\t})\n\n\tprivate filterGroup: () => Filter = this.RULE('filterGroup', () => {\n\t\treturn this.OR([\n\t\t\t{\n\t\t\t\tALT: () => {\n\t\t\t\t\tthis.CONSUME(tokens.LeftParenthesis)\n\t\t\t\t\tconst subFilter = this.SUBRULE(this.disjunction)\n\t\t\t\t\tthis.CONSUME1(tokens.RightParenthesis)\n\t\t\t\t\treturn subFilter\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE1(this.filterAtom),\n\t\t\t},\n\t\t])\n\t})\n\n\tprivate filterAtom: () => Filter = this.RULE('filterAtom', () => {\n\t\treturn this.OR([\n\t\t\t{\n\t\t\t\tALT: () => {\n\t\t\t\t\tconst variable = this.SUBRULE(this.variable)\n\t\t\t\t\treturn this.ACTION(() => {\n\t\t\t\t\t\tif (typeof variable !== 'object' || variable instanceof GraphQlBuilder.GraphQlLiteral) {\n\t\t\t\t\t\t\tthrow new QueryLanguageError(`Invalid filter value '${JSON.stringify(variable)}'`)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn variable\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE1(this.fieldWhere),\n\t\t\t},\n\t\t])\n\t})\n\n\tprivate fieldWhere: () => Parser.AST.FieldWhere = this.RULE('fieldWhere', () => {\n\t\tconst fields: FieldName[] = []\n\n\t\tthis.AT_LEAST_ONE_SEP({\n\t\t\tSEP: tokens.Dot,\n\t\t\tDEF: () => {\n\t\t\t\tfields.push(this.SUBRULE(this.fieldIdentifier))\n\t\t\t},\n\t\t})\n\n\t\tconst condition = this.SUBRULE(this.condition)\n\n\t\tlet i = fields.length - 1\n\t\tlet where: Parser.AST.FieldWhere = {\n\t\t\t[fields[i--]]: condition,\n\t\t}\n\n\t\twhile (i >= 0) {\n\t\t\twhere = {\n\t\t\t\t[fields[i--]]: where,\n\t\t\t}\n\t\t}\n\n\t\treturn where\n\t})\n\n\tprivate condition: () => Parser.AST.Condition = this.RULE('condition', () => {\n\t\tconst operator = this.SUBRULE(this.conditionOperator)\n\t\tconst columnValue = this.SUBRULE(this.columnValue)\n\t\tconst condition: Parser.AST.Condition = {}\n\n\t\treturn this.ACTION(() => {\n\t\t\tif (columnValue === null) {\n\t\t\t\tif (operator === 'eq') {\n\t\t\t\t\tcondition.null = true\n\t\t\t\t} else if (operator === 'notEq') {\n\t\t\t\t\tcondition.null = false\n\t\t\t\t} else {\n\t\t\t\t\tthrow new QueryLanguageError(`The null keyword as a right hand operand can only be tested for (in)equality.`)\n\t\t\t\t}\n\t\t\t\treturn condition\n\t\t\t}\n\t\t\tcondition[operator] = columnValue\n\n\t\t\treturn condition\n\t\t})\n\t})\n\n\tprivate conditionOperator: () => Parser.AST.ConditionOperator = this.RULE<Parser.AST.ConditionOperator>(\n\t\t'conditionOperator',\n\t\t() => {\n\t\t\treturn this.OR([\n\t\t\t\t{\n\t\t\t\t\tALT: () => {\n\t\t\t\t\t\tthis.CONSUME(tokens.Equals)\n\t\t\t\t\t\treturn 'eq'\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tALT: () => {\n\t\t\t\t\t\tthis.CONSUME(tokens.NotEquals)\n\t\t\t\t\t\treturn 'notEq'\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tALT: () => {\n\t\t\t\t\t\tthis.CONSUME(tokens.LowerThan)\n\t\t\t\t\t\treturn 'lt'\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tALT: () => {\n\t\t\t\t\t\tthis.CONSUME(tokens.LowerEqual)\n\t\t\t\t\t\treturn 'lte'\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tALT: () => {\n\t\t\t\t\t\tthis.CONSUME(tokens.GreaterThan)\n\t\t\t\t\t\treturn 'gt'\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tALT: () => {\n\t\t\t\t\t\tthis.CONSUME(tokens.GreaterEqual)\n\t\t\t\t\t\treturn 'gte'\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t])\n\t\t},\n\t)\n\n\tprivate columnValue: () => Parser.AST.ColumnValue = this.RULE<Parser.AST.ColumnValue>('columnValue', () => {\n\t\treturn this.OR([\n\t\t\t{\n\t\t\t\tALT: () => {\n\t\t\t\t\tthis.CONSUME(tokens.Null)\n\t\t\t\t\treturn null\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => {\n\t\t\t\t\tthis.CONSUME(tokens.True)\n\t\t\t\t\treturn true\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => {\n\t\t\t\t\tthis.CONSUME(tokens.False)\n\t\t\t\t\treturn false\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE(this.primaryValue),\n\t\t\t},\n\t\t])\n\t})\n\n\tprivate uniqueWhere = this.RULE('uniqueWhere', () => {\n\t\tconst where: UniqueWhere = {}\n\n\t\tthis.CONSUME(tokens.LeftParenthesis)\n\t\tthis.AT_LEAST_ONE_SEP({\n\t\t\tSEP: tokens.Comma,\n\t\t\tDEF: () => {\n\t\t\t\tconst nestedFields: string[] = []\n\t\t\t\tthis.AT_LEAST_ONE_SEP1({\n\t\t\t\t\tSEP: tokens.Dot,\n\t\t\t\t\tDEF: () => {\n\t\t\t\t\t\tnestedFields.push(this.SUBRULE(this.fieldIdentifier))\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tthis.CONSUME(tokens.Equals)\n\t\t\t\tconst primaryValue = this.SUBRULE<Input.PrimaryValue<GraphQlBuilder.GraphQlLiteral>>(this.primaryValue)\n\n\t\t\t\tthis.ACTION(() => {\n\t\t\t\t\tlet nestedWhere = where\n\t\t\t\t\tfor (let i = 0, len = nestedFields.length; i < len; i++) {\n\t\t\t\t\t\tconst nestedField = nestedFields[i]\n\n\t\t\t\t\t\tconst isLast = len - 1 === i\n\n\t\t\t\t\t\tif (isLast) {\n\t\t\t\t\t\t\tif (nestedField in nestedWhere) {\n\t\t\t\t\t\t\t\tthrow new QueryLanguageError(`Duplicate '${nestedFields.slice(0, i + 1).join('.')}' field`)\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tnestedWhere[nestedField] = primaryValue\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (nestedField in nestedWhere) {\n\t\t\t\t\t\t\t\tconst existingWhere = nestedWhere[nestedField]\n\n\t\t\t\t\t\t\t\tif (typeof existingWhere === 'object' && !(existingWhere instanceof GraphQlBuilder.GraphQlLiteral)) {\n\t\t\t\t\t\t\t\t\tnestedWhere = existingWhere\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tthrow new QueryLanguageError(\n\t\t\t\t\t\t\t\t\t\t`Malformed expression: cannot simultaneously treat the '${nestedFields\n\t\t\t\t\t\t\t\t\t\t\t.slice(0, i + 1)\n\t\t\t\t\t\t\t\t\t\t\t.join('.')}' ` + `field as a scalar as well as a relation.`,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst newWhere = {}\n\t\t\t\t\t\t\t\tnestedWhere[nestedField] = newWhere\n\t\t\t\t\t\t\t\tnestedWhere = newWhere\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t},\n\t\t})\n\t\tthis.CONSUME(tokens.RightParenthesis)\n\n\t\treturn where\n\t})\n\n\tprivate orderBy: () => Input.OrderBy<CrudQueryBuilder.OrderDirection>[] = this.RULE<\n\t\tInput.OrderBy<CrudQueryBuilder.OrderDirection>[]\n\t>('orderBy', () => {\n\t\tconst order: Input.OrderBy<CrudQueryBuilder.OrderDirection>[] = []\n\n\t\tthis.AT_LEAST_ONE_SEP({\n\t\t\tSEP: tokens.Comma,\n\t\t\tDEF: () => {\n\t\t\t\tconst fieldNames: FieldName[] = []\n\t\t\t\tthis.AT_LEAST_ONE_SEP1({\n\t\t\t\t\tSEP: tokens.Dot,\n\t\t\t\t\tDEF: () => {\n\t\t\t\t\t\tfieldNames.push(this.SUBRULE(this.fieldIdentifier))\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tlet literal = this.OPTION(() => this.SUBRULE1(this.graphQlLiteral)) as\n\t\t\t\t\t| CrudQueryBuilder.OrderDirection\n\t\t\t\t\t| undefined\n\n\t\t\t\tthis.ACTION(() => {\n\t\t\t\t\tif (literal) {\n\t\t\t\t\t\tif (literal.value !== 'asc' && literal.value !== 'desc') {\n\t\t\t\t\t\t\tthrow new QueryLanguageError(`The only valid order directions are \\`asc\\` and \\`desc\\`.`)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tliteral = new GraphQlBuilder.GraphQlLiteral('asc')\n\t\t\t\t\t}\n\t\t\t\t\tlet orderBy: Input.FieldOrderBy<CrudQueryBuilder.OrderDirection> = literal\n\n\t\t\t\t\tfor (let i = fieldNames.length - 1; i >= 0; i--) {\n\t\t\t\t\t\torderBy = { [fieldNames[i]]: orderBy }\n\t\t\t\t\t}\n\t\t\t\t\torder.push(orderBy as Input.OrderBy<CrudQueryBuilder.OrderDirection>)\n\t\t\t\t})\n\t\t\t},\n\t\t})\n\n\t\treturn order\n\t})\n\n\tprivate taggedMap: () => ParsedTaggedMap = this.RULE<ParsedTaggedMap>('taggedMap', () => {\n\t\tconst name = this.SUBRULE(this.identifier)\n\t\treturn {\n\t\t\tname,\n\t\t\tentries: this.OPTION(() => this.SUBRULE(this.taggedMapEntries)) ?? [],\n\t\t}\n\t})\n\n\tprivate taggedMapEntries: () => ParsedTaggedMapEntry[] = this.RULE<ParsedTaggedMapEntry[]>('taggedMapEntries', () => {\n\t\tthis.CONSUME(tokens.LeftParenthesis)\n\t\tconst entries: ParsedTaggedMapEntry[] = []\n\t\tthis.AT_LEAST_ONE_SEP({\n\t\t\tSEP: tokens.Comma,\n\t\t\tDEF: () => entries.push(this.SUBRULE(this.taggedMapEntry)),\n\t\t})\n\t\tthis.CONSUME(tokens.RightParenthesis)\n\n\t\treturn entries\n\t})\n\n\tprivate taggedMapEntry: () => ParsedTaggedMapEntry = this.RULE<ParsedTaggedMapEntry>('taggedMapEntry', () => {\n\t\tconst variableName = this.CONSUME(tokens.Identifier).image\n\t\tthis.CONSUME1(tokens.Colon)\n\t\tconst value = this.OR([\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE(this.taggedMapLiteralValue),\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE(this.taggedMapVariableValue),\n\t\t\t},\n\t\t])\n\n\t\treturn {\n\t\t\tkey: variableName,\n\t\t\tvalue,\n\t\t}\n\t})\n\n\tprivate taggedMapLiteralValue: () => ParsedTaggedMapLiteralValue = this.RULE<ParsedTaggedMapLiteralValue>('taggedMapLiteralValue', () => {\n\t\tconst value = this.OR([\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE(this.string),\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE(this.number),\n\t\t\t},\n\t\t])\n\n\t\treturn {\n\t\t\ttype: 'literal',\n\t\t\tvalue,\n\t\t}\n\t})\n\n\tprivate taggedMapVariableValue: () => ParsedTaggedMapVariableValue = this.RULE<ParsedTaggedMapVariableValue>('taggedMapVariableValue', () => {\n\t\tconst start = this.CONSUME(tokens.DollarSign)\n\t\tthis.SUBRULE(this.relativeSingleField)\n\t\tconst end = this.LA(0)\n\t\tconst field = this.input.slice(this.input.indexOf(start) + 1, this.input.indexOf(end) + 1).map(it => it.image).join('')\n\n\t\treturn {\n\t\t\ttype: 'variable',\n\t\t\tvalue: field,\n\t\t}\n\t})\n\n\n\tprivate fieldName: () => FieldName = this.RULE<FieldName>('fieldName', () => {\n\t\treturn this.OR([\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE(this.fieldIdentifier),\n\t\t\t},\n\t\t])\n\t})\n\n\tprivate primaryValue = this.RULE<Input.PrimaryValue<GraphQlBuilder.GraphQlLiteral>>('primaryValue', () => {\n\t\treturn this.OR([\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE(this.string),\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE(this.number),\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE(this.graphQlLiteral),\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => {\n\t\t\t\t\tconst variableValue = this.SUBRULE(this.variable)\n\t\t\t\t\treturn this.ACTION(() => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\ttypeof variableValue === 'string' ||\n\t\t\t\t\t\t\ttypeof variableValue === 'number' ||\n\t\t\t\t\t\t\tvariableValue instanceof GraphQlBuilder.GraphQlLiteral\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn variableValue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow new QueryLanguageError(\n\t\t\t\t\t\t\t`A variable can resolve to a literal, string or a number, not ${typeof variableValue}`,\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\t})\n\n\tprivate fieldIdentifier: () => FieldName = this.RULE('fieldIdentifier', () => {\n\t\treturn this.SUBRULE(this.identifier)\n\t\t// return this.OR([\n\t\t// \t{\n\t\t// \t\tALT: () => this.SUBRULE(this.identifier),\n\t\t// \t},\n\t\t// \t{\n\t\t// \t\tALT: () => {\n\t\t// \t\t\tconst variable = this.SUBRULE(this.variable)\n\t\t// \t\t\treturn this.ACTION(() => {\n\t\t// \t\t\t\tif (!(typeof variable === 'string') || !TokenRegExps.identifier.test(variable)) {\n\t\t// \t\t\t\t\tthrow new QueryLanguageError(`The value \\$${variable} is not a valid field identifier.`)\n\t\t// \t\t\t\t}\n\t\t// \t\t\t\treturn variable\n\t\t// \t\t\t})\n\t\t// \t\t},\n\t\t// \t},\n\t\t// ])\n\t})\n\n\tprivate identifier: () => string = this.RULE('identifier', () => {\n\t\treturn this.OR([\n\t\t\t{\n\t\t\t\tALT: () => this.CONSUME(tokens.Identifier).image,\n\t\t\t},\n\t\t\t{\n\t\t\t\t// TODO this is a temporary hack to allow for literals that start with an uppercase letter… 🙈\n\t\t\t\tALT: () => this.CONSUME(tokens.EntityIdentifier).image,\n\t\t\t},\n\t\t])\n\t})\n\n\tprivate entityIdentifier: () => EntityName = this.RULE('entityIdentifier', () => {\n\t\treturn this.OR([\n\t\t\t{\n\t\t\t\tALT: () => this.CONSUME(tokens.EntityIdentifier).image,\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => {\n\t\t\t\t\tconst variable = this.SUBRULE(this.variable)\n\t\t\t\t\treturn this.ACTION(() => {\n\t\t\t\t\t\tif (!(typeof variable === 'string') || !TokenRegExps.entityIdentifier.test(variable)) {\n\t\t\t\t\t\t\tthrow new QueryLanguageError(`The value of the variable \\$${variable} is not a valid entity identifier.`)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn variable\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\t})\n\n\tprivate string = this.RULE('string', () => {\n\t\tconst image = this.CONSUME(tokens.StringLiteral).image\n\t\treturn image\n\t\t\t.substring(1, image.length - 1)\n\t\t\t.replace(\"\\\\'\", \"'\")\n\t\t\t.replace('\\\\b', '\\b')\n\t\t\t.replace('\\\\f', '\\f')\n\t\t\t.replace('\\\\n', '\\n')\n\t\t\t.replace('\\\\r', '\\r')\n\t\t\t.replace('\\\\t', '\\t')\n\t\t\t.replace('\\\\v', '\\v')\n\t})\n\n\tprivate number = this.RULE('number', () => {\n\t\treturn parseFloat(this.CONSUME(tokens.NumberLiteral).image)\n\t})\n\n\tprivate graphQlLiteral: () => GraphQlBuilder.GraphQlLiteral = this.RULE('graphQlLiteral', () => {\n\t\tconst image = this.SUBRULE(this.identifier)\n\n\t\treturn new GraphQlBuilder.GraphQlLiteral(image)\n\t})\n\n\tprivate variable = this.RULE<string | number | GraphQlLiteral | Filter | UniqueWhere>('variable', () => {\n\t\tthis.CONSUME(tokens.DollarSign)\n\t\tconst variableName = this.CONSUME(tokens.Identifier).image\n\n\t\treturn this.ACTION(() => {\n\t\t\tif (Parser.environment.hasName(variableName)) {\n\t\t\t\treturn Parser.environment.getValue(variableName)\n\t\t\t}\n\t\t\tif (Parser.environment.hasDimension(variableName)) {\n\t\t\t\tconst dimensionValue = Parser.environment.getDimension(variableName)\n\n\t\t\t\tif (dimensionValue.length === 1) {\n\t\t\t\t\treturn dimensionValue[0]\n\t\t\t\t}\n\t\t\t\tthrow new QueryLanguageError(\n\t\t\t\t\t`The variable \\$${variableName} resolved to a dimension which exists but contains ${dimensionValue.length} values. It has to contain exactly one. ` +\n\t\t\t\t\t\t`Perhaps you forgot to set the 'maxItems' prop of your DimensionsSwitcher?`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tthrow new QueryLanguageError(`Undefined variable \\$${variableName}.`)\n\t\t})\n\t})\n\n\tprivate constructor() {\n\t\tsuper(tokenList, { outputCst: false, maxLookahead: 1 })\n\t\tthis.performSelfAnalysis()\n\t}\n\n\tpublic static parseQueryLanguageExpression<E extends Parser.EntryPoint>(\n\t\tinput: string,\n\t\tentry: E,\n\t\tenvironment: Environment,\n\t): Parser.ParserResult[E] {\n\t\tconst cached = this.cacheStore.get(environment, entry, input)\n\n\t\tif (cached !== undefined) {\n\t\t\treturn cached\n\t\t}\n\n\t\tconst lexingResult = Parser.lexer.tokenize((Parser.rawInput = input))\n\n\t\tif (lexingResult.errors.length !== 0) {\n\t\t\tthrow new QueryLanguageError(\n\t\t\t\t`Failed to tokenize '${input}'.\\n\\n${lexingResult.errors.map(i => i.message).join('\\n')}`,\n\t\t\t)\n\t\t}\n\n\t\tParser.environment = environment\n\t\tParser.parser.input = lexingResult.tokens\n\n\t\tlet expression: Parser.ParserResult[keyof Parser.ParserResult]\n\n\t\tswitch (entry) {\n\t\t\tcase 'relativeSingleField':\n\t\t\t\texpression = Parser.parser.relativeSingleField()\n\t\t\t\tbreak\n\t\t\tcase 'relativeSingleEntity':\n\t\t\t\texpression = Parser.parser.relativeSingleEntity()\n\t\t\t\tbreak\n\t\t\tcase 'relativeEntityList':\n\t\t\t\texpression = Parser.parser.relativeEntityList()\n\t\t\t\tbreak\n\t\t\tcase 'qualifiedEntityList':\n\t\t\t\texpression = Parser.parser.qualifiedEntityList()\n\t\t\t\tbreak\n\t\t\tcase 'qualifiedFieldList':\n\t\t\t\texpression = Parser.parser.qualifiedFieldList()\n\t\t\t\tbreak\n\t\t\tcase 'qualifiedSingleEntity':\n\t\t\t\texpression = Parser.parser.qualifiedSingleEntity()\n\t\t\t\tbreak\n\t\t\tcase 'unconstrainedQualifiedEntityList':\n\t\t\t\texpression = Parser.parser.unconstrainedQualifiedEntityList()\n\t\t\t\tbreak\n\t\t\tcase 'unconstrainedQualifiedSingleEntity':\n\t\t\t\texpression = Parser.parser.unconstrainedQualifiedSingleEntity()\n\t\t\t\tbreak\n\t\t\tcase 'uniqueWhere':\n\t\t\t\texpression = Parser.parser.uniqueWhere()\n\t\t\t\tbreak\n\t\t\tcase 'filter':\n\t\t\t\texpression = Parser.parser.nonUniqueWhere()\n\t\t\t\tbreak\n\t\t\tcase 'orderBy':\n\t\t\t\texpression = Parser.parser.orderBy()\n\t\t\t\tbreak\n\t\t\tcase 'taggedMap':\n\t\t\t\texpression = Parser.parser.taggedMap()\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\tthrow new QueryLanguageError(`Not implemented entry point '${entry}'`)\n\t\t}\n\n\t\tif (Parser.parser.errors.length !== 0) {\n\t\t\tthrow new QueryLanguageError(\n\t\t\t\t`Failed to parse '${input}'.\\n\\n${Parser.parser.errors.map(i => i.message).join('\\n')}`,\n\t\t\t)\n\t\t}\n\n\t\tthis.cacheStore.set(environment, entry, input, expression as Parser.ParserResult[E])\n\n\t\treturn expression as Parser.ParserResult[E]\n\t}\n}\n\nnamespace Parser {\n\texport namespace AST {\n\t\texport type FieldWhere = Input.FieldWhere<Condition>\n\n\t\texport type ColumnValue = Input.ColumnValue<GraphQlBuilder.GraphQlLiteral>\n\n\t\texport type Condition = Input.Condition<ColumnValue>\n\n\t\texport type ConditionOperator = keyof Pick<Condition, 'eq' | 'notEq' | 'lt' | 'lte' | 'gt' | 'gte'>\n\t}\n\n\texport interface ParserResult {\n\t\tqualifiedEntityList: ParsedQualifiedEntityList // E.g. Author[age < 123].son.sisters(name = 'Jane')\n\t\tqualifiedFieldList: ParsedQualifiedFieldList // E.g. Author[age < 123].son.sister.name\n\t\tqualifiedSingleEntity: ParsedQualifiedSingleEntity // E.g. Author(id = 123).son.sister\n\t\tunconstrainedQualifiedEntityList: ParsedUnconstrainedQualifiedEntityList // E.g. Author.son.sister\n\t\tunconstrainedQualifiedSingleEntity: ParsedUnconstrainedQualifiedSingleEntity // E.g. Author.son.sister\n\t\trelativeSingleField: ParsedRelativeSingleField // E.g. authors(id = 123).person.name\n\t\trelativeSingleEntity: ParsedRelativeSingleEntity // E.g. localesByLocale(locale.slug = en)\n\t\trelativeEntityList: ParsedRelativeEntityList // E.g. genres(slug = 'sciFi').authors[age < 123]\n\t\tuniqueWhere: UniqueWhere // E.g. (author.mother.id = 123)\n\t\tfilter: Filter // E.g. [author.son.age < 123]\n\t\torderBy: OrderBy // E.g. items.order asc, items.content.name asc\n\t\ttaggedMap: ParsedTaggedMap // E.g editUser(id: $entity.id, foo: 'bar')\n\t}\n\n\texport type EntryPoint = keyof ParserResult\n}\n\nexport { Parser }\n"],"names":[],"mappings":";;;;;;;AA+BA,qBAAqB,sBAAsB;AAAA,SAC3B,WAAmB;AAAA,SACnB,QAAQ,IAAI,MAAM;AAAA,SAClB,SAAS,IAAI;AAAA,SACb,cAA2B,IAAI;AAAA,SAC/B,aAAyB,IAAI;AAAA,EAEpC,sBAAsB,KAAK,KAAgC,uBAAuB,MAAM;AAC/F,UAAM,aAAa,KAAK,QAAQ,KAAK;AACrC,UAAM,SAAS,KAAK,OAAO,MAAM,KAAK,QAAQ,KAAK;AAEnD,UAAM,uBAAuB,KAAK,QAAQ,MAAM;AAC/C,WAAK,QAAQ,OAAO;AACpB,aAAO,KAAK,QAAQ,KAAK;AAAA;AAE1B,UAAM,qBAAqB,KAAK,OAAO,MACtC,yBAAyB,SAAY,KAAK,qBAAqB;AAGhE,WAAO;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA;AAAA;AAAA,EAIM,qBAAqB,KAAK,KAA+B,sBAAsB,MAAM;AAC5F,UAAM,aAAa,KAAK,QAAQ,KAAK;AACrC,UAAM,SAAS,KAAK,OAAO,MAAM,KAAK,QAAQ,KAAK;AAEnD,SAAK,QAAQ,OAAO;AAEpB,UAAM,EAAE,oBAAoB,UAAU,KAAK,QAAQ,KAAK;AAExD,WAAO;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA;AAAA,EAIM,wBAAwB,KAAK,KAAkC,yBAAyB,MAAM;AACr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K;AAAA;AAIlF,SAAK,WAAW,IAAI,aAAa,OAAO,OAAO;AAE/C,WAAO;AAAA;AAAA;;;;"}
1
+ {"version":3,"file":"Parser.js","sources":["../../../src/queryLanguage/Parser.ts"],"sourcesContent":["import { CrudQueryBuilder, GraphQlBuilder, GraphQlLiteral, Input } from '@contember/client'\nimport { EmbeddedActionsParser, Lexer } from 'chevrotain'\nimport { Environment } from '../dao'\nimport type { EntityName, FieldName, Filter, OrderBy, UniqueWhere } from '../treeParameters'\nimport type {\n\tParsedTaggedMap,\n\tParsedTaggedMapVariableValue,\n\tParsedTaggedMapLiteralValue,\n\tParsedTaggedMapEntry,\n\tParsedHasManyRelation,\n\tParsedHasOneRelation,\n\tParsedQualifiedEntityList,\n\tParsedQualifiedFieldList,\n\tParsedQualifiedSingleEntity,\n\tParsedRelativeEntityList,\n\tParsedRelativeSingleEntity,\n\tParsedRelativeSingleField,\n\tParsedUnconstrainedQualifiedEntityList,\n\tParsedUnconstrainedQualifiedSingleEntity,\n} from './ParserResults'\nimport { CacheStore } from './CacheStore'\nimport { QueryLanguageError } from './QueryLanguageError'\nimport { tokenList, TokenRegExps, tokens } from './tokenList'\n\n/**\n * TODO:\n * \t- double quoted strings\n * \t- collections (objects & lists)\n * \t- collection operators (e.g. 'in', 'notIn', etc.)\n * \t- filtering toOne\n */\nclass Parser extends EmbeddedActionsParser {\n\tprivate static rawInput: string = ''\n\tprivate static lexer = new Lexer(tokenList)\n\tprivate static parser = new Parser()\n\tprivate static environment: Environment = new Environment()\n\tprivate static cacheStore: CacheStore = new CacheStore()\n\n\tprivate qualifiedEntityList = this.RULE<ParsedQualifiedEntityList>('qualifiedEntityList', () => {\n\t\tconst entityName = this.SUBRULE(this.entityIdentifier)\n\t\tconst filter = this.OPTION(() => this.SUBRULE(this.nonUniqueWhere))\n\n\t\tconst relativeSingleEntity = this.OPTION1(() => {\n\t\t\tthis.CONSUME(tokens.Dot)\n\t\t\treturn this.SUBRULE(this.relativeSingleEntity)\n\t\t})\n\t\tconst hasOneRelationPath = this.ACTION(() =>\n\t\t\trelativeSingleEntity === undefined ? [] : relativeSingleEntity.hasOneRelationPath,\n\t\t)\n\n\t\treturn {\n\t\t\tentityName,\n\t\t\tfilter,\n\t\t\thasOneRelationPath,\n\t\t}\n\t})\n\n\tprivate qualifiedFieldList = this.RULE<ParsedQualifiedFieldList>('qualifiedFieldList', () => {\n\t\tconst entityName = this.SUBRULE(this.entityIdentifier)\n\t\tconst filter = this.OPTION(() => this.SUBRULE(this.nonUniqueWhere))\n\n\t\tthis.CONSUME(tokens.Dot)\n\n\t\tconst { hasOneRelationPath, field } = this.SUBRULE(this.relativeSingleField)\n\n\t\treturn {\n\t\t\tentityName,\n\t\t\tfield,\n\t\t\tfilter,\n\t\t\thasOneRelationPath,\n\t\t}\n\t})\n\n\tprivate qualifiedSingleEntity = this.RULE<ParsedQualifiedSingleEntity>('qualifiedSingleEntity', () => {\n\t\tconst entityName = this.SUBRULE(this.entityIdentifier)\n\n\t\t// TODO this will probably go away once we support singleton entities\n\t\tconst where = this.SUBRULE(this.uniqueWhere)\n\t\tconst filter = this.OPTION(() => this.SUBRULE(this.nonUniqueWhere))\n\t\tconst relativeSingleEntity = this.OPTION1(() => {\n\t\t\tthis.CONSUME(tokens.Dot)\n\t\t\treturn this.SUBRULE(this.relativeSingleEntity)\n\t\t})\n\n\t\tconst hasOneRelationPath = this.ACTION(() =>\n\t\t\trelativeSingleEntity === undefined ? [] : relativeSingleEntity.hasOneRelationPath,\n\t\t)\n\n\t\treturn {\n\t\t\tentityName,\n\t\t\twhere,\n\t\t\thasOneRelationPath,\n\t\t\tfilter,\n\t\t}\n\t})\n\n\tprivate unconstrainedQualifiedEntityList = this.RULE<ParsedUnconstrainedQualifiedEntityList>(\n\t\t'unconstrainedQualifiedEntityList',\n\t\t() => {\n\t\t\tconst entityName = this.SUBRULE(this.entityIdentifier)\n\t\t\tconst relativeSingleEntity = this.OPTION(() => {\n\t\t\t\tthis.CONSUME(tokens.Dot)\n\t\t\t\treturn this.SUBRULE(this.relativeSingleEntity)\n\t\t\t})\n\n\t\t\tconst hasOneRelationPath = this.ACTION(() =>\n\t\t\t\trelativeSingleEntity === undefined ? [] : relativeSingleEntity.hasOneRelationPath,\n\t\t\t)\n\n\t\t\treturn {\n\t\t\t\tentityName,\n\t\t\t\thasOneRelationPath,\n\t\t\t}\n\t\t},\n\t)\n\n\tprivate unconstrainedQualifiedSingleEntity = this.RULE<ParsedUnconstrainedQualifiedSingleEntity>(\n\t\t'unconstrainedQualifiedSingleEntity',\n\t\t() => {\n\t\t\tconst entityName = this.SUBRULE(this.entityIdentifier)\n\t\t\tconst relativeSingleEntity = this.OPTION1(() => {\n\t\t\t\tthis.CONSUME(tokens.Dot)\n\t\t\t\treturn this.SUBRULE(this.relativeSingleEntity)\n\t\t\t})\n\n\t\t\tconst hasOneRelationPath = this.ACTION(() =>\n\t\t\t\trelativeSingleEntity === undefined ? [] : relativeSingleEntity.hasOneRelationPath,\n\t\t\t)\n\n\t\t\treturn {\n\t\t\t\tentityName,\n\t\t\t\thasOneRelationPath,\n\t\t\t}\n\t\t},\n\t)\n\n\tprivate relativeSingleField = this.RULE<ParsedRelativeSingleField>('relativeSingleField', () => {\n\t\tlet { hasOneRelationPath } = this.SUBRULE(this.relativeSingleEntity)\n\n\t\tconst last = this.ACTION(() => hasOneRelationPath.pop()!)\n\n\t\tthis.ACTION(() => {\n\t\t\tif (last.reducedBy !== undefined || last.filter !== undefined) {\n\t\t\t\tthrow new QueryLanguageError(\n\t\t\t\t\t`Cannot parse '${Parser.rawInput}': the last field '${last.field}' is being reduced or filtered, which, grammatically, makes it a relation but a single field is expected.`,\n\t\t\t\t)\n\t\t\t}\n\t\t})\n\n\t\tconst field = this.ACTION(() => last.field)\n\n\t\treturn {\n\t\t\thasOneRelationPath,\n\t\t\tfield,\n\t\t}\n\t})\n\n\tprivate relativeSingleEntity = this.RULE<ParsedRelativeSingleEntity>('relativeSingleEntity', () => {\n\t\tconst hasOneRelationPath: ParsedHasOneRelation[] = []\n\n\t\tthis.AT_LEAST_ONE_SEP({\n\t\t\tSEP: tokens.Dot,\n\t\t\tDEF: () => {\n\t\t\t\thasOneRelationPath.push(this.SUBRULE(this.hasOneRelation))\n\t\t\t},\n\t\t})\n\n\t\treturn {\n\t\t\thasOneRelationPath,\n\t\t}\n\t})\n\n\tprivate relativeEntityList = this.RULE<ParsedRelativeEntityList>('relativeEntityList', () => {\n\t\tlet { hasOneRelationPath } = this.SUBRULE(this.relativeSingleEntity)\n\n\t\tconst last = this.ACTION(() => hasOneRelationPath.pop()!)\n\n\t\tthis.ACTION(() => {\n\t\t\tif (last.reducedBy !== undefined) {\n\t\t\t\tthrow new QueryLanguageError(\n\t\t\t\t\t`Cannot parse '${Parser.rawInput}': the last field '${last.field}' is being reduced, which, grammatically, makes it a has-one relation but a has-many relation is expected.`,\n\t\t\t\t)\n\t\t\t}\n\t\t})\n\n\t\tconst hasManyRelation = this.ACTION(\n\t\t\t(): ParsedHasManyRelation => ({\n\t\t\t\tfield: last.field,\n\t\t\t\tfilter: last.filter,\n\t\t\t}),\n\t\t)\n\n\t\treturn {\n\t\t\thasOneRelationPath,\n\t\t\thasManyRelation,\n\t\t}\n\t})\n\n\tprivate hasOneRelation = this.RULE<ParsedHasOneRelation>('hasOneRelation', () => {\n\t\tconst fieldName = this.SUBRULE(this.fieldName)\n\t\tconst reducedBy = this.OPTION(() => this.SUBRULE(this.uniqueWhere))\n\t\tconst filter = this.OPTION1(() => this.SUBRULE(this.nonUniqueWhere))\n\t\tconst hasOneRelation: ParsedHasOneRelation = {\n\t\t\tfield: fieldName,\n\t\t\tfilter,\n\t\t\treducedBy,\n\t\t}\n\n\t\treturn hasOneRelation\n\t})\n\n\tprivate nonUniqueWhere: () => Filter = this.RULE('nonUniqueWhere', () => {\n\t\tconst cnfWhere: Filter[] = []\n\n\t\tthis.AT_LEAST_ONE(() => {\n\t\t\tthis.CONSUME(tokens.LeftBracket)\n\n\t\t\tcnfWhere.push(this.SUBRULE(this.disjunction))\n\n\t\t\tthis.CONSUME(tokens.RightBracket)\n\t\t})\n\t\tif (cnfWhere.length === 1) {\n\t\t\treturn cnfWhere[0]\n\t\t}\n\t\treturn {\n\t\t\tand: cnfWhere,\n\t\t}\n\t})\n\n\tprivate disjunction: () => Filter = this.RULE('disjunction', () => {\n\t\tconst conjunctions: Filter[] = []\n\n\t\tthis.AT_LEAST_ONE_SEP({\n\t\t\tSEP: tokens.Or,\n\t\t\tDEF: () => {\n\t\t\t\tconjunctions.push(this.SUBRULE(this.conjunction))\n\t\t\t},\n\t\t})\n\t\tif (conjunctions.length === 1) {\n\t\t\treturn conjunctions[0]\n\t\t}\n\t\treturn {\n\t\t\tor: conjunctions,\n\t\t}\n\t})\n\n\tprivate conjunction: () => Filter = this.RULE('conjunction', () => {\n\t\tconst negations: Filter[] = []\n\n\t\tthis.AT_LEAST_ONE_SEP({\n\t\t\tSEP: tokens.And,\n\t\t\tDEF: () => {\n\t\t\t\tnegations.push(this.SUBRULE(this.negation))\n\t\t\t},\n\t\t})\n\t\tif (negations.length === 1) {\n\t\t\treturn negations[0]\n\t\t}\n\t\treturn {\n\t\t\tand: negations,\n\t\t}\n\t})\n\n\t// TODO this is to naïve and needs rewriting\n\tprivate negation: () => Filter = this.RULE('negation', () => {\n\t\treturn this.OR([\n\t\t\t{\n\t\t\t\tALT: () => {\n\t\t\t\t\tthis.CONSUME(tokens.Not)\n\t\t\t\t\treturn {\n\t\t\t\t\t\tnot: this.SUBRULE(this.filterGroup),\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => {\n\t\t\t\t\treturn this.SUBRULE1(this.filterGroup)\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\t})\n\n\tprivate filterGroup: () => Filter = this.RULE('filterGroup', () => {\n\t\treturn this.OR([\n\t\t\t{\n\t\t\t\tALT: () => {\n\t\t\t\t\tthis.CONSUME(tokens.LeftParenthesis)\n\t\t\t\t\tconst subFilter = this.SUBRULE(this.disjunction)\n\t\t\t\t\tthis.CONSUME1(tokens.RightParenthesis)\n\t\t\t\t\treturn subFilter\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE1(this.filterAtom),\n\t\t\t},\n\t\t])\n\t})\n\n\tprivate filterAtom: () => Filter = this.RULE('filterAtom', () => {\n\t\treturn this.OR([\n\t\t\t{\n\t\t\t\tALT: () => {\n\t\t\t\t\tconst variable = this.SUBRULE(this.variable)\n\t\t\t\t\treturn this.ACTION(() => {\n\t\t\t\t\t\tif (typeof variable !== 'object' || variable instanceof GraphQlBuilder.GraphQlLiteral) {\n\t\t\t\t\t\t\tthrow new QueryLanguageError(`Invalid filter value '${JSON.stringify(variable)}'`)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn variable\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE1(this.fieldWhere),\n\t\t\t},\n\t\t])\n\t})\n\n\tprivate fieldWhere: () => Parser.AST.FieldWhere = this.RULE('fieldWhere', () => {\n\t\tconst fields: FieldName[] = []\n\n\t\tthis.AT_LEAST_ONE_SEP({\n\t\t\tSEP: tokens.Dot,\n\t\t\tDEF: () => {\n\t\t\t\tfields.push(this.SUBRULE(this.fieldIdentifier))\n\t\t\t},\n\t\t})\n\n\t\tconst condition = this.SUBRULE(this.condition)\n\n\t\tlet i = fields.length - 1\n\t\tlet where: Parser.AST.FieldWhere = {\n\t\t\t[fields[i--]]: condition,\n\t\t}\n\n\t\twhile (i >= 0) {\n\t\t\twhere = {\n\t\t\t\t[fields[i--]]: where,\n\t\t\t}\n\t\t}\n\n\t\treturn where\n\t})\n\n\tprivate condition: () => Parser.AST.Condition = this.RULE('condition', () => {\n\t\tconst operator = this.SUBRULE(this.conditionOperator)\n\t\tconst columnValue = this.SUBRULE(this.columnValue)\n\t\tconst condition: Parser.AST.Condition = {}\n\n\t\treturn this.ACTION(() => {\n\t\t\tif (columnValue === null) {\n\t\t\t\tif (operator === 'eq') {\n\t\t\t\t\tcondition.null = true\n\t\t\t\t} else if (operator === 'notEq') {\n\t\t\t\t\tcondition.null = false\n\t\t\t\t} else {\n\t\t\t\t\tthrow new QueryLanguageError(`The null keyword as a right hand operand can only be tested for (in)equality.`)\n\t\t\t\t}\n\t\t\t\treturn condition\n\t\t\t}\n\t\t\tcondition[operator] = columnValue\n\n\t\t\treturn condition\n\t\t})\n\t})\n\n\tprivate conditionOperator: () => Parser.AST.ConditionOperator = this.RULE<Parser.AST.ConditionOperator>(\n\t\t'conditionOperator',\n\t\t() => {\n\t\t\treturn this.OR([\n\t\t\t\t{\n\t\t\t\t\tALT: () => {\n\t\t\t\t\t\tthis.CONSUME(tokens.Equals)\n\t\t\t\t\t\treturn 'eq'\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tALT: () => {\n\t\t\t\t\t\tthis.CONSUME(tokens.NotEquals)\n\t\t\t\t\t\treturn 'notEq'\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tALT: () => {\n\t\t\t\t\t\tthis.CONSUME(tokens.LowerThan)\n\t\t\t\t\t\treturn 'lt'\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tALT: () => {\n\t\t\t\t\t\tthis.CONSUME(tokens.LowerEqual)\n\t\t\t\t\t\treturn 'lte'\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tALT: () => {\n\t\t\t\t\t\tthis.CONSUME(tokens.GreaterThan)\n\t\t\t\t\t\treturn 'gt'\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tALT: () => {\n\t\t\t\t\t\tthis.CONSUME(tokens.GreaterEqual)\n\t\t\t\t\t\treturn 'gte'\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t])\n\t\t},\n\t)\n\n\tprivate columnValue: () => Parser.AST.ColumnValue = this.RULE<Parser.AST.ColumnValue>('columnValue', () => {\n\t\treturn this.OR([\n\t\t\t{\n\t\t\t\tALT: () => {\n\t\t\t\t\tthis.CONSUME(tokens.Null)\n\t\t\t\t\treturn null\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => {\n\t\t\t\t\tthis.CONSUME(tokens.True)\n\t\t\t\t\treturn true\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => {\n\t\t\t\t\tthis.CONSUME(tokens.False)\n\t\t\t\t\treturn false\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE(this.primaryValue),\n\t\t\t},\n\t\t])\n\t})\n\n\tprivate uniqueWhere = this.RULE('uniqueWhere', () => {\n\t\tconst where: UniqueWhere = {}\n\n\t\tthis.CONSUME(tokens.LeftParenthesis)\n\t\tthis.AT_LEAST_ONE_SEP({\n\t\t\tSEP: tokens.Comma,\n\t\t\tDEF: () => {\n\t\t\t\tconst nestedFields: string[] = []\n\t\t\t\tthis.AT_LEAST_ONE_SEP1({\n\t\t\t\t\tSEP: tokens.Dot,\n\t\t\t\t\tDEF: () => {\n\t\t\t\t\t\tnestedFields.push(this.SUBRULE(this.fieldIdentifier))\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tthis.CONSUME(tokens.Equals)\n\t\t\t\tconst primaryValue = this.SUBRULE<Input.PrimaryValue<GraphQlBuilder.GraphQlLiteral>>(this.primaryValue)\n\n\t\t\t\tthis.ACTION(() => {\n\t\t\t\t\tlet nestedWhere = where\n\t\t\t\t\tfor (let i = 0, len = nestedFields.length; i < len; i++) {\n\t\t\t\t\t\tconst nestedField = nestedFields[i]\n\n\t\t\t\t\t\tconst isLast = len - 1 === i\n\n\t\t\t\t\t\tif (isLast) {\n\t\t\t\t\t\t\tif (nestedField in nestedWhere) {\n\t\t\t\t\t\t\t\tthrow new QueryLanguageError(`Duplicate '${nestedFields.slice(0, i + 1).join('.')}' field`)\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tnestedWhere[nestedField] = primaryValue\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (nestedField in nestedWhere) {\n\t\t\t\t\t\t\t\tconst existingWhere = nestedWhere[nestedField]\n\n\t\t\t\t\t\t\t\tif (typeof existingWhere === 'object' && !(existingWhere instanceof GraphQlBuilder.GraphQlLiteral)) {\n\t\t\t\t\t\t\t\t\tnestedWhere = existingWhere\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tthrow new QueryLanguageError(\n\t\t\t\t\t\t\t\t\t\t`Malformed expression: cannot simultaneously treat the '${nestedFields\n\t\t\t\t\t\t\t\t\t\t\t.slice(0, i + 1)\n\t\t\t\t\t\t\t\t\t\t\t.join('.')}' ` + `field as a scalar as well as a relation.`,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst newWhere = {}\n\t\t\t\t\t\t\t\tnestedWhere[nestedField] = newWhere\n\t\t\t\t\t\t\t\tnestedWhere = newWhere\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t},\n\t\t})\n\t\tthis.CONSUME(tokens.RightParenthesis)\n\n\t\treturn where\n\t})\n\n\tprivate orderBy: () => Input.OrderBy<CrudQueryBuilder.OrderDirection>[] = this.RULE<\n\t\tInput.OrderBy<CrudQueryBuilder.OrderDirection>[]\n\t>('orderBy', () => {\n\t\tconst order: Input.OrderBy<CrudQueryBuilder.OrderDirection>[] = []\n\n\t\tthis.AT_LEAST_ONE_SEP({\n\t\t\tSEP: tokens.Comma,\n\t\t\tDEF: () => {\n\t\t\t\tconst fieldNames: FieldName[] = []\n\t\t\t\tthis.AT_LEAST_ONE_SEP1({\n\t\t\t\t\tSEP: tokens.Dot,\n\t\t\t\t\tDEF: () => {\n\t\t\t\t\t\tfieldNames.push(this.SUBRULE(this.fieldIdentifier))\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tlet literal = this.OPTION(() => this.SUBRULE1(this.graphQlLiteral)) as\n\t\t\t\t\t| CrudQueryBuilder.OrderDirection\n\t\t\t\t\t| undefined\n\n\t\t\t\tthis.ACTION(() => {\n\t\t\t\t\tif (literal) {\n\t\t\t\t\t\tif (literal.value !== 'asc' && literal.value !== 'desc') {\n\t\t\t\t\t\t\tthrow new QueryLanguageError(`The only valid order directions are \\`asc\\` and \\`desc\\`.`)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tliteral = new GraphQlBuilder.GraphQlLiteral('asc')\n\t\t\t\t\t}\n\t\t\t\t\tlet orderBy: Input.FieldOrderBy<CrudQueryBuilder.OrderDirection> = literal\n\n\t\t\t\t\tfor (let i = fieldNames.length - 1; i >= 0; i--) {\n\t\t\t\t\t\torderBy = { [fieldNames[i]]: orderBy }\n\t\t\t\t\t}\n\t\t\t\t\torder.push(orderBy as Input.OrderBy<CrudQueryBuilder.OrderDirection>)\n\t\t\t\t})\n\t\t\t},\n\t\t})\n\n\t\treturn order\n\t})\n\n\tprivate taggedMap: () => ParsedTaggedMap = this.RULE<ParsedTaggedMap>('taggedMap', () => {\n\t\tconst name = this.SUBRULE(this.pageName)\n\t\treturn {\n\t\t\tname,\n\t\t\tentries: this.OPTION(() => this.SUBRULE(this.taggedMapEntries)) ?? [],\n\t\t}\n\t})\n\n\tprivate taggedMapEntries: () => ParsedTaggedMapEntry[] = this.RULE<ParsedTaggedMapEntry[]>('taggedMapEntries', () => {\n\t\tthis.CONSUME(tokens.LeftParenthesis)\n\t\tconst entries: ParsedTaggedMapEntry[] = []\n\t\tthis.AT_LEAST_ONE_SEP({\n\t\t\tSEP: tokens.Comma,\n\t\t\tDEF: () => entries.push(this.SUBRULE(this.taggedMapEntry)),\n\t\t})\n\t\tthis.CONSUME(tokens.RightParenthesis)\n\n\t\treturn entries\n\t})\n\n\tprivate taggedMapEntry: () => ParsedTaggedMapEntry = this.RULE<ParsedTaggedMapEntry>('taggedMapEntry', () => {\n\t\tconst variableName = this.CONSUME(tokens.Identifier).image\n\t\tthis.CONSUME1(tokens.Colon)\n\t\tconst value = this.OR([\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE(this.taggedMapLiteralValue),\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE(this.taggedMapVariableValue),\n\t\t\t},\n\t\t])\n\n\t\treturn {\n\t\t\tkey: variableName,\n\t\t\tvalue,\n\t\t}\n\t})\n\n\tprivate taggedMapLiteralValue: () => ParsedTaggedMapLiteralValue = this.RULE<ParsedTaggedMapLiteralValue>('taggedMapLiteralValue', () => {\n\t\tconst value = this.OR([\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE(this.string),\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE(this.number),\n\t\t\t},\n\t\t])\n\n\t\treturn {\n\t\t\ttype: 'literal',\n\t\t\tvalue,\n\t\t}\n\t})\n\n\tprivate taggedMapVariableValue: () => ParsedTaggedMapVariableValue = this.RULE<ParsedTaggedMapVariableValue>('taggedMapVariableValue', () => {\n\t\tconst start = this.CONSUME(tokens.DollarSign)\n\t\tthis.SUBRULE(this.relativeSingleField)\n\t\tconst end = this.LA(0)\n\t\tconst field = this.input.slice(this.input.indexOf(start) + 1, this.input.indexOf(end) + 1).map(it => it.image).join('')\n\n\t\treturn {\n\t\t\ttype: 'variable',\n\t\t\tvalue: field,\n\t\t}\n\t})\n\n\n\tprivate fieldName: () => FieldName = this.RULE<FieldName>('fieldName', () => {\n\t\treturn this.OR([\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE(this.fieldIdentifier),\n\t\t\t},\n\t\t])\n\t})\n\n\tprivate primaryValue = this.RULE<Input.PrimaryValue<GraphQlBuilder.GraphQlLiteral>>('primaryValue', () => {\n\t\treturn this.OR([\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE(this.string),\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE(this.number),\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => this.SUBRULE(this.graphQlLiteral),\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => {\n\t\t\t\t\tconst variableValue = this.SUBRULE(this.variable)\n\t\t\t\t\treturn this.ACTION(() => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\ttypeof variableValue === 'string' ||\n\t\t\t\t\t\t\ttypeof variableValue === 'number' ||\n\t\t\t\t\t\t\tvariableValue instanceof GraphQlBuilder.GraphQlLiteral\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn variableValue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow new QueryLanguageError(\n\t\t\t\t\t\t\t`A variable can resolve to a literal, string or a number, not ${typeof variableValue}`,\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\t})\n\n\tprivate fieldIdentifier: () => FieldName = this.RULE('fieldIdentifier', () => {\n\t\treturn this.SUBRULE(this.identifier)\n\t\t// return this.OR([\n\t\t// \t{\n\t\t// \t\tALT: () => this.SUBRULE(this.identifier),\n\t\t// \t},\n\t\t// \t{\n\t\t// \t\tALT: () => {\n\t\t// \t\t\tconst variable = this.SUBRULE(this.variable)\n\t\t// \t\t\treturn this.ACTION(() => {\n\t\t// \t\t\t\tif (!(typeof variable === 'string') || !TokenRegExps.identifier.test(variable)) {\n\t\t// \t\t\t\t\tthrow new QueryLanguageError(`The value \\$${variable} is not a valid field identifier.`)\n\t\t// \t\t\t\t}\n\t\t// \t\t\t\treturn variable\n\t\t// \t\t\t})\n\t\t// \t\t},\n\t\t// \t},\n\t\t// ])\n\t})\n\n\tprivate identifier: () => string = this.RULE('identifier', () => {\n\t\treturn this.OR([\n\t\t\t{\n\t\t\t\tALT: () => this.CONSUME(tokens.Identifier).image,\n\t\t\t},\n\t\t\t{\n\t\t\t\t// TODO this is a temporary hack to allow for literals that start with an uppercase letter… 🙈\n\t\t\t\tALT: () => this.CONSUME(tokens.EntityIdentifier).image,\n\t\t\t},\n\t\t])\n\t})\n\n\tprivate pageName: () => string = this.RULE('pageName', () => {\n\t\tconst parts: string[] = []\n\n\t\tthis.AT_LEAST_ONE_SEP({\n\t\t\tSEP: tokens.Slash,\n\t\t\tDEF: () => parts.push(this.CONSUME(tokens.Identifier).image),\n\t\t})\n\n\t\treturn parts.join('/')\n\t})\n\n\tprivate entityIdentifier: () => EntityName = this.RULE('entityIdentifier', () => {\n\t\treturn this.OR([\n\t\t\t{\n\t\t\t\tALT: () => this.CONSUME(tokens.EntityIdentifier).image,\n\t\t\t},\n\t\t\t{\n\t\t\t\tALT: () => {\n\t\t\t\t\tconst variable = this.SUBRULE(this.variable)\n\t\t\t\t\treturn this.ACTION(() => {\n\t\t\t\t\t\tif (!(typeof variable === 'string') || !TokenRegExps.entityIdentifier.test(variable)) {\n\t\t\t\t\t\t\tthrow new QueryLanguageError(`The value of the variable \\$${variable} is not a valid entity identifier.`)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn variable\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\t})\n\n\tprivate string = this.RULE('string', () => {\n\t\tconst image = this.CONSUME(tokens.StringLiteral).image\n\t\treturn image\n\t\t\t.substring(1, image.length - 1)\n\t\t\t.replace(\"\\\\'\", \"'\")\n\t\t\t.replace('\\\\b', '\\b')\n\t\t\t.replace('\\\\f', '\\f')\n\t\t\t.replace('\\\\n', '\\n')\n\t\t\t.replace('\\\\r', '\\r')\n\t\t\t.replace('\\\\t', '\\t')\n\t\t\t.replace('\\\\v', '\\v')\n\t})\n\n\tprivate number = this.RULE('number', () => {\n\t\treturn parseFloat(this.CONSUME(tokens.NumberLiteral).image)\n\t})\n\n\tprivate graphQlLiteral: () => GraphQlBuilder.GraphQlLiteral = this.RULE('graphQlLiteral', () => {\n\t\tconst image = this.SUBRULE(this.identifier)\n\n\t\treturn new GraphQlBuilder.GraphQlLiteral(image)\n\t})\n\n\tprivate variable = this.RULE<string | number | GraphQlLiteral | Filter | UniqueWhere>('variable', () => {\n\t\tthis.CONSUME(tokens.DollarSign)\n\t\tconst variableName = this.CONSUME(tokens.Identifier).image\n\n\t\treturn this.ACTION(() => {\n\t\t\tif (Parser.environment.hasName(variableName)) {\n\t\t\t\treturn Parser.environment.getValue(variableName)\n\t\t\t}\n\t\t\tif (Parser.environment.hasDimension(variableName)) {\n\t\t\t\tconst dimensionValue = Parser.environment.getDimension(variableName)\n\n\t\t\t\tif (dimensionValue.length === 1) {\n\t\t\t\t\treturn dimensionValue[0]\n\t\t\t\t}\n\t\t\t\tthrow new QueryLanguageError(\n\t\t\t\t\t`The variable \\$${variableName} resolved to a dimension which exists but contains ${dimensionValue.length} values. It has to contain exactly one. ` +\n\t\t\t\t\t\t`Perhaps you forgot to set the 'maxItems' prop of your DimensionsSwitcher?`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tthrow new QueryLanguageError(`Undefined variable \\$${variableName}.`)\n\t\t})\n\t})\n\n\tprivate constructor() {\n\t\tsuper(tokenList, { outputCst: false, maxLookahead: 1 })\n\t\tthis.performSelfAnalysis()\n\t}\n\n\tpublic static parseQueryLanguageExpression<E extends Parser.EntryPoint>(\n\t\tinput: string,\n\t\tentry: E,\n\t\tenvironment: Environment,\n\t): Parser.ParserResult[E] {\n\t\tconst cached = this.cacheStore.get(environment, entry, input)\n\n\t\tif (cached !== undefined) {\n\t\t\treturn cached\n\t\t}\n\n\t\tconst lexingResult = Parser.lexer.tokenize((Parser.rawInput = input))\n\n\t\tif (lexingResult.errors.length !== 0) {\n\t\t\tthrow new QueryLanguageError(\n\t\t\t\t`Failed to tokenize '${input}'.\\n\\n${lexingResult.errors.map(i => i.message).join('\\n')}`,\n\t\t\t)\n\t\t}\n\n\t\tParser.environment = environment\n\t\tParser.parser.input = lexingResult.tokens\n\n\t\tlet expression: Parser.ParserResult[keyof Parser.ParserResult]\n\n\t\tswitch (entry) {\n\t\t\tcase 'relativeSingleField':\n\t\t\t\texpression = Parser.parser.relativeSingleField()\n\t\t\t\tbreak\n\t\t\tcase 'relativeSingleEntity':\n\t\t\t\texpression = Parser.parser.relativeSingleEntity()\n\t\t\t\tbreak\n\t\t\tcase 'relativeEntityList':\n\t\t\t\texpression = Parser.parser.relativeEntityList()\n\t\t\t\tbreak\n\t\t\tcase 'qualifiedEntityList':\n\t\t\t\texpression = Parser.parser.qualifiedEntityList()\n\t\t\t\tbreak\n\t\t\tcase 'qualifiedFieldList':\n\t\t\t\texpression = Parser.parser.qualifiedFieldList()\n\t\t\t\tbreak\n\t\t\tcase 'qualifiedSingleEntity':\n\t\t\t\texpression = Parser.parser.qualifiedSingleEntity()\n\t\t\t\tbreak\n\t\t\tcase 'unconstrainedQualifiedEntityList':\n\t\t\t\texpression = Parser.parser.unconstrainedQualifiedEntityList()\n\t\t\t\tbreak\n\t\t\tcase 'unconstrainedQualifiedSingleEntity':\n\t\t\t\texpression = Parser.parser.unconstrainedQualifiedSingleEntity()\n\t\t\t\tbreak\n\t\t\tcase 'uniqueWhere':\n\t\t\t\texpression = Parser.parser.uniqueWhere()\n\t\t\t\tbreak\n\t\t\tcase 'filter':\n\t\t\t\texpression = Parser.parser.nonUniqueWhere()\n\t\t\t\tbreak\n\t\t\tcase 'orderBy':\n\t\t\t\texpression = Parser.parser.orderBy()\n\t\t\t\tbreak\n\t\t\tcase 'taggedMap':\n\t\t\t\texpression = Parser.parser.taggedMap()\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\tthrow new QueryLanguageError(`Not implemented entry point '${entry}'`)\n\t\t}\n\n\t\tif (Parser.parser.errors.length !== 0) {\n\t\t\tthrow new QueryLanguageError(\n\t\t\t\t`Failed to parse '${input}'.\\n\\n${Parser.parser.errors.map(i => i.message).join('\\n')}`,\n\t\t\t)\n\t\t}\n\n\t\tthis.cacheStore.set(environment, entry, input, expression as Parser.ParserResult[E])\n\n\t\treturn expression as Parser.ParserResult[E]\n\t}\n}\n\nnamespace Parser {\n\texport namespace AST {\n\t\texport type FieldWhere = Input.FieldWhere<Condition>\n\n\t\texport type ColumnValue = Input.ColumnValue<GraphQlBuilder.GraphQlLiteral>\n\n\t\texport type Condition = Input.Condition<ColumnValue>\n\n\t\texport type ConditionOperator = keyof Pick<Condition, 'eq' | 'notEq' | 'lt' | 'lte' | 'gt' | 'gte'>\n\t}\n\n\texport interface ParserResult {\n\t\tqualifiedEntityList: ParsedQualifiedEntityList // E.g. Author[age < 123].son.sisters(name = 'Jane')\n\t\tqualifiedFieldList: ParsedQualifiedFieldList // E.g. Author[age < 123].son.sister.name\n\t\tqualifiedSingleEntity: ParsedQualifiedSingleEntity // E.g. Author(id = 123).son.sister\n\t\tunconstrainedQualifiedEntityList: ParsedUnconstrainedQualifiedEntityList // E.g. Author.son.sister\n\t\tunconstrainedQualifiedSingleEntity: ParsedUnconstrainedQualifiedSingleEntity // E.g. Author.son.sister\n\t\trelativeSingleField: ParsedRelativeSingleField // E.g. authors(id = 123).person.name\n\t\trelativeSingleEntity: ParsedRelativeSingleEntity // E.g. localesByLocale(locale.slug = en)\n\t\trelativeEntityList: ParsedRelativeEntityList // E.g. genres(slug = 'sciFi').authors[age < 123]\n\t\tuniqueWhere: UniqueWhere // E.g. (author.mother.id = 123)\n\t\tfilter: Filter // E.g. [author.son.age < 123]\n\t\torderBy: OrderBy // E.g. items.order asc, items.content.name asc\n\t\ttaggedMap: ParsedTaggedMap // E.g editUser(id: $entity.id, foo: 'bar')\n\t}\n\n\texport type EntryPoint = keyof ParserResult\n}\n\nexport { Parser }\n"],"names":[],"mappings":";;;;;;;AA+BA,qBAAqB,sBAAsB;AAAA,SAC3B,WAAmB;AAAA,SACnB,QAAQ,IAAI,MAAM;AAAA,SAClB,SAAS,IAAI;AAAA,SACb,cAA2B,IAAI;AAAA,SAC/B,aAAyB,IAAI;AAAA,EAEpC,sBAAsB,KAAK,KAAgC,uB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;AACrC,YAAM,IAAI,mBACT,uBAAuB;AAAA;AAAA,EAAc,aAAa,OAAO,IAAI,OAAK,EAAE,SAAS,KAAK;AAAA;AAIpF,WAAO,cAAc;AACrB,WAAO,OAAO,QAAQ,aAAa;AAEnC,QAAI;AAEJ,YAAQ;AAAA,WACF;AACJ,qBAAa,OAAO,OAAO;AAC3B;AAAA,WACI;AACJ,qBAAa,OAAO,OAAO;AAC3B;AAAA,WACI;AACJ,qBAAa,OAAO,OAAO;AAC3B;AAAA,WACI;AACJ,qBAAa,OAAO,OAAO;AAC3B;AAAA,WACI;AACJ,qBAAa,OAAO,OAAO;AAC3B;AAAA,WACI;AACJ,qBAAa,OAAO,OAAO;AAC3B;AAAA,WACI;AACJ,qBAAa,OAAO,OAAO;AAC3B;AAAA,WACI;AACJ,qBAAa,OAAO,OAAO;AAC3B;AAAA,WACI;AACJ,qBAAa,OAAO,OAAO;AAC3B;AAAA,WACI;AACJ,qBAAa,OAAO,OAAO;AAC3B;AAAA,WACI;AACJ,qBAAa,OAAO,OAAO;AAC3B;AAAA,WACI;AACJ,qBAAa,OAAO,OAAO;AAC3B;AAAA;AAEA,cAAM,IAAI,mBAAmB,gCAAgC;AAAA;AAG/D,QAAI,OAAO,OAAO,OAAO,WAAW,GAAG;AACtC,YAAM,IAAI,mBACT,oBAAoB;AAAA;AAAA,EAAc,OAAO,OAAO,OAAO,IAAI,OAAK,EAAE,SAAS,KAAK;AAAA;AAIlF,SAAK,WAAW,IAAI,aAAa,OAAO,OAAO;AAE/C,WAAO;AAAA;AAAA;;;;"}
@@ -36,6 +36,10 @@ const tokens = {
36
36
  name: "Colon",
37
37
  pattern: /:/
38
38
  }),
39
+ Slash: createToken({
40
+ name: "Slash",
41
+ pattern: /\//
42
+ }),
39
43
  NumberLiteral: createToken({
40
44
  name: "NumberLiteral",
41
45
  pattern: /-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?/
@@ -123,6 +127,7 @@ const tokenList = [
123
127
  tokens.Dot,
124
128
  tokens.Comma,
125
129
  tokens.Colon,
130
+ tokens.Slash,
126
131
  tokens.StringLiteral,
127
132
  tokens.NumberLiteral,
128
133
  tokens.LeftParenthesis,
@@ -1 +1 @@
1
- {"version":3,"file":"tokenList.js","sources":["../../../src/queryLanguage/tokenList.ts"],"sourcesContent":["import { createToken, Lexer } from 'chevrotain'\n\nexport namespace TokenRegExps {\n\texport const entityIdentifier = /[A-Z_]\\w*/\n\texport const identifier = /[a-zA-Z_]\\w*/\n}\n\nconst identifier = createToken({\n\tname: 'Identifier',\n\tpattern: TokenRegExps.identifier,\n})\n\nexport const tokens = {\n\tWhiteSpace: createToken({\n\t\tname: 'WhiteSpace',\n\t\tpattern: /\\s+/,\n\t\tgroup: Lexer.SKIPPED,\n\t}),\n\n\tEntityIdentifier: createToken({\n\t\tname: 'EntityIdentifier',\n\t\tpattern: TokenRegExps.entityIdentifier,\n\t}),\n\n\tIdentifier: identifier,\n\n\tDollarSign: createToken({\n\t\tname: 'DollarSign',\n\t\tpattern: /\\$/,\n\t}),\n\n\tDot: createToken({\n\t\tname: 'Dot',\n\t\tpattern: /\\./,\n\t}),\n\n\tComma: createToken({\n\t\tname: 'Comma',\n\t\tpattern: /,/,\n\t}),\n\n\tColon: createToken({\n\t\tname: 'Colon',\n\t\tpattern: /:/,\n\t}),\n\n\tNumberLiteral: createToken({\n\t\tname: 'NumberLiteral',\n\t\tpattern: /-?(0|[1-9]\\d*)(\\.\\d+)?([eE][+-]?\\d+)?/,\n\t}),\n\n\tStringLiteral: createToken({\n\t\tname: 'StringLiteral',\n\t\tpattern: /'(:?[^\\\\']|\\\\(:?[bfnrtv'\\\\/]|u[0-9a-fA-F]{4}))*'/,\n\t}),\n\n\tLeftParenthesis: createToken({\n\t\tname: 'LeftParenthesis',\n\t\tpattern: /\\(/,\n\t}),\n\n\tRightParenthesis: createToken({\n\t\tname: 'RightParenthesis',\n\t\tpattern: /\\)/,\n\t}),\n\n\tLeftBracket: createToken({\n\t\tname: 'LeftBracket',\n\t\tpattern: /\\[/,\n\t}),\n\n\tRightBracket: createToken({\n\t\tname: 'RightBracket',\n\t\tpattern: /]/,\n\t}),\n\n\tNotEquals: createToken({\n\t\tname: 'NotEquals',\n\t\tpattern: /!=/,\n\t}),\n\n\tTrue: createToken({\n\t\tname: 'True',\n\t\tpattern: /true/,\n\t\tlonger_alt: identifier,\n\t}),\n\n\tFalse: createToken({\n\t\tname: 'False',\n\t\tpattern: /false/,\n\t\tlonger_alt: identifier,\n\t}),\n\n\tNull: createToken({\n\t\tname: 'Null',\n\t\tpattern: /null/,\n\t\tlonger_alt: identifier,\n\t}),\n\n\tEquals: createToken({\n\t\tname: 'Equals',\n\t\tpattern: /=/,\n\t}),\n\n\tNot: createToken({\n\t\tname: 'Not',\n\t\tpattern: /!/,\n\t}),\n\n\tAnd: createToken({\n\t\tname: 'And',\n\t\tpattern: /&&/,\n\t}),\n\n\tOr: createToken({\n\t\tname: 'Or',\n\t\tpattern: /\\|\\|/,\n\t}),\n\n\tLowerEqual: createToken({\n\t\tname: 'LowerEqual',\n\t\tpattern: /<=/,\n\t}),\n\n\tGreaterEqual: createToken({\n\t\tname: 'GreaterEqual',\n\t\tpattern: />=/,\n\t}),\n\n\tLowerThan: createToken({\n\t\tname: 'LowerThan',\n\t\tpattern: /</,\n\t}),\n\n\tGreaterThan: createToken({\n\t\tname: 'GreaterThan',\n\t\tpattern: />/,\n\t}),\n}\n\nconst tokenList = [\n\ttokens.WhiteSpace,\n\ttokens.True,\n\ttokens.False,\n\ttokens.Null,\n\ttokens.EntityIdentifier,\n\ttokens.Identifier,\n\ttokens.DollarSign,\n\ttokens.Dot,\n\ttokens.Comma,\n\ttokens.Colon,\n\ttokens.StringLiteral,\n\ttokens.NumberLiteral,\n\ttokens.LeftParenthesis,\n\ttokens.RightParenthesis,\n\ttokens.LeftBracket,\n\ttokens.RightBracket,\n\ttokens.NotEquals,\n\ttokens.Equals,\n\ttokens.Not,\n\ttokens.GreaterEqual,\n\ttokens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AS;AAAA,IACT,YAAY;AAAA;AAAA,EAGb,OAAO,YAAY;AAAA,IAClB,MAAM;AAAA,IACN,SAAS;AAAA,IACT,YAAY;AAAA;AAAA,EAGb,MAAM,YAAY;AAAA,IACjB,MAAM;AAAA,IACN,SAAS;AAAA,IACT,YAAY;AAAA;AAAA,EAGb,QAAQ,YAAY;AAAA,IACnB,MAAM;AAAA,IACN,SAAS;AAAA;AAAA,EAGV,KAAK,YAAY;AAAA,IAChB,MAAM;AAAA,IACN,SAAS;AAAA;AAAA,EAGV,KAAK,YAAY;AAAA,IAChB,MAAM;AAAA,IACN,SAAS;AAAA;AAAA,EAGV,IAAI,YAAY;AAAA,IACf,MAAM;AAAA,IACN,SAAS;AAAA;AAAA,EAGV,YAAY,YAAY;AAAA,IACvB,MAAM;AAAA,IACN,SAAS;AAAA;AAAA,EAGV,cAAc,YAAY;AAAA,IACzB,MAAM;AAAA,IACN,SAAS;AAAA;AAAA,EAGV,WAAW,YAAY;AAAA,IACtB,MAAM;AAAA,IACN,SAAS;AAAA;AAAA,EAGV,aAAa,YAAY;AAAA,IACxB,MAAM;AAAA,IACN,SAAS;AAAA;AAAA;MAIL,YAAY;AAAA,EACjB,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA;;;;"}
1
+ {"version":3,"file":"tokenList.js","sources":["../../../src/queryLanguage/tokenList.ts"],"sourcesContent":["import { createToken, Lexer } from 'chevrotain'\n\nexport namespace TokenRegExps {\n\texport const entityIdentifier = /[A-Z_]\\w*/\n\texport const identifier = /[a-zA-Z_]\\w*/\n}\n\nconst identifier = createToken({\n\tname: 'Identifier',\n\tpattern: TokenRegExps.identifier,\n})\n\nexport const tokens = {\n\tWhiteSpace: createToken({\n\t\tname: 'WhiteSpace',\n\t\tpattern: /\\s+/,\n\t\tgroup: Lexer.SKIPPED,\n\t}),\n\n\tEntityIdentifier: createToken({\n\t\tname: 'EntityIdentifier',\n\t\tpattern: TokenRegExps.entityIdentifier,\n\t}),\n\n\tIdentifier: identifier,\n\n\tDollarSign: createToken({\n\t\tname: 'DollarSign',\n\t\tpattern: /\\$/,\n\t}),\n\n\tDot: createToken({\n\t\tname: 'Dot',\n\t\tpattern: /\\./,\n\t}),\n\n\tComma: createToken({\n\t\tname: 'Comma',\n\t\tpattern: /,/,\n\t}),\n\n\tColon: createToken({\n\t\tname: 'Colon',\n\t\tpattern: /:/,\n\t}),\n\n\tSlash: createToken({\n\t\tname: 'Slash',\n\t\tpattern: /\\//,\n\t}),\n\n\tNumberLiteral: createToken({\n\t\tname: 'NumberLiteral',\n\t\tpattern: /-?(0|[1-9]\\d*)(\\.\\d+)?([eE][+-]?\\d+)?/,\n\t}),\n\n\tStringLiteral: createToken({\n\t\tname: 'StringLiteral',\n\t\tpattern: /'(:?[^\\\\']|\\\\(:?[bfnrtv'\\\\/]|u[0-9a-fA-F]{4}))*'/,\n\t}),\n\n\tLeftParenthesis: createToken({\n\t\tname: 'LeftParenthesis',\n\t\tpattern: /\\(/,\n\t}),\n\n\tRightParenthesis: createToken({\n\t\tname: 'RightParenthesis',\n\t\tpattern: /\\)/,\n\t}),\n\n\tLeftBracket: createToken({\n\t\tname: 'LeftBracket',\n\t\tpattern: /\\[/,\n\t}),\n\n\tRightBracket: createToken({\n\t\tname: 'RightBracket',\n\t\tpattern: /]/,\n\t}),\n\n\tNotEquals: createToken({\n\t\tname: 'NotEquals',\n\t\tpattern: /!=/,\n\t}),\n\n\tTrue: createToken({\n\t\tname: 'True',\n\t\tpattern: /true/,\n\t\tlonger_alt: identifier,\n\t}),\n\n\tFalse: createToken({\n\t\tname: 'False',\n\t\tpattern: /false/,\n\t\tlonger_alt: identifier,\n\t}),\n\n\tNull: createToken({\n\t\tname: 'Null',\n\t\tpattern: /null/,\n\t\tlonger_alt: identifier,\n\t}),\n\n\tEquals: createToken({\n\t\tname: 'Equals',\n\t\tpattern: /=/,\n\t}),\n\n\tNot: createToken({\n\t\tname: 'Not',\n\t\tpattern: /!/,\n\t}),\n\n\tAnd: createToken({\n\t\tname: 'And',\n\t\tpattern: /&&/,\n\t}),\n\n\tOr: createToken({\n\t\tname: 'Or',\n\t\tpattern: /\\|\\|/,\n\t}),\n\n\tLowerEqual: createToken({\n\t\tname: 'LowerEqual',\n\t\tpattern: /<=/,\n\t}),\n\n\tGreaterEqual: createToken({\n\t\tname: 'GreaterEqual',\n\t\tpattern: />=/,\n\t}),\n\n\tLowerThan: createToken({\n\t\tname: 'LowerThan',\n\t\tpattern: /</,\n\t}),\n\n\tGreaterThan: createToken({\n\t\tname: 'GreaterThan',\n\t\tpattern: />/,\n\t}),\n}\n\nconst tokenList = [\n\ttokens.WhiteSpace,\n\ttokens.True,\n\ttokens.False,\n\ttokens.Null,\n\ttokens.EntityIdentifier,\n\ttokens.Identifier,\n\ttokens.DollarSign,\n\ttokens.Dot,\n\ttokens.Comma,\n\ttokens.Colon,\n\ttokens.Slash,\n\ttokens.StringLiteral,\n\ttokens.NumberLiteral,\n\ttokens.LeftParenthesis,\n\ttokens.RightParenthesis,\n\ttokens.LeftBracket,\n\ttokens.RightBracket,\n\ttokens.NotEquals,\n\ttokens.Equals,\n\ttokens.Not,\n\ttokens.GreaterEqual,\n\ttokens.GreaterThan,\n\ttokens.LowerEqual,\n\ttokens.LowerThan,\n\ttokens.And,\n\ttokens.Or,\n]\n\nexport { tokenList }\n"],"names":[],"mappings":";;IAEiB;AAAV,EAAU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B,MAAM;AAAA,IACN,SAAS;AAAA,IACT,YAAY;AAAA;AAAA,EAGb,MAAM,YAAY;AAAA,IACjB,MAAM;AAAA,IACN,SAAS;AAAA,IACT,YAAY;AAAA;AAAA,EAGb,QAAQ,YAAY;AAAA,IACnB,MAAM;AAAA,IACN,SAAS;AAAA;AAAA,EAGV,KAAK,YAAY;AAAA,IAChB,MAAM;AAAA,IACN,SAAS;AAAA;AAAA,EAGV,KAAK,YAAY;AAAA,IAChB,MAAM;AAAA,IACN,SAAS;AAAA;AAAA,EAGV,IAAI,YAAY;AAAA,IACf,MAAM;AAAA,IACN,SAAS;AAAA;AAAA,EAGV,YAAY,YAAY;AAAA,IACvB,MAAM;AAAA,IACN,SAAS;AAAA;AAAA,EAGV,cAAc,YAAY;AAAA,IACzB,MAAM;AAAA,IACN,SAAS;AAAA;AAAA,EAGV,WAAW,YAAY;AAAA,IACtB,MAAM;AAAA,IACN,SAAS;AAAA;AAAA,EAGV,aAAa,YAAY;AAAA,IACxB,MAAM;AAAA,IACN,SAAS;AAAA;AAAA;MAIL,YAAY;AAAA,EACjB,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA;;;;"}
@@ -181,7 +181,7 @@ const _DataBinding = class {
181
181
  }
182
182
  async extendTree(newFragment, options = {}) {
183
183
  if (options.signal?.aborted) {
184
- return Promise.reject();
184
+ return Promise.reject(DataBindingExtendAborted);
185
185
  }
186
186
  const markerTreeRoot = new MarkerTreeGenerator(newFragment, options.environment ?? this.environment).generate();
187
187
  if (this.treeStore.effectivelyHasTreeRoot(markerTreeRoot)) {
@@ -199,7 +199,7 @@ const _DataBinding = class {
199
199
  newFragment,
200
200
  newTreeRootId: this.getNewTreeRootId(),
201
201
  options,
202
- reject,
202
+ reject: () => reject(DataBindingExtendAborted),
203
203
  resolve
204
204
  });
205
205
  const pendingExtensionsCount = this.pendingExtensions.size;
@@ -321,5 +321,6 @@ __publicField(DataBinding, "getNextTreeRootIdSeed", (() => {
321
321
  let seed = 1;
322
322
  return () => seed++;
323
323
  })());
324
- export { DataBinding };
324
+ const DataBindingExtendAborted = Symbol("aborted");
325
+ export { DataBinding, DataBindingExtendAborted };
325
326
  //# sourceMappingURL=DataBinding.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DataBinding.js","sources":["../../../src/core/DataBinding.ts"],"sourcesContent":["import type { GraphQlClient, GraphQlClientFailedRequestMetadata, TreeFilter } from '@contember/client'\nimport type { ReactNode } from 'react'\nimport {\n\tAsyncBatchUpdatesOptions,\n\tBatchUpdatesOptions,\n\tBindingOperations,\n\tExtendTreeOptions,\n\tPersistErrorOptions,\n\tPersistSuccessOptions,\n\tTreeRootAccessor,\n} from '../accessors'\nimport {\n\tmetadataToRequestError,\n\tMutationRequestResponse,\n\tQueryRequestResponse,\n\tRequestError,\n\tSuccessfulPersistResult,\n} from '../accessorTree'\nimport type { Environment } from '../dao'\nimport type { MarkerTreeRoot } from '../markers'\nimport type { TreeRootId } from '../treeParameters'\nimport { assertNever, generateEnumerabilityPreventingEntropy } from '../utils'\nimport { AccessorErrorManager } from './AccessorErrorManager'\nimport { Config } from './Config'\nimport { DirtinessTracker } from './DirtinessTracker'\nimport { EventManager } from './EventManager'\nimport { createBatchUpdatesOptions } from './factories'\nimport { MarkerMerger } from './MarkerMerger'\nimport { MarkerTreeGenerator } from './MarkerTreeGenerator'\nimport { MutationGenerator } from './MutationGenerator'\nimport { QueryGenerator } from './QueryGenerator'\nimport { Schema, SchemaLoader, SchemaValidator } from './schema'\nimport { StateIterator } from './state'\nimport { StateInitializer } from './StateInitializer'\nimport { TreeAugmenter } from './TreeAugmenter'\nimport { TreeFilterGenerator } from './TreeFilterGenerator'\nimport { TreeStore } from './TreeStore'\nimport type { UpdateMetadata } from './UpdateMetadata'\nimport { getCombinedSignal } from './utils'\n\nexport class DataBinding {\n\tprivate static readonly schemaLoadCache: Map<string, Schema | Promise<Schema>> = new Map()\n\n\tprivate readonly accessorErrorManager: AccessorErrorManager\n\tprivate readonly batchUpdatesOptions: BatchUpdatesOptions\n\tprivate readonly asyncBatchUpdatesOptions: AsyncBatchUpdatesOptions\n\tprivate readonly bindingOperations: BindingOperations\n\tprivate readonly config: Config\n\tprivate readonly dirtinessTracker: DirtinessTracker\n\tprivate readonly eventManager: EventManager\n\tprivate readonly stateInitializer: StateInitializer\n\tprivate readonly treeAugmenter: TreeAugmenter\n\tprivate readonly treeStore: TreeStore\n\n\t// private treeRootListeners: {\n\t// \teventListeners: {}\n\t// } = {\n\t// \teventListeners: {},\n\t// }\n\n\tpublic constructor(\n\t\tprivate readonly contentApiClient: GraphQlClient,\n\t\tprivate readonly systemApiClient: GraphQlClient,\n\t\tprivate readonly tenantApiClient: GraphQlClient,\n\t\tprivate readonly environment: Environment,\n\t\tprivate readonly onUpdate: (newData: TreeRootAccessor) => void,\n\t\tprivate readonly onError: (error: RequestError) => void,\n\t\tprivate readonly onPersistSuccess: (result: SuccessfulPersistResult) => void,\n\t) {\n\t\tthis.config = new Config()\n\t\tthis.treeStore = new TreeStore()\n\t\tthis.batchUpdatesOptions = createBatchUpdatesOptions(environment, this.treeStore)\n\t\tthis.asyncBatchUpdatesOptions = {\n\t\t\t...this.batchUpdatesOptions,\n\t\t\tcontentClient: contentApiClient,\n\t\t\tsystemClient: systemApiClient,\n\t\t\ttenantClient: tenantApiClient,\n\t\t}\n\t\tthis.dirtinessTracker = new DirtinessTracker()\n\t\tthis.eventManager = new EventManager(\n\t\t\tthis.asyncBatchUpdatesOptions,\n\t\t\tthis.batchUpdatesOptions,\n\t\t\tthis.config,\n\t\t\tthis.dirtinessTracker,\n\t\t\tthis.resolvedOnUpdate,\n\t\t\tthis.treeStore,\n\t\t)\n\t\tthis.accessorErrorManager = new AccessorErrorManager(this.eventManager, this.treeStore)\n\t\tthis.stateInitializer = new StateInitializer(\n\t\t\tthis.accessorErrorManager,\n\t\t\tthis.batchUpdatesOptions,\n\t\t\tthis.config,\n\t\t\tthis.eventManager,\n\t\t\tthis.treeStore,\n\t\t)\n\t\tthis.treeAugmenter = new TreeAugmenter(this.eventManager, this.stateInitializer, this.treeStore)\n\n\t\t// TODO move this elsewhere\n\t\tthis.bindingOperations = Object.freeze<BindingOperations>({\n\t\t\t...this.asyncBatchUpdatesOptions,\n\t\t\tgetTreeFilters: (): TreeFilter[] => {\n\t\t\t\tconst generator = new TreeFilterGenerator(this.treeStore)\n\t\t\t\treturn generator.generateTreeFilter()\n\t\t\t},\n\t\t\tbatchDeferredUpdates: performUpdates => {\n\t\t\t\tthis.eventManager.syncTransaction(() => performUpdates(this.bindingOperations))\n\t\t\t},\n\t\t\textendTree: async (...args) => await this.extendTree(...args),\n\t\t\tpersist: async ({ signal, onPersistSuccess, onPersistError } = {}) =>\n\t\t\t\tawait this.eventManager.persistOperation(async () => {\n\t\t\t\t\tfor (let attemptNumber = 1; attemptNumber <= this.config.getValue('maxPersistAttempts'); attemptNumber++) {\n\t\t\t\t\t\t// TODO if the tree is in an inconsistent state, wait for lock releases\n\n\t\t\t\t\t\tthis.eventManager.syncTransaction(() => {\n\t\t\t\t\t\t\tthis.accessorErrorManager.clearErrors()\n\t\t\t\t\t\t})\n\t\t\t\t\t\tawait this.eventManager.triggerOnBeforePersist()\n\n\t\t\t\t\t\tlet shouldTryAgain = false\n\t\t\t\t\t\tconst proposedBackOffs: number[] = []\n\t\t\t\t\t\tconst persistErrorOptions: PersistErrorOptions = {\n\t\t\t\t\t\t\t...this.bindingOperations,\n\t\t\t\t\t\t\ttryAgain: options => {\n\t\t\t\t\t\t\t\tshouldTryAgain = true\n\t\t\t\t\t\t\t\tif (options?.proposedBackoff !== undefined && options.proposedBackoff > 0) {\n\t\t\t\t\t\t\t\t\tproposedBackOffs.push(options.proposedBackoff)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tattemptNumber,\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (this.accessorErrorManager.hasErrors()) {\n\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistError(persistErrorOptions)\n\t\t\t\t\t\t\tawait onPersistError?.(persistErrorOptions)\n\n\t\t\t\t\t\t\tif (shouldTryAgain) {\n\t\t\t\t\t\t\t\tcontinue // Trying again immediately\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tthrow {\n\t\t\t\t\t\t\t\terrors: this.accessorErrorManager.getErrors(),\n\t\t\t\t\t\t\t\ttype: 'invalidInput',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst generator = new MutationGenerator(this.treeStore)\n\t\t\t\t\t\tconst mutation = generator.getPersistMutation()\n\n\t\t\t\t\t\tif (mutation === undefined) {\n\t\t\t\t\t\t\tthis.dirtinessTracker.reset() // TODO This ideally shouldn't be necessary but given the current limitations, this makes for better UX.\n\t\t\t\t\t\t\tconst persistSuccessOptions: PersistSuccessOptions = {\n\t\t\t\t\t\t\t\t...this.bindingOperations,\n\t\t\t\t\t\t\t\tsuccessType: 'nothingToPersist',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistSuccess(persistSuccessOptions)\n\t\t\t\t\t\t\tawait onPersistSuccess?.(persistSuccessOptions)\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\ttype: 'nothingToPersist',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst mutationResponse: MutationRequestResponse = await this.contentApiClient.sendRequest(mutation, {\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tconst mutationData = mutationResponse.data?.transaction ?? {}\n\t\t\t\t\t\tconst aliases = Object.keys(mutationData)\n\t\t\t\t\t\tif (!mutationResponse.data) {\n\t\t\t\t\t\t\tthrow {\n\t\t\t\t\t\t\t\terrors: mutationData.errors,\n\t\t\t\t\t\t\t\ttype: 'invalidResponse',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (aliases.every(item => mutationData[item].ok)) {\n\t\t\t\t\t\t\tconst persistedEntityIds = aliases.map(alias => mutationData[alias].node?.id).filter(id => id !== undefined)\n\t\t\t\t\t\t\tconst result: SuccessfulPersistResult = {\n\t\t\t\t\t\t\t\ttype: 'justSuccess',\n\t\t\t\t\t\t\t\tpersistedEntityIds,\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tawait this.eventManager.asyncTransaction(async () => {\n\t\t\t\t\t\t\t\t\tthis.resetTreeAfterSuccessfulPersist()\n\t\t\t\t\t\t\t\t\tthis.treeAugmenter.updatePersistedData(\n\t\t\t\t\t\t\t\t\t\tObject.fromEntries(\n\t\t\t\t\t\t\t\t\t\t\tObject.entries(mutationData).map(([placeholderName, subTreeResponse]) => [\n\t\t\t\t\t\t\t\t\t\t\t\tplaceholderName,\n\t\t\t\t\t\t\t\t\t\t\t\tsubTreeResponse.node,\n\t\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tconst persistSuccessOptions: PersistSuccessOptions = {\n\t\t\t\t\t\t\t\t\t\t...this.bindingOperations,\n\t\t\t\t\t\t\t\t\t\tsuccessType: result.type,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistSuccess(persistSuccessOptions)\n\t\t\t\t\t\t\t\t\tawait onPersistSuccess?.(persistSuccessOptions)\n\n\t\t\t\t\t\t\t\t\tthis.treeAugmenter.resetCreatingSubTrees()\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t\tconsole.error(e)\n\t\t\t\t\t\t\t\tconst resultWithError = {\n\t\t\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\t\t\tafterPersistError: e,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tthis.onPersistSuccess(resultWithError)\n\t\t\t\t\t\t\t\treturn resultWithError\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.onPersistSuccess(result)\n\t\t\t\t\t\t\treturn result\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.eventManager.syncTransaction(() => this.accessorErrorManager.replaceErrors(mutationData))\n\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistError(persistErrorOptions)\n\t\t\t\t\t\t\tawait onPersistError?.(persistErrorOptions)\n\t\t\t\t\t\t\tif (shouldTryAgain) {\n\t\t\t\t\t\t\t\tif (proposedBackOffs.length) {\n\t\t\t\t\t\t\t\t\tconst geometricMean = Math.round(\n\t\t\t\t\t\t\t\t\t\tMath.pow(\n\t\t\t\t\t\t\t\t\t\t\tproposedBackOffs.reduce((a, b) => a * b, 1),\n\t\t\t\t\t\t\t\t\t\t\t1 / proposedBackOffs.length,\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, geometricMean))\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthrow {\n\t\t\t\t\t\t\t\terrors: this.accessorErrorManager.getErrors(),\n\t\t\t\t\t\t\t\ttype: 'invalidInput',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Max attempts exceeded\n\t\t\t\t\t// TODO fire persist error\n\t\t\t\t\tthrow {\n\t\t\t\t\t\ttype: 'givenUp',\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t})\n\t}\n\n\tprivate resolvedOnUpdate = ({ isMutating }: UpdateMetadata) => {\n\t\tthis.onUpdate(new TreeRootAccessor(this.dirtinessTracker.hasChanges(), isMutating, this.bindingOperations))\n\t}\n\n\t// This is currently useless but potentially future-compatible\n\t// private readonly addTreeRootEventListener: TreeRootAccessor.AddTreeRootEventListener = this.getAddEventListener(\n\t// \tthis.treeRootListeners,\n\t// )\n\n\tprivate pendingExtensions: Set<{\n\t\tmarkerTreeRoot: MarkerTreeRoot\n\t\tnewFragment: ReactNode\n\t\tnewTreeRootId: TreeRootId | undefined\n\t\toptions: ExtendTreeOptions\n\t\treject: () => void\n\t\tresolve: (newRootId: TreeRootId | undefined) => void\n\t}> = new Set()\n\n\tpublic async extendTree(newFragment: ReactNode, options: ExtendTreeOptions = {}): Promise<TreeRootId | undefined> {\n\t\tif (options.signal?.aborted) {\n\t\t\treturn Promise.reject()\n\t\t}\n\t\tconst markerTreeRoot = new MarkerTreeGenerator(newFragment, options.environment ?? this.environment).generate()\n\n\t\tif (this.treeStore.effectivelyHasTreeRoot(markerTreeRoot)) {\n\t\t\t// This isn't perfectly accurate as theoretically, we could already have all the data necessary but this\n\t\t\t// could still be false.\n\n\t\t\tconst schema = await this.getOrLoadSchema()\n\t\t\tthis.treeStore.setSchema(schema)\n\t\t\tif (import.meta.env.DEV) {\n\t\t\t\t// For most trees, checking this against the schema should be unnecessary since if we already effectively\n\t\t\t\t// have this tree root, then assuming everything we already have is valid, this should match the schema as well.\n\t\t\t\t// However, we might be dealing with an isCreating tree root which is completely new. Also, we can just lean\n\t\t\t\t// towards the safe side since developer machines can generally handle the potentially unnecessary check anyway.\n\t\t\t\tSchemaValidator.assertTreeValid(schema, markerTreeRoot)\n\t\t\t}\n\n\t\t\treturn this.eventManager.syncOperation(() => {\n\t\t\t\tconst newTreeRootId = this.getNewTreeRootId()\n\t\t\t\tthis.treeAugmenter.extendTreeStates(newTreeRootId, markerTreeRoot)\n\t\t\t\treturn newTreeRootId\n\t\t\t})\n\t\t}\n\n\t\treturn await new Promise((resolve, reject) => {\n\t\t\tthis.pendingExtensions.add({\n\t\t\t\tmarkerTreeRoot,\n\t\t\t\tnewFragment,\n\t\t\t\tnewTreeRootId: this.getNewTreeRootId(),\n\t\t\t\toptions,\n\t\t\t\treject,\n\t\t\t\tresolve,\n\t\t\t})\n\t\t\tconst pendingExtensionsCount = this.pendingExtensions.size\n\n\t\t\tPromise.resolve().then(() => {\n\t\t\t\tif (pendingExtensionsCount < this.pendingExtensions.size) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.flushBatchedTreeExtensions()\n\t\t\t})\n\t\t})\n\t}\n\n\tprivate async flushBatchedTreeExtensions() {\n\t\t// This is an async operation so we just take whatever pendingExtensions there are now and let any new ones\n\t\t// accumulate in an empty set.\n\t\tconst pendingExtensions = Array.from(this.pendingExtensions).filter(extension => {\n\t\t\tif (extension.options.signal?.aborted) {\n\t\t\t\textension.reject()\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn true\n\t\t})\n\t\tthis.pendingExtensions.clear()\n\n\t\tconst aggregateMarkerTreeRoot = pendingExtensions.reduce<MarkerTreeRoot | undefined>(\n\t\t\t(previousValue, currentValue) => {\n\t\t\t\tif (previousValue === undefined) {\n\t\t\t\t\treturn currentValue.markerTreeRoot\n\t\t\t\t}\n\t\t\t\treturn MarkerMerger.mergeMarkerTreeRoots(previousValue, currentValue.markerTreeRoot)\n\t\t\t},\n\t\t\tundefined,\n\t\t)\n\n\t\tif (aggregateMarkerTreeRoot === undefined) {\n\t\t\treturn\n\t\t}\n\n\t\tconst aggregateSignal = getCombinedSignal(pendingExtensions.map(extension => extension.options.signal))\n\n\t\t// Even if we don't have a schema yet, we'll still optimistically fire the request so as to prevent a waterfall\n\t\t// in the most likely case that things will go fine and the query does match the schema. If it doesn't, then we\n\t\t// just get a \"400 Bad Request\" but that's not enough to make us delay the happy path.\n\t\tconst [aggregatePersistedData, schema] = await Promise.all([\n\t\t\tthis.fetchPersistedData(aggregateMarkerTreeRoot, aggregateSignal),\n\t\t\tthis.getOrLoadSchema(),\n\t\t])\n\t\tthis.treeStore.setSchema(schema)\n\n\t\tif (import.meta.env.DEV) {\n\t\t\tfor (const extension of pendingExtensions) {\n\t\t\t\tSchemaValidator.assertTreeValid(schema, extension.markerTreeRoot)\n\t\t\t}\n\t\t}\n\n\t\tif (aggregateSignal?.aborted) {\n\t\t\treturn\n\t\t}\n\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tthis.treeAugmenter.extendPersistedData(aggregatePersistedData?.data ?? {})\n\n\t\t\tfor (const extension of pendingExtensions) {\n\t\t\t\tthis.treeAugmenter.extendTreeStates(extension.newTreeRootId, extension.markerTreeRoot)\n\t\t\t\textension.resolve(extension.newTreeRootId)\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate async fetchPersistedData(\n\t\ttree: MarkerTreeRoot,\n\t\tsignal?: AbortSignal,\n\t): Promise<QueryRequestResponse | undefined> {\n\t\tconst queryGenerator = new QueryGenerator(tree)\n\t\tconst query = queryGenerator.getReadQuery()\n\n\t\tlet queryResponse: QueryRequestResponse | undefined = undefined\n\n\t\ttry {\n\t\t\tqueryResponse =\n\t\t\t\tquery === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: await this.contentApiClient.sendRequest(query, {\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t })\n\t\t} catch (metadata) {\n\t\t\tif (metadata.name === 'AbortError') {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.onError(metadataToRequestError(metadata as GraphQlClientFailedRequestMetadata))\n\t\t}\n\t\treturn queryResponse\n\t}\n\n\tprivate resetTreeAfterSuccessfulPersist() {\n\t\tthis.eventManager.syncTransaction(() => {\n\t\t\tthis.accessorErrorManager.clearErrors()\n\t\t\tthis.dirtinessTracker.reset()\n\n\t\t\tfor (const [, rootState] of StateIterator.eachRootState(this.treeStore)) {\n\t\t\t\tfor (const state of StateIterator.depthFirstAllNodes(rootState)) {\n\t\t\t\t\tswitch (state.type) {\n\t\t\t\t\t\tcase 'field': {\n\t\t\t\t\t\t\tif (state.hasUnpersistedChanges || state.touchLog?.size) {\n\t\t\t\t\t\t\t\tstate.touchLog?.clear()\n\t\t\t\t\t\t\t\tstate.hasUnpersistedChanges = false\n\t\t\t\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase 'entityList':\n\t\t\t\t\t\t\tif (state.unpersistedChangesCount > 0 || state.plannedRemovals?.size) {\n\t\t\t\t\t\t\t\tstate.unpersistedChangesCount = 0\n\t\t\t\t\t\t\t\tstate.plannedRemovals?.clear()\n\t\t\t\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase 'entityRealm': {\n\t\t\t\t\t\t\tif (state.unpersistedChangesCount > 0 || state.plannedHasOneDeletions?.size) {\n\t\t\t\t\t\t\t\tstate.unpersistedChangesCount = 0\n\t\t\t\t\t\t\t\tstate.plannedHasOneDeletions?.clear()\n\t\t\t\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tassertNever(state)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate getOrLoadSchema(): Schema | Promise<Schema> {\n\t\tconst existing = DataBinding.schemaLoadCache.get(this.contentApiClient.apiUrl)\n\t\tif (existing !== undefined) {\n\t\t\treturn existing\n\t\t}\n\n\t\tconst schemaPromise = SchemaLoader.loadSchema(this.contentApiClient, this.config.getValue('maxSchemaLoadAttempts'))\n\t\tschemaPromise.then(schema => {\n\t\t\tDataBinding.schemaLoadCache.set(this.contentApiClient.apiUrl, schema)\n\t\t})\n\t\tDataBinding.schemaLoadCache.set(this.contentApiClient.apiUrl, schemaPromise)\n\t\treturn schemaPromise\n\t}\n\n\tprivate static getNextTreeRootIdSeed = (() => {\n\t\tlet seed = 1\n\t\treturn () => seed++\n\t})()\n\n\tprivate getNewTreeRootId() {\n\t\t// TODO this is an awful, awful hack.\n\t\t// TODO the particular shape of the alias is relied on in MutationAlias. If you change this, change it there too.\n\t\treturn this.treeStore.markerTrees.size === 0\n\t\t\t? undefined\n\t\t\t: `${generateEnumerabilityPreventingEntropy()}-${DataBinding.getNextTreeRootIdSeed()}`\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;2BAwCyB;AAAA,EAoBjB,YACW,kBACA,iBACA,iBACA,aACA,UACA,SACA,kBAChB;AAzBe;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA6LT,4CAAmB,CAAC,EAAE,iBAAiC;WACzD,SAAS,IAAI,iBAAiB,KAAK,iBAAiB,cAAc,YAAY,KAAK;AAAA;AAQjF,iEAOC;;;;;;;;SA5LH,SAAS,IAAI;SACb,YAAY,IAAI;SAChB,sBAAsB,0BAA0B,aAAa,KAAK;SAClE,2BAA2B;AAAA,SAC5B,KAAK;AAAA,MACR,eAAe;AAAA,MACf,cAAc;AAAA,MACd,cAAc;AAAA;SAEV,mBAAmB,IAAI;SACvB,eAAe,IAAI,aACvB,KAAK,0BACL,KAAK,qBACL,KAAK,QACL,KAAK,kBACL,KAAK,kBACL,KAAK;SAED,uBAAuB,IAAI,qBAAqB,KAAK,cAAc,KAAK;SACxE,mBAAmB,IAAI,iBAC3B,KAAK,sBACL,KAAK,qBAC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AA;;"}
1
+ {"version":3,"file":"DataBinding.js","sources":["../../../src/core/DataBinding.ts"],"sourcesContent":["import type { GraphQlClient, GraphQlClientFailedRequestMetadata, TreeFilter } from '@contember/client'\nimport type { ReactNode } from 'react'\nimport {\n\tAsyncBatchUpdatesOptions,\n\tBatchUpdatesOptions,\n\tBindingOperations,\n\tExtendTreeOptions,\n\tPersistErrorOptions,\n\tPersistSuccessOptions,\n\tTreeRootAccessor,\n} from '../accessors'\nimport {\n\tmetadataToRequestError,\n\tMutationRequestResponse,\n\tQueryRequestResponse,\n\tRequestError,\n\tSuccessfulPersistResult,\n} from '../accessorTree'\nimport type { Environment } from '../dao'\nimport type { MarkerTreeRoot } from '../markers'\nimport type { TreeRootId } from '../treeParameters'\nimport { assertNever, generateEnumerabilityPreventingEntropy } from '../utils'\nimport { AccessorErrorManager } from './AccessorErrorManager'\nimport { Config } from './Config'\nimport { DirtinessTracker } from './DirtinessTracker'\nimport { EventManager } from './EventManager'\nimport { createBatchUpdatesOptions } from './factories'\nimport { MarkerMerger } from './MarkerMerger'\nimport { MarkerTreeGenerator } from './MarkerTreeGenerator'\nimport { MutationGenerator } from './MutationGenerator'\nimport { QueryGenerator } from './QueryGenerator'\nimport { Schema, SchemaLoader, SchemaValidator } from './schema'\nimport { StateIterator } from './state'\nimport { StateInitializer } from './StateInitializer'\nimport { TreeAugmenter } from './TreeAugmenter'\nimport { TreeFilterGenerator } from './TreeFilterGenerator'\nimport { TreeStore } from './TreeStore'\nimport type { UpdateMetadata } from './UpdateMetadata'\nimport { getCombinedSignal } from './utils'\n\nexport class DataBinding {\n\tprivate static readonly schemaLoadCache: Map<string, Schema | Promise<Schema>> = new Map()\n\n\tprivate readonly accessorErrorManager: AccessorErrorManager\n\tprivate readonly batchUpdatesOptions: BatchUpdatesOptions\n\tprivate readonly asyncBatchUpdatesOptions: AsyncBatchUpdatesOptions\n\tprivate readonly bindingOperations: BindingOperations\n\tprivate readonly config: Config\n\tprivate readonly dirtinessTracker: DirtinessTracker\n\tprivate readonly eventManager: EventManager\n\tprivate readonly stateInitializer: StateInitializer\n\tprivate readonly treeAugmenter: TreeAugmenter\n\tprivate readonly treeStore: TreeStore\n\n\t// private treeRootListeners: {\n\t// \teventListeners: {}\n\t// } = {\n\t// \teventListeners: {},\n\t// }\n\n\tpublic constructor(\n\t\tprivate readonly contentApiClient: GraphQlClient,\n\t\tprivate readonly systemApiClient: GraphQlClient,\n\t\tprivate readonly tenantApiClient: GraphQlClient,\n\t\tprivate readonly environment: Environment,\n\t\tprivate readonly onUpdate: (newData: TreeRootAccessor) => void,\n\t\tprivate readonly onError: (error: RequestError) => void,\n\t\tprivate readonly onPersistSuccess: (result: SuccessfulPersistResult) => void,\n\t) {\n\t\tthis.config = new Config()\n\t\tthis.treeStore = new TreeStore()\n\t\tthis.batchUpdatesOptions = createBatchUpdatesOptions(environment, this.treeStore)\n\t\tthis.asyncBatchUpdatesOptions = {\n\t\t\t...this.batchUpdatesOptions,\n\t\t\tcontentClient: contentApiClient,\n\t\t\tsystemClient: systemApiClient,\n\t\t\ttenantClient: tenantApiClient,\n\t\t}\n\t\tthis.dirtinessTracker = new DirtinessTracker()\n\t\tthis.eventManager = new EventManager(\n\t\t\tthis.asyncBatchUpdatesOptions,\n\t\t\tthis.batchUpdatesOptions,\n\t\t\tthis.config,\n\t\t\tthis.dirtinessTracker,\n\t\t\tthis.resolvedOnUpdate,\n\t\t\tthis.treeStore,\n\t\t)\n\t\tthis.accessorErrorManager = new AccessorErrorManager(this.eventManager, this.treeStore)\n\t\tthis.stateInitializer = new StateInitializer(\n\t\t\tthis.accessorErrorManager,\n\t\t\tthis.batchUpdatesOptions,\n\t\t\tthis.config,\n\t\t\tthis.eventManager,\n\t\t\tthis.treeStore,\n\t\t)\n\t\tthis.treeAugmenter = new TreeAugmenter(this.eventManager, this.stateInitializer, this.treeStore)\n\n\t\t// TODO move this elsewhere\n\t\tthis.bindingOperations = Object.freeze<BindingOperations>({\n\t\t\t...this.asyncBatchUpdatesOptions,\n\t\t\tgetTreeFilters: (): TreeFilter[] => {\n\t\t\t\tconst generator = new TreeFilterGenerator(this.treeStore)\n\t\t\t\treturn generator.generateTreeFilter()\n\t\t\t},\n\t\t\tbatchDeferredUpdates: performUpdates => {\n\t\t\t\tthis.eventManager.syncTransaction(() => performUpdates(this.bindingOperations))\n\t\t\t},\n\t\t\textendTree: async (...args) => await this.extendTree(...args),\n\t\t\tpersist: async ({ signal, onPersistSuccess, onPersistError } = {}) =>\n\t\t\t\tawait this.eventManager.persistOperation(async () => {\n\t\t\t\t\tfor (let attemptNumber = 1; attemptNumber <= this.config.getValue('maxPersistAttempts'); attemptNumber++) {\n\t\t\t\t\t\t// TODO if the tree is in an inconsistent state, wait for lock releases\n\n\t\t\t\t\t\tthis.eventManager.syncTransaction(() => {\n\t\t\t\t\t\t\tthis.accessorErrorManager.clearErrors()\n\t\t\t\t\t\t})\n\t\t\t\t\t\tawait this.eventManager.triggerOnBeforePersist()\n\n\t\t\t\t\t\tlet shouldTryAgain = false\n\t\t\t\t\t\tconst proposedBackOffs: number[] = []\n\t\t\t\t\t\tconst persistErrorOptions: PersistErrorOptions = {\n\t\t\t\t\t\t\t...this.bindingOperations,\n\t\t\t\t\t\t\ttryAgain: options => {\n\t\t\t\t\t\t\t\tshouldTryAgain = true\n\t\t\t\t\t\t\t\tif (options?.proposedBackoff !== undefined && options.proposedBackoff > 0) {\n\t\t\t\t\t\t\t\t\tproposedBackOffs.push(options.proposedBackoff)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tattemptNumber,\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (this.accessorErrorManager.hasErrors()) {\n\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistError(persistErrorOptions)\n\t\t\t\t\t\t\tawait onPersistError?.(persistErrorOptions)\n\n\t\t\t\t\t\t\tif (shouldTryAgain) {\n\t\t\t\t\t\t\t\tcontinue // Trying again immediately\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tthrow {\n\t\t\t\t\t\t\t\terrors: this.accessorErrorManager.getErrors(),\n\t\t\t\t\t\t\t\ttype: 'invalidInput',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst generator = new MutationGenerator(this.treeStore)\n\t\t\t\t\t\tconst mutation = generator.getPersistMutation()\n\n\t\t\t\t\t\tif (mutation === undefined) {\n\t\t\t\t\t\t\tthis.dirtinessTracker.reset() // TODO This ideally shouldn't be necessary but given the current limitations, this makes for better UX.\n\t\t\t\t\t\t\tconst persistSuccessOptions: PersistSuccessOptions = {\n\t\t\t\t\t\t\t\t...this.bindingOperations,\n\t\t\t\t\t\t\t\tsuccessType: 'nothingToPersist',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistSuccess(persistSuccessOptions)\n\t\t\t\t\t\t\tawait onPersistSuccess?.(persistSuccessOptions)\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\ttype: 'nothingToPersist',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst mutationResponse: MutationRequestResponse = await this.contentApiClient.sendRequest(mutation, {\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tconst mutationData = mutationResponse.data?.transaction ?? {}\n\t\t\t\t\t\tconst aliases = Object.keys(mutationData)\n\t\t\t\t\t\tif (!mutationResponse.data) {\n\t\t\t\t\t\t\tthrow {\n\t\t\t\t\t\t\t\terrors: mutationData.errors,\n\t\t\t\t\t\t\t\ttype: 'invalidResponse',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (aliases.every(item => mutationData[item].ok)) {\n\t\t\t\t\t\t\tconst persistedEntityIds = aliases.map(alias => mutationData[alias].node?.id).filter(id => id !== undefined)\n\t\t\t\t\t\t\tconst result: SuccessfulPersistResult = {\n\t\t\t\t\t\t\t\ttype: 'justSuccess',\n\t\t\t\t\t\t\t\tpersistedEntityIds,\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tawait this.eventManager.asyncTransaction(async () => {\n\t\t\t\t\t\t\t\t\tthis.resetTreeAfterSuccessfulPersist()\n\t\t\t\t\t\t\t\t\tthis.treeAugmenter.updatePersistedData(\n\t\t\t\t\t\t\t\t\t\tObject.fromEntries(\n\t\t\t\t\t\t\t\t\t\t\tObject.entries(mutationData).map(([placeholderName, subTreeResponse]) => [\n\t\t\t\t\t\t\t\t\t\t\t\tplaceholderName,\n\t\t\t\t\t\t\t\t\t\t\t\tsubTreeResponse.node,\n\t\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tconst persistSuccessOptions: PersistSuccessOptions = {\n\t\t\t\t\t\t\t\t\t\t...this.bindingOperations,\n\t\t\t\t\t\t\t\t\t\tsuccessType: result.type,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistSuccess(persistSuccessOptions)\n\t\t\t\t\t\t\t\t\tawait onPersistSuccess?.(persistSuccessOptions)\n\n\t\t\t\t\t\t\t\t\tthis.treeAugmenter.resetCreatingSubTrees()\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t\tconsole.error(e)\n\t\t\t\t\t\t\t\tconst resultWithError = {\n\t\t\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\t\t\tafterPersistError: e,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tthis.onPersistSuccess(resultWithError)\n\t\t\t\t\t\t\t\treturn resultWithError\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.onPersistSuccess(result)\n\t\t\t\t\t\t\treturn result\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.eventManager.syncTransaction(() => this.accessorErrorManager.replaceErrors(mutationData))\n\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistError(persistErrorOptions)\n\t\t\t\t\t\t\tawait onPersistError?.(persistErrorOptions)\n\t\t\t\t\t\t\tif (shouldTryAgain) {\n\t\t\t\t\t\t\t\tif (proposedBackOffs.length) {\n\t\t\t\t\t\t\t\t\tconst geometricMean = Math.round(\n\t\t\t\t\t\t\t\t\t\tMath.pow(\n\t\t\t\t\t\t\t\t\t\t\tproposedBackOffs.reduce((a, b) => a * b, 1),\n\t\t\t\t\t\t\t\t\t\t\t1 / proposedBackOffs.length,\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, geometricMean))\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthrow {\n\t\t\t\t\t\t\t\terrors: this.accessorErrorManager.getErrors(),\n\t\t\t\t\t\t\t\ttype: 'invalidInput',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Max attempts exceeded\n\t\t\t\t\t// TODO fire persist error\n\t\t\t\t\tthrow {\n\t\t\t\t\t\ttype: 'givenUp',\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t})\n\t}\n\n\tprivate resolvedOnUpdate = ({ isMutating }: UpdateMetadata) => {\n\t\tthis.onUpdate(new TreeRootAccessor(this.dirtinessTracker.hasChanges(), isMutating, this.bindingOperations))\n\t}\n\n\t// This is currently useless but potentially future-compatible\n\t// private readonly addTreeRootEventListener: TreeRootAccessor.AddTreeRootEventListener = this.getAddEventListener(\n\t// \tthis.treeRootListeners,\n\t// )\n\n\tprivate pendingExtensions: Set<{\n\t\tmarkerTreeRoot: MarkerTreeRoot\n\t\tnewFragment: ReactNode\n\t\tnewTreeRootId: TreeRootId | undefined\n\t\toptions: ExtendTreeOptions\n\t\treject: () => void\n\t\tresolve: (newRootId: TreeRootId | undefined) => void\n\t}> = new Set()\n\n\tpublic async extendTree(newFragment: ReactNode, options: ExtendTreeOptions = {}): Promise<TreeRootId | undefined> {\n\t\tif (options.signal?.aborted) {\n\t\t\treturn Promise.reject(DataBindingExtendAborted)\n\t\t}\n\t\tconst markerTreeRoot = new MarkerTreeGenerator(newFragment, options.environment ?? this.environment).generate()\n\n\t\tif (this.treeStore.effectivelyHasTreeRoot(markerTreeRoot)) {\n\t\t\t// This isn't perfectly accurate as theoretically, we could already have all the data necessary but this\n\t\t\t// could still be false.\n\n\t\t\tconst schema = await this.getOrLoadSchema()\n\t\t\tthis.treeStore.setSchema(schema)\n\t\t\tif (import.meta.env.DEV) {\n\t\t\t\t// For most trees, checking this against the schema should be unnecessary since if we already effectively\n\t\t\t\t// have this tree root, then assuming everything we already have is valid, this should match the schema as well.\n\t\t\t\t// However, we might be dealing with an isCreating tree root which is completely new. Also, we can just lean\n\t\t\t\t// towards the safe side since developer machines can generally handle the potentially unnecessary check anyway.\n\t\t\t\tSchemaValidator.assertTreeValid(schema, markerTreeRoot)\n\t\t\t}\n\n\t\t\treturn this.eventManager.syncOperation(() => {\n\t\t\t\tconst newTreeRootId = this.getNewTreeRootId()\n\t\t\t\tthis.treeAugmenter.extendTreeStates(newTreeRootId, markerTreeRoot)\n\t\t\t\treturn newTreeRootId\n\t\t\t})\n\t\t}\n\n\t\treturn await new Promise((resolve, reject) => {\n\t\t\tthis.pendingExtensions.add({\n\t\t\t\tmarkerTreeRoot,\n\t\t\t\tnewFragment,\n\t\t\t\tnewTreeRootId: this.getNewTreeRootId(),\n\t\t\t\toptions,\n\t\t\t\treject: () => reject(DataBindingExtendAborted),\n\t\t\t\tresolve,\n\t\t\t})\n\t\t\tconst pendingExtensionsCount = this.pendingExtensions.size\n\n\t\t\tPromise.resolve().then(() => {\n\t\t\t\tif (pendingExtensionsCount < this.pendingExtensions.size) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.flushBatchedTreeExtensions()\n\t\t\t})\n\t\t})\n\t}\n\n\tprivate async flushBatchedTreeExtensions() {\n\t\t// This is an async operation so we just take whatever pendingExtensions there are now and let any new ones\n\t\t// accumulate in an empty set.\n\t\tconst pendingExtensions = Array.from(this.pendingExtensions).filter(extension => {\n\t\t\tif (extension.options.signal?.aborted) {\n\t\t\t\textension.reject()\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn true\n\t\t})\n\t\tthis.pendingExtensions.clear()\n\n\t\tconst aggregateMarkerTreeRoot = pendingExtensions.reduce<MarkerTreeRoot | undefined>(\n\t\t\t(previousValue, currentValue) => {\n\t\t\t\tif (previousValue === undefined) {\n\t\t\t\t\treturn currentValue.markerTreeRoot\n\t\t\t\t}\n\t\t\t\treturn MarkerMerger.mergeMarkerTreeRoots(previousValue, currentValue.markerTreeRoot)\n\t\t\t},\n\t\t\tundefined,\n\t\t)\n\n\t\tif (aggregateMarkerTreeRoot === undefined) {\n\t\t\treturn\n\t\t}\n\n\t\tconst aggregateSignal = getCombinedSignal(pendingExtensions.map(extension => extension.options.signal))\n\n\t\t// Even if we don't have a schema yet, we'll still optimistically fire the request so as to prevent a waterfall\n\t\t// in the most likely case that things will go fine and the query does match the schema. If it doesn't, then we\n\t\t// just get a \"400 Bad Request\" but that's not enough to make us delay the happy path.\n\t\tconst [aggregatePersistedData, schema] = await Promise.all([\n\t\t\tthis.fetchPersistedData(aggregateMarkerTreeRoot, aggregateSignal),\n\t\t\tthis.getOrLoadSchema(),\n\t\t])\n\t\tthis.treeStore.setSchema(schema)\n\n\t\tif (import.meta.env.DEV) {\n\t\t\tfor (const extension of pendingExtensions) {\n\t\t\t\tSchemaValidator.assertTreeValid(schema, extension.markerTreeRoot)\n\t\t\t}\n\t\t}\n\n\t\tif (aggregateSignal?.aborted) {\n\t\t\treturn\n\t\t}\n\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tthis.treeAugmenter.extendPersistedData(aggregatePersistedData?.data ?? {})\n\n\t\t\tfor (const extension of pendingExtensions) {\n\t\t\t\tthis.treeAugmenter.extendTreeStates(extension.newTreeRootId, extension.markerTreeRoot)\n\t\t\t\textension.resolve(extension.newTreeRootId)\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate async fetchPersistedData(\n\t\ttree: MarkerTreeRoot,\n\t\tsignal?: AbortSignal,\n\t): Promise<QueryRequestResponse | undefined> {\n\t\tconst queryGenerator = new QueryGenerator(tree)\n\t\tconst query = queryGenerator.getReadQuery()\n\n\t\tlet queryResponse: QueryRequestResponse | undefined = undefined\n\n\t\ttry {\n\t\t\tqueryResponse =\n\t\t\t\tquery === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: await this.contentApiClient.sendRequest(query, {\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t })\n\t\t} catch (metadata) {\n\t\t\tif (metadata.name === 'AbortError') {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.onError(metadataToRequestError(metadata as GraphQlClientFailedRequestMetadata))\n\t\t}\n\t\treturn queryResponse\n\t}\n\n\tprivate resetTreeAfterSuccessfulPersist() {\n\t\tthis.eventManager.syncTransaction(() => {\n\t\t\tthis.accessorErrorManager.clearErrors()\n\t\t\tthis.dirtinessTracker.reset()\n\n\t\t\tfor (const [, rootState] of StateIterator.eachRootState(this.treeStore)) {\n\t\t\t\tfor (const state of StateIterator.depthFirstAllNodes(rootState)) {\n\t\t\t\t\tswitch (state.type) {\n\t\t\t\t\t\tcase 'field': {\n\t\t\t\t\t\t\tif (state.hasUnpersistedChanges || state.touchLog?.size) {\n\t\t\t\t\t\t\t\tstate.touchLog?.clear()\n\t\t\t\t\t\t\t\tstate.hasUnpersistedChanges = false\n\t\t\t\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase 'entityList':\n\t\t\t\t\t\t\tif (state.unpersistedChangesCount > 0 || state.plannedRemovals?.size) {\n\t\t\t\t\t\t\t\tstate.unpersistedChangesCount = 0\n\t\t\t\t\t\t\t\tstate.plannedRemovals?.clear()\n\t\t\t\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase 'entityRealm': {\n\t\t\t\t\t\t\tif (state.unpersistedChangesCount > 0 || state.plannedHasOneDeletions?.size) {\n\t\t\t\t\t\t\t\tstate.unpersistedChangesCount = 0\n\t\t\t\t\t\t\t\tstate.plannedHasOneDeletions?.clear()\n\t\t\t\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tassertNever(state)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate getOrLoadSchema(): Schema | Promise<Schema> {\n\t\tconst existing = DataBinding.schemaLoadCache.get(this.contentApiClient.apiUrl)\n\t\tif (existing !== undefined) {\n\t\t\treturn existing\n\t\t}\n\n\t\tconst schemaPromise = SchemaLoader.loadSchema(this.contentApiClient, this.config.getValue('maxSchemaLoadAttempts'))\n\t\tschemaPromise.then(schema => {\n\t\t\tDataBinding.schemaLoadCache.set(this.contentApiClient.apiUrl, schema)\n\t\t})\n\t\tDataBinding.schemaLoadCache.set(this.contentApiClient.apiUrl, schemaPromise)\n\t\treturn schemaPromise\n\t}\n\n\tprivate static getNextTreeRootIdSeed = (() => {\n\t\tlet seed = 1\n\t\treturn () => seed++\n\t})()\n\n\tprivate getNewTreeRootId() {\n\t\t// TODO this is an awful, awful hack.\n\t\t// TODO the particular shape of the alias is relied on in MutationAlias. If you change this, change it there too.\n\t\treturn this.treeStore.markerTrees.size === 0\n\t\t\t? undefined\n\t\t\t: `${generateEnumerabilityPreventingEntropy()}-${DataBinding.getNextTreeRootIdSeed()}`\n\t}\n}\n\nexport const DataBindingExtendAborted = Symbol('aborted')\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;2BAwCyB;AAAA,EAoBjB,YACW,kBACA,iBACA,iBACA,aACA,UACA,SACA,kBAChB;AAzBe;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA6LT,4CAAmB,CAAC,EAAE,iBAAiC;WACzD,SAAS,IAAI,iBAAiB,KAAK,iBAAiB,cAAc,YAAY,KAAK;AAAA;AAQjF,iEAOC;;;;;;;;SA5LH,SAAS,IAAI;SACb,YAAY,IAAI;SAChB,sBAAsB,0BAA0B,aAAa,KAAK;SAClE,2BAA2B;AAAA,SAC5B,KAAK;AAAA,MACR,eAAe;AAAA,MACf,cAAc;AAAA,MACd,cAAc;AAAA;SAEV,mBAAmB,IAAI;SACvB,eAAe,IAAI,aACvB,KAAK,0BACL,KAAK,qBACL,KAAK,QACL,KAAK,kBACL,KAAK,kBACL,KAAK;SAED,uBAAuB,IAAI,qBAAqB,KAAK,cAAc,KAAK;SACxE,mBAAmB,IAAI,iBAC3B,KAAK,sBACL,KAAK,qBACL,KAAK,QACL,KAAK,cACL,KAAK;SAED,gBAAgB,IAAI,cAAc,KAAK,cAAc,KAAK,kBAAkB,KAAK;SAGjF,oBAAoB,OAAO,OAA0B;AAAA,SACtD,KAAK;AAAA,MACR,gBAAgB,MAAoB;cAC7B,YAAY,IAAI,oBAAoB,KAAK;eACxC,UAAU;AAAA;AAAA,MAElB,sBAAsB,oBAAkB;aAClC,aAAa,gBAAgB,MAAM,eAAe,KAAK;AAAA;AAAA,MAE7D,YAAY,UAAU,SAAS,MAAM,KAAK,WAAW,GAAG;AAAA,MACxD,SAAS,OAAO,EAAE,QAAQ,qCAAkB,mBAAmB,OAC9D,MAAM,KAAK,aAAa,iBAAiB,YAAY;iBAC3C,gBAAgB,GAAG,iBAA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;sBAClD,UAAU;sBACV,wBAAwB;qBACzB,aAAa,oBAAoB,OAAO,aAAa;AAAA;;;iBAIvD;kBACA,MAAM,0BAA0B,KAAK,MAAM,iBAAiB,MAAM;sBAC/D,0BAA0B;sBAC1B,iBAAiB;qBAClB,aAAa,oBAAoB,OAAO,aAAa;AAAA;;iBAGvD,eAAe;kBACf,MAAM,0BAA0B,KAAK,MAAM,wBAAwB,MAAM;sBACtE,0BAA0B;sBAC1B,wBAAwB;qBACzB,aAAa,oBAAoB,OAAO,aAAa;AAAA;;;;;;;;;;EAYzD,kBAA4C;UAC7C,WAAW,aAAY,gBAAgB,IAAI,KAAK,iBAAiB;QACnE,aAAa,QAAW;aACpB;AAAA;UAGF,gBAAgB,aAAa,WAAW,KAAK,kBAAkB,KAAK,OAAO,SAAS;kBAC5E,KAAK,YAAU;mBAChB,gBAAgB,IAAI,KAAK,iBAAiB,QAAQ;AAAA;iBAEnD,gBAAgB,IAAI,KAAK,iBAAiB,QAAQ;WACvD;AAAA;AAAA,EAQA,mBAAmB;WAGnB,KAAK,UAAU,YAAY,SAAS,IACxC,SACA,GAAG,4CAA4C,aAAY;AAAA;AAAA;;AA1ZvC,2BAAA,uCAA6D;AAgZtE,2BAAA,gCAA+B;MACzC,OAAO;SACJ,MAAM;AAAA;MAYF,2BAA2B,OAAO;;"}
@@ -48,7 +48,7 @@ export { ClientGeneratedUuid, ServerGeneratedUuid, UnpersistedEntityDummyId } fr
48
48
  export { useDataBinding } from "./accessorTree/useDataBinding.js";
49
49
  export { useDirtinessState } from "./accessorTree/useDirtinessState.js";
50
50
  export { useMutationState } from "./accessorTree/useMutationState.js";
51
- export { DataBinding } from "./core/DataBinding.js";
51
+ export { DataBinding, DataBindingExtendAborted } from "./core/DataBinding.js";
52
52
  export { MarkerMerger } from "./core/MarkerMerger.js";
53
53
  export { MarkerTreeGenerator } from "./core/MarkerTreeGenerator.js";
54
54
  export { TreeParameterMerger } from "./core/TreeParameterMerger.js";
@@ -409,7 +409,7 @@ const _Parser = class extends EmbeddedActionsParser {
409
409
  return order;
410
410
  }));
411
411
  __publicField(this, "taggedMap", this.RULE("taggedMap", () => {
412
- const name = this.SUBRULE(this.identifier);
412
+ const name = this.SUBRULE(this.pageName);
413
413
  return {
414
414
  name,
415
415
  entries: this.OPTION(() => this.SUBRULE(this.taggedMapEntries)) ?? []
@@ -509,6 +509,14 @@ const _Parser = class extends EmbeddedActionsParser {
509
509
  }
510
510
  ]);
511
511
  }));
512
+ __publicField(this, "pageName", this.RULE("pageName", () => {
513
+ const parts = [];
514
+ this.AT_LEAST_ONE_SEP({
515
+ SEP: tokens.Slash,
516
+ DEF: () => parts.push(this.CONSUME(tokens.Identifier).image)
517
+ });
518
+ return parts.join("/");
519
+ }));
512
520
  __publicField(this, "entityIdentifier", this.RULE("entityIdentifier", () => {
513
521
  return this.OR([
514
522
  {