@fluid-experimental/tree 2.0.0-internal.2.2.1 → 2.0.0-internal.2.3.0
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/.eslintrc.js +1 -11
- package/dist/Checkout.d.ts +2 -1
- package/dist/Checkout.d.ts.map +1 -1
- package/dist/Checkout.js +33 -26
- package/dist/Checkout.js.map +1 -1
- package/dist/TransactionInternal.d.ts +4 -0
- package/dist/TransactionInternal.d.ts.map +1 -1
- package/dist/TransactionInternal.js +6 -0
- package/dist/TransactionInternal.js.map +1 -1
- package/lib/Checkout.d.ts +2 -1
- package/lib/Checkout.d.ts.map +1 -1
- package/lib/Checkout.js +33 -26
- package/lib/Checkout.js.map +1 -1
- package/lib/TransactionInternal.d.ts +4 -0
- package/lib/TransactionInternal.d.ts.map +1 -1
- package/lib/TransactionInternal.js +6 -0
- package/lib/TransactionInternal.js.map +1 -1
- package/lib/test/Checkout.tests.d.ts.map +1 -1
- package/lib/test/Checkout.tests.js +4 -4
- package/lib/test/Checkout.tests.js.map +1 -1
- package/package.json +19 -18
- package/src/Checkout.ts +48 -32
- package/src/TransactionInternal.ts +7 -0
package/.eslintrc.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
|
-
extends: ['@fluidframework/eslint-config-fluid'],
|
|
7
|
+
extends: ['@fluidframework/eslint-config-fluid/minimal', 'prettier'],
|
|
8
8
|
root: true,
|
|
9
9
|
rules: {
|
|
10
10
|
// TODO: Recover "noUnusedLocals" behavior as part of linting. (This rule seems to be broken in the Fluid repo.)
|
|
@@ -18,16 +18,6 @@ module.exports = {
|
|
|
18
18
|
avoidEscape: true,
|
|
19
19
|
},
|
|
20
20
|
],
|
|
21
|
-
// Intentionally not unifying signatures can enable more scoped API documentation and a better developer experience, which accounts
|
|
22
|
-
// for all violations of this rule in this package at the time of writing.
|
|
23
|
-
'@typescript-eslint/unified-signatures': 'off',
|
|
24
|
-
|
|
25
|
-
// Prettier
|
|
26
|
-
'comma-dangle': 'off',
|
|
27
|
-
'@typescript-eslint/comma-dangle': 'off',
|
|
28
|
-
'@typescript-eslint/member-delimiter-style': 'off',
|
|
29
|
-
'max-len': 'off',
|
|
30
|
-
'no-mixed-spaces-and-tabs': 'off',
|
|
31
21
|
|
|
32
22
|
// Rules which could be re-enabled (by dropping these overrides, as they are enabled in base config) with some minor fixes:
|
|
33
23
|
'@typescript-eslint/no-shadow': 'off',
|
package/dist/Checkout.d.ts
CHANGED
|
@@ -121,11 +121,12 @@ export declare abstract class Checkout extends EventEmitterWithErrorHandling<ICh
|
|
|
121
121
|
* Ends the ongoing edit operation and commits it to the history.
|
|
122
122
|
*
|
|
123
123
|
* Malformed edits are considered an error, and will assert:
|
|
124
|
-
* All named detached sequences must have been used or
|
|
124
|
+
* All named detached sequences must have been used or the Edit is malformed.
|
|
125
125
|
*
|
|
126
126
|
* @returns the `id` of the committed edit
|
|
127
127
|
*/
|
|
128
128
|
closeEdit(): EditId;
|
|
129
|
+
private validateChangesApplied;
|
|
129
130
|
/**
|
|
130
131
|
* Inform the Checkout that a particular edit is know to have a specific result when applied to a particular TreeView.
|
|
131
132
|
* This may be used as a caching hint to avoid recomputation.
|
package/dist/Checkout.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkout.d.ts","sourceRoot":"","sources":["../src/Checkout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAe,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAC7F,OAAO,EAAE,WAAW,EAAE,WAAW,EAA0C,MAAM,oCAAoC,CAAC;AAEtH,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EA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,CAAC,GAAG,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM;IAQvD;;;;OAIG;IACI,YAAY,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS;IAC5D,YAAY,CAAC,GAAG,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS;IAgBtE;;;;;;;;;;OAUG;IACI,iBAAiB,IAAI,oBAAoB,CAAC,KAAK,GAAG,oBAAoB,CAAC,OAAO;IAuBrF;;;OAGG;IACI,SAAS,IAAI,IAAI;IAOxB;;;;OAIG;IACI,aAAa,IAAI,UAAU;IAQlC;;;OAGG;IACI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAYnC;;;;OAIG;IACH,SAAS,CAAC,UAAU,IAAI,IAAI;IAU5B;;OAEG;aACa,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAEtD;;;OAGG;aACa,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAErD;;;OAGG;IACI,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI;CAUnC"}
|
package/dist/Checkout.js
CHANGED
|
@@ -105,7 +105,7 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
105
105
|
* Ends the ongoing edit operation and commits it to the history.
|
|
106
106
|
*
|
|
107
107
|
* Malformed edits are considered an error, and will assert:
|
|
108
|
-
* All named detached sequences must have been used or
|
|
108
|
+
* All named detached sequences must have been used or the Edit is malformed.
|
|
109
109
|
*
|
|
110
110
|
* @returns the `id` of the committed edit
|
|
111
111
|
*/
|
|
@@ -113,35 +113,42 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
113
113
|
const { currentEdit } = this;
|
|
114
114
|
(0, Common_1.assert)(currentEdit !== undefined, 'An edit is not open.');
|
|
115
115
|
this.currentEdit = undefined;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const { failure } = editingResult;
|
|
119
|
-
const additionalProps = {};
|
|
120
|
-
switch (failure.kind) {
|
|
121
|
-
case TransactionInternal_1.TransactionInternal.FailureKind.BadPlace:
|
|
122
|
-
additionalProps.placeFailure = failure.placeFailure;
|
|
123
|
-
break;
|
|
124
|
-
case TransactionInternal_1.TransactionInternal.FailureKind.BadRange: {
|
|
125
|
-
const { rangeFailure } = failure;
|
|
126
|
-
if (typeof rangeFailure === 'string') {
|
|
127
|
-
additionalProps.rangeFailure = rangeFailure;
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
additionalProps.rangeFailure = rangeFailure.kind;
|
|
131
|
-
additionalProps.rangeEndpointFailure = rangeFailure.placeFailure;
|
|
132
|
-
}
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
default:
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
this.logger.sendErrorEvent(Object.assign({ eventName: 'FailedLocalEdit', status: editingResult.status === 0 ? 'Malformed' : 'Invalid', failureKind: editingResult.failure.kind }, additionalProps));
|
|
139
|
-
(0, Common_1.fail)('Locally constructed edits must be well-formed and valid');
|
|
116
|
+
if (currentEdit.failure !== undefined) {
|
|
117
|
+
(0, Common_1.fail)('Cannot close a transaction that has already failed. Use abortEdit instead.');
|
|
140
118
|
}
|
|
119
|
+
const editingResult = currentEdit.close();
|
|
120
|
+
this.validateChangesApplied(editingResult);
|
|
141
121
|
const id = (0, EditUtilities_1.newEditId)();
|
|
142
122
|
this.handleNewEdit(id, editingResult);
|
|
143
123
|
return id;
|
|
144
124
|
}
|
|
125
|
+
validateChangesApplied(result) {
|
|
126
|
+
if (result.status === persisted_types_1.EditStatus.Applied) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const { failure } = result;
|
|
130
|
+
const additionalProps = {};
|
|
131
|
+
switch (failure.kind) {
|
|
132
|
+
case TransactionInternal_1.TransactionInternal.FailureKind.BadPlace:
|
|
133
|
+
additionalProps.placeFailure = failure.placeFailure;
|
|
134
|
+
break;
|
|
135
|
+
case TransactionInternal_1.TransactionInternal.FailureKind.BadRange: {
|
|
136
|
+
const { rangeFailure } = failure;
|
|
137
|
+
if (typeof rangeFailure === 'string') {
|
|
138
|
+
additionalProps.rangeFailure = rangeFailure;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
additionalProps.rangeFailure = rangeFailure.kind;
|
|
142
|
+
additionalProps.rangeEndpointFailure = rangeFailure.placeFailure;
|
|
143
|
+
}
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
default:
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
this.logger.sendErrorEvent(Object.assign({ eventName: 'FailedLocalEdit', status: result.status === 0 ? 'Malformed' : 'Invalid', failureKind: failure.kind }, additionalProps));
|
|
150
|
+
(0, Common_1.fail)('Locally constructed edits must be well-formed and valid.');
|
|
151
|
+
}
|
|
145
152
|
/**
|
|
146
153
|
* Inform the Checkout that a particular edit is know to have a specific result when applied to a particular TreeView.
|
|
147
154
|
* This may be used as a caching hint to avoid recomputation.
|
|
@@ -169,7 +176,7 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
169
176
|
(0, Common_1.assert)(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');
|
|
170
177
|
const changeArray = (0, Common_1.unwrapRestOrArray)(changes);
|
|
171
178
|
const { status } = this.currentEdit.applyChanges(changeArray.map((c) => this.tree.internalizeChange(c)));
|
|
172
|
-
(
|
|
179
|
+
this.validateChangesApplied({ status, failure: this.currentEdit.failure });
|
|
173
180
|
this.emitChange();
|
|
174
181
|
}
|
|
175
182
|
tryApplyChangesInternal(...changes) {
|
package/dist/Checkout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkout.js","sourceRoot":"","sources":["../src/Checkout.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAA6F;AAE7F,qCAAwE;AAExE,2CAA+C;AAI/C,+DAAoG;AACpG,uDAAqE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AAa,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;SACvD;IACF,CAAC;IAaD;;;OAGG;IACI,OAAO,CAAC,KAAa;QAC3B,IAAI,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO;SACP;QAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAErB,6BAA6B;QAC7B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,4BAAe,CAAC,aAAa,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACzE,CAAC;CACD;AApVD,4BAoVC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ChildLogger, EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils';\nimport { IDisposable, IErrorEvent, ITelemetryLogger, ITelemetryProperties } from '@fluidframework/common-definitions';\nimport { assert, fail, RestOrArray, unwrapRestOrArray } from './Common';\nimport { EditId } from './Identifiers';\nimport { CachingLogViewer } from './LogViewer';\nimport { TreeView } from './TreeView';\nimport { RevisionView } from './RevisionView';\nimport { EditCommittedHandler, SharedTree } from './SharedTree';\nimport { GenericTransaction, TransactionInternal, ValidEditingResult } from './TransactionInternal';\nimport { ChangeInternal, Edit, EditStatus } from './persisted-types';\nimport { SharedTreeEvent } from './EventTypes';\nimport { newEditId } from './EditUtilities';\nimport { Change } from './ChangeTypes';\n\n/**\n * An event emitted by a `Checkout` to indicate a state change. See {@link ICheckoutEvents} for event argument information.\n * @public\n */\nexport enum CheckoutEvent {\n\t/**\n\t * `currentView` has changed.\n\t * Passed a before and after TreeView.\n\t */\n\tViewChange = 'viewChange',\n}\n\n/**\n * Events which may be emitted by `Checkout`. See {@link CheckoutEvent} for documentation of event semantics.\n */\nexport interface ICheckoutEvents extends IErrorEvent {\n\t(event: 'viewChange', listener: (before: TreeView, after: TreeView) => void);\n}\n\n/**\n * The result of validation of an Edit.\n * @public\n */\nexport enum EditValidationResult {\n\t/**\n\t * The edit contained one or more malformed changes (e.g. was missing required fields such as `id`),\n\t * or contained a sequence of changes that could not possibly be applied sequentially without error\n\t * (e.g. an edit which tries to insert the same detached node twice).\n\t */\n\tMalformed,\n\t/**\n\t * The edit is well-formed but cannot be applied to the current view, generally because concurrent changes\n\t * caused one or more merge conflicts.\n\t * For example, the edit refers to the `StablePlace` after node `C`, but `C` has since been deleted.\n\t */\n\tInvalid,\n\t/**\n\t * The edit is well-formed and can be applied to the current view.\n\t */\n\tValid,\n}\n\n/**\n * A mutable Checkout of a SharedTree, allowing viewing and interactive transactional editing.\n * Provides {@link https://en.wikipedia.org/wiki/Snapshot_isolation | snapshot-isolation} while editing.\n *\n * A Checkout always shows a consistent sequence of versions of the SharedTree, but it may skip intermediate versions, and may fall behind.\n * In this case consistent means the sequence of versions could occur with fully synchronous shared tree access,\n * though the timing of sequenced edits arriving to the Checkout may be later than they actually arrive in the SharedTree.\n * Specifically no sequenced edits will arrive during an ongoing edit (to implement snapshot isolation):\n * they will be applied asynchronously some time after the ongoing edit is ended.\n *\n * Events emitted by `Checkout` are documented in {@link CheckoutEvent}.\n * Exceptions thrown during event handling will be emitted as error events, which are automatically surfaced as error events on the\n * `SharedTree` used at construction time.\n * @public\n */\nexport abstract class Checkout extends EventEmitterWithErrorHandling<ICheckoutEvents> implements IDisposable {\n\t/**\n\t * The view of the latest committed revision.\n\t * Does not include changes from any open edits.\n\t *\n\t * When this changes, emitChange must be called.\n\t */\n\tprotected abstract get latestCommittedView(): RevisionView;\n\n\t/**\n\t * The last view for which invalidation was sent.\n\t * Updated by emitChange.\n\t */\n\tprivate previousView: TreeView;\n\n\t/**\n\t * A handler for 'committedEdit' SharedTreeEvent\n\t */\n\tprivate readonly editCommittedHandler: EditCommittedHandler;\n\n\t/**\n\t * The shared tree this checkout views/edits.\n\t */\n\tpublic readonly tree: SharedTree;\n\n\t/**\n\t * `tree`'s log viewer as a CachingLogViewer if it is one, otherwise undefined.\n\t * Used for optimizations if provided.\n\t */\n\tprivate readonly cachingLogViewer?: CachingLogViewer;\n\n\t/**\n\t * Holds the state required to manage the currently open edit.\n\t * Undefined if there is currently not an open edit.\n\t *\n\t * Since `currentView` exposes the the intermediate state from this edit,\n\t * operations that modify `currentEdit.view` must call `emitChange` to handle invalidation.\n\t */\n\tprivate currentEdit?: GenericTransaction;\n\n\tprivate readonly logger: ITelemetryLogger;\n\n\tpublic disposed: boolean = false;\n\n\tprotected constructor(tree: SharedTree, currentView: RevisionView, onEditCommitted: EditCommittedHandler) {\n\t\tsuper((_event, error: unknown) => {\n\t\t\tthis.tree.emit('error', error);\n\t\t});\n\t\tthis.tree = tree;\n\t\tthis.logger = ChildLogger.create(this.tree.logger, 'Checkout');\n\t\tif (tree.logViewer instanceof CachingLogViewer) {\n\t\t\tthis.cachingLogViewer = tree.logViewer;\n\t\t}\n\t\tthis.previousView = currentView;\n\t\tthis.editCommittedHandler = onEditCommitted;\n\n\t\t// If there is an ongoing edit, emitChange will no-op, which is fine.\n\t\tthis.tree.on(SharedTreeEvent.EditCommitted, this.editCommittedHandler);\n\t}\n\n\t/**\n\t * @returns the current view of the tree, including the result of changes applied so far during an edit.\n\t * Note that any external edits (from other clients) will not added to view while there is a `currentEdit`.\n\t */\n\tpublic get currentView(): TreeView {\n\t\treturn this.currentEdit?.view ?? this.latestCommittedView;\n\t}\n\n\t/**\n\t * @returns true iff there is an open edit.\n\t * @internal\n\t */\n\tpublic hasOpenEdit(): boolean {\n\t\treturn this.currentEdit !== undefined;\n\t}\n\n\t/**\n\t * Opens a new edit operation.\n\t * Changes accumulate in the edit via calls to `applyChanges()`.\n\t */\n\tpublic openEdit(): void {\n\t\tassert(this.currentEdit === undefined, 'An edit is already open.');\n\t\tthis.currentEdit = TransactionInternal.factory(this.latestCommittedView);\n\t}\n\n\t/**\n\t * Ends the ongoing edit operation and commits it to the history.\n\t *\n\t * Malformed edits are considered an error, and will assert:\n\t * All named detached sequences must have been used or theEdit is malformed.\n\t *\n\t * @returns the `id` of the committed edit\n\t */\n\tpublic closeEdit(): EditId {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\tthis.currentEdit = undefined;\n\t\tconst editingResult = currentEdit.close();\n\t\tif (editingResult.status !== EditStatus.Applied) {\n\t\t\tconst { failure } = editingResult;\n\t\t\tconst additionalProps: ITelemetryProperties = {};\n\t\t\tswitch (failure.kind) {\n\t\t\t\tcase TransactionInternal.FailureKind.BadPlace:\n\t\t\t\t\tadditionalProps.placeFailure = failure.placeFailure;\n\t\t\t\t\tbreak;\n\t\t\t\tcase TransactionInternal.FailureKind.BadRange: {\n\t\t\t\t\tconst { rangeFailure } = failure;\n\t\t\t\t\tif (typeof rangeFailure === 'string') {\n\t\t\t\t\t\tadditionalProps.rangeFailure = rangeFailure;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tadditionalProps.rangeFailure = rangeFailure.kind;\n\t\t\t\t\t\tadditionalProps.rangeEndpointFailure = rangeFailure.placeFailure;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\teventName: 'FailedLocalEdit',\n\t\t\t\tstatus: editingResult.status === 0 ? 'Malformed' : 'Invalid',\n\t\t\t\tfailureKind: editingResult.failure.kind,\n\t\t\t\t...additionalProps,\n\t\t\t});\n\t\t\tfail('Locally constructed edits must be well-formed and valid');\n\t\t}\n\n\t\tconst id: EditId = newEditId();\n\t\tthis.handleNewEdit(id, editingResult);\n\t\treturn id;\n\t}\n\n\t/**\n\t * Inform the Checkout that a particular edit is know to have a specific result when applied to a particular TreeView.\n\t * This may be used as a caching hint to avoid recomputation.\n\t */\n\tprotected hintKnownEditingResult(edit: Edit<ChangeInternal>, result: ValidEditingResult): void {\n\t\t// As an optimization, inform logViewer of this editing result so it can reuse it if applied to the same before revision.\n\t\tthis.cachingLogViewer?.setKnownEditingResult(edit, result);\n\t}\n\n\t/**\n\t * Take any needed action between when an edit is completed.\n\t * Usually this will include submitting it to a SharedTree.\n\t *\n\t * Override this to customize.\n\t */\n\tprotected handleNewEdit(id: EditId, result: ValidEditingResult): void {\n\t\tconst edit: Edit<ChangeInternal> = { id, changes: result.changes };\n\n\t\tthis.hintKnownEditingResult(edit, result);\n\n\t\t// Since external edits could have been applied while currentEdit was pending,\n\t\t// do not use the produced view: just go to the newest revision\n\t\t// (which processLocalEdit will do, including invalidation).\n\t\tthis.tree.applyEditInternal(edit);\n\t}\n\n\t/**\n\t * Applies the supplied changes to the tree and emits a change event.\n\t * Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).\n\t * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.\n\t */\n\tpublic applyChanges(changes: readonly Change[]): void;\n\tpublic applyChanges(...changes: readonly Change[]): void;\n\tpublic applyChanges(...changes: RestOrArray<Change>): void {\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray.map((c) => this.tree.internalizeChange(c)));\n\t\tassert(status === EditStatus.Applied, 'Locally constructed edits must be well-formed and valid.');\n\t\tthis.emitChange();\n\t}\n\n\t/**\n\t * Applies the supplied changes to the tree and emits a change event.\n\t * Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).\n\t * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.\n\t */\n\tprotected tryApplyChangesInternal(changes: readonly ChangeInternal[]): EditStatus;\n\tprotected tryApplyChangesInternal(...changes: readonly ChangeInternal[]): EditStatus;\n\tprotected tryApplyChangesInternal(...changes: RestOrArray<ChangeInternal>): EditStatus {\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray);\n\t\tif (status === EditStatus.Applied) {\n\t\t\tthis.emitChange();\n\t\t}\n\t\treturn status;\n\t}\n\n\t/**\n\t * Convenience helper for applying an edit containing the given changes.\n\t * Opens an edit, applies the given changes, and closes the edit. See (`openEdit()`/`applyChanges()`/`closeEdit()`).\n\t */\n\tpublic applyEdit(changes: readonly Change[]): EditId;\n\tpublic applyEdit(...changes: readonly Change[]): EditId;\n\tpublic applyEdit(...changes: RestOrArray<Change>): EditId {\n\t\tthis.openEdit();\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tthis.applyChanges(changeArray);\n\t\treturn this.closeEdit();\n\t}\n\n\t/**\n\t * Apply an edit, if valid, otherwise does nothing (the edit is not added to the history).\n\t * If the edit applied, its changes will be immediately visible on this checkout, though it still may end up invalid once sequenced due to concurrent edits.\n\t * @returns The EditId if the edit was valid and thus applied, and undefined if it was invalid and thus not applied.\n\t */\n\tpublic tryApplyEdit(changes: readonly Change[]): EditId | undefined;\n\tpublic tryApplyEdit(...changes: readonly Change[]): EditId | undefined;\n\tpublic tryApplyEdit(...changes: RestOrArray<Change>): EditId | undefined {\n\t\tthis.openEdit();\n\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray.map((c) => this.tree.internalizeChange(c)));\n\t\tif (status === EditStatus.Applied) {\n\t\t\tthis.emitChange();\n\t\t\treturn this.closeEdit();\n\t\t}\n\n\t\tthis.abortEdit();\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Rebases the ongoing edit to the latest revision loaded by this 'Checkout'.\n\t * If the rebase succeeds (none of the changes in the ongoing edit became invalid), the ongoing edit will remain open and the current\n\t * view will reflect those changes.\n\t *\n\t * If the rebase fails (changes become invalid), the ongoing edit will be aborted and\n\t * currentView will return to showing the newest committed revision as it always does when there is no ongoing edit.\n\t *\n\t * Must only be called during an open edit.\n\t * @returns - the result of the rebase.\n\t */\n\tpublic rebaseCurrentEdit(): EditValidationResult.Valid | EditValidationResult.Invalid {\n\t\tassert(this.currentEdit !== undefined, 'An edit is not open.');\n\t\tassert(this.currentEdit.status === EditStatus.Applied, 'Local edits should always be valid.');\n\t\t// When closed, the result might indicate Malformed due to unused detached entities.\n\t\t// This is not an error, as the edit was still open and can still use those entities.\n\t\tconst priorResults = this.currentEdit.close();\n\t\tconst rebasedEdit = TransactionInternal.factory(this.latestCommittedView).applyChanges(priorResults.changes);\n\t\tassert(\n\t\t\trebasedEdit.status !== EditStatus.Malformed,\n\t\t\t'Malformed changes should have been caught on original application.'\n\t\t);\n\t\tlet status: EditValidationResult.Valid | EditValidationResult.Invalid;\n\t\tif (rebasedEdit.status === EditStatus.Invalid) {\n\t\t\tstatus = EditValidationResult.Invalid;\n\t\t\tthis.currentEdit = undefined;\n\t\t} else {\n\t\t\tstatus = EditValidationResult.Valid;\n\t\t\tthis.currentEdit = rebasedEdit;\n\t\t}\n\t\tthis.emitChange();\n\t\treturn status;\n\t}\n\n\t/**\n\t * Ends the ongoing edit operation without committing it to the history.\n\t * Can only be called if an edit is open.\n\t */\n\tpublic abortEdit(): void {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\tthis.currentEdit = undefined;\n\t\tthis.emitChange();\n\t}\n\n\t/**\n\t * @returns the {@link EditStatus} of the current edit.\n\t * Has no side effects.\n\t * Can only be called if an edit is open.\n\t */\n\tpublic getEditStatus(): EditStatus {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\t// TODO: could this ever be anything other than 'Applied'\n\t\t// TODO: shouldn't this be an EditValidationResult since 'Applied' does not indicate the edit has been applied?\n\t\treturn currentEdit.status;\n\t}\n\n\t/**\n\t * Reverts a collection of edits.\n\t * @param editIds - the edits to revert\n\t */\n\tpublic revert(editId: EditId): void {\n\t\tassert(this.currentEdit !== undefined);\n\t\tconst index = this.tree.edits.getIndexOfId(editId);\n\t\tconst edit =\n\t\t\tthis.tree.edits.tryGetEditAtIndex(index) ?? fail('Edit with the specified ID does not exist in memory');\n\t\tconst before = this.tree.logViewer.getRevisionViewInMemory(index);\n\t\tconst changes = this.tree.revertChanges(edit.changes, before);\n\t\tif (changes !== undefined) {\n\t\t\tthis.tryApplyChangesInternal(changes);\n\t\t}\n\t}\n\n\t/**\n\t * Send invalidation message for all changes since last call to emitChange.\n\t * This must be called every time `currentView` could have changed.\n\t * It is ok to make excessive calls to this: change notifications will be cheaply de-duplicated.\n\t */\n\tprotected emitChange(): void {\n\t\tconst current = this.currentView;\n\t\tconst previous = this.previousView;\n\t\tif (!previous.hasEqualForest(current, true)) {\n\t\t\t// Set previousView before calling emit to make reentrant case work (where the event handler causes an edit).\n\t\t\tthis.previousView = current;\n\t\t\tthis.emit(CheckoutEvent.ViewChange, previous, current);\n\t\t}\n\t}\n\n\t/**\n\t * @returns a Promise which completes after all currently known edits are available in this checkout.\n\t */\n\tpublic abstract waitForPendingUpdates(): Promise<void>;\n\n\t/**\n\t * @returns a Promise which completes after edits that were closed on this checkout (before calling this) have been\n\t * submitted to Fluid. This does NOT wait for the Fluid service to ack them\n\t */\n\tpublic abstract waitForEditsToSubmit(): Promise<void>;\n\n\t/**\n\t * release all unmanaged resources\n\t * e.g. unregister event listeners\n\t */\n\tpublic dispose(error?: Error): void {\n\t\tif (this.disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.disposed = true;\n\n\t\t// remove registered listener\n\t\tthis.tree.off(SharedTreeEvent.EditCommitted, this.editCommittedHandler);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Checkout.js","sourceRoot":"","sources":["../src/Checkout.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAA6F;AAE7F,qCAAwE;AAExE,2CAA+C;AAI/C,+DAAmH;AACnH,uDAAqE;AACrE,6CAA+C;AAC/C,mDAA4C;AAG5C;;;GAGG;AACH,IAAY,aAMX;AAND,WAAY,aAAa;IACxB;;;OAGG;IACH,0CAAyB,CAAA;AAC1B,CAAC,EANW,aAAa,GA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AC7G,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;YAC5B,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;SACvD;IACF,CAAC;IAaD;;;OAGG;IACI,OAAO,CAAC,KAAa;QAC3B,IAAI,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO;SACP;QAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAErB,6BAA6B;QAC7B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,4BAAe,CAAC,aAAa,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACzE,CAAC;CACD;AApWD,4BAoWC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ChildLogger, EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils';\nimport { IDisposable, IErrorEvent, ITelemetryLogger, ITelemetryProperties } from '@fluidframework/common-definitions';\nimport { assert, fail, RestOrArray, unwrapRestOrArray } from './Common';\nimport { EditId } from './Identifiers';\nimport { CachingLogViewer } from './LogViewer';\nimport { TreeView } from './TreeView';\nimport { RevisionView } from './RevisionView';\nimport { EditCommittedHandler, SharedTree } from './SharedTree';\nimport { EditingResult, GenericTransaction, TransactionInternal, ValidEditingResult } from './TransactionInternal';\nimport { ChangeInternal, Edit, EditStatus } from './persisted-types';\nimport { SharedTreeEvent } from './EventTypes';\nimport { newEditId } from './EditUtilities';\nimport { Change } from './ChangeTypes';\n\n/**\n * An event emitted by a `Checkout` to indicate a state change. See {@link ICheckoutEvents} for event argument information.\n * @public\n */\nexport enum CheckoutEvent {\n\t/**\n\t * `currentView` has changed.\n\t * Passed a before and after TreeView.\n\t */\n\tViewChange = 'viewChange',\n}\n\n/**\n * Events which may be emitted by `Checkout`. See {@link CheckoutEvent} for documentation of event semantics.\n */\nexport interface ICheckoutEvents extends IErrorEvent {\n\t(event: 'viewChange', listener: (before: TreeView, after: TreeView) => void);\n}\n\n/**\n * The result of validation of an Edit.\n * @public\n */\nexport enum EditValidationResult {\n\t/**\n\t * The edit contained one or more malformed changes (e.g. was missing required fields such as `id`),\n\t * or contained a sequence of changes that could not possibly be applied sequentially without error\n\t * (e.g. an edit which tries to insert the same detached node twice).\n\t */\n\tMalformed,\n\t/**\n\t * The edit is well-formed but cannot be applied to the current view, generally because concurrent changes\n\t * caused one or more merge conflicts.\n\t * For example, the edit refers to the `StablePlace` after node `C`, but `C` has since been deleted.\n\t */\n\tInvalid,\n\t/**\n\t * The edit is well-formed and can be applied to the current view.\n\t */\n\tValid,\n}\n\n/**\n * A mutable Checkout of a SharedTree, allowing viewing and interactive transactional editing.\n * Provides {@link https://en.wikipedia.org/wiki/Snapshot_isolation | snapshot-isolation} while editing.\n *\n * A Checkout always shows a consistent sequence of versions of the SharedTree, but it may skip intermediate versions, and may fall behind.\n * In this case consistent means the sequence of versions could occur with fully synchronous shared tree access,\n * though the timing of sequenced edits arriving to the Checkout may be later than they actually arrive in the SharedTree.\n * Specifically no sequenced edits will arrive during an ongoing edit (to implement snapshot isolation):\n * they will be applied asynchronously some time after the ongoing edit is ended.\n *\n * Events emitted by `Checkout` are documented in {@link CheckoutEvent}.\n * Exceptions thrown during event handling will be emitted as error events, which are automatically surfaced as error events on the\n * `SharedTree` used at construction time.\n * @public\n */\nexport abstract class Checkout extends EventEmitterWithErrorHandling<ICheckoutEvents> implements IDisposable {\n\t/**\n\t * The view of the latest committed revision.\n\t * Does not include changes from any open edits.\n\t *\n\t * When this changes, emitChange must be called.\n\t */\n\tprotected abstract get latestCommittedView(): RevisionView;\n\n\t/**\n\t * The last view for which invalidation was sent.\n\t * Updated by emitChange.\n\t */\n\tprivate previousView: TreeView;\n\n\t/**\n\t * A handler for 'committedEdit' SharedTreeEvent\n\t */\n\tprivate readonly editCommittedHandler: EditCommittedHandler;\n\n\t/**\n\t * The shared tree this checkout views/edits.\n\t */\n\tpublic readonly tree: SharedTree;\n\n\t/**\n\t * `tree`'s log viewer as a CachingLogViewer if it is one, otherwise undefined.\n\t * Used for optimizations if provided.\n\t */\n\tprivate readonly cachingLogViewer?: CachingLogViewer;\n\n\t/**\n\t * Holds the state required to manage the currently open edit.\n\t * Undefined if there is currently not an open edit.\n\t *\n\t * Since `currentView` exposes the the intermediate state from this edit,\n\t * operations that modify `currentEdit.view` must call `emitChange` to handle invalidation.\n\t */\n\tprivate currentEdit?: GenericTransaction;\n\n\tprivate readonly logger: ITelemetryLogger;\n\n\tpublic disposed: boolean = false;\n\n\tprotected constructor(tree: SharedTree, currentView: RevisionView, onEditCommitted: EditCommittedHandler) {\n\t\tsuper((_event, error: unknown) => {\n\t\t\tthis.tree.emit('error', error);\n\t\t});\n\t\tthis.tree = tree;\n\t\tthis.logger = ChildLogger.create(this.tree.logger, 'Checkout');\n\t\tif (tree.logViewer instanceof CachingLogViewer) {\n\t\t\tthis.cachingLogViewer = tree.logViewer;\n\t\t}\n\t\tthis.previousView = currentView;\n\t\tthis.editCommittedHandler = onEditCommitted;\n\n\t\t// If there is an ongoing edit, emitChange will no-op, which is fine.\n\t\tthis.tree.on(SharedTreeEvent.EditCommitted, this.editCommittedHandler);\n\t}\n\n\t/**\n\t * @returns the current view of the tree, including the result of changes applied so far during an edit.\n\t * Note that any external edits (from other clients) will not added to view while there is a `currentEdit`.\n\t */\n\tpublic get currentView(): TreeView {\n\t\treturn this.currentEdit?.view ?? this.latestCommittedView;\n\t}\n\n\t/**\n\t * @returns true iff there is an open edit.\n\t * @internal\n\t */\n\tpublic hasOpenEdit(): boolean {\n\t\treturn this.currentEdit !== undefined;\n\t}\n\n\t/**\n\t * Opens a new edit operation.\n\t * Changes accumulate in the edit via calls to `applyChanges()`.\n\t */\n\tpublic openEdit(): void {\n\t\tassert(this.currentEdit === undefined, 'An edit is already open.');\n\t\tthis.currentEdit = TransactionInternal.factory(this.latestCommittedView);\n\t}\n\n\t/**\n\t * Ends the ongoing edit operation and commits it to the history.\n\t *\n\t * Malformed edits are considered an error, and will assert:\n\t * All named detached sequences must have been used or the Edit is malformed.\n\t *\n\t * @returns the `id` of the committed edit\n\t */\n\tpublic closeEdit(): EditId {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\tthis.currentEdit = undefined;\n\t\tif (currentEdit.failure !== undefined) {\n\t\t\tfail('Cannot close a transaction that has already failed. Use abortEdit instead.');\n\t\t}\n\n\t\tconst editingResult = currentEdit.close();\n\t\tthis.validateChangesApplied(editingResult);\n\t\tconst id: EditId = newEditId();\n\t\tthis.handleNewEdit(id, editingResult);\n\t\treturn id;\n\t}\n\n\tprivate validateChangesApplied(result: EditingResult): asserts result is ValidEditingResult;\n\tprivate validateChangesApplied(result: {\n\t\tstatus: EditStatus;\n\t\tfailure: TransactionInternal.Failure | undefined;\n\t}): asserts result is { status: EditStatus.Applied; failure: undefined };\n\tprivate validateChangesApplied(\n\t\tresult: EditingResult | { status: EditStatus; failure: TransactionInternal.Failure | undefined }\n\t) {\n\t\tif (result.status === EditStatus.Applied) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { failure } = result as { failure: TransactionInternal.Failure };\n\t\tconst additionalProps: ITelemetryProperties = {};\n\t\tswitch (failure.kind) {\n\t\t\tcase TransactionInternal.FailureKind.BadPlace:\n\t\t\t\tadditionalProps.placeFailure = failure.placeFailure;\n\t\t\t\tbreak;\n\t\t\tcase TransactionInternal.FailureKind.BadRange: {\n\t\t\t\tconst { rangeFailure } = failure;\n\t\t\t\tif (typeof rangeFailure === 'string') {\n\t\t\t\t\tadditionalProps.rangeFailure = rangeFailure;\n\t\t\t\t} else {\n\t\t\t\t\tadditionalProps.rangeFailure = rangeFailure.kind;\n\t\t\t\t\tadditionalProps.rangeEndpointFailure = rangeFailure.placeFailure;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\n\t\tthis.logger.sendErrorEvent({\n\t\t\teventName: 'FailedLocalEdit',\n\t\t\tstatus: result.status === 0 ? 'Malformed' : 'Invalid',\n\t\t\tfailureKind: failure.kind,\n\t\t\t...additionalProps,\n\t\t});\n\t\tfail('Locally constructed edits must be well-formed and valid.');\n\t}\n\n\t/**\n\t * Inform the Checkout that a particular edit is know to have a specific result when applied to a particular TreeView.\n\t * This may be used as a caching hint to avoid recomputation.\n\t */\n\tprotected hintKnownEditingResult(edit: Edit<ChangeInternal>, result: ValidEditingResult): void {\n\t\t// As an optimization, inform logViewer of this editing result so it can reuse it if applied to the same before revision.\n\t\tthis.cachingLogViewer?.setKnownEditingResult(edit, result);\n\t}\n\n\t/**\n\t * Take any needed action between when an edit is completed.\n\t * Usually this will include submitting it to a SharedTree.\n\t *\n\t * Override this to customize.\n\t */\n\tprotected handleNewEdit(id: EditId, result: ValidEditingResult): void {\n\t\tconst edit: Edit<ChangeInternal> = { id, changes: result.changes };\n\n\t\tthis.hintKnownEditingResult(edit, result);\n\n\t\t// Since external edits could have been applied while currentEdit was pending,\n\t\t// do not use the produced view: just go to the newest revision\n\t\t// (which processLocalEdit will do, including invalidation).\n\t\tthis.tree.applyEditInternal(edit);\n\t}\n\n\t/**\n\t * Applies the supplied changes to the tree and emits a change event.\n\t * Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).\n\t * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.\n\t */\n\tpublic applyChanges(changes: readonly Change[]): void;\n\tpublic applyChanges(...changes: readonly Change[]): void;\n\tpublic applyChanges(...changes: RestOrArray<Change>): void {\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray.map((c) => this.tree.internalizeChange(c)));\n\t\tthis.validateChangesApplied({ status, failure: this.currentEdit.failure });\n\t\tthis.emitChange();\n\t}\n\n\t/**\n\t * Applies the supplied changes to the tree and emits a change event.\n\t * Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).\n\t * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.\n\t */\n\tprotected tryApplyChangesInternal(changes: readonly ChangeInternal[]): EditStatus;\n\tprotected tryApplyChangesInternal(...changes: readonly ChangeInternal[]): EditStatus;\n\tprotected tryApplyChangesInternal(...changes: RestOrArray<ChangeInternal>): EditStatus {\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray);\n\t\tif (status === EditStatus.Applied) {\n\t\t\tthis.emitChange();\n\t\t}\n\t\treturn status;\n\t}\n\n\t/**\n\t * Convenience helper for applying an edit containing the given changes.\n\t * Opens an edit, applies the given changes, and closes the edit. See (`openEdit()`/`applyChanges()`/`closeEdit()`).\n\t */\n\tpublic applyEdit(changes: readonly Change[]): EditId;\n\tpublic applyEdit(...changes: readonly Change[]): EditId;\n\tpublic applyEdit(...changes: RestOrArray<Change>): EditId {\n\t\tthis.openEdit();\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tthis.applyChanges(changeArray);\n\t\treturn this.closeEdit();\n\t}\n\n\t/**\n\t * Apply an edit, if valid, otherwise does nothing (the edit is not added to the history).\n\t * If the edit applied, its changes will be immediately visible on this checkout, though it still may end up invalid once sequenced due to concurrent edits.\n\t * @returns The EditId if the edit was valid and thus applied, and undefined if it was invalid and thus not applied.\n\t */\n\tpublic tryApplyEdit(changes: readonly Change[]): EditId | undefined;\n\tpublic tryApplyEdit(...changes: readonly Change[]): EditId | undefined;\n\tpublic tryApplyEdit(...changes: RestOrArray<Change>): EditId | undefined {\n\t\tthis.openEdit();\n\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray.map((c) => this.tree.internalizeChange(c)));\n\t\tif (status === EditStatus.Applied) {\n\t\t\tthis.emitChange();\n\t\t\treturn this.closeEdit();\n\t\t}\n\n\t\tthis.abortEdit();\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Rebases the ongoing edit to the latest revision loaded by this 'Checkout'.\n\t * If the rebase succeeds (none of the changes in the ongoing edit became invalid), the ongoing edit will remain open and the current\n\t * view will reflect those changes.\n\t *\n\t * If the rebase fails (changes become invalid), the ongoing edit will be aborted and\n\t * currentView will return to showing the newest committed revision as it always does when there is no ongoing edit.\n\t *\n\t * Must only be called during an open edit.\n\t * @returns - the result of the rebase.\n\t */\n\tpublic rebaseCurrentEdit(): EditValidationResult.Valid | EditValidationResult.Invalid {\n\t\tassert(this.currentEdit !== undefined, 'An edit is not open.');\n\t\tassert(this.currentEdit.status === EditStatus.Applied, 'Local edits should always be valid.');\n\t\t// When closed, the result might indicate Malformed due to unused detached entities.\n\t\t// This is not an error, as the edit was still open and can still use those entities.\n\t\tconst priorResults = this.currentEdit.close();\n\t\tconst rebasedEdit = TransactionInternal.factory(this.latestCommittedView).applyChanges(priorResults.changes);\n\t\tassert(\n\t\t\trebasedEdit.status !== EditStatus.Malformed,\n\t\t\t'Malformed changes should have been caught on original application.'\n\t\t);\n\t\tlet status: EditValidationResult.Valid | EditValidationResult.Invalid;\n\t\tif (rebasedEdit.status === EditStatus.Invalid) {\n\t\t\tstatus = EditValidationResult.Invalid;\n\t\t\tthis.currentEdit = undefined;\n\t\t} else {\n\t\t\tstatus = EditValidationResult.Valid;\n\t\t\tthis.currentEdit = rebasedEdit;\n\t\t}\n\t\tthis.emitChange();\n\t\treturn status;\n\t}\n\n\t/**\n\t * Ends the ongoing edit operation without committing it to the history.\n\t * Can only be called if an edit is open.\n\t */\n\tpublic abortEdit(): void {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\tthis.currentEdit = undefined;\n\t\tthis.emitChange();\n\t}\n\n\t/**\n\t * @returns the {@link EditStatus} of the current edit.\n\t * Has no side effects.\n\t * Can only be called if an edit is open.\n\t */\n\tpublic getEditStatus(): EditStatus {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\t// TODO: could this ever be anything other than 'Applied'\n\t\t// TODO: shouldn't this be an EditValidationResult since 'Applied' does not indicate the edit has been applied?\n\t\treturn currentEdit.status;\n\t}\n\n\t/**\n\t * Reverts a collection of edits.\n\t * @param editIds - the edits to revert\n\t */\n\tpublic revert(editId: EditId): void {\n\t\tassert(this.currentEdit !== undefined);\n\t\tconst index = this.tree.edits.getIndexOfId(editId);\n\t\tconst edit =\n\t\t\tthis.tree.edits.tryGetEditAtIndex(index) ?? fail('Edit with the specified ID does not exist in memory');\n\t\tconst before = this.tree.logViewer.getRevisionViewInMemory(index);\n\t\tconst changes = this.tree.revertChanges(edit.changes, before);\n\t\tif (changes !== undefined) {\n\t\t\tthis.tryApplyChangesInternal(changes);\n\t\t}\n\t}\n\n\t/**\n\t * Send invalidation message for all changes since last call to emitChange.\n\t * This must be called every time `currentView` could have changed.\n\t * It is ok to make excessive calls to this: change notifications will be cheaply de-duplicated.\n\t */\n\tprotected emitChange(): void {\n\t\tconst current = this.currentView;\n\t\tconst previous = this.previousView;\n\t\tif (!previous.hasEqualForest(current, true)) {\n\t\t\t// Set previousView before calling emit to make reentrant case work (where the event handler causes an edit).\n\t\t\tthis.previousView = current;\n\t\t\tthis.emit(CheckoutEvent.ViewChange, previous, current);\n\t\t}\n\t}\n\n\t/**\n\t * @returns a Promise which completes after all currently known edits are available in this checkout.\n\t */\n\tpublic abstract waitForPendingUpdates(): Promise<void>;\n\n\t/**\n\t * @returns a Promise which completes after edits that were closed on this checkout (before calling this) have been\n\t * submitted to Fluid. This does NOT wait for the Fluid service to ack them\n\t */\n\tpublic abstract waitForEditsToSubmit(): Promise<void>;\n\n\t/**\n\t * release all unmanaged resources\n\t * e.g. unregister event listeners\n\t */\n\tpublic dispose(error?: Error): void {\n\t\tif (this.disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.disposed = true;\n\n\t\t// remove registered listener\n\t\tthis.tree.off(SharedTreeEvent.EditCommitted, this.editCommittedHandler);\n\t}\n}\n"]}
|
|
@@ -176,6 +176,10 @@ export declare class GenericTransaction {
|
|
|
176
176
|
* The status code of the most recent attempted change.
|
|
177
177
|
*/
|
|
178
178
|
get steps(): readonly ReconciliationChange[];
|
|
179
|
+
/**
|
|
180
|
+
* Information about why the transaction failed. Defined if and only if `status` is invalid or malformed.
|
|
181
|
+
*/
|
|
182
|
+
get failure(): TransactionInternal.Failure | undefined;
|
|
179
183
|
/** @returns the final `EditStatus` and `TreeView` after all changes are applied. */
|
|
180
184
|
close(): EditingResult;
|
|
181
185
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionInternal.d.ts","sourceRoot":"","sources":["../src/TransactionInternal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAuC,MAAM,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAwB,MAAM,eAAe,CAAC;AAE7F,OAAO,EAEN,iBAAiB,EACjB,cAAc,EAGd,kBAAkB,EAElB,UAAU,EAGV,mBAAmB,EACnB,mBAAmB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAKN,wBAAwB,EACxB,wBAAwB,EAGxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;;GAGG;AACH,oBAAY,aAAa,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;AAErE;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,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S,CAAC;QACjD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;KACvB,GACD;QACA,QAAQ,CAAC,IAAI,EAAE,uBAAuB,CAAC,QAAQ,CAAC;QAChD,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;KAC3B,CAAC;IAEL;;OAEG;IACH,MAAM,MAAM,uBAAuB;QAClC;;WAEG;QACH,QAAQ,aAAa;QACrB;;WAEG;QACH,SAAS,cAAc;QACvB;;WAEG;QACH,SAAS,cAAc;QACvB;;WAEG;QACH,QAAQ,aAAa;KACrB;;CACD"}
|
|
@@ -67,6 +67,12 @@ class GenericTransaction {
|
|
|
67
67
|
get steps() {
|
|
68
68
|
return this.state.steps;
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Information about why the transaction failed. Defined if and only if `status` is invalid or malformed.
|
|
72
|
+
*/
|
|
73
|
+
get failure() {
|
|
74
|
+
return this.state.failure;
|
|
75
|
+
}
|
|
70
76
|
/** @returns the final `EditStatus` and `TreeView` after all changes are applied. */
|
|
71
77
|
close() {
|
|
72
78
|
(0, Common_1.assert)(this.open, 'transaction has already been closed');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionInternal.js","sourceRoot":"","sources":["../src/TransactionInternal.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qCAAuE;AACvE,+CAA6F;AAC7F,2DAA2D;AAC3D,uDAa2B;AAC3B,mDASyB;AA4IzB;;;;;;;;;;;;GAYG;AACH,MAAa,kBAAkB;IAM9B;;;OAGG;IACH,YAAmB,IAAkB,EAAE,MAAgC;QAN/D,SAAI,GAAG,IAAI,CAAC;QAOnB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG;YACZ,IAAI,EAAE,IAAI,CAAC,kBAAkB,EAAE;YAC/B,MAAM,EAAE,4BAAU,CAAC,OAAO;YAC1B,OAAO,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;QACH,oCAAqB,CAAA;QACrB;;WAEG;QACH,oCAAqB,CAAA;QACrB;;WAEG;QACH,0DAA2C,CAAA;IAC5C,CAAC,EArCW,WAAW,GAAX,+BAAW,KAAX,+BAAW,QAqCtB;IA2MD;;OAEG;IACH,IAAY,uBAiBX;IAjBD,WAAY,uBAAuB;QAClC;;WAEG;QACH,gDAAqB,CAAA;QACrB;;WAEG;QACH,kDAAuB,CAAA;QACvB;;WAEG;QACH,kDAAuB,CAAA;QACvB;;WAEG;QACH,gDAAqB,CAAA;IACtB,CAAC,EAjBW,uBAAuB,GAAvB,2CAAuB,KAAvB,2CAAuB,QAiBlC;AACF,CAAC,EAvpBgB,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAupBnC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, copyPropertyIfDefined, fail, Result } from './Common';\nimport { NodeId, DetachedSequenceId, TraitLabel, isDetachedSequenceId } from './Identifiers';\nimport { rangeFromStableRange } from './TreeViewUtilities';\nimport {\n\tBuildInternal,\n\tBuildNodeInternal,\n\tChangeInternal,\n\tChangeTypeInternal,\n\tConstraintEffect,\n\tConstraintInternal,\n\tDetachInternal,\n\tEditStatus,\n\tInsertInternal,\n\tSetValueInternal,\n\tStablePlaceInternal,\n\tStableRangeInternal,\n} from './persisted-types';\nimport {\n\tdetachRange,\n\tinsertIntoTrait,\n\tvalidateStablePlace,\n\tvalidateStableRange,\n\tBadPlaceValidationResult,\n\tBadRangeValidationResult,\n\tPlaceValidationResult,\n\tRangeValidationResultKind,\n} from './EditUtilities';\nimport { RevisionView, TransactionView } from './RevisionView';\nimport { ReconciliationChange, ReconciliationPath } from './ReconciliationPath';\nimport { TreeViewNode } from './TreeView';\n\n/**\n * Result of applying a transaction.\n * @public\n */\nexport type EditingResult = FailedEditingResult | ValidEditingResult;\n\n/**\n * Basic result of applying a transaction.\n * @public\n */\nexport interface EditingResultBase {\n\t/**\n\t * The final status of the transaction.\n\t */\n\treadonly status: EditStatus;\n\t/**\n\t * The valid changes applied as part of the transaction.\n\t */\n\treadonly changes: readonly ChangeInternal[];\n\t/**\n\t * The editing steps applied as part of the transaction.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n\t/**\n\t * The revision preceding the transaction.\n\t */\n\treadonly before: RevisionView;\n}\n\n/**\n * Result of applying an invalid or malformed transaction.\n * @public\n */\nexport interface FailedEditingResult extends EditingResultBase {\n\t/**\n\t * {@inheritDoc EditingResultBase.status}\n\t */\n\treadonly status: EditStatus.Invalid | EditStatus.Malformed;\n\t/**\n\t * Information about what caused the transaction to fail.\n\t */\n\treadonly failure: TransactionInternal.Failure;\n\t/**\n\t * The valid changes applied as part of the transaction.\n\t * Those were ultimately abandoned due to the transaction failure.\n\t */\n\treadonly changes: readonly ChangeInternal[];\n\t/**\n\t * The editing steps applied as part of the transaction.\n\t * Those were ultimately abandoned due to the transaction failure.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n}\n\n/**\n * Result of applying a valid transaction.\n * @public\n */\nexport interface ValidEditingResult extends EditingResultBase {\n\t/**\n\t * {@inheritDoc EditingResultBase.status}\n\t */\n\treadonly status: EditStatus.Applied;\n\t/**\n\t * The new revision produced by the transaction.\n\t */\n\treadonly after: RevisionView;\n}\n\n/**\n * The result of applying a change within a transaction.\n * @public\n */\nexport type ChangeResult = Result<TransactionView, TransactionFailure>;\n\n/**\n * The ongoing state of a transaction.\n * @public\n */\nexport type TransactionState = SucceedingTransactionState | FailingTransactionState;\n\n/**\n * The state of a transaction that has not encountered an error.\n */\nexport interface SucceedingTransactionState {\n\t/**\n\t * The current status of the transaction.\n\t */\n\treadonly status: EditStatus.Applied;\n\t/**\n\t * The view reflecting the latest applied change.\n\t */\n\treadonly view: TransactionView;\n\t/**\n\t * The applied changes so far.\n\t */\n\treadonly changes: readonly ChangeInternal[];\n\t/**\n\t * The editing steps applied so far.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n}\n\n/**\n * The state of a transaction that has encountered an error.\n */\nexport interface FailingTransactionState extends TransactionFailure {\n\t/**\n\t * The view reflecting the latest applied change.\n\t */\n\treadonly view: TransactionView;\n\t/**\n\t * The applied changes so far.\n\t */\n\treadonly changes: readonly ChangeInternal[];\n\t/**\n\t * The editing steps applied so far.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n}\n\n/**\n * The failure state of a transaction.\n */\nexport interface TransactionFailure {\n\t/**\n\t * The status indicating the kind of failure encountered.\n\t */\n\treadonly status: EditStatus.Invalid | EditStatus.Malformed;\n\t/**\n\t * Information about what caused the transaction to fail.\n\t */\n\treadonly failure: TransactionInternal.Failure;\n}\n\n/**\n * A mutable transaction for applying sequences of changes to a TreeView.\n * Allows viewing the intermediate states.\n *\n * Contains necessary state to apply changes within an edit to a TreeView.\n *\n * May have any number of changes applied to make up the edit.\n * Use `close` to complete the transaction, returning the array of changes and an EditingResult showing the\n * results of applying the changes as an Edit to the initial TreeView (passed to the constructor).\n *\n * No data outside the Transaction is modified by Transaction:\n * the results from `close` must be used to actually submit an `Edit`.\n */\nexport class GenericTransaction {\n\tprivate readonly policy: GenericTransactionPolicy;\n\tprotected readonly before: RevisionView;\n\tprivate state: TransactionState;\n\tprivate open = true;\n\n\t/**\n\t * Create and open an edit of the provided `TreeView`. After applying 0 or more changes, this editor should be closed via `close()`.\n\t * @param view - the `TreeView` at which this edit begins. The first change will be applied against this view.\n\t */\n\tpublic constructor(view: RevisionView, policy: GenericTransactionPolicy) {\n\t\tthis.before = view;\n\t\tthis.policy = policy;\n\t\tthis.state = {\n\t\t\tview: view.openForTransaction(),\n\t\t\tstatus: EditStatus.Applied,\n\t\t\tchanges: [],\n\t\t\tsteps: [],\n\t\t};\n\t}\n\n\t/** Whether or not this transaction has been closed via `close()` */\n\tpublic get isOpen(): boolean {\n\t\treturn this.open;\n\t}\n\n\t/**\n\t * The most up-to-date `TreeView` for this edit. This is the state of the tree after all changes applied so far.\n\t */\n\tpublic get view(): TransactionView {\n\t\treturn this.state.view;\n\t}\n\n\t/**\n\t * The status code of the most recent attempted change.\n\t */\n\tpublic get status(): EditStatus {\n\t\treturn this.state.status;\n\t}\n\n\t/**\n\t * The status code of the most recent attempted change.\n\t */\n\tpublic get changes(): readonly ChangeInternal[] {\n\t\treturn this.state.changes;\n\t}\n\n\t/**\n\t * The status code of the most recent attempted change.\n\t */\n\tpublic get steps(): readonly ReconciliationChange[] {\n\t\treturn this.state.steps;\n\t}\n\n\t/** @returns the final `EditStatus` and `TreeView` after all changes are applied. */\n\tpublic close(): EditingResult {\n\t\tassert(this.open, 'transaction has already been closed');\n\t\tthis.open = false;\n\t\tif (this.state.status === EditStatus.Applied) {\n\t\t\tconst validation = this.policy.validateOnClose(this.state);\n\t\t\tif (Result.isOk(validation)) {\n\t\t\t\tif (validation.result !== this.view) {\n\t\t\t\t\tthis.state = { ...this.state, view: validation.result };\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tstatus: EditStatus.Applied,\n\t\t\t\t\tsteps: this.steps,\n\t\t\t\t\tchanges: this.changes,\n\t\t\t\t\tbefore: this.before,\n\t\t\t\t\tafter: this.view.close(),\n\t\t\t\t};\n\t\t\t}\n\t\t\tthis.state = { ...this.state, ...validation.error };\n\t\t\treturn {\n\t\t\t\t...validation.error,\n\t\t\t\tsteps: this.steps,\n\t\t\t\tchanges: this.changes,\n\t\t\t\tbefore: this.before,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tstatus: this.state.status,\n\t\t\tfailure: this.state.failure,\n\t\t\tsteps: this.steps,\n\t\t\tchanges: this.changes,\n\t\t\tbefore: this.before,\n\t\t};\n\t}\n\n\t/**\n\t * A helper to apply a sequence of changes. Changes will be applied one after the other. If a change fails to apply,\n\t * the remaining changes in `changes` will be ignored.\n\t * @param changes - the sequence of changes to apply.\n\t * @param path - the reconciliation path for the first change.\n\t * @returns this\n\t */\n\tpublic applyChanges(changes: Iterable<ChangeInternal>, path: ReconciliationPath = []): this {\n\t\tconst iter = changes[Symbol.iterator]();\n\t\tconst firsChangeInternal = iter.next().value;\n\t\tlet iterResult = iter.next();\n\t\tif (iterResult.done === true) {\n\t\t\tfor (const change of changes) {\n\t\t\t\tif (this.applyChange(change, path).status !== EditStatus.Applied) {\n\t\t\t\t\treturn this;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\n\t\tif (this.applyChange(firsChangeInternal, path).status !== EditStatus.Applied) {\n\t\t\treturn this;\n\t\t}\n\n\t\tconst ongoingEdit = {\n\t\t\t0: this.steps[this.steps.length - 1],\n\t\t\tbefore: this.view,\n\t\t\tafter: this.view,\n\t\t\tlength: 1,\n\t\t};\n\n\t\t/**\n\t\t * We use a Proxy instead of `{ ...path, ...objectWithOngoingEdit }` to avoid eagerly demanding all parts of the path, which may\n\t\t * require extensive computation.\n\t\t */\n\t\tconst pathWithOngoingEdit = new Proxy(path, {\n\t\t\tget: (target: ReconciliationPath, prop: string): ReconciliationPath[number | 'length'] => {\n\t\t\t\tif (prop === 'length') {\n\t\t\t\t\treturn target.length + 1;\n\t\t\t\t}\n\t\t\t\treturn prop === String(target.length) ? ongoingEdit : target[prop];\n\t\t\t},\n\t\t});\n\n\t\twhile (iterResult.done !== true) {\n\t\t\tif (this.applyChange(iterResult.value, pathWithOngoingEdit).status !== EditStatus.Applied) {\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tongoingEdit[ongoingEdit.length] = this.steps[this.steps.length - 1];\n\t\t\tongoingEdit.length += 1;\n\t\t\tongoingEdit.after = this.view;\n\t\t\titerResult = iter.next();\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Attempt to apply the given change as part of this edit. This method should not be called if a previous change in this edit failed to\n\t * apply.\n\t * @param change - the change to apply\n\t * @param path - the reconciliation path for the change.\n\t * @returns this\n\t */\n\tpublic applyChange(change: ChangeInternal, path: ReconciliationPath = []): this {\n\t\tassert(this.open, 'Editor must be open to apply changes.');\n\t\tif (this.state.status !== EditStatus.Applied) {\n\t\t\tfail('Cannot apply change to an edit unless all previous changes have applied');\n\t\t}\n\t\tconst resolutionResult = this.policy.tryResolveChange(this.state, change, path);\n\t\tif (Result.isError(resolutionResult)) {\n\t\t\tthis.state = { ...this.state, ...resolutionResult.error };\n\t\t\treturn this;\n\t\t}\n\t\tconst resolvedChange = resolutionResult.result;\n\t\tconst changeResult = this.policy.dispatchChange(this.state, resolvedChange);\n\t\tthis.state = Result.isOk(changeResult)\n\t\t\t? {\n\t\t\t\t\tstatus: EditStatus.Applied,\n\t\t\t\t\tview: changeResult.result,\n\t\t\t\t\tchanges: this.changes.concat(change),\n\t\t\t\t\tsteps: this.steps.concat({ resolvedChange, after: changeResult.result }),\n\t\t\t }\n\t\t\t: {\n\t\t\t\t\t...this.state,\n\t\t\t\t\t...changeResult.error,\n\t\t\t };\n\t\treturn this;\n\t}\n}\n\n/**\n * An object that encapsulates the rules and state pertaining to a specific subclass of {@link GenericTransaction}.\n * The characteristics that define such a subclass (and an implementation of this interface) are:\n * - The type of change that can be applied\n * - How those changes impact the state of the tree\n * - How those changes are resolved in the face of concurrent changes\n * - What makes a transaction valid\n * - The kind of situations that might lead to a transaction failure\n *\n * Instances of this type are passed to the {@link GenericTransaction} constructor.\n */\nexport interface GenericTransactionPolicy {\n\t/**\n\t * Given a change, attempts to derive an equivalent change which can be applied to the current state even if the given change was issued\n\t * over a different state. This can be used to apply a sequence of changes that were issued concurrently, i.e., without knowledge of\n\t * each other.\n\t * @param state - The current state on which the returned change will be applied.\n\t * @param change - The original change issued.\n\t * @param path - The reconciliation path for the change.\n\t * @returns The change to be applied to the current state, or a failure if the change cannot be resolved.\n\t */\n\ttryResolveChange(\n\t\tstate: SucceedingTransactionState,\n\t\tchange: ChangeInternal,\n\t\tpath: ReconciliationPath\n\t): Result<ChangeInternal, TransactionFailure>;\n\n\t/**\n\t * Provides a new state given the current state and a change to apply.\n\t * @param state - The current state on which the change is applied.\n\t * @param change - The change to apply to the current state.\n\t * @returns The new state reflecting the applied change, or a failure.\n\t */\n\tdispatchChange(state: SucceedingTransactionState, change: ChangeInternal): ChangeResult;\n\n\t/**\n\t * Additional transaction validation when the transaction is closed.\n\t * @param state - The current state of the transaction.\n\t * @returns The new state reflecting the closed transaction, or a failure if the transaction cannot be closed.\n\t */\n\tvalidateOnClose(state: SucceedingTransactionState): ChangeResult;\n}\n\n/**\n * A mutable transaction for applying sequences of changes to a TreeView.\n * Allows viewing the intermediate states.\n *\n * Contains necessary state to apply changes within an edit to a TreeView.\n *\n * May have any number of changes applied to make up the edit.\n * Use `close` to complete the transaction, returning the array of changes and an EditingResult showing the\n * results of applying the changes as an Edit to the initial TreeView (passed to the constructor).\n *\n * No data outside the Transaction is modified by Transaction:\n * the results from `close` must be used to actually submit an `Edit`.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace TransactionInternal {\n\t/**\n\t * Makes a new {@link GenericTransaction} that follows the {@link TransactionInternal.Policy} policy.\n\t */\n\texport function factory(view: RevisionView): GenericTransaction {\n\t\treturn new GenericTransaction(view, new Policy());\n\t}\n\n\ttype ValidState = SucceedingTransactionState;\n\n\t/**\n\t * The policy followed by a {@link TransactionInternal}.\n\t */\n\texport class Policy implements GenericTransactionPolicy {\n\t\t/**\n\t\t * Maps detached sequences of nodes to their NodeIds\n\t\t */\n\t\tprotected readonly detached: Map<DetachedSequenceId, readonly NodeId[]> = new Map();\n\n\t\t/**\n\t\t * Resolves change with Result.Ok\n\t\t *\n\t\t * @param state - Unused\n\t\t * @param change - Change to resolve\n\t\t * @returns Result.Ok which contains change\n\t\t */\n\t\tpublic tryResolveChange(state: ValidState, change: ChangeInternal): Result.Ok<ChangeInternal> {\n\t\t\treturn Result.ok(change);\n\t\t}\n\n\t\t/**\n\t\t * Validates the transaction when it is closed\n\t\t *\n\t\t * @param state - Current state\n\t\t * @returns a {@link ChangeResult} containing either the change result or a Failure\n\t\t */\n\t\tpublic validateOnClose(state: ValidState): ChangeResult {\n\t\t\t// Making the policy choice that storing a detached sequences in an edit but not using it is an error.\n\t\t\treturn this.detached.size !== 0\n\t\t\t\t? Result.error({\n\t\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\t\tfailure: {\n\t\t\t\t\t\t\tkind: FailureKind.UnusedDetachedSequence,\n\t\t\t\t\t\t\tsequenceId: this.detached.keys().next().value,\n\t\t\t\t\t\t},\n\t\t\t\t })\n\t\t\t\t: Result.ok(state.view);\n\t\t}\n\n\t\t/**\n\t\t * Applies a given change\n\t\t *\n\t\t * @param state - Current state\n\t\t * @param change - Change to apply\n\t\t * @returns a {@link ChangeResult} containing either the change result or a Failure\n\t\t */\n\t\tpublic dispatchChange(state: ValidState, change: ChangeInternal): ChangeResult {\n\t\t\tswitch (change.type) {\n\t\t\t\tcase ChangeTypeInternal.Build:\n\t\t\t\t\treturn this.applyBuild(state, change);\n\t\t\t\tcase ChangeTypeInternal.Insert:\n\t\t\t\t\treturn this.applyInsert(state, change);\n\t\t\t\tcase ChangeTypeInternal.Detach:\n\t\t\t\t\treturn this.applyDetach(state, change);\n\t\t\t\tcase ChangeTypeInternal.Constraint:\n\t\t\t\t\treturn this.applyConstraint(state, change);\n\t\t\t\tcase ChangeTypeInternal.SetValue:\n\t\t\t\t\treturn this.applySetValue(state, change);\n\t\t\t\tdefault:\n\t\t\t\t\treturn fail('Attempted to apply unsupported change');\n\t\t\t}\n\t\t}\n\n\t\tprivate applyBuild(state: ValidState, change: BuildInternal): ChangeResult {\n\t\t\tif (this.detached.has(change.destination)) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.DetachedSequenceIdAlreadyInUse,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\tsequenceId: change.destination,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tlet idAlreadyPresent: NodeId | undefined;\n\t\t\tlet duplicateIdInBuild: NodeId | undefined;\n\t\t\tlet invalidId: NodeId | undefined;\n\t\t\tlet detachedSequenceNotFound: DetachedSequenceId | undefined;\n\t\t\tconst map = new Map<NodeId, TreeViewNode>();\n\t\t\tconst newIds = this.createViewNodesForTree(\n\t\t\t\tchange.source,\n\t\t\t\t(id, viewNode) => {\n\t\t\t\t\tif (map.has(id)) {\n\t\t\t\t\t\tduplicateIdInBuild = id;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tif (state.view.hasNode(viewNode.identifier)) {\n\t\t\t\t\t\tidAlreadyPresent = id;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tmap.set(id, viewNode);\n\t\t\t\t\treturn false;\n\t\t\t\t},\n\t\t\t\t(detachedId) => {\n\t\t\t\t\tdetachedSequenceNotFound = detachedId;\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif (idAlreadyPresent !== undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: { kind: FailureKind.IdAlreadyInUse, change, id: idAlreadyPresent },\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (duplicateIdInBuild !== undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\tfailure: { kind: FailureKind.DuplicateIdInBuild, change, id: duplicateIdInBuild },\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (invalidId !== undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: { kind: FailureKind.UnknownId, change, id: invalidId },\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (detachedSequenceNotFound !== undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.DetachedSequenceNotFound,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\tsequenceId: detachedSequenceNotFound,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst view = state.view.addNodes(map.values());\n\t\t\tthis.detached.set(\n\t\t\t\tchange.destination,\n\t\t\t\tnewIds ?? fail('Unhandled failure case in Transaction.createViewNodesForTree')\n\t\t\t);\n\t\t\treturn Result.ok(view);\n\t\t}\n\n\t\tprivate applyInsert(state: ValidState, change: InsertInternal): ChangeResult {\n\t\t\tconst source = this.detached.get(change.source);\n\t\t\tif (source === undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.DetachedSequenceNotFound,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\tsequenceId: change.source,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst validatedDestination = validateStablePlace(state.view, change.destination);\n\t\t\tif (validatedDestination.result !== PlaceValidationResult.Valid) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus:\n\t\t\t\t\t\tvalidatedDestination.result === PlaceValidationResult.Malformed\n\t\t\t\t\t\t\t? EditStatus.Malformed\n\t\t\t\t\t\t\t: EditStatus.Invalid,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.BadPlace,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\tplace: change.destination,\n\t\t\t\t\t\tplaceFailure: validatedDestination.result,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tthis.detached.delete(change.source);\n\t\t\tconst view = insertIntoTrait(state.view, source, validatedDestination);\n\t\t\treturn Result.ok(view);\n\t\t}\n\n\t\tprivate applyDetach(state: ValidState, change: DetachInternal): ChangeResult {\n\t\t\tconst validatedSource = validateStableRange(state.view, change.source);\n\t\t\tif (validatedSource.result !== RangeValidationResultKind.Valid) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus:\n\t\t\t\t\t\tvalidatedSource.result === RangeValidationResultKind.PlacesInDifferentTraits ||\n\t\t\t\t\t\tvalidatedSource.result === RangeValidationResultKind.Inverted ||\n\t\t\t\t\t\tvalidatedSource.result.placeFailure !== PlaceValidationResult.Malformed\n\t\t\t\t\t\t\t? EditStatus.Invalid\n\t\t\t\t\t\t\t: EditStatus.Malformed,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.BadRange,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\trange: change.source,\n\t\t\t\t\t\trangeFailure: validatedSource.result,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst result = detachRange(state.view, validatedSource);\n\t\t\tlet modifiedView = result.view;\n\t\t\tconst { detached } = result;\n\n\t\t\t// Store or dispose detached\n\t\t\tif (change.destination !== undefined) {\n\t\t\t\tif (this.detached.has(change.destination)) {\n\t\t\t\t\treturn Result.error({\n\t\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\t\tfailure: {\n\t\t\t\t\t\t\tkind: FailureKind.DetachedSequenceIdAlreadyInUse,\n\t\t\t\t\t\t\tchange,\n\t\t\t\t\t\t\tsequenceId: change.destination,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthis.detached.set(change.destination, detached);\n\t\t\t} else {\n\t\t\t\tmodifiedView = modifiedView.deleteNodes(detached);\n\t\t\t}\n\t\t\treturn Result.ok(modifiedView);\n\t\t}\n\n\t\tprivate applyConstraint(state: ValidState, change: ConstraintInternal): ChangeResult {\n\t\t\t// TODO: Implement identityHash and contentHash\n\t\t\tassert(change.identityHash === undefined, 'identityHash constraint is not implemented');\n\t\t\tassert(change.contentHash === undefined, 'contentHash constraint is not implemented');\n\n\t\t\tconst validatedChange = validateStableRange(state.view, change.toConstrain);\n\t\t\tif (validatedChange.result !== RangeValidationResultKind.Valid) {\n\t\t\t\treturn validatedChange.result !== RangeValidationResultKind.PlacesInDifferentTraits &&\n\t\t\t\t\tvalidatedChange.result !== RangeValidationResultKind.Inverted &&\n\t\t\t\t\tvalidatedChange.result.placeFailure !== PlaceValidationResult.Malformed\n\t\t\t\t\t? change.effect === ConstraintEffect.ValidRetry\n\t\t\t\t\t\t? Result.ok(state.view)\n\t\t\t\t\t\t: Result.error({\n\t\t\t\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\t\t\t\tfailure: {\n\t\t\t\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadRange,\n\t\t\t\t\t\t\t\t\t\trangeFailure: validatedChange.result,\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 })\n\t\t\t\t\t: Result.error({\n\t\t\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\t\t\tfailure: {\n\t\t\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadRange,\n\t\t\t\t\t\t\t\t\trangeFailure: validatedChange.result,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t });\n\t\t\t}\n\n\t\t\tconst { start, end } = rangeFromStableRange(state.view, validatedChange);\n\t\t\tconst startIndex = state.view.findIndexWithinTrait(start);\n\t\t\tconst endIndex = state.view.findIndexWithinTrait(end);\n\n\t\t\tif (change.length !== undefined && change.length !== endIndex - startIndex) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadLength,\n\t\t\t\t\t\t\tactual: endIndex - startIndex,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (change.parentNode !== undefined && change.parentNode !== end.trait.parent) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadParent,\n\t\t\t\t\t\t\tactual: change.parentNode,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (change.label !== undefined && change.label !== end.trait.label) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadLabel,\n\t\t\t\t\t\t\tactual: end.trait.label,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn Result.ok(state.view);\n\t\t}\n\n\t\tprivate applySetValue(state: ValidState, change: SetValueInternal): ChangeResult {\n\t\t\tif (!state.view.hasNode(change.nodeToModify)) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: { kind: FailureKind.UnknownId, change, id: change.nodeToModify },\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst newView = state.view.setNodeValue(change.nodeToModify, change.payload);\n\t\t\treturn Result.ok(newView);\n\t\t}\n\n\t\t/**\n\t\t * Generates tree view nodes from the supplied edit nodes.\n\t\t * Invokes onCreateNode for each new node, and halts creation early if it returns true.\n\t\t * Invokes onInvalidDetachedId and halts early for any invalid detached IDs referenced in the edit node sequence.\n\t\t * @returns all the top-level node IDs in `sequence` (both from nodes and from detached sequences).\n\t\t */\n\t\tprotected createViewNodesForTree(\n\t\t\tsequence: Iterable<BuildNodeInternal>,\n\t\t\tonCreateNode: (stableId: NodeId, node: TreeViewNode) => boolean,\n\t\t\tonInvalidDetachedId: (sequenceId: DetachedSequenceId) => void\n\t\t): NodeId[] | undefined {\n\t\t\tconst topLevelIds: NodeId[] = [];\n\t\t\tconst unprocessed: BuildNodeInternal[] = [];\n\t\t\tfor (const buildNode of sequence) {\n\t\t\t\tif (isDetachedSequenceId(buildNode)) {\n\t\t\t\t\tconst detachedIds = this.getDetachedNodeIds(buildNode, onInvalidDetachedId);\n\t\t\t\t\tif (detachedIds === undefined) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t\ttopLevelIds.push(...detachedIds);\n\t\t\t\t} else {\n\t\t\t\t\tunprocessed.push(buildNode);\n\t\t\t\t\ttopLevelIds.push(buildNode.identifier);\n\t\t\t\t}\n\t\t\t}\n\t\t\twhile (unprocessed.length > 0) {\n\t\t\t\tconst node = unprocessed.pop();\n\t\t\t\tassert(node !== undefined && !isDetachedSequenceId(node));\n\t\t\t\tconst traits = new Map<TraitLabel, readonly NodeId[]>();\n\t\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\t\tfor (const key in node.traits) {\n\t\t\t\t\tif (Object.prototype.hasOwnProperty.call(node.traits, key)) {\n\t\t\t\t\t\tconst children = node.traits[key];\n\t\t\t\t\t\tif (children.length > 0) {\n\t\t\t\t\t\t\tconst childIds: NodeId[] = [];\n\t\t\t\t\t\t\tfor (const child of children) {\n\t\t\t\t\t\t\t\tif (isDetachedSequenceId(child)) {\n\t\t\t\t\t\t\t\t\tconst detachedIds = this.getDetachedNodeIds(child, onInvalidDetachedId);\n\t\t\t\t\t\t\t\t\tif (detachedIds === undefined) {\n\t\t\t\t\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tchildIds.push(...detachedIds);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tchildIds.push(child.identifier);\n\t\t\t\t\t\t\t\t\tunprocessed.push(child);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttraits.set(key as TraitLabel, childIds);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst newNode: TreeViewNode = {\n\t\t\t\t\tidentifier: node.identifier,\n\t\t\t\t\tdefinition: node.definition,\n\t\t\t\t\ttraits,\n\t\t\t\t};\n\t\t\t\tcopyPropertyIfDefined(node, newNode, 'payload');\n\t\t\t\tif (onCreateNode(node.identifier, newNode)) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn topLevelIds;\n\t\t}\n\n\t\tprivate getDetachedNodeIds(\n\t\t\tdetachedId: DetachedSequenceId,\n\t\t\tonInvalidDetachedId: (sequenceId: DetachedSequenceId) => void\n\t\t): readonly NodeId[] | undefined {\n\t\t\t// Retrieve the detached sequence from the void.\n\t\t\tconst detachedNodeIds = this.detached.get(detachedId);\n\t\t\tif (detachedNodeIds === undefined) {\n\t\t\t\tonInvalidDetachedId(detachedId);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\t// Since we have retrieved the sequence, remove it from the void to prevent a second tree from multi-parenting it later\n\t\t\tthis.detached.delete(detachedId);\n\t\t\treturn detachedNodeIds;\n\t\t}\n\t}\n\n\t/**\n\t * The kinds of failures that a transaction might encounter.\n\t */\n\texport enum FailureKind {\n\t\t/**\n\t\t * Transaction has an unused DetachedSequenceId\n\t\t */\n\t\tUnusedDetachedSequence = 'UnusedDetachedSequence',\n\t\t/**\n\t\t * Transaction has a build operation using an already in use DetachedSequenceID.\n\t\t */\n\t\tDetachedSequenceIdAlreadyInUse = 'DetachedSequenceIdAlreadyInUse',\n\t\t/**\n\t\t * Transaction tries to operate on an unknown DetachedSequenceID\n\t\t */\n\t\tDetachedSequenceNotFound = 'DetachedSequenceNotFound',\n\t\t/**\n\t\t * Transaction has a build which uses a duplicated NodeId\n\t\t */\n\t\tDuplicateIdInBuild = 'DuplicateIdInBuild',\n\t\t/**\n\t\t * Transaction tries to build a node using an ID which is already used in the current state\n\t\t */\n\t\tIdAlreadyInUse = 'IdAlreadyInUse',\n\t\t/**\n\t\t * Transaction tries to set value of an unknown node\n\t\t */\n\t\tUnknownId = 'UnknownId',\n\t\t/**\n\t\t * Transaction tries to insert in an invalid Place\n\t\t */\n\t\tBadPlace = 'BadPlace',\n\t\t/**\n\t\t * Transaction tries to detach an invalid Range\n\t\t */\n\t\tBadRange = 'BadRange',\n\t\t/**\n\t\t * Transaction has an invalid constraint\n\t\t */\n\t\tConstraintViolation = 'ConstraintViolation',\n\t}\n\n\t/**\n\t * A failure encountered by a transaction.\n\t */\n\texport type Failure =\n\t\t| UnusedDetachedSequenceFailure\n\t\t| DetachedSequenceIdAlreadyInUseFailure\n\t\t| DetachedSequenceNotFoundFailure\n\t\t| DuplicateIdInBuildFailure\n\t\t| IdAlreadyInUseFailure\n\t\t| UnknownIdFailure\n\t\t| BadPlaceFailure\n\t\t| BadRangeFailure\n\t\t| ConstraintViolationFailure;\n\n\t/**\n\t * Error returned when a transaction is closed while there is an unused detached sequence.\n\t */\n\texport interface UnusedDetachedSequenceFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.UnusedDetachedSequence)\n\t\t */\n\t\treadonly kind: FailureKind.UnusedDetachedSequence;\n\t\t/**\n\t\t * The unused DetachedSequenceId\n\t\t */\n\t\treadonly sequenceId: DetachedSequenceId;\n\t}\n\n\t/**\n\t * Error thrown when a transaction encounters a build operation using an already in use DetachedSequenceID.\n\t */\n\texport interface DetachedSequenceIdAlreadyInUseFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.DetachedSequenceIdAlreadyInUse)\n\t\t */\n\t\treadonly kind: FailureKind.DetachedSequenceIdAlreadyInUse;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * The DetachedSequenceId that is already in use\n\t\t */\n\t\treadonly sequenceId: DetachedSequenceId;\n\t}\n\n\t/**\n\t * Error thrown when a transaction tries to operate on an unknown DetachedSequenceID\n\t */\n\texport interface DetachedSequenceNotFoundFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.DetachedSequenceNotFound)\n\t\t */\n\t\treadonly kind: FailureKind.DetachedSequenceNotFound;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * The DetachedSequenceId that wasn't found\n\t\t */\n\t\treadonly sequenceId: DetachedSequenceId;\n\t}\n\n\t/**\n\t * Error thrown when a build uses a duplicated NodeId\n\t */\n\texport interface DuplicateIdInBuildFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.DuplicateIdInBuild)\n\t\t */\n\t\treadonly kind: FailureKind.DuplicateIdInBuild;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * ID of duplicated node\n\t\t */\n\t\treadonly id: NodeId;\n\t}\n\n\t/**\n\t * Error thrown when a build node ID is already used in the current state\n\t */\n\texport interface IdAlreadyInUseFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.IdAlreadyInUse)\n\t\t */\n\t\treadonly kind: FailureKind.IdAlreadyInUse;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * ID of already in use node\n\t\t */\n\t\treadonly id: NodeId;\n\t}\n\n\t/**\n\t * Error thrown when a change is attempted on an unknown NodeId\n\t */\n\texport interface UnknownIdFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.UnknownId)\n\t\t */\n\t\treadonly kind: FailureKind.UnknownId;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * The unknown ID\n\t\t */\n\t\treadonly id: NodeId;\n\t}\n\n\t/**\n\t * Error thrown when an insert change uses an invalid Place\n\t */\n\texport interface BadPlaceFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.BadPlace)\n\t\t */\n\t\treadonly kind: FailureKind.BadPlace;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * The faulting place\n\t\t */\n\t\treadonly place: StablePlaceInternal;\n\t\t/**\n\t\t * The reason for the failure\n\t\t */\n\t\treadonly placeFailure: BadPlaceValidationResult;\n\t}\n\n\t/**\n\t * Error thrown when a detach operation is given an invalid or malformed Range\n\t */\n\texport interface BadRangeFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.BadRange)\n\t\t */\n\t\treadonly kind: FailureKind.BadRange;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * Faulting range\n\t\t */\n\t\treadonly range: StableRangeInternal;\n\t\t/**\n\t\t * The reason for the failure\n\t\t */\n\t\treadonly rangeFailure: BadRangeValidationResult;\n\t}\n\n\t/**\n\t * Error thrown when a constraint fails to apply\n\t */\n\texport interface ConstraintViolationFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.ConstraintViolation)\n\t\t */\n\t\treadonly kind: FailureKind.ConstraintViolation;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly constraint: ConstraintInternal;\n\t\t/**\n\t\t * The first violation the constraint encounters (there may be others).\n\t\t */\n\t\treadonly violation: ConstraintViolationResult;\n\t}\n\n\t/**\n\t * The details of what kind of constraint was violated and caused a ConstraintViolationFailure error to occur\n\t */\n\texport type ConstraintViolationResult =\n\t\t| {\n\t\t\t\treadonly kind: ConstraintViolationKind.BadRange;\n\t\t\t\treadonly rangeFailure: BadRangeValidationResult;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: ConstraintViolationKind.BadLength;\n\t\t\t\treadonly actual: number;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: ConstraintViolationKind.BadParent;\n\t\t\t\treadonly actual: NodeId;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: ConstraintViolationKind.BadLabel;\n\t\t\t\treadonly actual: TraitLabel;\n\t\t };\n\n\t/**\n\t * Enum of possible kinds of constraint violations that can be encountered\n\t */\n\texport enum ConstraintViolationKind {\n\t\t/**\n\t\t * The constraint failed because it applies to an invalid range\n\t\t */\n\t\tBadRange = 'BadRange',\n\t\t/**\n\t\t * The constraint failed because the length prescribed by the constraint does not match the length of range being constrained\n\t\t */\n\t\tBadLength = 'BadLength',\n\t\t/**\n\t\t * The constraint failed because the parent prescribed by the constraint does not match the actual parent of the range being constrained\n\t\t */\n\t\tBadParent = 'BadParent',\n\t\t/**\n\t\t * The constraint failed because the trait label prescribed by the constraint does not match the actual trait label of the range being constrained\n\t\t */\n\t\tBadLabel = 'BadLabel',\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TransactionInternal.js","sourceRoot":"","sources":["../src/TransactionInternal.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qCAAuE;AACvE,+CAA6F;AAC7F,2DAA2D;AAC3D,uDAa2B;AAC3B,mDASyB;AA4IzB;;;;;;;;;;;;GAYG;AACH,MAAa,kBAAkB;IAM9B;;;OAGG;IACH,YAAmB,IAAkB,EAAE,MAAgC;QAN/D,SAAI,GAAG,IAAI,CAAC;QAOnB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG;YACZ,IAAI,EAAE,IAAI,CAAC,kBAAkB,EAAE;YAC/B,MAAM,EAAE,4BAAU,CAAC,OAAO;YAC1B,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,EAAE;SACT,CAAC;IACH,CAAC;IAED,oEAAoE;IACpE,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;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B,CAAA;QACrB;;WAEG;QACH,0DAA2C,CAAA;IAC5C,CAAC,EArCW,WAAW,GAAX,+BAAW,KAAX,+BAAW,QAqCtB;IA2MD;;OAEG;IACH,IAAY,uBAiBX;IAjBD,WAAY,uBAAuB;QAClC;;WAEG;QACH,gDAAqB,CAAA;QACrB;;WAEG;QACH,kDAAuB,CAAA;QACvB;;WAEG;QACH,kDAAuB,CAAA;QACvB;;WAEG;QACH,gDAAqB,CAAA;IACtB,CAAC,EAjBW,uBAAuB,GAAvB,2CAAuB,KAAvB,2CAAuB,QAiBlC;AACF,CAAC,EAvpBgB,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAupBnC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, copyPropertyIfDefined, fail, Result } from './Common';\nimport { NodeId, DetachedSequenceId, TraitLabel, isDetachedSequenceId } from './Identifiers';\nimport { rangeFromStableRange } from './TreeViewUtilities';\nimport {\n\tBuildInternal,\n\tBuildNodeInternal,\n\tChangeInternal,\n\tChangeTypeInternal,\n\tConstraintEffect,\n\tConstraintInternal,\n\tDetachInternal,\n\tEditStatus,\n\tInsertInternal,\n\tSetValueInternal,\n\tStablePlaceInternal,\n\tStableRangeInternal,\n} from './persisted-types';\nimport {\n\tdetachRange,\n\tinsertIntoTrait,\n\tvalidateStablePlace,\n\tvalidateStableRange,\n\tBadPlaceValidationResult,\n\tBadRangeValidationResult,\n\tPlaceValidationResult,\n\tRangeValidationResultKind,\n} from './EditUtilities';\nimport { RevisionView, TransactionView } from './RevisionView';\nimport { ReconciliationChange, ReconciliationPath } from './ReconciliationPath';\nimport { TreeViewNode } from './TreeView';\n\n/**\n * Result of applying a transaction.\n * @public\n */\nexport type EditingResult = FailedEditingResult | ValidEditingResult;\n\n/**\n * Basic result of applying a transaction.\n * @public\n */\nexport interface EditingResultBase {\n\t/**\n\t * The final status of the transaction.\n\t */\n\treadonly status: EditStatus;\n\t/**\n\t * The valid changes applied as part of the transaction.\n\t */\n\treadonly changes: readonly ChangeInternal[];\n\t/**\n\t * The editing steps applied as part of the transaction.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n\t/**\n\t * The revision preceding the transaction.\n\t */\n\treadonly before: RevisionView;\n}\n\n/**\n * Result of applying an invalid or malformed transaction.\n * @public\n */\nexport interface FailedEditingResult extends EditingResultBase {\n\t/**\n\t * {@inheritDoc EditingResultBase.status}\n\t */\n\treadonly status: EditStatus.Invalid | EditStatus.Malformed;\n\t/**\n\t * Information about what caused the transaction to fail.\n\t */\n\treadonly failure: TransactionInternal.Failure;\n\t/**\n\t * The valid changes applied as part of the transaction.\n\t * Those were ultimately abandoned due to the transaction failure.\n\t */\n\treadonly changes: readonly ChangeInternal[];\n\t/**\n\t * The editing steps applied as part of the transaction.\n\t * Those were ultimately abandoned due to the transaction failure.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n}\n\n/**\n * Result of applying a valid transaction.\n * @public\n */\nexport interface ValidEditingResult extends EditingResultBase {\n\t/**\n\t * {@inheritDoc EditingResultBase.status}\n\t */\n\treadonly status: EditStatus.Applied;\n\t/**\n\t * The new revision produced by the transaction.\n\t */\n\treadonly after: RevisionView;\n}\n\n/**\n * The result of applying a change within a transaction.\n * @public\n */\nexport type ChangeResult = Result<TransactionView, TransactionFailure>;\n\n/**\n * The ongoing state of a transaction.\n * @public\n */\nexport type TransactionState = SucceedingTransactionState | FailingTransactionState;\n\n/**\n * The state of a transaction that has not encountered an error.\n */\nexport interface SucceedingTransactionState {\n\t/**\n\t * The current status of the transaction.\n\t */\n\treadonly status: EditStatus.Applied;\n\t/**\n\t * The view reflecting the latest applied change.\n\t */\n\treadonly view: TransactionView;\n\t/**\n\t * The applied changes so far.\n\t */\n\treadonly changes: readonly ChangeInternal[];\n\t/**\n\t * The editing steps applied so far.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n}\n\n/**\n * The state of a transaction that has encountered an error.\n */\nexport interface FailingTransactionState extends TransactionFailure {\n\t/**\n\t * The view reflecting the latest applied change.\n\t */\n\treadonly view: TransactionView;\n\t/**\n\t * The applied changes so far.\n\t */\n\treadonly changes: readonly ChangeInternal[];\n\t/**\n\t * The editing steps applied so far.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n}\n\n/**\n * The failure state of a transaction.\n */\nexport interface TransactionFailure {\n\t/**\n\t * The status indicating the kind of failure encountered.\n\t */\n\treadonly status: EditStatus.Invalid | EditStatus.Malformed;\n\t/**\n\t * Information about what caused the transaction to fail.\n\t */\n\treadonly failure: TransactionInternal.Failure;\n}\n\n/**\n * A mutable transaction for applying sequences of changes to a TreeView.\n * Allows viewing the intermediate states.\n *\n * Contains necessary state to apply changes within an edit to a TreeView.\n *\n * May have any number of changes applied to make up the edit.\n * Use `close` to complete the transaction, returning the array of changes and an EditingResult showing the\n * results of applying the changes as an Edit to the initial TreeView (passed to the constructor).\n *\n * No data outside the Transaction is modified by Transaction:\n * the results from `close` must be used to actually submit an `Edit`.\n */\nexport class GenericTransaction {\n\tprivate readonly policy: GenericTransactionPolicy;\n\tprotected readonly before: RevisionView;\n\tprivate state: TransactionState;\n\tprivate open = true;\n\n\t/**\n\t * Create and open an edit of the provided `TreeView`. After applying 0 or more changes, this editor should be closed via `close()`.\n\t * @param view - the `TreeView` at which this edit begins. The first change will be applied against this view.\n\t */\n\tpublic constructor(view: RevisionView, policy: GenericTransactionPolicy) {\n\t\tthis.before = view;\n\t\tthis.policy = policy;\n\t\tthis.state = {\n\t\t\tview: view.openForTransaction(),\n\t\t\tstatus: EditStatus.Applied,\n\t\t\tchanges: [],\n\t\t\tsteps: [],\n\t\t};\n\t}\n\n\t/** Whether or not this transaction has been closed via `close()` */\n\tpublic get isOpen(): boolean {\n\t\treturn this.open;\n\t}\n\n\t/**\n\t * The most up-to-date `TreeView` for this edit. This is the state of the tree after all changes applied so far.\n\t */\n\tpublic get view(): TransactionView {\n\t\treturn this.state.view;\n\t}\n\n\t/**\n\t * The status code of the most recent attempted change.\n\t */\n\tpublic get status(): EditStatus {\n\t\treturn this.state.status;\n\t}\n\n\t/**\n\t * The status code of the most recent attempted change.\n\t */\n\tpublic get changes(): readonly ChangeInternal[] {\n\t\treturn this.state.changes;\n\t}\n\n\t/**\n\t * The status code of the most recent attempted change.\n\t */\n\tpublic get steps(): readonly ReconciliationChange[] {\n\t\treturn this.state.steps;\n\t}\n\n\t/**\n\t * Information about why the transaction failed. Defined if and only if `status` is invalid or malformed.\n\t */\n\tpublic get failure(): TransactionInternal.Failure | undefined {\n\t\treturn (this.state as FailingTransactionState).failure;\n\t}\n\n\t/** @returns the final `EditStatus` and `TreeView` after all changes are applied. */\n\tpublic close(): EditingResult {\n\t\tassert(this.open, 'transaction has already been closed');\n\t\tthis.open = false;\n\t\tif (this.state.status === EditStatus.Applied) {\n\t\t\tconst validation = this.policy.validateOnClose(this.state);\n\t\t\tif (Result.isOk(validation)) {\n\t\t\t\tif (validation.result !== this.view) {\n\t\t\t\t\tthis.state = { ...this.state, view: validation.result };\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tstatus: EditStatus.Applied,\n\t\t\t\t\tsteps: this.steps,\n\t\t\t\t\tchanges: this.changes,\n\t\t\t\t\tbefore: this.before,\n\t\t\t\t\tafter: this.view.close(),\n\t\t\t\t};\n\t\t\t}\n\t\t\tthis.state = { ...this.state, ...validation.error };\n\t\t\treturn {\n\t\t\t\t...validation.error,\n\t\t\t\tsteps: this.steps,\n\t\t\t\tchanges: this.changes,\n\t\t\t\tbefore: this.before,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tstatus: this.state.status,\n\t\t\tfailure: this.state.failure,\n\t\t\tsteps: this.steps,\n\t\t\tchanges: this.changes,\n\t\t\tbefore: this.before,\n\t\t};\n\t}\n\n\t/**\n\t * A helper to apply a sequence of changes. Changes will be applied one after the other. If a change fails to apply,\n\t * the remaining changes in `changes` will be ignored.\n\t * @param changes - the sequence of changes to apply.\n\t * @param path - the reconciliation path for the first change.\n\t * @returns this\n\t */\n\tpublic applyChanges(changes: Iterable<ChangeInternal>, path: ReconciliationPath = []): this {\n\t\tconst iter = changes[Symbol.iterator]();\n\t\tconst firsChangeInternal = iter.next().value;\n\t\tlet iterResult = iter.next();\n\t\tif (iterResult.done === true) {\n\t\t\tfor (const change of changes) {\n\t\t\t\tif (this.applyChange(change, path).status !== EditStatus.Applied) {\n\t\t\t\t\treturn this;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\n\t\tif (this.applyChange(firsChangeInternal, path).status !== EditStatus.Applied) {\n\t\t\treturn this;\n\t\t}\n\n\t\tconst ongoingEdit = {\n\t\t\t0: this.steps[this.steps.length - 1],\n\t\t\tbefore: this.view,\n\t\t\tafter: this.view,\n\t\t\tlength: 1,\n\t\t};\n\n\t\t/**\n\t\t * We use a Proxy instead of `{ ...path, ...objectWithOngoingEdit }` to avoid eagerly demanding all parts of the path, which may\n\t\t * require extensive computation.\n\t\t */\n\t\tconst pathWithOngoingEdit = new Proxy(path, {\n\t\t\tget: (target: ReconciliationPath, prop: string): ReconciliationPath[number | 'length'] => {\n\t\t\t\tif (prop === 'length') {\n\t\t\t\t\treturn target.length + 1;\n\t\t\t\t}\n\t\t\t\treturn prop === String(target.length) ? ongoingEdit : target[prop];\n\t\t\t},\n\t\t});\n\n\t\twhile (iterResult.done !== true) {\n\t\t\tif (this.applyChange(iterResult.value, pathWithOngoingEdit).status !== EditStatus.Applied) {\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tongoingEdit[ongoingEdit.length] = this.steps[this.steps.length - 1];\n\t\t\tongoingEdit.length += 1;\n\t\t\tongoingEdit.after = this.view;\n\t\t\titerResult = iter.next();\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Attempt to apply the given change as part of this edit. This method should not be called if a previous change in this edit failed to\n\t * apply.\n\t * @param change - the change to apply\n\t * @param path - the reconciliation path for the change.\n\t * @returns this\n\t */\n\tpublic applyChange(change: ChangeInternal, path: ReconciliationPath = []): this {\n\t\tassert(this.open, 'Editor must be open to apply changes.');\n\t\tif (this.state.status !== EditStatus.Applied) {\n\t\t\tfail('Cannot apply change to an edit unless all previous changes have applied');\n\t\t}\n\t\tconst resolutionResult = this.policy.tryResolveChange(this.state, change, path);\n\t\tif (Result.isError(resolutionResult)) {\n\t\t\tthis.state = { ...this.state, ...resolutionResult.error };\n\t\t\treturn this;\n\t\t}\n\t\tconst resolvedChange = resolutionResult.result;\n\t\tconst changeResult = this.policy.dispatchChange(this.state, resolvedChange);\n\t\tthis.state = Result.isOk(changeResult)\n\t\t\t? {\n\t\t\t\t\tstatus: EditStatus.Applied,\n\t\t\t\t\tview: changeResult.result,\n\t\t\t\t\tchanges: this.changes.concat(change),\n\t\t\t\t\tsteps: this.steps.concat({ resolvedChange, after: changeResult.result }),\n\t\t\t }\n\t\t\t: {\n\t\t\t\t\t...this.state,\n\t\t\t\t\t...changeResult.error,\n\t\t\t };\n\t\treturn this;\n\t}\n}\n\n/**\n * An object that encapsulates the rules and state pertaining to a specific subclass of {@link GenericTransaction}.\n * The characteristics that define such a subclass (and an implementation of this interface) are:\n * - The type of change that can be applied\n * - How those changes impact the state of the tree\n * - How those changes are resolved in the face of concurrent changes\n * - What makes a transaction valid\n * - The kind of situations that might lead to a transaction failure\n *\n * Instances of this type are passed to the {@link GenericTransaction} constructor.\n */\nexport interface GenericTransactionPolicy {\n\t/**\n\t * Given a change, attempts to derive an equivalent change which can be applied to the current state even if the given change was issued\n\t * over a different state. This can be used to apply a sequence of changes that were issued concurrently, i.e., without knowledge of\n\t * each other.\n\t * @param state - The current state on which the returned change will be applied.\n\t * @param change - The original change issued.\n\t * @param path - The reconciliation path for the change.\n\t * @returns The change to be applied to the current state, or a failure if the change cannot be resolved.\n\t */\n\ttryResolveChange(\n\t\tstate: SucceedingTransactionState,\n\t\tchange: ChangeInternal,\n\t\tpath: ReconciliationPath\n\t): Result<ChangeInternal, TransactionFailure>;\n\n\t/**\n\t * Provides a new state given the current state and a change to apply.\n\t * @param state - The current state on which the change is applied.\n\t * @param change - The change to apply to the current state.\n\t * @returns The new state reflecting the applied change, or a failure.\n\t */\n\tdispatchChange(state: SucceedingTransactionState, change: ChangeInternal): ChangeResult;\n\n\t/**\n\t * Additional transaction validation when the transaction is closed.\n\t * @param state - The current state of the transaction.\n\t * @returns The new state reflecting the closed transaction, or a failure if the transaction cannot be closed.\n\t */\n\tvalidateOnClose(state: SucceedingTransactionState): ChangeResult;\n}\n\n/**\n * A mutable transaction for applying sequences of changes to a TreeView.\n * Allows viewing the intermediate states.\n *\n * Contains necessary state to apply changes within an edit to a TreeView.\n *\n * May have any number of changes applied to make up the edit.\n * Use `close` to complete the transaction, returning the array of changes and an EditingResult showing the\n * results of applying the changes as an Edit to the initial TreeView (passed to the constructor).\n *\n * No data outside the Transaction is modified by Transaction:\n * the results from `close` must be used to actually submit an `Edit`.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace TransactionInternal {\n\t/**\n\t * Makes a new {@link GenericTransaction} that follows the {@link TransactionInternal.Policy} policy.\n\t */\n\texport function factory(view: RevisionView): GenericTransaction {\n\t\treturn new GenericTransaction(view, new Policy());\n\t}\n\n\ttype ValidState = SucceedingTransactionState;\n\n\t/**\n\t * The policy followed by a {@link TransactionInternal}.\n\t */\n\texport class Policy implements GenericTransactionPolicy {\n\t\t/**\n\t\t * Maps detached sequences of nodes to their NodeIds\n\t\t */\n\t\tprotected readonly detached: Map<DetachedSequenceId, readonly NodeId[]> = new Map();\n\n\t\t/**\n\t\t * Resolves change with Result.Ok\n\t\t *\n\t\t * @param state - Unused\n\t\t * @param change - Change to resolve\n\t\t * @returns Result.Ok which contains change\n\t\t */\n\t\tpublic tryResolveChange(state: ValidState, change: ChangeInternal): Result.Ok<ChangeInternal> {\n\t\t\treturn Result.ok(change);\n\t\t}\n\n\t\t/**\n\t\t * Validates the transaction when it is closed\n\t\t *\n\t\t * @param state - Current state\n\t\t * @returns a {@link ChangeResult} containing either the change result or a Failure\n\t\t */\n\t\tpublic validateOnClose(state: ValidState): ChangeResult {\n\t\t\t// Making the policy choice that storing a detached sequences in an edit but not using it is an error.\n\t\t\treturn this.detached.size !== 0\n\t\t\t\t? Result.error({\n\t\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\t\tfailure: {\n\t\t\t\t\t\t\tkind: FailureKind.UnusedDetachedSequence,\n\t\t\t\t\t\t\tsequenceId: this.detached.keys().next().value,\n\t\t\t\t\t\t},\n\t\t\t\t })\n\t\t\t\t: Result.ok(state.view);\n\t\t}\n\n\t\t/**\n\t\t * Applies a given change\n\t\t *\n\t\t * @param state - Current state\n\t\t * @param change - Change to apply\n\t\t * @returns a {@link ChangeResult} containing either the change result or a Failure\n\t\t */\n\t\tpublic dispatchChange(state: ValidState, change: ChangeInternal): ChangeResult {\n\t\t\tswitch (change.type) {\n\t\t\t\tcase ChangeTypeInternal.Build:\n\t\t\t\t\treturn this.applyBuild(state, change);\n\t\t\t\tcase ChangeTypeInternal.Insert:\n\t\t\t\t\treturn this.applyInsert(state, change);\n\t\t\t\tcase ChangeTypeInternal.Detach:\n\t\t\t\t\treturn this.applyDetach(state, change);\n\t\t\t\tcase ChangeTypeInternal.Constraint:\n\t\t\t\t\treturn this.applyConstraint(state, change);\n\t\t\t\tcase ChangeTypeInternal.SetValue:\n\t\t\t\t\treturn this.applySetValue(state, change);\n\t\t\t\tdefault:\n\t\t\t\t\treturn fail('Attempted to apply unsupported change');\n\t\t\t}\n\t\t}\n\n\t\tprivate applyBuild(state: ValidState, change: BuildInternal): ChangeResult {\n\t\t\tif (this.detached.has(change.destination)) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.DetachedSequenceIdAlreadyInUse,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\tsequenceId: change.destination,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tlet idAlreadyPresent: NodeId | undefined;\n\t\t\tlet duplicateIdInBuild: NodeId | undefined;\n\t\t\tlet invalidId: NodeId | undefined;\n\t\t\tlet detachedSequenceNotFound: DetachedSequenceId | undefined;\n\t\t\tconst map = new Map<NodeId, TreeViewNode>();\n\t\t\tconst newIds = this.createViewNodesForTree(\n\t\t\t\tchange.source,\n\t\t\t\t(id, viewNode) => {\n\t\t\t\t\tif (map.has(id)) {\n\t\t\t\t\t\tduplicateIdInBuild = id;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tif (state.view.hasNode(viewNode.identifier)) {\n\t\t\t\t\t\tidAlreadyPresent = id;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tmap.set(id, viewNode);\n\t\t\t\t\treturn false;\n\t\t\t\t},\n\t\t\t\t(detachedId) => {\n\t\t\t\t\tdetachedSequenceNotFound = detachedId;\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif (idAlreadyPresent !== undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: { kind: FailureKind.IdAlreadyInUse, change, id: idAlreadyPresent },\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (duplicateIdInBuild !== undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\tfailure: { kind: FailureKind.DuplicateIdInBuild, change, id: duplicateIdInBuild },\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (invalidId !== undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: { kind: FailureKind.UnknownId, change, id: invalidId },\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (detachedSequenceNotFound !== undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.DetachedSequenceNotFound,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\tsequenceId: detachedSequenceNotFound,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst view = state.view.addNodes(map.values());\n\t\t\tthis.detached.set(\n\t\t\t\tchange.destination,\n\t\t\t\tnewIds ?? fail('Unhandled failure case in Transaction.createViewNodesForTree')\n\t\t\t);\n\t\t\treturn Result.ok(view);\n\t\t}\n\n\t\tprivate applyInsert(state: ValidState, change: InsertInternal): ChangeResult {\n\t\t\tconst source = this.detached.get(change.source);\n\t\t\tif (source === undefined) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.DetachedSequenceNotFound,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\tsequenceId: change.source,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst validatedDestination = validateStablePlace(state.view, change.destination);\n\t\t\tif (validatedDestination.result !== PlaceValidationResult.Valid) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus:\n\t\t\t\t\t\tvalidatedDestination.result === PlaceValidationResult.Malformed\n\t\t\t\t\t\t\t? EditStatus.Malformed\n\t\t\t\t\t\t\t: EditStatus.Invalid,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.BadPlace,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\tplace: change.destination,\n\t\t\t\t\t\tplaceFailure: validatedDestination.result,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tthis.detached.delete(change.source);\n\t\t\tconst view = insertIntoTrait(state.view, source, validatedDestination);\n\t\t\treturn Result.ok(view);\n\t\t}\n\n\t\tprivate applyDetach(state: ValidState, change: DetachInternal): ChangeResult {\n\t\t\tconst validatedSource = validateStableRange(state.view, change.source);\n\t\t\tif (validatedSource.result !== RangeValidationResultKind.Valid) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus:\n\t\t\t\t\t\tvalidatedSource.result === RangeValidationResultKind.PlacesInDifferentTraits ||\n\t\t\t\t\t\tvalidatedSource.result === RangeValidationResultKind.Inverted ||\n\t\t\t\t\t\tvalidatedSource.result.placeFailure !== PlaceValidationResult.Malformed\n\t\t\t\t\t\t\t? EditStatus.Invalid\n\t\t\t\t\t\t\t: EditStatus.Malformed,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.BadRange,\n\t\t\t\t\t\tchange,\n\t\t\t\t\t\trange: change.source,\n\t\t\t\t\t\trangeFailure: validatedSource.result,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst result = detachRange(state.view, validatedSource);\n\t\t\tlet modifiedView = result.view;\n\t\t\tconst { detached } = result;\n\n\t\t\t// Store or dispose detached\n\t\t\tif (change.destination !== undefined) {\n\t\t\t\tif (this.detached.has(change.destination)) {\n\t\t\t\t\treturn Result.error({\n\t\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\t\tfailure: {\n\t\t\t\t\t\t\tkind: FailureKind.DetachedSequenceIdAlreadyInUse,\n\t\t\t\t\t\t\tchange,\n\t\t\t\t\t\t\tsequenceId: change.destination,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthis.detached.set(change.destination, detached);\n\t\t\t} else {\n\t\t\t\tmodifiedView = modifiedView.deleteNodes(detached);\n\t\t\t}\n\t\t\treturn Result.ok(modifiedView);\n\t\t}\n\n\t\tprivate applyConstraint(state: ValidState, change: ConstraintInternal): ChangeResult {\n\t\t\t// TODO: Implement identityHash and contentHash\n\t\t\tassert(change.identityHash === undefined, 'identityHash constraint is not implemented');\n\t\t\tassert(change.contentHash === undefined, 'contentHash constraint is not implemented');\n\n\t\t\tconst validatedChange = validateStableRange(state.view, change.toConstrain);\n\t\t\tif (validatedChange.result !== RangeValidationResultKind.Valid) {\n\t\t\t\treturn validatedChange.result !== RangeValidationResultKind.PlacesInDifferentTraits &&\n\t\t\t\t\tvalidatedChange.result !== RangeValidationResultKind.Inverted &&\n\t\t\t\t\tvalidatedChange.result.placeFailure !== PlaceValidationResult.Malformed\n\t\t\t\t\t? change.effect === ConstraintEffect.ValidRetry\n\t\t\t\t\t\t? Result.ok(state.view)\n\t\t\t\t\t\t: Result.error({\n\t\t\t\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\t\t\t\tfailure: {\n\t\t\t\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadRange,\n\t\t\t\t\t\t\t\t\t\trangeFailure: validatedChange.result,\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 })\n\t\t\t\t\t: Result.error({\n\t\t\t\t\t\t\tstatus: EditStatus.Malformed,\n\t\t\t\t\t\t\tfailure: {\n\t\t\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadRange,\n\t\t\t\t\t\t\t\t\trangeFailure: validatedChange.result,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t });\n\t\t\t}\n\n\t\t\tconst { start, end } = rangeFromStableRange(state.view, validatedChange);\n\t\t\tconst startIndex = state.view.findIndexWithinTrait(start);\n\t\t\tconst endIndex = state.view.findIndexWithinTrait(end);\n\n\t\t\tif (change.length !== undefined && change.length !== endIndex - startIndex) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadLength,\n\t\t\t\t\t\t\tactual: endIndex - startIndex,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (change.parentNode !== undefined && change.parentNode !== end.trait.parent) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadParent,\n\t\t\t\t\t\t\tactual: change.parentNode,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (change.label !== undefined && change.label !== end.trait.label) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: {\n\t\t\t\t\t\tkind: FailureKind.ConstraintViolation,\n\t\t\t\t\t\tconstraint: change,\n\t\t\t\t\t\tviolation: {\n\t\t\t\t\t\t\tkind: ConstraintViolationKind.BadLabel,\n\t\t\t\t\t\t\tactual: end.trait.label,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn Result.ok(state.view);\n\t\t}\n\n\t\tprivate applySetValue(state: ValidState, change: SetValueInternal): ChangeResult {\n\t\t\tif (!state.view.hasNode(change.nodeToModify)) {\n\t\t\t\treturn Result.error({\n\t\t\t\t\tstatus: EditStatus.Invalid,\n\t\t\t\t\tfailure: { kind: FailureKind.UnknownId, change, id: change.nodeToModify },\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst newView = state.view.setNodeValue(change.nodeToModify, change.payload);\n\t\t\treturn Result.ok(newView);\n\t\t}\n\n\t\t/**\n\t\t * Generates tree view nodes from the supplied edit nodes.\n\t\t * Invokes onCreateNode for each new node, and halts creation early if it returns true.\n\t\t * Invokes onInvalidDetachedId and halts early for any invalid detached IDs referenced in the edit node sequence.\n\t\t * @returns all the top-level node IDs in `sequence` (both from nodes and from detached sequences).\n\t\t */\n\t\tprotected createViewNodesForTree(\n\t\t\tsequence: Iterable<BuildNodeInternal>,\n\t\t\tonCreateNode: (stableId: NodeId, node: TreeViewNode) => boolean,\n\t\t\tonInvalidDetachedId: (sequenceId: DetachedSequenceId) => void\n\t\t): NodeId[] | undefined {\n\t\t\tconst topLevelIds: NodeId[] = [];\n\t\t\tconst unprocessed: BuildNodeInternal[] = [];\n\t\t\tfor (const buildNode of sequence) {\n\t\t\t\tif (isDetachedSequenceId(buildNode)) {\n\t\t\t\t\tconst detachedIds = this.getDetachedNodeIds(buildNode, onInvalidDetachedId);\n\t\t\t\t\tif (detachedIds === undefined) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t\ttopLevelIds.push(...detachedIds);\n\t\t\t\t} else {\n\t\t\t\t\tunprocessed.push(buildNode);\n\t\t\t\t\ttopLevelIds.push(buildNode.identifier);\n\t\t\t\t}\n\t\t\t}\n\t\t\twhile (unprocessed.length > 0) {\n\t\t\t\tconst node = unprocessed.pop();\n\t\t\t\tassert(node !== undefined && !isDetachedSequenceId(node));\n\t\t\t\tconst traits = new Map<TraitLabel, readonly NodeId[]>();\n\t\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\t\tfor (const key in node.traits) {\n\t\t\t\t\tif (Object.prototype.hasOwnProperty.call(node.traits, key)) {\n\t\t\t\t\t\tconst children = node.traits[key];\n\t\t\t\t\t\tif (children.length > 0) {\n\t\t\t\t\t\t\tconst childIds: NodeId[] = [];\n\t\t\t\t\t\t\tfor (const child of children) {\n\t\t\t\t\t\t\t\tif (isDetachedSequenceId(child)) {\n\t\t\t\t\t\t\t\t\tconst detachedIds = this.getDetachedNodeIds(child, onInvalidDetachedId);\n\t\t\t\t\t\t\t\t\tif (detachedIds === undefined) {\n\t\t\t\t\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tchildIds.push(...detachedIds);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tchildIds.push(child.identifier);\n\t\t\t\t\t\t\t\t\tunprocessed.push(child);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttraits.set(key as TraitLabel, childIds);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst newNode: TreeViewNode = {\n\t\t\t\t\tidentifier: node.identifier,\n\t\t\t\t\tdefinition: node.definition,\n\t\t\t\t\ttraits,\n\t\t\t\t};\n\t\t\t\tcopyPropertyIfDefined(node, newNode, 'payload');\n\t\t\t\tif (onCreateNode(node.identifier, newNode)) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn topLevelIds;\n\t\t}\n\n\t\tprivate getDetachedNodeIds(\n\t\t\tdetachedId: DetachedSequenceId,\n\t\t\tonInvalidDetachedId: (sequenceId: DetachedSequenceId) => void\n\t\t): readonly NodeId[] | undefined {\n\t\t\t// Retrieve the detached sequence from the void.\n\t\t\tconst detachedNodeIds = this.detached.get(detachedId);\n\t\t\tif (detachedNodeIds === undefined) {\n\t\t\t\tonInvalidDetachedId(detachedId);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\t// Since we have retrieved the sequence, remove it from the void to prevent a second tree from multi-parenting it later\n\t\t\tthis.detached.delete(detachedId);\n\t\t\treturn detachedNodeIds;\n\t\t}\n\t}\n\n\t/**\n\t * The kinds of failures that a transaction might encounter.\n\t */\n\texport enum FailureKind {\n\t\t/**\n\t\t * Transaction has an unused DetachedSequenceId\n\t\t */\n\t\tUnusedDetachedSequence = 'UnusedDetachedSequence',\n\t\t/**\n\t\t * Transaction has a build operation using an already in use DetachedSequenceID.\n\t\t */\n\t\tDetachedSequenceIdAlreadyInUse = 'DetachedSequenceIdAlreadyInUse',\n\t\t/**\n\t\t * Transaction tries to operate on an unknown DetachedSequenceID\n\t\t */\n\t\tDetachedSequenceNotFound = 'DetachedSequenceNotFound',\n\t\t/**\n\t\t * Transaction has a build which uses a duplicated NodeId\n\t\t */\n\t\tDuplicateIdInBuild = 'DuplicateIdInBuild',\n\t\t/**\n\t\t * Transaction tries to build a node using an ID which is already used in the current state\n\t\t */\n\t\tIdAlreadyInUse = 'IdAlreadyInUse',\n\t\t/**\n\t\t * Transaction tries to set value of an unknown node\n\t\t */\n\t\tUnknownId = 'UnknownId',\n\t\t/**\n\t\t * Transaction tries to insert in an invalid Place\n\t\t */\n\t\tBadPlace = 'BadPlace',\n\t\t/**\n\t\t * Transaction tries to detach an invalid Range\n\t\t */\n\t\tBadRange = 'BadRange',\n\t\t/**\n\t\t * Transaction has an invalid constraint\n\t\t */\n\t\tConstraintViolation = 'ConstraintViolation',\n\t}\n\n\t/**\n\t * A failure encountered by a transaction.\n\t */\n\texport type Failure =\n\t\t| UnusedDetachedSequenceFailure\n\t\t| DetachedSequenceIdAlreadyInUseFailure\n\t\t| DetachedSequenceNotFoundFailure\n\t\t| DuplicateIdInBuildFailure\n\t\t| IdAlreadyInUseFailure\n\t\t| UnknownIdFailure\n\t\t| BadPlaceFailure\n\t\t| BadRangeFailure\n\t\t| ConstraintViolationFailure;\n\n\t/**\n\t * Error returned when a transaction is closed while there is an unused detached sequence.\n\t */\n\texport interface UnusedDetachedSequenceFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.UnusedDetachedSequence)\n\t\t */\n\t\treadonly kind: FailureKind.UnusedDetachedSequence;\n\t\t/**\n\t\t * The unused DetachedSequenceId\n\t\t */\n\t\treadonly sequenceId: DetachedSequenceId;\n\t}\n\n\t/**\n\t * Error thrown when a transaction encounters a build operation using an already in use DetachedSequenceID.\n\t */\n\texport interface DetachedSequenceIdAlreadyInUseFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.DetachedSequenceIdAlreadyInUse)\n\t\t */\n\t\treadonly kind: FailureKind.DetachedSequenceIdAlreadyInUse;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * The DetachedSequenceId that is already in use\n\t\t */\n\t\treadonly sequenceId: DetachedSequenceId;\n\t}\n\n\t/**\n\t * Error thrown when a transaction tries to operate on an unknown DetachedSequenceID\n\t */\n\texport interface DetachedSequenceNotFoundFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.DetachedSequenceNotFound)\n\t\t */\n\t\treadonly kind: FailureKind.DetachedSequenceNotFound;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * The DetachedSequenceId that wasn't found\n\t\t */\n\t\treadonly sequenceId: DetachedSequenceId;\n\t}\n\n\t/**\n\t * Error thrown when a build uses a duplicated NodeId\n\t */\n\texport interface DuplicateIdInBuildFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.DuplicateIdInBuild)\n\t\t */\n\t\treadonly kind: FailureKind.DuplicateIdInBuild;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * ID of duplicated node\n\t\t */\n\t\treadonly id: NodeId;\n\t}\n\n\t/**\n\t * Error thrown when a build node ID is already used in the current state\n\t */\n\texport interface IdAlreadyInUseFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.IdAlreadyInUse)\n\t\t */\n\t\treadonly kind: FailureKind.IdAlreadyInUse;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * ID of already in use node\n\t\t */\n\t\treadonly id: NodeId;\n\t}\n\n\t/**\n\t * Error thrown when a change is attempted on an unknown NodeId\n\t */\n\texport interface UnknownIdFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.UnknownId)\n\t\t */\n\t\treadonly kind: FailureKind.UnknownId;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * The unknown ID\n\t\t */\n\t\treadonly id: NodeId;\n\t}\n\n\t/**\n\t * Error thrown when an insert change uses an invalid Place\n\t */\n\texport interface BadPlaceFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.BadPlace)\n\t\t */\n\t\treadonly kind: FailureKind.BadPlace;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * The faulting place\n\t\t */\n\t\treadonly place: StablePlaceInternal;\n\t\t/**\n\t\t * The reason for the failure\n\t\t */\n\t\treadonly placeFailure: BadPlaceValidationResult;\n\t}\n\n\t/**\n\t * Error thrown when a detach operation is given an invalid or malformed Range\n\t */\n\texport interface BadRangeFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.BadRange)\n\t\t */\n\t\treadonly kind: FailureKind.BadRange;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly change: ChangeInternal;\n\t\t/**\n\t\t * Faulting range\n\t\t */\n\t\treadonly range: StableRangeInternal;\n\t\t/**\n\t\t * The reason for the failure\n\t\t */\n\t\treadonly rangeFailure: BadRangeValidationResult;\n\t}\n\n\t/**\n\t * Error thrown when a constraint fails to apply\n\t */\n\texport interface ConstraintViolationFailure {\n\t\t/**\n\t\t * Failure kind (will always be FailureKind.ConstraintViolation)\n\t\t */\n\t\treadonly kind: FailureKind.ConstraintViolation;\n\t\t/**\n\t\t * Faulting Change\n\t\t */\n\t\treadonly constraint: ConstraintInternal;\n\t\t/**\n\t\t * The first violation the constraint encounters (there may be others).\n\t\t */\n\t\treadonly violation: ConstraintViolationResult;\n\t}\n\n\t/**\n\t * The details of what kind of constraint was violated and caused a ConstraintViolationFailure error to occur\n\t */\n\texport type ConstraintViolationResult =\n\t\t| {\n\t\t\t\treadonly kind: ConstraintViolationKind.BadRange;\n\t\t\t\treadonly rangeFailure: BadRangeValidationResult;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: ConstraintViolationKind.BadLength;\n\t\t\t\treadonly actual: number;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: ConstraintViolationKind.BadParent;\n\t\t\t\treadonly actual: NodeId;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: ConstraintViolationKind.BadLabel;\n\t\t\t\treadonly actual: TraitLabel;\n\t\t };\n\n\t/**\n\t * Enum of possible kinds of constraint violations that can be encountered\n\t */\n\texport enum ConstraintViolationKind {\n\t\t/**\n\t\t * The constraint failed because it applies to an invalid range\n\t\t */\n\t\tBadRange = 'BadRange',\n\t\t/**\n\t\t * The constraint failed because the length prescribed by the constraint does not match the length of range being constrained\n\t\t */\n\t\tBadLength = 'BadLength',\n\t\t/**\n\t\t * The constraint failed because the parent prescribed by the constraint does not match the actual parent of the range being constrained\n\t\t */\n\t\tBadParent = 'BadParent',\n\t\t/**\n\t\t * The constraint failed because the trait label prescribed by the constraint does not match the actual trait label of the range being constrained\n\t\t */\n\t\tBadLabel = 'BadLabel',\n\t}\n}\n"]}
|
package/lib/Checkout.d.ts
CHANGED
|
@@ -121,11 +121,12 @@ export declare abstract class Checkout extends EventEmitterWithErrorHandling<ICh
|
|
|
121
121
|
* Ends the ongoing edit operation and commits it to the history.
|
|
122
122
|
*
|
|
123
123
|
* Malformed edits are considered an error, and will assert:
|
|
124
|
-
* All named detached sequences must have been used or
|
|
124
|
+
* All named detached sequences must have been used or the Edit is malformed.
|
|
125
125
|
*
|
|
126
126
|
* @returns the `id` of the committed edit
|
|
127
127
|
*/
|
|
128
128
|
closeEdit(): EditId;
|
|
129
|
+
private validateChangesApplied;
|
|
129
130
|
/**
|
|
130
131
|
* Inform the Checkout that a particular edit is know to have a specific result when applied to a particular TreeView.
|
|
131
132
|
* This may be used as a caching hint to avoid recomputation.
|
package/lib/Checkout.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkout.d.ts","sourceRoot":"","sources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