@contember/binding 1.1.0-alpha.6 → 1.1.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/accessorTree/NormalizedPersistedData.js.map +1 -1
- package/dist/development/core/AccessorErrorManager.js +2 -2
- package/dist/development/core/AccessorErrorManager.js.map +1 -1
- package/dist/development/core/DataBinding.js +8 -7
- package/dist/development/core/DataBinding.js.map +1 -1
- package/dist/development/core/ErrorsPreprocessor.js +9 -13
- package/dist/development/core/ErrorsPreprocessor.js.map +1 -1
- package/dist/development/core/MutationGenerator.js +79 -43
- package/dist/development/core/MutationGenerator.js.map +1 -1
- package/dist/development/core/RequestResponseNormalizer.js +93 -130
- package/dist/development/core/RequestResponseNormalizer.js.map +1 -1
- package/dist/development/core/StateInitializer.js.map +1 -1
- package/dist/development/core/TreeAugmenter.js +4 -4
- package/dist/development/core/TreeAugmenter.js.map +1 -1
- package/dist/development/core/TreeStore.js +4 -4
- package/dist/development/core/TreeStore.js.map +1 -1
- package/dist/development/core/VariableInputTransformer.js.map +1 -1
- package/dist/development/core/requestAliases/MutationAlias.js +2 -40
- package/dist/development/core/requestAliases/MutationAlias.js.map +1 -1
- package/dist/development/helperComponents/helpers/evaluateCondition.js.map +1 -1
- package/dist/production/accessorTree/NormalizedPersistedData.js.map +1 -1
- package/dist/production/core/AccessorErrorManager.js +2 -2
- package/dist/production/core/AccessorErrorManager.js.map +1 -1
- package/dist/production/core/DataBinding.js +8 -7
- package/dist/production/core/DataBinding.js.map +1 -1
- package/dist/production/core/ErrorsPreprocessor.js +9 -13
- package/dist/production/core/ErrorsPreprocessor.js.map +1 -1
- package/dist/production/core/MutationGenerator.js +79 -43
- package/dist/production/core/MutationGenerator.js.map +1 -1
- package/dist/production/core/RequestResponseNormalizer.js +93 -130
- package/dist/production/core/RequestResponseNormalizer.js.map +1 -1
- package/dist/production/core/StateInitializer.js.map +1 -1
- package/dist/production/core/TreeAugmenter.js +4 -4
- package/dist/production/core/TreeAugmenter.js.map +1 -1
- package/dist/production/core/TreeStore.js +4 -4
- package/dist/production/core/TreeStore.js.map +1 -1
- package/dist/production/core/VariableInputTransformer.js.map +1 -1
- package/dist/production/core/requestAliases/MutationAlias.js +2 -33
- package/dist/production/core/requestAliases/MutationAlias.js.map +1 -1
- package/dist/production/helperComponents/helpers/evaluateCondition.js.map +1 -1
- package/dist/types/accessorTree/NormalizedPersistedData.d.ts +2 -2
- package/dist/types/accessorTree/NormalizedPersistedData.d.ts.map +1 -1
- package/dist/types/accessorTree/QueryRequestResponse.d.ts +2 -2
- package/dist/types/accessorTree/QueryRequestResponse.d.ts.map +1 -1
- package/dist/types/core/AccessorErrorManager.d.ts +2 -1
- package/dist/types/core/AccessorErrorManager.d.ts.map +1 -1
- package/dist/types/core/DataBinding.d.ts.map +1 -1
- package/dist/types/core/ErrorsPreprocessor.d.ts +3 -1
- package/dist/types/core/ErrorsPreprocessor.d.ts.map +1 -1
- package/dist/types/core/MutationGenerator.d.ts +25 -1
- package/dist/types/core/MutationGenerator.d.ts.map +1 -1
- package/dist/types/core/RequestResponseNormalizer.d.ts +6 -7
- package/dist/types/core/RequestResponseNormalizer.d.ts.map +1 -1
- package/dist/types/core/StateInitializer.d.ts.map +1 -1
- package/dist/types/core/TreeAugmenter.d.ts +3 -2
- package/dist/types/core/TreeAugmenter.d.ts.map +1 -1
- package/dist/types/core/TreeStore.d.ts +3 -2
- package/dist/types/core/TreeStore.d.ts.map +1 -1
- package/dist/types/core/VariableInputTransformer.d.ts +2 -2
- package/dist/types/core/VariableInputTransformer.d.ts.map +1 -1
- package/dist/types/core/requestAliases/MutationAlias.d.ts +0 -3
- package/dist/types/core/requestAliases/MutationAlias.d.ts.map +1 -1
- package/dist/types/core/requestAliases/index.d.ts +0 -3
- package/dist/types/core/requestAliases/index.d.ts.map +1 -1
- package/dist/types/core/state/FieldState.d.ts +2 -2
- package/dist/types/core/state/FieldState.d.ts.map +1 -1
- package/dist/types/coreComponents/Field.d.ts +1 -1
- package/dist/types/coreComponents/Field.d.ts.map +1 -1
- package/dist/types/entityEvents/useDerivedField.d.ts +2 -2
- package/dist/types/entityEvents/useDerivedField.d.ts.map +1 -1
- package/dist/types/helperComponents/FieldView.d.ts +7 -7
- package/dist/types/helperComponents/FieldView.d.ts.map +1 -1
- package/dist/types/helperComponents/SugaredField.d.ts +1 -1
- package/dist/types/helperComponents/SugaredField.d.ts.map +1 -1
- package/dist/types/helperComponents/helpers/evaluateCondition.d.ts +2 -2
- package/dist/types/helperComponents/helpers/evaluateCondition.d.ts.map +1 -1
- package/dist/types/markers/FieldMarker.d.ts +3 -3
- package/dist/types/markers/FieldMarker.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/FieldValue.d.ts +2 -2
- package/dist/types/treeParameters/primitives/FieldValue.d.ts.map +1 -1
- package/dist/types/treeParameters/primitives/Json.d.ts +7 -0
- package/dist/types/treeParameters/primitives/Json.d.ts.map +1 -0
- package/dist/types/treeParameters/primitives/index.d.ts +1 -0
- package/dist/types/treeParameters/primitives/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/accessorTree/NormalizedPersistedData.ts +2 -2
- package/src/accessorTree/QueryRequestResponse.ts +2 -2
- package/src/core/AccessorErrorManager.ts +3 -2
- package/src/core/DataBinding.ts +8 -6
- package/src/core/ErrorsPreprocessor.ts +14 -16
- package/src/core/MutationGenerator.ts +112 -56
- package/src/core/RequestResponseNormalizer.ts +110 -161
- package/src/core/StateInitializer.ts +5 -4
- package/src/core/TreeAugmenter.ts +5 -4
- package/src/core/TreeStore.ts +5 -4
- package/src/core/VariableInputTransformer.ts +2 -2
- package/src/core/requestAliases/MutationAlias.ts +2 -57
- package/src/core/requestAliases/index.ts +0 -3
- package/src/core/state/FieldState.ts +2 -2
- package/src/helperComponents/helpers/evaluateCondition.ts +2 -2
- package/src/treeParameters/primitives/FieldValue.ts +2 -2
- package/src/treeParameters/primitives/Json.ts +7 -0
- package/src/treeParameters/primitives/index.ts +1 -0
- package/dist/development/core/requestAliases/mutationOperationSubTreeType.js +0 -6
- package/dist/development/core/requestAliases/mutationOperationSubTreeType.js.map +0 -1
- package/dist/development/core/requestAliases/mutationOperationType.js +0 -7
- package/dist/development/core/requestAliases/mutationOperationType.js.map +0 -1
- package/dist/production/core/requestAliases/mutationOperationSubTreeType.js +0 -6
- package/dist/production/core/requestAliases/mutationOperationSubTreeType.js.map +0 -1
- package/dist/production/core/requestAliases/mutationOperationType.js +0 -7
- package/dist/production/core/requestAliases/mutationOperationType.js.map +0 -1
- package/dist/types/core/requestAliases/TopLevelMutationOperation.d.ts +0 -11
- package/dist/types/core/requestAliases/TopLevelMutationOperation.d.ts.map +0 -1
- package/dist/types/core/requestAliases/mutationOperationSubTreeType.d.ts +0 -5
- package/dist/types/core/requestAliases/mutationOperationSubTreeType.d.ts.map +0 -1
- package/dist/types/core/requestAliases/mutationOperationType.d.ts +0 -6
- package/dist/types/core/requestAliases/mutationOperationType.d.ts.map +0 -1
- package/src/core/requestAliases/TopLevelMutationOperation.ts +0 -11
- package/src/core/requestAliases/mutationOperationSubTreeType.ts +0 -4
- package/src/core/requestAliases/mutationOperationType.ts +0 -5
|
@@ -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 } 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.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\n\t\t\t\t\t\tif (mutationResponse.errors !== undefined && mutationResponse.errors.length > 0) {\n\t\t\t\t\t\t\tthis.onError({\n\t\t\t\t\t\t\t\ttype: 'gqlError',\n\t\t\t\t\t\t\t\tquery: mutation,\n\t\t\t\t\t\t\t\terrors: mutationResponse.errors,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!mutationResponse.data?.transaction) {\n\t\t\t\t\t\t\tthrow {\n\t\t\t\t\t\t\t\terrors: [],\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}\n\t\t\t\t\t\tconst { __typename, ...mutationData } = mutationResponse.data.transaction\n\t\t\t\t\t\tconst aliases = Object.keys(mutationData)\n\t\t\t\t\t\tif (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 schema = await this.getOrLoadSchema()\n\t\tthis.treeStore.setSchema(schema)\n\t\tconst markerTreeRoot = new MarkerTreeGenerator(newFragment, (options.environment ?? this.environment).withSchema(schema)).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\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\tconst aggregatePersistedData = await this.fetchPersistedData(aggregateMarkerTreeRoot, aggregateSignal)\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\n\t\tif (queryResponse && queryResponse.errors !== undefined && queryResponse.errors.length > 0) {\n\t\t\tthis.onError({\n\t\t\t\ttype: 'gqlError',\n\t\t\t\tquery: query ?? 'unknown query',\n\t\t\t\terrors: queryResponse.errors,\n\t\t\t})\n\t\t}\n\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":";;;;;;;;;;;;;;;;;;;;;;;;;;AAwCO,2BAAkB;AAAA,EAoBjB,YACW,kBACA,iBACA,iBACA,aACA,UACA,SACA,kBAChB;AAzBe;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAqMT,4CAAmB,CAAC,EAAE,iBAAiC;AACzD,WAAA,SAAS,IAAI,iBAAiB,KAAK,iBAAiB,cAAc,YAAY,KAAK,iBAAiB,CAAC;AAAA,IAAA;AAQnG,iEAOC;AA5MS,SAAA,mBAAA;AACA,SAAA,kBAAA;AACA,SAAA,kBAAA;AACA,SAAA,cAAA;AACA,SAAA,WAAA;AACA,SAAA,UAAA;AACA,SAAA,mBAAA;AAEZ,SAAA,SAAS,IAAI;AACb,SAAA,YAAY,IAAI;AACrB,SAAK,sBAAsB,0BAA0B,aAAa,KAAK,SAAS;AAChF,SAAK,2BAA2B;AAAA,SAC5B,K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S,yBAA+B,OAAA;AAC7C,MAAI,OAAO;AACX,SAAO,MAAM;AAAA;AAYF,MAAA,2BAA2B,OAAO,SAAS;;"}
|
|
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 } 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.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 mutationResult = generator.getPersistMutation()\n\n\t\t\t\t\t\tif (mutationResult === 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\t\t\t\t\t\tconst { query, operations } = mutationResult\n\n\t\t\t\t\t\tconst mutationResponse: MutationRequestResponse = await this.contentApiClient.sendRequest(query, {\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t})\n\n\t\t\t\t\t\tif (mutationResponse.errors !== undefined && mutationResponse.errors.length > 0) {\n\t\t\t\t\t\t\tthis.onError({\n\t\t\t\t\t\t\t\ttype: 'gqlError',\n\t\t\t\t\t\t\t\tquery,\n\t\t\t\t\t\t\t\terrors: mutationResponse.errors,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!mutationResponse.data?.transaction) {\n\t\t\t\t\t\t\tthrow {\n\t\t\t\t\t\t\t\terrors: [],\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}\n\t\t\t\t\t\tconst { __typename, ...mutationData } = mutationResponse.data.transaction\n\t\t\t\t\t\tconst aliases = Object.keys(mutationData)\n\t\t\t\t\t\tif (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\toperations,\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, operations))\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 schema = await this.getOrLoadSchema()\n\t\tthis.treeStore.setSchema(schema)\n\t\tconst markerTreeRoot = new MarkerTreeGenerator(newFragment, (options.environment ?? this.environment).withSchema(schema)).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\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\tconst aggregatePersistedData = await this.fetchPersistedData(aggregateMarkerTreeRoot, aggregateSignal)\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 ?? {}, aggregateMarkerTreeRoot)\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\n\t\tif (queryResponse && queryResponse.errors !== undefined && queryResponse.errors.length > 0) {\n\t\t\tthis.onError({\n\t\t\t\ttype: 'gqlError',\n\t\t\t\tquery: query ?? 'unknown query',\n\t\t\t\terrors: queryResponse.errors,\n\t\t\t})\n\t\t}\n\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.getNext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qB;AAAA,cAChF;AACA;AAAA,YACD;AAAA;AAEC,0BAAiB;AAAA;AAAA,QAEpB;AAAA,MACD;AAAA,IAAA,CACA;AAAA,EACF;AAAA,EAEQ,kBAA4C;AACnD,UAAM,WAAW,aAAY,gBAAgB,IAAI,KAAK,iBAAiB,MAAM;AAC7E,QAAI,aAAa,QAAW;AACpB,aAAA;AAAA,IACR;AAEM,UAAA,gBAAgB,aAAa,WAAW,KAAK,kBAAkB,KAAK,OAAO,SAAS,uBAAuB,CAAC;AAClH,kBAAc,KAAK,CAAU,WAAA;AAC5B,mBAAY,gBAAgB,IAAI,KAAK,iBAAiB,QAAQ,MAAM;AAAA,IAAA,CACpE;AACD,iBAAY,gBAAgB,IAAI,KAAK,iBAAiB,QAAQ,aAAa;AACpE,WAAA;AAAA,EACR;AAAA,EAOQ,mBAAmB;AAGnB,WAAA,KAAK,UAAU,YAAY,SAAS,IACxC,SACA,GAAG,uCAA4C,KAAA,aAAY,sBAAsB;AAAA,EACrF;AACD;AA3ZO;AACkB,cADlB,aACkB,uCAA6D;AA8YtE,cA/YT,aA+YS,yBAA+B,OAAA;AAC7C,MAAI,OAAO;AACX,SAAO,MAAM;AAAA;AAYF,MAAA,2BAA2B,OAAO,SAAS;;"}
|
|
@@ -1,42 +1,38 @@
|
|
|
1
1
|
import { MutationAlias } from "./requestAliases/MutationAlias.js";
|
|
2
|
-
import { mutationOperationSubTreeType } from "./requestAliases/mutationOperationSubTreeType.js";
|
|
3
2
|
import { assertNever } from "../utils/assertNever.js";
|
|
4
3
|
class ErrorsPreprocessor {
|
|
5
|
-
constructor(requestResponse) {
|
|
4
|
+
constructor(requestResponse, operations) {
|
|
6
5
|
this.requestResponse = requestResponse;
|
|
6
|
+
this.operations = operations;
|
|
7
7
|
}
|
|
8
8
|
preprocess() {
|
|
9
9
|
const treeRoot = /* @__PURE__ */ new Map();
|
|
10
10
|
if (this.requestResponse === void 0) {
|
|
11
11
|
return treeRoot;
|
|
12
12
|
}
|
|
13
|
-
for (const
|
|
14
|
-
const mutationResponse = this.requestResponse[
|
|
13
|
+
for (const operation of this.operations) {
|
|
14
|
+
const mutationResponse = this.requestResponse[operation.alias];
|
|
15
15
|
const processedResponse = this.processMutationResponse(mutationResponse);
|
|
16
16
|
if (processedResponse === void 0) {
|
|
17
17
|
continue;
|
|
18
18
|
}
|
|
19
|
-
const
|
|
20
|
-
if (
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
const { subTreeType, subTreePlaceholder, entityId } = operation;
|
|
24
|
-
if (subTreeType === mutationOperationSubTreeType.singleEntity) {
|
|
19
|
+
const { subTreeType, subTreePlaceholder, id } = operation;
|
|
20
|
+
if (subTreeType === "single") {
|
|
25
21
|
if (treeRoot.has(subTreePlaceholder)) {
|
|
26
22
|
return this.rejectCorruptData();
|
|
27
23
|
}
|
|
28
24
|
treeRoot.set(subTreePlaceholder, processedResponse);
|
|
29
|
-
} else if (subTreeType ===
|
|
25
|
+
} else if (subTreeType === "list") {
|
|
30
26
|
const child = treeRoot.get(subTreePlaceholder);
|
|
31
27
|
if (child === void 0) {
|
|
32
28
|
treeRoot.set(subTreePlaceholder, {
|
|
33
29
|
nodeType: "iNode",
|
|
34
|
-
children: /* @__PURE__ */ new Map([[
|
|
30
|
+
children: /* @__PURE__ */ new Map([[id, processedResponse]]),
|
|
35
31
|
validation: [],
|
|
36
32
|
execution: []
|
|
37
33
|
});
|
|
38
34
|
} else if (child.nodeType === "iNode") {
|
|
39
|
-
child.children.set(
|
|
35
|
+
child.children.set(id, processedResponse);
|
|
40
36
|
}
|
|
41
37
|
} else {
|
|
42
38
|
return assertNever();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorsPreprocessor.js","sources":["../../../src/core/ErrorsPreprocessor.ts"],"sourcesContent":["import type { ErrorAccessor } from '../accessors'\nimport type { ExecutionError, MutationDataResponse, MutationResponse, ValidationError } from '../accessorTree'\nimport type { EntityId, FieldName, PlaceholderName } from '../treeParameters'\nimport { assertNever } from '../utils'\nimport { MutationAlias, mutationOperationSubTreeType } from './requestAliases'\n\nclass ErrorsPreprocessor {\n\tpublic constructor(private readonly requestResponse: MutationDataResponse) {}\n\n\tpublic preprocess(): ErrorsPreprocessor.ErrorTreeRoot {\n\t\tconst treeRoot: ErrorsPreprocessor.ErrorTreeRoot = new Map()\n\n\t\tif (this.requestResponse === undefined) {\n\t\t\treturn treeRoot\n\t\t}\n\n\t\tfor (const mutationAlias in this.requestResponse) {\n\t\t\tconst mutationResponse = this.requestResponse[mutationAlias]\n\t\t\tconst processedResponse = this.processMutationResponse(mutationResponse)\n\n\t\t\tif (processedResponse === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst operation = MutationAlias.decodeTopLevel(mutationAlias)\n\n\t\t\tif (operation === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst { subTreeType, subTreePlaceholder, entityId } = operation\n\n\t\t\tif (subTreeType === mutationOperationSubTreeType.singleEntity) {\n\t\t\t\tif (treeRoot.has(subTreePlaceholder)) {\n\t\t\t\t\treturn this.rejectCorruptData()\n\t\t\t\t}\n\t\t\t\ttreeRoot.set(subTreePlaceholder, processedResponse)\n\t\t\t} else if (subTreeType === mutationOperationSubTreeType.entityList) {\n\t\t\t\tconst child = treeRoot.get(subTreePlaceholder)\n\n\t\t\t\tif (child === undefined) {\n\t\t\t\t\ttreeRoot.set(subTreePlaceholder, {\n\t\t\t\t\t\tnodeType: 'iNode',\n\t\t\t\t\t\tchildren: new Map([[entityId, processedResponse]]),\n\t\t\t\t\t\tvalidation: [],\n\t\t\t\t\t\texecution: [],\n\t\t\t\t\t})\n\t\t\t\t} else if (child.nodeType === 'iNode') {\n\t\t\t\t\tchild.children.set(entityId, processedResponse)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn assertNever(subTreeType)\n\t\t\t}\n\t\t}\n\t\treturn treeRoot\n\t}\n\n\tprivate processMutationResponse(mutationResponse: MutationResponse): ErrorsPreprocessor.ErrorNode | undefined {\n\t\tif (mutationResponse.ok && mutationResponse.validation?.valid && mutationResponse.errors.length === 0) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (mutationResponse.validation?.errors.length) {\n\t\t\treturn this.getErrorNode(mutationResponse.validation?.errors)\n\t\t}\n\t\tif (mutationResponse.errors.length) {\n\t\t\treturn this.getErrorNode(mutationResponse.errors)\n\t\t}\n\t\treturn undefined\n\t}\n\n\tprivate getErrorNode(errors: ValidationError[] | ExecutionError[]): ErrorsPreprocessor.ErrorNode {\n\t\tconst [head, ...tail] = errors\n\n\t\tlet rootNode = this.getRootNode(head)\n\n\t\terrorLoop: for (const error of tail) {\n\t\t\tlet currentNode = rootNode\n\n\t\t\tfor (let i = 0, pathLength = error.path.length; i < pathLength; i++) {\n\t\t\t\tconst pathNode = error.path[i]\n\n\t\t\t\tif (currentNode.nodeType === 'leaf') {\n\t\t\t\t\t(currentNode as any as ErrorsPreprocessor.ErrorINode).nodeType = 'iNode'\n\t\t\t\t\t;(currentNode as any as ErrorsPreprocessor.ErrorINode).children = new Map()\n\t\t\t\t}\n\n\t\t\t\tif (pathNode.__typename === '_FieldPathFragment') {\n\t\t\t\t\tif (currentNode.nodeType === 'iNode') {\n\t\t\t\t\t\tlet alias = pathNode.field\n\t\t\t\t\t\tlet nextIndex = i + 1\n\t\t\t\t\t\tif (nextIndex in error.path) {\n\t\t\t\t\t\t\tconst nextPathNode = error.path[nextIndex]\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tnextPathNode.__typename === '_IndexPathFragment' &&\n\t\t\t\t\t\t\t\ttypeof nextPathNode.alias === 'string' &&\n\t\t\t\t\t\t\t\tnextPathNode.alias.startsWith(pathNode.field)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// We're dealing with a reduced hasMany relation.\n\t\t\t\t\t\t\t\ti++\n\t\t\t\t\t\t\t\tnextIndex++\n\t\t\t\t\t\t\t\talias = nextPathNode.alias\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!(alias in currentNode.children)) {\n\t\t\t\t\t\t\tcurrentNode.children.set(alias, this.getRootNode(error, nextIndex))\n\t\t\t\t\t\t\tif (nextIndex <= error.path.length) {\n\t\t\t\t\t\t\t\t// This path has been handled by getRootNode\n\t\t\t\t\t\t\t\tcontinue errorLoop\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcurrentNode = currentNode.children.get(alias)!\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.rejectCorruptData()\n\t\t\t\t\t}\n\t\t\t\t} else if (pathNode.__typename === '_IndexPathFragment') {\n\t\t\t\t\tif (currentNode.nodeType === 'iNode') {\n\t\t\t\t\t\tconst alias = pathNode.alias\n\n\t\t\t\t\t\tif (alias === null) {\n\t\t\t\t\t\t\tthrow new ErrorsPreprocessor.ErrorsPreprocessorError(\n\t\t\t\t\t\t\t\t`Corrupt data: undefined alias for node with index ${pathNode.index}.`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst entityId = MutationAlias.decodeEntityId(alias)\n\n\t\t\t\t\t\tif (!(entityId in currentNode.children)) {\n\t\t\t\t\t\t\tcurrentNode.children.set(entityId, this.getRootNode(error, i + 1))\n\t\t\t\t\t\t\tif (i + 1 <= error.path.length) {\n\t\t\t\t\t\t\t\t// This path has been handled by getRootNode\n\t\t\t\t\t\t\t\tcontinue errorLoop\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcurrentNode = currentNode.children.get(entityId)!\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.rejectCorruptData()\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tassertNever(pathNode)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.isExecutionError(error)) {\n\t\t\t\tcurrentNode.execution.push({ type: 'execution', code: error.type, developerMessage: error.message })\n\t\t\t} else {\n\t\t\t\tcurrentNode.validation.push(this.createValidationError(error.message.text))\n\t\t\t}\n\t\t}\n\n\t\treturn rootNode\n\t}\n\n\tprivate getRootNode(error: ValidationError | ExecutionError, startIndex: number = 0): ErrorsPreprocessor.ErrorNode {\n\t\tlet rootNode: ErrorsPreprocessor.ErrorNode = {\n\t\t\tvalidation: this.isExecutionError(error) ? [] : [this.createValidationError(error.message.text)],\n\t\t\texecution: this.isExecutionError(error) ? [{ type: 'execution', code: error.type, developerMessage: error.message }] : [],\n\t\t\tnodeType: 'leaf',\n\t\t}\n\n\t\tfor (let i = error.path.length - 1; i >= startIndex; i--) {\n\t\t\tconst pathNode = error.path[i]\n\t\t\tif (pathNode.__typename === '_FieldPathFragment') {\n\t\t\t\trootNode = {\n\t\t\t\t\tvalidation: [],\n\t\t\t\t\texecution: [],\n\t\t\t\t\tnodeType: 'iNode',\n\t\t\t\t\tchildren: new Map([[pathNode.field, rootNode]]),\n\t\t\t\t}\n\t\t\t} else if (pathNode.__typename === '_IndexPathFragment') {\n\t\t\t\tconst alias = pathNode.alias\n\n\t\t\t\tif (alias === null) {\n\t\t\t\t\tthrow new ErrorsPreprocessor.ErrorsPreprocessorError(\n\t\t\t\t\t\t`Corrupt data: undefined alias for node with index ${pathNode.index}.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\trootNode = {\n\t\t\t\t\tvalidation: [],\n\t\t\t\t\texecution: [],\n\t\t\t\t\tnodeType: 'iNode',\n\t\t\t\t\tchildren: new Map([[MutationAlias.decodeEntityId(alias), rootNode]]),\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tassertNever(pathNode)\n\t\t\t}\n\t\t}\n\n\t\treturn rootNode\n\t}\n\n\tprivate createValidationError(message: string): ErrorAccessor.ValidationError {\n\t\tif (message === 'Field is required') {\n\t\t\t// TODO this is just awful. Validation errors currently don't have error codes which makes it more difficult\n\t\t\t// \tto translate the error messages. This is the most common such error, and so we just make up a code\n\t\t\t// \tin order to facilitate error handling further downstream.\n\t\t\treturn {\n\t\t\t\ttype: 'validation',\n\t\t\t\tcode: 'fieldRequired',\n\t\t\t\tmessage,\n\t\t\t}\n\t\t}\n\t\treturn { type: 'validation', message, code: undefined }\n\t}\n\n\tprivate isExecutionError(error: ValidationError | ExecutionError): error is ExecutionError {\n\t\treturn 'type' in error\n\t}\n\n\tprivate rejectCorruptData(): never {\n\t\tthrow new ErrorsPreprocessor.ErrorsPreprocessorError(\n\t\t\t'Received corrupted data: a node cannot be simultaneously field-indexed and path-indexed.',\n\t\t)\n\t}\n}\n\nnamespace ErrorsPreprocessor {\n\texport interface BaseErrorNode {\n\t\tvalidation: ErrorAccessor.ValidationError[]\n\t\texecution: ErrorAccessor.ExecutionError[]\n\t}\n\n\texport interface LeafErrorNode extends BaseErrorNode {\n\t\tnodeType: 'leaf'\n\t}\n\n\texport interface ErrorINode extends BaseErrorNode {\n\t\tnodeType: 'iNode'\n\t\tchildren: Map<FieldName | EntityId, ErrorNode>\n\t}\n\n\texport type ErrorNode = ErrorINode | LeafErrorNode\n\n\texport type ErrorTreeRoot = Map<PlaceholderName, ErrorNode>\n\n\texport class ErrorsPreprocessorError extends Error {}\n}\n\nexport { ErrorsPreprocessor }\n"],"names":[],"mappings":";;;AAMA,MAAM,mBAAmB;AAAA,EACjB,YAA6B,iBAAuC;AAAvC,SAAA,kBAAA;AAAA,EAAwC;AAAA,EAErE,aAA+C;AAC/C,UAAA,+BAAiD;AAEnD,QAAA,KAAK,oBAAoB,QAAW;AAChC,aAAA;AAAA,IACR;AAEW,eAAA,iBAAiB,KAAK,iBAAiB;AAC3C,YAAA,mBAAmB,KAAK,gBAAgB;AACxC,YAAA,oBAAoB,KAAK,wBAAwB,gBAAgB;AAEvE,UAAI,sBAAsB,QAAW;AACpC;AAAA,MACD;AAEM,YAAA,YAAY,cAAc,eAAe,aAAa;AAE5D,UAAI,cAAc,QAAW;AAC5B;AAAA,MACD;AAEM,YAAA,EAAE,aAAa,oBAAoB,aAAa;AAElD,UAAA,gBAAgB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A,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN;AAAA,MAAA;AAAA,IAEF;AACA,WAAO,EAAE,MAAM,cAAc,SAAS,MAAM;EAC7C;AAAA,EAEQ,iBAAiB,OAAkE;AAC1F,WAAO,UAAU;AAAA,EAClB;AAAA,EAEQ,oBAA2B;AAC5B,UAAA,IAAI,mBAAmB,wBAC5B,0FACD;AAAA,EACD;AACD;AAEA,AAAA,EAAU,wBAAV;AAmBQ,QAAM,gCAAgC,MAAM;AAAA,EAAC;AAAvC,sBAAA,0BAAA;AAAA,GAnBJ,sBAAA,sBAAA,CAAA,EAAA;;"}
|
|
1
|
+
{"version":3,"file":"ErrorsPreprocessor.js","sources":["../../../src/core/ErrorsPreprocessor.ts"],"sourcesContent":["import type { ErrorAccessor } from '../accessors'\nimport type { ExecutionError, MutationDataResponse, MutationResponse, ValidationError } from '../accessorTree'\nimport type { EntityId, FieldName, PlaceholderName } from '../treeParameters'\nimport { assertNever } from '../utils'\nimport { MutationAlias } from './requestAliases'\nimport { SubMutationOperation } from './MutationGenerator'\n\nclass ErrorsPreprocessor {\n\tpublic constructor(\n\t\tprivate readonly requestResponse: MutationDataResponse,\n\t\tprivate readonly operations: SubMutationOperation[],\n\t) {}\n\n\tpublic preprocess(): ErrorsPreprocessor.ErrorTreeRoot {\n\t\tconst treeRoot: ErrorsPreprocessor.ErrorTreeRoot = new Map()\n\n\t\tif (this.requestResponse === undefined) {\n\t\t\treturn treeRoot\n\t\t}\n\n\t\tfor (const operation of this.operations) {\n\t\t\tconst mutationResponse = this.requestResponse[operation.alias]\n\t\t\tconst processedResponse = this.processMutationResponse(mutationResponse)\n\n\t\t\tif (processedResponse === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst { subTreeType, subTreePlaceholder, id } = operation\n\n\t\t\tif (subTreeType === 'single') {\n\t\t\t\tif (treeRoot.has(subTreePlaceholder)) {\n\t\t\t\t\treturn this.rejectCorruptData()\n\t\t\t\t}\n\t\t\t\ttreeRoot.set(subTreePlaceholder, processedResponse)\n\t\t\t} else if (subTreeType === 'list') {\n\t\t\t\tconst child = treeRoot.get(subTreePlaceholder)\n\n\t\t\t\tif (child === undefined) {\n\t\t\t\t\ttreeRoot.set(subTreePlaceholder, {\n\t\t\t\t\t\tnodeType: 'iNode',\n\t\t\t\t\t\tchildren: new Map([[id, processedResponse]]),\n\t\t\t\t\t\tvalidation: [],\n\t\t\t\t\t\texecution: [],\n\t\t\t\t\t})\n\t\t\t\t} else if (child.nodeType === 'iNode') {\n\t\t\t\t\tchild.children.set(id, processedResponse)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn assertNever(subTreeType)\n\t\t\t}\n\n\t\t}\n\t\treturn treeRoot\n\t}\n\n\tprivate processMutationResponse(mutationResponse: MutationResponse): ErrorsPreprocessor.ErrorNode | undefined {\n\t\tif (mutationResponse.ok && mutationResponse.validation?.valid && mutationResponse.errors.length === 0) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (mutationResponse.validation?.errors.length) {\n\t\t\treturn this.getErrorNode(mutationResponse.validation?.errors)\n\t\t}\n\t\tif (mutationResponse.errors.length) {\n\t\t\treturn this.getErrorNode(mutationResponse.errors)\n\t\t}\n\t\treturn undefined\n\t}\n\n\tprivate getErrorNode(errors: ValidationError[] | ExecutionError[]): ErrorsPreprocessor.ErrorNode {\n\t\tconst [head, ...tail] = errors\n\n\t\tlet rootNode = this.getRootNode(head)\n\n\t\terrorLoop: for (const error of tail) {\n\t\t\tlet currentNode = rootNode\n\n\t\t\tfor (let i = 0, pathLength = error.path.length; i < pathLength; i++) {\n\t\t\t\tconst pathNode = error.path[i]\n\n\t\t\t\tif (currentNode.nodeType === 'leaf') {\n\t\t\t\t\t(currentNode as any as ErrorsPreprocessor.ErrorINode).nodeType = 'iNode'\n\t\t\t\t\t;(currentNode as any as ErrorsPreprocessor.ErrorINode).children = new Map()\n\t\t\t\t}\n\n\t\t\t\tif (pathNode.__typename === '_FieldPathFragment') {\n\t\t\t\t\tif (currentNode.nodeType === 'iNode') {\n\t\t\t\t\t\tlet alias = pathNode.field\n\t\t\t\t\t\tlet nextIndex = i + 1\n\t\t\t\t\t\tif (nextIndex in error.path) {\n\t\t\t\t\t\t\tconst nextPathNode = error.path[nextIndex]\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tnextPathNode.__typename === '_IndexPathFragment' &&\n\t\t\t\t\t\t\t\ttypeof nextPathNode.alias === 'string' &&\n\t\t\t\t\t\t\t\tnextPathNode.alias.startsWith(pathNode.field)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// We're dealing with a reduced hasMany relation.\n\t\t\t\t\t\t\t\ti++\n\t\t\t\t\t\t\t\tnextIndex++\n\t\t\t\t\t\t\t\talias = nextPathNode.alias\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!(alias in currentNode.children)) {\n\t\t\t\t\t\t\tcurrentNode.children.set(alias, this.getRootNode(error, nextIndex))\n\t\t\t\t\t\t\tif (nextIndex <= error.path.length) {\n\t\t\t\t\t\t\t\t// This path has been handled by getRootNode\n\t\t\t\t\t\t\t\tcontinue errorLoop\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcurrentNode = currentNode.children.get(alias)!\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.rejectCorruptData()\n\t\t\t\t\t}\n\t\t\t\t} else if (pathNode.__typename === '_IndexPathFragment') {\n\t\t\t\t\tif (currentNode.nodeType === 'iNode') {\n\t\t\t\t\t\tconst alias = pathNode.alias\n\n\t\t\t\t\t\tif (alias === null) {\n\t\t\t\t\t\t\tthrow new ErrorsPreprocessor.ErrorsPreprocessorError(\n\t\t\t\t\t\t\t\t`Corrupt data: undefined alias for node with index ${pathNode.index}.`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst entityId = MutationAlias.decodeEntityId(alias)\n\n\t\t\t\t\t\tif (!(entityId in currentNode.children)) {\n\t\t\t\t\t\t\tcurrentNode.children.set(entityId, this.getRootNode(error, i + 1))\n\t\t\t\t\t\t\tif (i + 1 <= error.path.length) {\n\t\t\t\t\t\t\t\t// This path has been handled by getRootNode\n\t\t\t\t\t\t\t\tcontinue errorLoop\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcurrentNode = currentNode.children.get(entityId)!\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.rejectCorruptData()\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tassertNever(pathNode)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.isExecutionError(error)) {\n\t\t\t\tcurrentNode.execution.push({ type: 'execution', code: error.type, developerMessage: error.message })\n\t\t\t} else {\n\t\t\t\tcurrentNode.validation.push(this.createValidationError(error.message.text))\n\t\t\t}\n\t\t}\n\n\t\treturn rootNode\n\t}\n\n\tprivate getRootNode(error: ValidationError | ExecutionError, startIndex: number = 0): ErrorsPreprocessor.ErrorNode {\n\t\tlet rootNode: ErrorsPreprocessor.ErrorNode = {\n\t\t\tvalidation: this.isExecutionError(error) ? [] : [this.createValidationError(error.message.text)],\n\t\t\texecution: this.isExecutionError(error) ? [{ type: 'execution', code: error.type, developerMessage: error.message }] : [],\n\t\t\tnodeType: 'leaf',\n\t\t}\n\n\t\tfor (let i = error.path.length - 1; i >= startIndex; i--) {\n\t\t\tconst pathNode = error.path[i]\n\t\t\tif (pathNode.__typename === '_FieldPathFragment') {\n\t\t\t\trootNode = {\n\t\t\t\t\tvalidation: [],\n\t\t\t\t\texecution: [],\n\t\t\t\t\tnodeType: 'iNode',\n\t\t\t\t\tchildren: new Map([[pathNode.field, rootNode]]),\n\t\t\t\t}\n\t\t\t} else if (pathNode.__typename === '_IndexPathFragment') {\n\t\t\t\tconst alias = pathNode.alias\n\n\t\t\t\tif (alias === null) {\n\t\t\t\t\tthrow new ErrorsPreprocessor.ErrorsPreprocessorError(\n\t\t\t\t\t\t`Corrupt data: undefined alias for node with index ${pathNode.index}.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\trootNode = {\n\t\t\t\t\tvalidation: [],\n\t\t\t\t\texecution: [],\n\t\t\t\t\tnodeType: 'iNode',\n\t\t\t\t\tchildren: new Map([[MutationAlias.decodeEntityId(alias), rootNode]]),\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tassertNever(pathNode)\n\t\t\t}\n\t\t}\n\n\t\treturn rootNode\n\t}\n\n\tprivate createValidationError(message: string): ErrorAccessor.ValidationError {\n\t\tif (message === 'Field is required') {\n\t\t\t// TODO this is just awful. Validation errors currently don't have error codes which makes it more difficult\n\t\t\t// \tto translate the error messages. This is the most common such error, and so we just make up a code\n\t\t\t// \tin order to facilitate error handling further downstream.\n\t\t\treturn {\n\t\t\t\ttype: 'validation',\n\t\t\t\tcode: 'fieldRequired',\n\t\t\t\tmessage,\n\t\t\t}\n\t\t}\n\t\treturn { type: 'validation', message, code: undefined }\n\t}\n\n\tprivate isExecutionError(error: ValidationError | ExecutionError): error is ExecutionError {\n\t\treturn 'type' in error\n\t}\n\n\tprivate rejectCorruptData(): never {\n\t\tthrow new ErrorsPreprocessor.ErrorsPreprocessorError(\n\t\t\t'Received corrupted data: a node cannot be simultaneously field-indexed and path-indexed.',\n\t\t)\n\t}\n}\n\nnamespace ErrorsPreprocessor {\n\texport interface BaseErrorNode {\n\t\tvalidation: ErrorAccessor.ValidationError[]\n\t\texecution: ErrorAccessor.ExecutionError[]\n\t}\n\n\texport interface LeafErrorNode extends BaseErrorNode {\n\t\tnodeType: 'leaf'\n\t}\n\n\texport interface ErrorINode extends BaseErrorNode {\n\t\tnodeType: 'iNode'\n\t\tchildren: Map<FieldName | EntityId, ErrorNode>\n\t}\n\n\texport type ErrorNode = ErrorINode | LeafErrorNode\n\n\texport type ErrorTreeRoot = Map<PlaceholderName, ErrorNode>\n\n\texport class ErrorsPreprocessorError extends Error {}\n}\n\nexport { ErrorsPrepr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;AAEvB,YAAI,UAAU,MAAM;AACnB,gBAAM,IAAI,mBAAmB,wBAC5B,qDAAqD,SAAS,QAC/D;AAAA,QACD;AAEW,mBAAA;AAAA,UACV,YAAY,CAAC;AAAA,UACb,WAAW,CAAC;AAAA,UACZ,UAAU;AAAA,UACV,UAAc,oBAAA,IAAI,CAAC,CAAC,cAAc,eAAe,KAAK,GAAG,QAAQ,CAAC,CAAC;AAAA,QAAA;AAAA,MACpE,OACM;AACN,oBAAoB;AAAA,MACrB;AAAA,IACD;AAEO,WAAA;AAAA,EACR;AAAA,EAEQ,sBAAsB,SAAgD;AAC7E,QAAI,YAAY,qBAAqB;AAI7B,aAAA;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN;AAAA,MAAA;AAAA,IAEF;AACA,WAAO,EAAE,MAAM,cAAc,SAAS,MAAM;EAC7C;AAAA,EAEQ,iBAAiB,OAAkE;AAC1F,WAAO,UAAU;AAAA,EAClB;AAAA,EAEQ,oBAA2B;AAC5B,UAAA,IAAI,mBAAmB,wBAC5B,0FACD;AAAA,EACD;AACD;AAEA,AAAA,EAAU,wBAAV;AAmBQ,QAAM,gCAAgC,MAAM;AAAA,EAAC;AAAvC,sBAAA,0BAAA;AAAA,GAnBJ,sBAAA,sBAAA,CAAA,EAAA;;"}
|
|
@@ -1,24 +1,30 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
1
7
|
import { CrudQueryBuilder, GraphQlBuilder } from "@contember/client";
|
|
2
8
|
import { BindingError } from "../BindingError.js";
|
|
3
9
|
import { PRIMARY_KEY_NAME, TYPENAME_KEY_NAME } from "../bindingTypes.js";
|
|
4
10
|
import { QueryGenerator } from "./QueryGenerator.js";
|
|
5
|
-
import { mutationOperationType } from "./requestAliases/mutationOperationType.js";
|
|
6
11
|
import { isEmptyObject } from "../utils/isEmptyObject.js";
|
|
7
12
|
import { ClientGeneratedUuid, ServerId } from "../accessorTree/RuntimeId.js";
|
|
8
|
-
import { mutationOperationSubTreeType } from "./requestAliases/mutationOperationSubTreeType.js";
|
|
9
|
-
import { MutationAlias } from "./requestAliases/MutationAlias.js";
|
|
10
13
|
import { assertNever } from "../utils/assertNever.js";
|
|
11
14
|
import { getEntityMarker } from "./state/getEntityMarker.js";
|
|
12
15
|
import { StateIterator } from "./state/StateIterator.js";
|
|
13
16
|
import { HasManyRelationMarker } from "../markers/HasManyRelationMarker.js";
|
|
14
17
|
import { HasOneRelationMarker } from "../markers/HasOneRelationMarker.js";
|
|
18
|
+
import { MutationAlias } from "./requestAliases/MutationAlias.js";
|
|
15
19
|
class MutationGenerator {
|
|
16
20
|
constructor(treeStore) {
|
|
21
|
+
__publicField(this, "aliasCounter", 1);
|
|
17
22
|
this.treeStore = treeStore;
|
|
18
23
|
}
|
|
19
24
|
getPersistMutation() {
|
|
20
25
|
try {
|
|
21
26
|
let builder = new CrudQueryBuilder.CrudQueryBuilder();
|
|
27
|
+
const operations = [];
|
|
22
28
|
const processedPlaceholdersByEntity = /* @__PURE__ */ new Map();
|
|
23
29
|
for (const [treeRootId, rootStates] of this.treeStore.subTreeStatesByRoot.entries()) {
|
|
24
30
|
for (const [placeholderName, subTreeState] of Array.from(rootStates.entries()).reverse()) {
|
|
@@ -26,13 +32,21 @@ class MutationGenerator {
|
|
|
26
32
|
continue;
|
|
27
33
|
}
|
|
28
34
|
if (subTreeState.type === "entityRealm") {
|
|
29
|
-
|
|
35
|
+
const subMutation = this.addSubMutation(processedPlaceholdersByEntity, placeholderName, "single", subTreeState.entity.id.value, subTreeState, builder);
|
|
36
|
+
if (subMutation) {
|
|
37
|
+
builder = subMutation[0];
|
|
38
|
+
operations.push(subMutation[1]);
|
|
39
|
+
}
|
|
30
40
|
} else if (subTreeState.type === "entityList") {
|
|
31
41
|
for (const childState of subTreeState.children.values()) {
|
|
32
42
|
if (childState.type === "entityRealmStub") {
|
|
33
43
|
continue;
|
|
34
44
|
}
|
|
35
|
-
|
|
45
|
+
const subMutation = this.addSubMutation(processedPlaceholdersByEntity, placeholderName, "list", childState.entity.id.value, childState, builder);
|
|
46
|
+
if (subMutation) {
|
|
47
|
+
builder = subMutation[0];
|
|
48
|
+
operations.push(subMutation[1]);
|
|
49
|
+
}
|
|
36
50
|
}
|
|
37
51
|
if (subTreeState.plannedRemovals) {
|
|
38
52
|
for (const [removedId, removalType] of subTreeState.plannedRemovals) {
|
|
@@ -40,13 +54,9 @@ class MutationGenerator {
|
|
|
40
54
|
continue;
|
|
41
55
|
}
|
|
42
56
|
if (removalType === "delete") {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
type: mutationOperationType.delete,
|
|
47
|
-
subTreeType: mutationOperationSubTreeType.entityList,
|
|
48
|
-
entityId: removedId
|
|
49
|
-
}), builder);
|
|
57
|
+
const alias = this.createAlias();
|
|
58
|
+
builder = this.addDeleteMutation(subTreeState.entityName, removedId, alias, builder);
|
|
59
|
+
operations.push({ alias, subTreePlaceholder: placeholderName, subTreeType: "list", type: "delete", id: removedId });
|
|
50
60
|
} else {
|
|
51
61
|
assertNever(removalType);
|
|
52
62
|
}
|
|
@@ -57,42 +67,65 @@ class MutationGenerator {
|
|
|
57
67
|
}
|
|
58
68
|
}
|
|
59
69
|
}
|
|
60
|
-
|
|
70
|
+
const query = builder.inTransaction(void 0, { deferForeignKeyConstraints: true }).getGql();
|
|
71
|
+
return { query, operations };
|
|
61
72
|
} catch (e) {
|
|
62
73
|
return void 0;
|
|
63
74
|
}
|
|
64
75
|
}
|
|
65
|
-
addSubMutation(processedPlaceholdersByEntity,
|
|
76
|
+
addSubMutation(processedPlaceholdersByEntity, subTreePlaceholder, subTreeType, entityId, realmState, queryBuilder) {
|
|
66
77
|
if (realmState.unpersistedChangesCount === 0) {
|
|
67
|
-
return
|
|
78
|
+
return void 0;
|
|
68
79
|
}
|
|
80
|
+
const fieldMarkers = getEntityMarker(realmState).fields.markers;
|
|
81
|
+
const alias = this.createAlias();
|
|
69
82
|
if (realmState.entity.isScheduledForDeletion) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
83
|
+
const builder2 = this.addDeleteMutation(realmState.entity.entityName, entityId, alias, queryBuilder);
|
|
84
|
+
return [
|
|
85
|
+
builder2,
|
|
86
|
+
{
|
|
87
|
+
alias,
|
|
88
|
+
subTreePlaceholder,
|
|
89
|
+
subTreeType,
|
|
90
|
+
type: "delete",
|
|
91
|
+
id: entityId
|
|
92
|
+
}
|
|
93
|
+
];
|
|
77
94
|
} else if (!realmState.entity.id.existsOnServer) {
|
|
78
|
-
|
|
79
|
-
|
|
95
|
+
const builder2 = this.addCreateMutation(processedPlaceholdersByEntity, realmState, alias, this.getNodeFragmentName(subTreePlaceholder, subTreeType, realmState), queryBuilder, fieldMarkers);
|
|
96
|
+
if (!builder2) {
|
|
97
|
+
return void 0;
|
|
98
|
+
}
|
|
99
|
+
return [
|
|
100
|
+
builder2,
|
|
101
|
+
{
|
|
102
|
+
alias,
|
|
103
|
+
subTreePlaceholder,
|
|
104
|
+
subTreeType,
|
|
105
|
+
type: "create",
|
|
106
|
+
markers: fieldMarkers,
|
|
107
|
+
id: entityId
|
|
108
|
+
}
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
const builder = this.addUpdateMutation(processedPlaceholdersByEntity, realmState, alias, this.getNodeFragmentName(subTreePlaceholder, subTreeType, realmState), queryBuilder, fieldMarkers);
|
|
112
|
+
if (!builder) {
|
|
113
|
+
return void 0;
|
|
114
|
+
}
|
|
115
|
+
return [
|
|
116
|
+
builder,
|
|
117
|
+
{
|
|
118
|
+
alias,
|
|
80
119
|
subTreePlaceholder,
|
|
81
|
-
type: mutationOperationType.create,
|
|
82
120
|
subTreeType,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
subTreePlaceholder,
|
|
89
|
-
type: mutationOperationType.update,
|
|
90
|
-
subTreeType,
|
|
91
|
-
entityId
|
|
92
|
-
}), this.getNodeFragmentName(subTreePlaceholder, subTreeType, realmState), queryBuilder);
|
|
121
|
+
type: "update",
|
|
122
|
+
id: entityId,
|
|
123
|
+
markers: fieldMarkers
|
|
124
|
+
}
|
|
125
|
+
];
|
|
93
126
|
}
|
|
94
127
|
getNodeFragmentName(subTreePlaceholder, subTreeType, realmState) {
|
|
95
|
-
if (subTreeType !==
|
|
128
|
+
if (subTreeType !== "list") {
|
|
96
129
|
return void 0;
|
|
97
130
|
}
|
|
98
131
|
return `${realmState.entity.entityName}_${subTreePlaceholder}`;
|
|
@@ -100,27 +133,27 @@ class MutationGenerator {
|
|
|
100
133
|
addDeleteMutation(entityName, deletedId, alias, queryBuilder = new CrudQueryBuilder.CrudQueryBuilder()) {
|
|
101
134
|
return queryBuilder.delete(entityName, (builder) => builder.ok().node((builder2) => builder2.column(PRIMARY_KEY_NAME)).by({ [PRIMARY_KEY_NAME]: deletedId }).errors().errorMessage(), alias);
|
|
102
135
|
}
|
|
103
|
-
addUpdateMutation(processedPlaceholdersByEntity, entityRealm, alias, nodeFragmentName, queryBuilder = new CrudQueryBuilder.CrudQueryBuilder()) {
|
|
136
|
+
addUpdateMutation(processedPlaceholdersByEntity, entityRealm, alias, nodeFragmentName, queryBuilder = new CrudQueryBuilder.CrudQueryBuilder(), fieldMarkers) {
|
|
104
137
|
const updateBuilder = this.registerUpdateMutationPart(processedPlaceholdersByEntity, entityRealm, new CrudQueryBuilder.WriteDataBuilder());
|
|
105
138
|
if (updateBuilder.data === void 0 || isEmptyObject(updateBuilder.data)) {
|
|
106
|
-
return
|
|
139
|
+
return void 0;
|
|
107
140
|
}
|
|
108
141
|
const runtimeId = entityRealm.entity.id;
|
|
109
142
|
if (!runtimeId.existsOnServer) {
|
|
110
|
-
return
|
|
143
|
+
return void 0;
|
|
111
144
|
}
|
|
112
|
-
const readBuilder = QueryGenerator.registerQueryPart(
|
|
145
|
+
const readBuilder = QueryGenerator.registerQueryPart(fieldMarkers, CrudQueryBuilder.ReadBuilder.instantiate());
|
|
113
146
|
if (nodeFragmentName) {
|
|
114
147
|
queryBuilder = queryBuilder.fragment(nodeFragmentName, entityRealm.entity.entityName, readBuilder);
|
|
115
148
|
}
|
|
116
149
|
return queryBuilder.update(entityRealm.entity.entityName, (builder) => builder.node(nodeFragmentName ? (builder2) => builder2.applyFragment(nodeFragmentName) : readBuilder).data(updateBuilder).by({ [PRIMARY_KEY_NAME]: runtimeId.value }).ok().validation().errors().errorMessage(), alias);
|
|
117
150
|
}
|
|
118
|
-
addCreateMutation(processedPlaceholdersByEntity, entityRealm, alias, nodeFragmentName, queryBuilder = new CrudQueryBuilder.CrudQueryBuilder()) {
|
|
151
|
+
addCreateMutation(processedPlaceholdersByEntity, entityRealm, alias, nodeFragmentName, queryBuilder = new CrudQueryBuilder.CrudQueryBuilder(), fieldMarkers) {
|
|
119
152
|
const createBuilder = this.registerCreateMutationPart(processedPlaceholdersByEntity, entityRealm, new CrudQueryBuilder.WriteDataBuilder());
|
|
120
153
|
if (createBuilder.data === void 0 || isEmptyObject(createBuilder.data)) {
|
|
121
|
-
return
|
|
154
|
+
return void 0;
|
|
122
155
|
}
|
|
123
|
-
const readBuilder = QueryGenerator.registerQueryPart(
|
|
156
|
+
const readBuilder = QueryGenerator.registerQueryPart(fieldMarkers, CrudQueryBuilder.ReadBuilder.instantiate());
|
|
124
157
|
if (nodeFragmentName) {
|
|
125
158
|
queryBuilder = queryBuilder.fragment(nodeFragmentName, entityRealm.entity.entityName, readBuilder);
|
|
126
159
|
}
|
|
@@ -442,6 +475,9 @@ class MutationGenerator {
|
|
|
442
475
|
}
|
|
443
476
|
return fieldSchema.enumName === null ? value : new GraphQlBuilder.GraphQlLiteral(value);
|
|
444
477
|
}
|
|
478
|
+
createAlias() {
|
|
479
|
+
return `op_${this.aliasCounter++}`;
|
|
480
|
+
}
|
|
445
481
|
}
|
|
446
482
|
export { MutationGenerator };
|
|
447
483
|
//# sourceMappingURL=MutationGenerator.js.map
|