@fluid-experimental/tree 2.0.0-internal.8.0.0 → 2.0.0-rc.1.0.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/CHANGELOG.md +34 -0
- package/api-extractor-lint.json +1 -10
- package/api-extractor.json +0 -9
- package/api-report/experimental-tree.api.md +131 -130
- package/dist/ChangeTypes.d.ts +15 -15
- package/dist/ChangeTypes.js +4 -4
- package/dist/ChangeTypes.js.map +1 -1
- package/dist/Checkout.d.ts +4 -4
- package/dist/Checkout.js +3 -3
- package/dist/Checkout.js.map +1 -1
- package/dist/Common.d.ts +1 -1
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js.map +1 -1
- package/dist/EagerCheckout.d.ts +1 -1
- package/dist/EagerCheckout.js +1 -1
- package/dist/EagerCheckout.js.map +1 -1
- package/dist/EditLog.d.ts +3 -2
- package/dist/EditLog.d.ts.map +1 -1
- package/dist/EditLog.js +3 -5
- package/dist/EditLog.js.map +1 -1
- package/dist/EditUtilities.d.ts +5 -5
- package/dist/EditUtilities.js +2 -2
- package/dist/EditUtilities.js.map +1 -1
- package/dist/EventTypes.d.ts +1 -1
- package/dist/EventTypes.js +1 -1
- package/dist/EventTypes.js.map +1 -1
- package/dist/Forest.d.ts +4 -4
- package/dist/Forest.js +3 -6
- package/dist/Forest.js.map +1 -1
- package/dist/Identifiers.d.ts +14 -14
- package/dist/Identifiers.js.map +1 -1
- package/dist/InitialTree.d.ts +1 -1
- package/dist/InitialTree.js +1 -1
- package/dist/InitialTree.js.map +1 -1
- package/dist/LogViewer.d.ts +2 -2
- package/dist/LogViewer.js +1 -1
- package/dist/LogViewer.js.map +1 -1
- package/dist/NodeIdUtilities.d.ts +3 -3
- package/dist/NodeIdUtilities.js.map +1 -1
- package/dist/PayloadUtilities.d.ts +1 -1
- package/dist/PayloadUtilities.js +1 -1
- package/dist/PayloadUtilities.js.map +1 -1
- package/dist/ReconciliationPath.d.ts +3 -3
- package/dist/ReconciliationPath.js.map +1 -1
- package/dist/RevisionValueCache.d.ts +1 -1
- package/dist/RevisionValueCache.js +2 -2
- package/dist/RevisionValueCache.js.map +1 -1
- package/dist/RevisionView.d.ts +2 -2
- package/dist/RevisionView.js +2 -2
- package/dist/RevisionView.js.map +1 -1
- package/dist/SharedTree.d.ts +14 -14
- package/dist/SharedTree.js +2 -2
- package/dist/SharedTree.js.map +1 -1
- package/dist/Transaction.d.ts +3 -3
- package/dist/Transaction.js +2 -2
- package/dist/Transaction.js.map +1 -1
- package/dist/TransactionInternal.d.ts +17 -17
- package/dist/TransactionInternal.js +3 -3
- package/dist/TransactionInternal.js.map +1 -1
- package/dist/TreeView.d.ts +7 -7
- package/dist/TreeView.js +1 -1
- package/dist/TreeView.js.map +1 -1
- package/dist/id-compressor/IdCompressor.js +2 -5
- package/dist/id-compressor/IdCompressor.js.map +1 -1
- package/dist/migration-shim/migrationShim.d.ts +3 -3
- package/dist/migration-shim/migrationShim.d.ts.map +1 -1
- package/dist/migration-shim/migrationShim.js +9 -5
- package/dist/migration-shim/migrationShim.js.map +1 -1
- package/dist/migration-shim/migrationShimFactory.d.ts +2 -2
- package/dist/migration-shim/migrationShimFactory.d.ts.map +1 -1
- package/dist/migration-shim/migrationShimFactory.js.map +1 -1
- package/dist/migration-shim/sharedTreeShim.d.ts +4 -4
- package/dist/migration-shim/sharedTreeShim.d.ts.map +1 -1
- package/dist/migration-shim/sharedTreeShim.js +1 -1
- package/dist/migration-shim/sharedTreeShim.js.map +1 -1
- package/dist/migration-shim/sharedTreeShimFactory.d.ts +1 -2
- package/dist/migration-shim/sharedTreeShimFactory.d.ts.map +1 -1
- package/dist/migration-shim/sharedTreeShimFactory.js.map +1 -1
- package/dist/migration-shim/shimDeltaConnection.d.ts +16 -0
- package/dist/migration-shim/shimDeltaConnection.d.ts.map +1 -1
- package/dist/migration-shim/shimDeltaConnection.js +16 -2
- package/dist/migration-shim/shimDeltaConnection.js.map +1 -1
- package/dist/migration-shim/types.d.ts +1 -1
- package/dist/migration-shim/types.d.ts.map +1 -1
- package/dist/migration-shim/types.js.map +1 -1
- package/dist/persisted-types/0.0.2.d.ts +24 -24
- package/dist/persisted-types/0.0.2.js +5 -5
- package/dist/persisted-types/0.0.2.js.map +1 -1
- package/dist/persisted-types/0.1.1.d.ts +14 -14
- package/dist/persisted-types/0.1.1.js +3 -3
- package/dist/persisted-types/0.1.1.js.map +1 -1
- package/dist/tree-alpha.d.ts +2674 -119
- package/dist/tree-beta.d.ts +1 -50
- package/dist/tree-public.d.ts +1 -52
- package/dist/tree-untrimmed.d.ts +142 -143
- package/lib/ChangeTypes.d.ts +15 -15
- package/lib/ChangeTypes.js +4 -4
- package/lib/ChangeTypes.js.map +1 -1
- package/lib/Checkout.d.ts +4 -4
- package/lib/Checkout.js +3 -3
- package/lib/Checkout.js.map +1 -1
- package/lib/Common.d.ts +1 -1
- package/lib/Common.d.ts.map +1 -1
- package/lib/Common.js.map +1 -1
- package/lib/EagerCheckout.d.ts +1 -1
- package/lib/EagerCheckout.js +1 -1
- package/lib/EagerCheckout.js.map +1 -1
- package/lib/EditLog.d.ts +3 -2
- package/lib/EditLog.d.ts.map +1 -1
- package/lib/EditLog.js +2 -1
- package/lib/EditLog.js.map +1 -1
- package/lib/EditUtilities.d.ts +5 -5
- package/lib/EditUtilities.js +2 -2
- package/lib/EditUtilities.js.map +1 -1
- package/lib/EventTypes.d.ts +1 -1
- package/lib/EventTypes.js +1 -1
- package/lib/EventTypes.js.map +1 -1
- package/lib/Forest.d.ts +4 -4
- package/lib/Forest.js +2 -2
- package/lib/Forest.js.map +1 -1
- package/lib/Identifiers.d.ts +14 -14
- package/lib/Identifiers.js.map +1 -1
- package/lib/InitialTree.d.ts +1 -1
- package/lib/InitialTree.js +1 -1
- package/lib/InitialTree.js.map +1 -1
- package/lib/LogViewer.d.ts +2 -2
- package/lib/LogViewer.js +1 -1
- package/lib/LogViewer.js.map +1 -1
- package/lib/NodeIdUtilities.d.ts +3 -3
- package/lib/NodeIdUtilities.js.map +1 -1
- package/lib/PayloadUtilities.d.ts +1 -1
- package/lib/PayloadUtilities.js +1 -1
- package/lib/PayloadUtilities.js.map +1 -1
- package/lib/ReconciliationPath.d.ts +3 -3
- package/lib/ReconciliationPath.js.map +1 -1
- package/lib/RevisionValueCache.d.ts +1 -1
- package/lib/RevisionValueCache.js +1 -1
- package/lib/RevisionValueCache.js.map +1 -1
- package/lib/RevisionView.d.ts +2 -2
- package/lib/RevisionView.js +2 -2
- package/lib/RevisionView.js.map +1 -1
- package/lib/SharedTree.d.ts +14 -14
- package/lib/SharedTree.js +2 -2
- package/lib/SharedTree.js.map +1 -1
- package/lib/Transaction.d.ts +3 -3
- package/lib/Transaction.js +2 -2
- package/lib/Transaction.js.map +1 -1
- package/lib/TransactionInternal.d.ts +17 -17
- package/lib/TransactionInternal.js +3 -3
- package/lib/TransactionInternal.js.map +1 -1
- package/lib/TreeView.d.ts +7 -7
- package/lib/TreeView.js +1 -1
- package/lib/TreeView.js.map +1 -1
- package/lib/id-compressor/IdCompressor.js +1 -1
- package/lib/id-compressor/IdCompressor.js.map +1 -1
- package/lib/migration-shim/migrationShim.d.ts +3 -3
- package/lib/migration-shim/migrationShim.d.ts.map +1 -1
- package/lib/migration-shim/migrationShim.js +9 -5
- package/lib/migration-shim/migrationShim.js.map +1 -1
- package/lib/migration-shim/migrationShimFactory.d.ts +2 -2
- package/lib/migration-shim/migrationShimFactory.d.ts.map +1 -1
- package/lib/migration-shim/migrationShimFactory.js.map +1 -1
- package/lib/migration-shim/sharedTreeShim.d.ts +4 -4
- package/lib/migration-shim/sharedTreeShim.d.ts.map +1 -1
- package/lib/migration-shim/sharedTreeShim.js +1 -1
- package/lib/migration-shim/sharedTreeShim.js.map +1 -1
- package/lib/migration-shim/sharedTreeShimFactory.d.ts +1 -2
- package/lib/migration-shim/sharedTreeShimFactory.d.ts.map +1 -1
- package/lib/migration-shim/sharedTreeShimFactory.js.map +1 -1
- package/lib/migration-shim/shimDeltaConnection.d.ts +16 -0
- package/lib/migration-shim/shimDeltaConnection.d.ts.map +1 -1
- package/lib/migration-shim/shimDeltaConnection.js +16 -2
- package/lib/migration-shim/shimDeltaConnection.js.map +1 -1
- package/lib/migration-shim/types.d.ts +1 -1
- package/lib/migration-shim/types.d.ts.map +1 -1
- package/lib/migration-shim/types.js.map +1 -1
- package/lib/persisted-types/0.0.2.d.ts +24 -24
- package/lib/persisted-types/0.0.2.js +5 -5
- package/lib/persisted-types/0.0.2.js.map +1 -1
- package/lib/persisted-types/0.1.1.d.ts +14 -14
- package/lib/persisted-types/0.1.1.js +3 -3
- package/lib/persisted-types/0.1.1.js.map +1 -1
- package/lib/test/utilities/TestUtilities.d.ts +1 -2
- package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
- package/lib/test/utilities/TestUtilities.js.map +1 -1
- package/package.json +25 -25
- package/src/ChangeTypes.ts +15 -15
- package/src/Checkout.ts +4 -4
- package/src/Common.ts +1 -1
- package/src/EagerCheckout.ts +1 -1
- package/src/EditLog.ts +4 -3
- package/src/EditUtilities.ts +5 -5
- package/src/EventTypes.ts +1 -1
- package/src/Forest.ts +5 -5
- package/src/Identifiers.ts +14 -14
- package/src/InitialTree.ts +1 -1
- package/src/LogViewer.ts +2 -2
- package/src/NodeIdUtilities.ts +3 -3
- package/src/PayloadUtilities.ts +1 -1
- package/src/ReconciliationPath.ts +3 -3
- package/src/RevisionValueCache.ts +2 -2
- package/src/RevisionView.ts +2 -2
- package/src/SharedTree.ts +14 -14
- package/src/Transaction.ts +3 -3
- package/src/TransactionInternal.ts +17 -17
- package/src/TreeView.ts +7 -7
- package/src/id-compressor/IdCompressor.ts +1 -1
- package/src/migration-shim/migrationShim.ts +17 -9
- package/src/migration-shim/migrationShimFactory.ts +2 -2
- package/src/migration-shim/sharedTreeShim.ts +6 -5
- package/src/migration-shim/sharedTreeShimFactory.ts +1 -2
- package/src/migration-shim/shimDeltaConnection.ts +16 -2
- package/src/migration-shim/types.ts +1 -1
- package/src/persisted-types/0.0.2.ts +24 -24
- package/src/persisted-types/0.1.1.ts +14 -14
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type IEvent, type IFluidHandle, type IFluidLoadable } from '@fluidframework/core-interfaces';
|
|
2
|
-
import { type IChannelAttributes, type IChannelServices, type IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
|
|
2
|
+
import { IChannelFactory, type IChannelAttributes, type IChannelServices, type IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
|
|
3
3
|
import { type IExperimentalIncrementalSummaryContext, type IGarbageCollectionData, type ITelemetryContext, type ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
|
|
4
|
-
import { type
|
|
4
|
+
import { type ITree } from '@fluidframework/tree';
|
|
5
5
|
import { EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils';
|
|
6
6
|
import { type SharedTreeFactory as LegacySharedTreeFactory, type SharedTree as LegacySharedTree } from '../SharedTree';
|
|
7
7
|
import { type IShim } from './types.js';
|
|
@@ -56,7 +56,7 @@ export declare class MigrationShim extends EventEmitterWithErrorHandling<IMigrat
|
|
|
56
56
|
private readonly legacyTreeFactory;
|
|
57
57
|
private readonly newTreeFactory;
|
|
58
58
|
private readonly populateNewSharedObjectFn;
|
|
59
|
-
constructor(id: string, runtime: IFluidDataStoreRuntime, legacyTreeFactory: LegacySharedTreeFactory, newTreeFactory:
|
|
59
|
+
constructor(id: string, runtime: IFluidDataStoreRuntime, legacyTreeFactory: LegacySharedTreeFactory, newTreeFactory: IChannelFactory, populateNewSharedObjectFn: (legacyTree: LegacySharedTree, newTree: ITree) => void);
|
|
60
60
|
private readonly processMigrateOp;
|
|
61
61
|
private readonly migrationDeltaHandler;
|
|
62
62
|
private services?;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrationShim.d.ts","sourceRoot":"","sources":["../../src/migration-shim/migrationShim.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,Y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IACM,gBAAgB,CACtB,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,EAC9B,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,EAChC,gBAAgB,CAAC,EAAE,iBAAiB,GAAG,SAAS,GAC9C,qBAAqB;IAGX,SAAS,CACrB,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,EAC9B,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,EAChC,gBAAgB,CAAC,EAAE,iBAAiB,GAAG,SAAS,EAChD,yBAAyB,CAAC,EAAE,sCAAsC,GAAG,SAAS,GAC5E,OAAO,CAAC,qBAAqB,CAAC;IAG1B,UAAU,IAAI,OAAO;IAKrB,OAAO,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAMhD,OAAO,CAAC,SAAS;IAgBjB;;;;;;OAMG;IACH,OAAO,CAAC,wBAAwB;IAiBzB,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,sBAAsB;IAG/D,MAAM,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC;IAC3C,IAAW,cAAc,IAAI,cAAc,CAE1C;CACD"}
|
|
@@ -10,6 +10,7 @@ import { NoDeltasChannelServices } from './shimChannelServices.js';
|
|
|
10
10
|
import { MigrationShimDeltaHandler } from './migrationDeltaHandler.js';
|
|
11
11
|
import { PreMigrationDeltaConnection, StampDeltaConnection } from './shimDeltaConnection.js';
|
|
12
12
|
import { ShimHandle } from './shimHandle.js';
|
|
13
|
+
const ghostSessionId = '3692b242-46c0-4076-abea-c2ac1e896dee';
|
|
13
14
|
/**
|
|
14
15
|
* The MigrationShim loads in place of the legacy SharedTree. It provides API surface for migrating it to the new SharedTree, while also providing access to the current SharedTree for usage.
|
|
15
16
|
*
|
|
@@ -34,16 +35,19 @@ export class MigrationShim extends EventEmitterWithErrorHandling {
|
|
|
34
35
|
this.newTreeFactory = newTreeFactory;
|
|
35
36
|
this.populateNewSharedObjectFn = populateNewSharedObjectFn;
|
|
36
37
|
this.processMigrateOp = (message) => {
|
|
37
|
-
if (
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
|
|
39
|
-
message.type !== MessageType.Operation ||
|
|
40
|
-
message.contents.type !== 'barrier') {
|
|
38
|
+
if (message.type !== MessageType.Operation || message.contents.type !== 'barrier') {
|
|
41
39
|
return false;
|
|
42
40
|
}
|
|
43
41
|
const newTree = this.newTreeFactory.create(this.runtime, this.id);
|
|
44
42
|
assert(this.preMigrationDeltaConnection !== undefined, 0x82f /* Should be in v1 state */);
|
|
45
43
|
this.preMigrationDeltaConnection.disableSubmit();
|
|
46
|
-
this.
|
|
44
|
+
const { idCompressor } = this.runtime;
|
|
45
|
+
if (idCompressor !== undefined) {
|
|
46
|
+
idCompressor.beginGhostSession(ghostSessionId, () => this.populateNewSharedObjectFn(this.legacyTree, newTree));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this.populateNewSharedObjectFn(this.legacyTree, newTree);
|
|
50
|
+
}
|
|
47
51
|
this.newTree = newTree;
|
|
48
52
|
this.reconnect();
|
|
49
53
|
this.emit('migrated');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrationShim.js","sourceRoot":"","sources":["../../src/migration-shim/migrationShim.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAcpE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,WAAW,EAAkC,MAAM,sCAAsC,CAAC;AAEnG,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAErG,OAAO,EAA6B,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,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AAI,2BAA2B,CACjE,IAAI,CAAC,QAAQ,CAAC,eAAe,EAC7B,IAAI,CAAC,qBAAqB,CAC1B,CAAC;QACF,MAAM,YAAY,GAAyB;YAC1C,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,aAAa;YAC1C,eAAe,EAAE,IAAI,CAAC,2BAA2B;SACjD,CAAC;QACF,OAAO,YAAY,CAAC;IACrB,CAAC;IAEM,SAAS,CAAC,MAA4B;QAC5C,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { AttachState } from '@fluidframework/container-definitions';\nimport { type IEvent, type IFluidHandle, type IFluidLoadable } from '@fluidframework/core-interfaces';\nimport {\n\ttype IChannelAttributes,\n\ttype IChannelServices,\n\ttype IFluidDataStoreRuntime,\n} from '@fluidframework/datastore-definitions';\nimport {\n\ttype IExperimentalIncrementalSummaryContext,\n\ttype IGarbageCollectionData,\n\ttype ITelemetryContext,\n\ttype ISummaryTreeWithStats,\n} from '@fluidframework/runtime-definitions';\nimport { type TreeFactory, type ITree } from '@fluid-experimental/tree2';\nimport { assert } from '@fluidframework/core-utils';\nimport { MessageType, type ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';\nimport { type EventEmitterEventType } from '@fluid-internal/client-utils';\nimport { DataProcessingError, EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils';\nimport { type SharedTreeFactory as LegacySharedTreeFactory, type SharedTree as LegacySharedTree } from '../SharedTree';\nimport { type IShimChannelServices, NoDeltasChannelServices } from './shimChannelServices.js';\nimport { MigrationShimDeltaHandler } from './migrationDeltaHandler.js';\nimport { PreMigrationDeltaConnection, StampDeltaConnection } from './shimDeltaConnection.js';\nimport { ShimHandle } from './shimHandle.js';\nimport { type IShim, type IOpContents } from './types.js';\n\n/**\n * Interface for migration events to indicate the stage of the migration. There really is two stages: before, and after.\n *\n * @internal\n */\nexport interface IMigrationEvent extends IEvent {\n\t/**\n\t * Event that is emitted when the migration is complete.\n\t */\n\t(event: 'migrated', listener: () => void);\n}\n\n/**\n * Interface for migration operation.\n */\nexport interface IMigrationOp {\n\t/**\n\t * Type of the migration operation.\n\t */\n\ttype: 'barrier';\n\t/**\n\t * Old channel attributes so we can do verification and understand what changed. This will allow future clients to\n\t * accurately reason about what state of the document was before the migration op initiated at.\n\t */\n\toldAttributes: IChannelAttributes;\n\t/**\n\t * New channel attributes so we can do verification and understand what changed. This will allow future clients to\n\t * accurately reason about what the migration state of the new container is expected to be.\n\t */\n\tnewAttributes: IChannelAttributes;\n}\n\n/**\n * The MigrationShim loads in place of the legacy SharedTree. It provides API surface for migrating it to the new SharedTree, while also providing access to the current SharedTree for usage.\n *\n * @remarks\n *\n * This MigrationShim is responsible for submitting a migration op, processing the migrate op, swapping from the old\n * tree to the new tree, loading an old tree snapshot and creating an old tree.\n *\n * The MigrationShim expects to always load from a legacy SharedTree snapshot, though by the time it catches up in\n * processing all ops, it may find that the migration has already occurred. After migration occurs, it modifies its\n * attributes to point at the SharedTreeShimFactory. This will cause future clients to load with a SharedTreeShim and\n * the new SharedTree snapshot instead after the next summarization.\n *\n * @internal\n */\nexport class MigrationShim extends EventEmitterWithErrorHandling<IMigrationEvent> implements IShim {\n\tpublic constructor(\n\t\tpublic readonly id: string,\n\t\tprivate readonly runtime: IFluidDataStoreRuntime,\n\t\tprivate readonly legacyTreeFactory: LegacySharedTreeFactory,\n\t\tprivate readonly newTreeFactory: TreeFactory,\n\t\tprivate readonly populateNewSharedObjectFn: (legacyTree: LegacySharedTree, newTree: ITree) => void\n\t) {\n\t\tsuper((event: EventEmitterEventType, e: unknown) => this.eventListenerErrorHandler(event, e));\n\t\t// TODO: consider flattening this class\n\t\tthis.migrationDeltaHandler = new MigrationShimDeltaHandler(\n\t\t\tthis.processMigrateOp,\n\t\t\tthis.submitLocalMessage,\n\t\t\tthis.newTreeFactory.attributes\n\t\t);\n\t\tthis.handle = new ShimHandle<MigrationShim>(this);\n\t}\n\n\tprivate readonly processMigrateOp = (message: ISequencedDocumentMessage): boolean => {\n\t\tif (\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\t\tmessage.type !== MessageType.Operation ||\n\t\t\t(message.contents as Partial<IMigrationOp>).type !== 'barrier'\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\tconst newTree = this.newTreeFactory.create(this.runtime, this.id);\n\t\tassert(this.preMigrationDeltaConnection !== undefined, 0x82f /* Should be in v1 state */);\n\t\tthis.preMigrationDeltaConnection.disableSubmit();\n\t\tthis.populateNewSharedObjectFn(this.legacyTree, newTree);\n\t\tthis.newTree = newTree;\n\t\tthis.reconnect();\n\t\tthis.emit('migrated');\n\t\treturn true;\n\t};\n\n\tprivate readonly migrationDeltaHandler: MigrationShimDeltaHandler;\n\tprivate services?: IChannelServices;\n\tprivate preMigrationDeltaConnection?: PreMigrationDeltaConnection;\n\tprivate postMigrationServices?: IShimChannelServices;\n\n\tprivate _legacyTree: LegacySharedTree | undefined;\n\tprivate get legacyTree(): LegacySharedTree {\n\t\tassert(this._legacyTree !== undefined, 0x7e6 /* Old tree not initialized */);\n\t\treturn this._legacyTree;\n\t}\n\n\tprivate newTree: ITree | undefined;\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.closeError}\n\t */\n\tprivate closeError?: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>;\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.eventListenerErrorHandler}\n\t */\n\tprivate eventListenerErrorHandler(event: EventEmitterEventType, e: unknown): void {\n\t\tconst error = DataProcessingError.wrapIfUnrecognized(e, 'SharedObjectEventListenerException');\n\t\terror.addTelemetryProperties({ emittedEventName: String(event) });\n\n\t\tthis.closeWithError(error);\n\t\tthrow error;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.closeWithError}\n\t */\n\tprivate closeWithError(error: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>): void {\n\t\tif (this.closeError === undefined) {\n\t\t\tthis.closeError = error;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.verifyNotClosed}\n\t */\n\tprivate verifyNotClosed(): void {\n\t\tif (this.closeError !== undefined) {\n\t\t\tthrow this.closeError;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.submitLocalMessage}\n\t */\n\tprivate readonly submitLocalMessage = (message: IOpContents): void => {\n\t\tthis.verifyNotClosed();\n\t\t// This is a copy of submit local message from SharedObject\n\t\tif (this.isAttached()) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.services!.deltaConnection.submit(message, undefined);\n\t\t}\n\t};\n\n\t// Migration occurs once this op is read.\n\tpublic submitMigrateOp(): void {\n\t\tconst migrateOp: IMigrationOp = {\n\t\t\ttype: 'barrier',\n\t\t\toldAttributes: this.legacyTreeFactory.attributes,\n\t\t\tnewAttributes: this.newTreeFactory.attributes,\n\t\t};\n\n\t\tthis.submitLocalMessage(migrateOp);\n\t}\n\n\tpublic get currentTree(): LegacySharedTree | ITree {\n\t\treturn this.newTree ?? this.legacyTree;\n\t}\n\n\tpublic async load(services: IChannelServices): Promise<void> {\n\t\tconst shimServices =\n\t\t\tthis.runtime.attachState === AttachState.Detached\n\t\t\t\t? new NoDeltasChannelServices(services)\n\t\t\t\t: this.generateShimServicesOnce(services);\n\t\tthis._legacyTree = (await this.legacyTreeFactory.load(\n\t\t\tthis.runtime,\n\t\t\tthis.id,\n\t\t\tshimServices,\n\t\t\tthis.legacyTreeFactory.attributes\n\t\t)) as LegacySharedTree;\n\t}\n\tpublic create(): void {\n\t\tthis._legacyTree = this.legacyTreeFactory.create(this.runtime, this.id);\n\t}\n\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn this.currentTree.attributes;\n\t}\n\tpublic getAttachSummary(\n\t\tfullTree?: boolean | undefined,\n\t\ttrackState?: boolean | undefined,\n\t\ttelemetryContext?: ITelemetryContext | undefined\n\t): ISummaryTreeWithStats {\n\t\treturn this.currentTree.getAttachSummary(fullTree, trackState, telemetryContext);\n\t}\n\tpublic async summarize(\n\t\tfullTree?: boolean | undefined,\n\t\ttrackState?: boolean | undefined,\n\t\ttelemetryContext?: ITelemetryContext | undefined,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext | undefined\n\t): Promise<ISummaryTreeWithStats> {\n\t\treturn this.currentTree.summarize(fullTree, trackState, telemetryContext, incrementalSummaryContext);\n\t}\n\tpublic isAttached(): boolean {\n\t\treturn this.currentTree.isAttached();\n\t}\n\n\t// Only connect to the legacy shared tree\n\tpublic connect(services: IChannelServices): void {\n\t\tconst shimServices = this.generateShimServicesOnce(services);\n\t\tthis.legacyTree.connect(shimServices);\n\t}\n\n\t// Only reconnect to the new shared tree this limits us to only migrating\n\tprivate reconnect(): void {\n\t\tassert(this.services !== undefined, 0x7e7 /* Not connected */);\n\t\tassert(this.newTree !== undefined, 0x7e8 /* New tree not initialized */);\n\t\tassert(this.postMigrationServices === undefined, 0x830 /* Already reconnected! */);\n\t\t// This method attaches the newTree's delta handler to the MigrationShimDeltaHandler\n\t\tthis.postMigrationServices = {\n\t\t\tobjectStorage: this.services.objectStorage,\n\t\t\tdeltaConnection: new StampDeltaConnection(\n\t\t\t\tthis.services.deltaConnection,\n\t\t\t\tthis.migrationDeltaHandler,\n\t\t\t\tthis.newTree.attributes\n\t\t\t),\n\t\t};\n\t\tthis.newTree.connect(this.postMigrationServices);\n\t}\n\n\t/**\n\t * Only generate the ShimServices once as the underlying DeltaHandler can only be connected to once. If we connect\n\t * twice, we will be in a \"v2\" state even though we really are in a \"v1\" state. We will encounter unexpected op\n\t * dropping behavior or lack thereof and may corrupt the document.\n\t * @param services - the services to generate the shim services from\n\t * @returns - shim services\n\t */\n\tprivate generateShimServicesOnce(services: IChannelServices): IShimChannelServices {\n\t\tassert(\n\t\t\tthis.services === undefined && this.preMigrationDeltaConnection === undefined,\n\t\t\t0x7e9 /* Already connected */\n\t\t);\n\t\tthis.services = services;\n\t\tthis.preMigrationDeltaConnection = new PreMigrationDeltaConnection(\n\t\t\tthis.services.deltaConnection,\n\t\t\tthis.migrationDeltaHandler\n\t\t);\n\t\tconst shimServices: IShimChannelServices = {\n\t\t\tobjectStorage: this.services.objectStorage,\n\t\t\tdeltaConnection: this.preMigrationDeltaConnection,\n\t\t};\n\t\treturn shimServices;\n\t}\n\n\tpublic getGCData(fullGC?: boolean | undefined): IGarbageCollectionData {\n\t\treturn this.currentTree.getGCData(fullGC);\n\t}\n\tpublic handle: IFluidHandle<MigrationShim>;\n\tpublic get IFluidLoadable(): IFluidLoadable {\n\t\treturn this;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"migrationShim.js","sourceRoot":"","sources":["../../src/migration-shim/migrationShim.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAiBpE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,WAAW,EAAkC,MAAM,sCAAsC,CAAC;AAEnG,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAErG,OAAO,EAA6B,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAmC7C,MAAM,cAAc,GAAG,sCAAmD,CAAC;AAE3E;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,aAAc,SAAQ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I,IAAI,CAAC,2BAA2B,KAAK,SAAS,EAC7E,KAAK,CAAC,uBAAuB,CAC7B,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,2BAA2B,GAAG,IAAI,2BAA2B,CACjE,IAAI,CAAC,QAAQ,CAAC,eAAe,EAC7B,IAAI,CAAC,qBAAqB,CAC1B,CAAC;QACF,MAAM,YAAY,GAAyB;YAC1C,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,aAAa;YAC1C,eAAe,EAAE,IAAI,CAAC,2BAA2B;SACjD,CAAC;QACF,OAAO,YAAY,CAAC;IACrB,CAAC;IAEM,SAAS,CAAC,MAA4B;QAC5C,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { AttachState } from '@fluidframework/container-definitions';\nimport { type IEvent, type IFluidHandle, type IFluidLoadable } from '@fluidframework/core-interfaces';\nimport {\n\tIChannelFactory,\n\ttype IChannelAttributes,\n\ttype IChannelServices,\n\ttype IFluidDataStoreRuntime,\n} from '@fluidframework/datastore-definitions';\nimport {\n\ttype IExperimentalIncrementalSummaryContext,\n\ttype IGarbageCollectionData,\n\ttype ITelemetryContext,\n\ttype ISummaryTreeWithStats,\n\tIIdCompressorCore,\n\tSessionId,\n} from '@fluidframework/runtime-definitions';\nimport { type ITree } from '@fluidframework/tree';\nimport { assert } from '@fluidframework/core-utils';\nimport { MessageType, type ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';\nimport { type EventEmitterEventType } from '@fluid-internal/client-utils';\nimport { DataProcessingError, EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils';\nimport { type SharedTreeFactory as LegacySharedTreeFactory, type SharedTree as LegacySharedTree } from '../SharedTree';\nimport { type IShimChannelServices, NoDeltasChannelServices } from './shimChannelServices.js';\nimport { MigrationShimDeltaHandler } from './migrationDeltaHandler.js';\nimport { PreMigrationDeltaConnection, StampDeltaConnection } from './shimDeltaConnection.js';\nimport { ShimHandle } from './shimHandle.js';\nimport { type IShim, type IOpContents } from './types.js';\n\n/**\n * Interface for migration events to indicate the stage of the migration. There really is two stages: before, and after.\n *\n * @internal\n */\nexport interface IMigrationEvent extends IEvent {\n\t/**\n\t * Event that is emitted when the migration is complete.\n\t */\n\t(event: 'migrated', listener: () => void);\n}\n\n/**\n * Interface for migration operation.\n */\nexport interface IMigrationOp {\n\t/**\n\t * Type of the migration operation.\n\t */\n\ttype: 'barrier';\n\t/**\n\t * Old channel attributes so we can do verification and understand what changed. This will allow future clients to\n\t * accurately reason about what state of the document was before the migration op initiated at.\n\t */\n\toldAttributes: IChannelAttributes;\n\t/**\n\t * New channel attributes so we can do verification and understand what changed. This will allow future clients to\n\t * accurately reason about what the migration state of the new container is expected to be.\n\t */\n\tnewAttributes: IChannelAttributes;\n}\n\nconst ghostSessionId = '3692b242-46c0-4076-abea-c2ac1e896dee' as SessionId;\n\n/**\n * The MigrationShim loads in place of the legacy SharedTree. It provides API surface for migrating it to the new SharedTree, while also providing access to the current SharedTree for usage.\n *\n * @remarks\n *\n * This MigrationShim is responsible for submitting a migration op, processing the migrate op, swapping from the old\n * tree to the new tree, loading an old tree snapshot and creating an old tree.\n *\n * The MigrationShim expects to always load from a legacy SharedTree snapshot, though by the time it catches up in\n * processing all ops, it may find that the migration has already occurred. After migration occurs, it modifies its\n * attributes to point at the SharedTreeShimFactory. This will cause future clients to load with a SharedTreeShim and\n * the new SharedTree snapshot instead after the next summarization.\n *\n * @internal\n */\nexport class MigrationShim extends EventEmitterWithErrorHandling<IMigrationEvent> implements IShim {\n\tpublic constructor(\n\t\tpublic readonly id: string,\n\t\tprivate readonly runtime: IFluidDataStoreRuntime,\n\t\tprivate readonly legacyTreeFactory: LegacySharedTreeFactory,\n\t\tprivate readonly newTreeFactory: IChannelFactory,\n\t\tprivate readonly populateNewSharedObjectFn: (legacyTree: LegacySharedTree, newTree: ITree) => void\n\t) {\n\t\tsuper((event: EventEmitterEventType, e: unknown) => this.eventListenerErrorHandler(event, e));\n\t\t// TODO: consider flattening this class\n\t\tthis.migrationDeltaHandler = new MigrationShimDeltaHandler(\n\t\t\tthis.processMigrateOp,\n\t\t\tthis.submitLocalMessage,\n\t\t\tthis.newTreeFactory.attributes\n\t\t);\n\t\tthis.handle = new ShimHandle<MigrationShim>(this);\n\t}\n\n\tprivate readonly processMigrateOp = (message: ISequencedDocumentMessage): boolean => {\n\t\tif (message.type !== MessageType.Operation || (message.contents as Partial<IMigrationOp>).type !== 'barrier') {\n\t\t\treturn false;\n\t\t}\n\t\tconst newTree = this.newTreeFactory.create(this.runtime, this.id) as ITree;\n\t\tassert(this.preMigrationDeltaConnection !== undefined, 0x82f /* Should be in v1 state */);\n\t\tthis.preMigrationDeltaConnection.disableSubmit();\n\t\tconst { idCompressor } = this.runtime;\n\t\tif (idCompressor !== undefined) {\n\t\t\t(idCompressor as unknown as IIdCompressorCore).beginGhostSession(ghostSessionId, () =>\n\t\t\t\tthis.populateNewSharedObjectFn(this.legacyTree, newTree)\n\t\t\t);\n\t\t} else {\n\t\t\tthis.populateNewSharedObjectFn(this.legacyTree, newTree);\n\t\t}\n\t\tthis.newTree = newTree;\n\t\tthis.reconnect();\n\t\tthis.emit('migrated');\n\t\treturn true;\n\t};\n\n\tprivate readonly migrationDeltaHandler: MigrationShimDeltaHandler;\n\tprivate services?: IChannelServices;\n\tprivate preMigrationDeltaConnection?: PreMigrationDeltaConnection;\n\tprivate postMigrationServices?: IShimChannelServices;\n\n\tprivate _legacyTree: LegacySharedTree | undefined;\n\tprivate get legacyTree(): LegacySharedTree {\n\t\tassert(this._legacyTree !== undefined, 0x7e6 /* Old tree not initialized */);\n\t\treturn this._legacyTree;\n\t}\n\n\tprivate newTree: ITree | undefined;\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.closeError}\n\t */\n\tprivate closeError?: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>;\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.eventListenerErrorHandler}\n\t */\n\tprivate eventListenerErrorHandler(event: EventEmitterEventType, e: unknown): void {\n\t\tconst error = DataProcessingError.wrapIfUnrecognized(e, 'SharedObjectEventListenerException');\n\t\terror.addTelemetryProperties({ emittedEventName: String(event) });\n\n\t\tthis.closeWithError(error);\n\t\tthrow error;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.closeWithError}\n\t */\n\tprivate closeWithError(error: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>): void {\n\t\tif (this.closeError === undefined) {\n\t\t\tthis.closeError = error;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.verifyNotClosed}\n\t */\n\tprivate verifyNotClosed(): void {\n\t\tif (this.closeError !== undefined) {\n\t\t\tthrow this.closeError;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.submitLocalMessage}\n\t */\n\tprivate readonly submitLocalMessage = (message: IOpContents): void => {\n\t\tthis.verifyNotClosed();\n\t\t// This is a copy of submit local message from SharedObject\n\t\tif (this.isAttached()) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.services!.deltaConnection.submit(message, undefined);\n\t\t}\n\t};\n\n\t// Migration occurs once this op is read.\n\tpublic submitMigrateOp(): void {\n\t\tconst migrateOp: IMigrationOp = {\n\t\t\ttype: 'barrier',\n\t\t\toldAttributes: this.legacyTreeFactory.attributes,\n\t\t\tnewAttributes: this.newTreeFactory.attributes,\n\t\t};\n\n\t\tthis.submitLocalMessage(migrateOp);\n\t}\n\n\tpublic get currentTree(): LegacySharedTree | ITree {\n\t\treturn this.newTree ?? this.legacyTree;\n\t}\n\n\tpublic async load(services: IChannelServices): Promise<void> {\n\t\tconst shimServices =\n\t\t\tthis.runtime.attachState === AttachState.Detached\n\t\t\t\t? new NoDeltasChannelServices(services)\n\t\t\t\t: this.generateShimServicesOnce(services);\n\t\tthis._legacyTree = (await this.legacyTreeFactory.load(\n\t\t\tthis.runtime,\n\t\t\tthis.id,\n\t\t\tshimServices,\n\t\t\tthis.legacyTreeFactory.attributes\n\t\t)) as LegacySharedTree;\n\t}\n\tpublic create(): void {\n\t\tthis._legacyTree = this.legacyTreeFactory.create(this.runtime, this.id);\n\t}\n\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn this.currentTree.attributes;\n\t}\n\tpublic getAttachSummary(\n\t\tfullTree?: boolean | undefined,\n\t\ttrackState?: boolean | undefined,\n\t\ttelemetryContext?: ITelemetryContext | undefined\n\t): ISummaryTreeWithStats {\n\t\treturn this.currentTree.getAttachSummary(fullTree, trackState, telemetryContext);\n\t}\n\tpublic async summarize(\n\t\tfullTree?: boolean | undefined,\n\t\ttrackState?: boolean | undefined,\n\t\ttelemetryContext?: ITelemetryContext | undefined,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext | undefined\n\t): Promise<ISummaryTreeWithStats> {\n\t\treturn this.currentTree.summarize(fullTree, trackState, telemetryContext, incrementalSummaryContext);\n\t}\n\tpublic isAttached(): boolean {\n\t\treturn this.currentTree.isAttached();\n\t}\n\n\t// Only connect to the legacy shared tree\n\tpublic connect(services: IChannelServices): void {\n\t\tconst shimServices = this.generateShimServicesOnce(services);\n\t\tthis.legacyTree.connect(shimServices);\n\t}\n\n\t// Only reconnect to the new shared tree this limits us to only migrating\n\tprivate reconnect(): void {\n\t\tassert(this.services !== undefined, 0x7e7 /* Not connected */);\n\t\tassert(this.newTree !== undefined, 0x7e8 /* New tree not initialized */);\n\t\tassert(this.postMigrationServices === undefined, 0x830 /* Already reconnected! */);\n\t\t// This method attaches the newTree's delta handler to the MigrationShimDeltaHandler\n\t\tthis.postMigrationServices = {\n\t\t\tobjectStorage: this.services.objectStorage,\n\t\t\tdeltaConnection: new StampDeltaConnection(\n\t\t\t\tthis.services.deltaConnection,\n\t\t\t\tthis.migrationDeltaHandler,\n\t\t\t\tthis.newTree.attributes\n\t\t\t),\n\t\t};\n\t\tthis.newTree.connect(this.postMigrationServices);\n\t}\n\n\t/**\n\t * Only generate the ShimServices once as the underlying DeltaHandler can only be connected to once. If we connect\n\t * twice, we will be in a \"v2\" state even though we really are in a \"v1\" state. We will encounter unexpected op\n\t * dropping behavior or lack thereof and may corrupt the document.\n\t * @param services - the services to generate the shim services from\n\t * @returns - shim services\n\t */\n\tprivate generateShimServicesOnce(services: IChannelServices): IShimChannelServices {\n\t\tassert(\n\t\t\tthis.services === undefined && this.preMigrationDeltaConnection === undefined,\n\t\t\t0x7e9 /* Already connected */\n\t\t);\n\t\tthis.services = services;\n\t\tthis.preMigrationDeltaConnection = new PreMigrationDeltaConnection(\n\t\t\tthis.services.deltaConnection,\n\t\t\tthis.migrationDeltaHandler\n\t\t);\n\t\tconst shimServices: IShimChannelServices = {\n\t\t\tobjectStorage: this.services.objectStorage,\n\t\t\tdeltaConnection: this.preMigrationDeltaConnection,\n\t\t};\n\t\treturn shimServices;\n\t}\n\n\tpublic getGCData(fullGC?: boolean | undefined): IGarbageCollectionData {\n\t\treturn this.currentTree.getGCData(fullGC);\n\t}\n\tpublic handle: IFluidHandle<MigrationShim>;\n\tpublic get IFluidLoadable(): IFluidLoadable {\n\t\treturn this;\n\t}\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { type IChannelAttributes, type IFluidDataStoreRuntime, type IChannelServices, type IChannelFactory } from '@fluidframework/datastore-definitions';
|
|
6
|
-
import { type
|
|
6
|
+
import { type ITree } from '@fluidframework/tree';
|
|
7
7
|
import { type SharedTreeFactory as LegacySharedTreeFactory, type SharedTree as LegacySharedTree } from '../SharedTree';
|
|
8
8
|
import { MigrationShim } from './migrationShim.js';
|
|
9
9
|
/**
|
|
@@ -22,7 +22,7 @@ export declare class MigrationShimFactory implements IChannelFactory {
|
|
|
22
22
|
private readonly oldFactory;
|
|
23
23
|
private readonly newFactory;
|
|
24
24
|
private readonly populateNewChannelFn;
|
|
25
|
-
constructor(oldFactory: LegacySharedTreeFactory, newFactory:
|
|
25
|
+
constructor(oldFactory: LegacySharedTreeFactory, newFactory: IChannelFactory, populateNewChannelFn: (oldChannel: LegacySharedTree, newChannel: ITree) => void);
|
|
26
26
|
/**
|
|
27
27
|
* This factory takes over the type of the oldFactory to load in its place. The user must not include the MigrationShimFactory and the oldFactory in the same registry to avoid conflict.
|
|
28
28
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrationShimFactory.d.ts","sourceRoot":"","sources":["../../src/migration-shim/migrationShimFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"migrationShimFactory.d.ts","sourceRoot":"","sources":["../../src/migration-shim/migrationShimFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,KAAK,iBAAiB,IAAI,uBAAuB,EAAE,KAAK,UAAU,IAAI,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACvH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD;;;;;;;;;;;GAWG;AACH,qBAAa,oBAAqB,YAAW,eAAe;IAE1D,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,oBAAoB;gBAFpB,UAAU,EAAE,uBAAuB,EACnC,UAAU,EAAE,eAAe,EAC3B,oBAAoB,EAAE,CAAC,UAAU,EAAE,gBAAgB,EAAE,UAAU,EAAE,KAAK,KAAK,IAAI;IAGjG;;;;OAIG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;;;OAIG;IACH,IAAW,UAAU,IAAI,kBAAkB,CAE1C;IAED;;;;;OAKG;IACU,IAAI,CAChB,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAC5B,OAAO,CAAC,aAAa,CAAC;IAczB;;;;;;OAMG;IACI,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,aAAa;CAYzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrationShimFactory.js","sourceRoot":"","sources":["../../src/migration-shim/migrationShimFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AASpD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,oBAAoB;IAChC,YACkB,UAAmC,EACnC,
|
|
1
|
+
{"version":3,"file":"migrationShimFactory.js","sourceRoot":"","sources":["../../src/migration-shim/migrationShimFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AASpD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,oBAAoB;IAChC,YACkB,UAAmC,EACnC,UAA2B,EAC3B,oBAA+E;QAF/E,eAAU,GAAV,UAAU,CAAyB;QACnC,eAAU,GAAV,UAAU,CAAiB;QAC3B,yBAAoB,GAApB,oBAAoB,CAA2D;IAC9F,CAAC;IAEJ;;;;OAIG;IACH,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACH,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAE9B,mKAAmK;QACnK,MAAM,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACrG,MAAM,aAAa,GAAG,IAAI,aAAa,CACtC,EAAE,EACF,OAAO,EACP,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,oBAAoB,CACzB,CAAC;QACF,MAAM,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,aAAa,CAAC;IACtB,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,OAA+B,EAAE,EAAU;QACxD,oCAAoC;QACpC,MAAM,aAAa,GAAG,IAAI,aAAa,CACtC,EAAE,EACF,OAAO,EACP,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,oBAAoB,CACzB,CAAC;QACF,aAAa,CAAC,MAAM,EAAE,CAAC;QACvB,OAAO,aAAa,CAAC;IACtB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from '@fluidframework/core-utils';\nimport {\n\ttype IChannelAttributes,\n\ttype IFluidDataStoreRuntime,\n\ttype IChannelServices,\n\ttype IChannelFactory,\n} from '@fluidframework/datastore-definitions';\nimport { type ITree } from '@fluidframework/tree';\nimport { type SharedTreeFactory as LegacySharedTreeFactory, type SharedTree as LegacySharedTree } from '../SharedTree';\nimport { MigrationShim } from './migrationShim.js';\nimport { attributesMatch } from './utils.js';\n\n/**\n * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link MigrationShim}.\n *\n * Creates the migration shim that allows a migration from legacy shared tree to shared tree.\n * @remarks\n *\n * It takes over the attributes of the legacy factory, so that it is loaded instead of the normal legacy factory. Once migration finishes, the shim it produces will change its attributes to those of the new factory - meaning that on the next summarization the shim will write a summary that will cause future clients to load a different factory and shim (the SharedTreeShimFactory and SharedTreeShim).\n * 1. pre-migration\n *\n * @sealed\n * @internal\n */\nexport class MigrationShimFactory implements IChannelFactory {\n\tpublic constructor(\n\t\tprivate readonly oldFactory: LegacySharedTreeFactory,\n\t\tprivate readonly newFactory: IChannelFactory,\n\t\tprivate readonly populateNewChannelFn: (oldChannel: LegacySharedTree, newChannel: ITree) => void\n\t) {}\n\n\t/**\n\t * This factory takes over the type of the oldFactory to load in its place. The user must not include the MigrationShimFactory and the oldFactory in the same registry to avoid conflict.\n\t *\n\t * {@link @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\tpublic get type(): string {\n\t\treturn this.oldFactory.type;\n\t}\n\n\t/**\n\t * Should be the LegacySharedTree attributes\n\t *\n\t * {@link @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn this.oldFactory.attributes;\n\t}\n\n\t/**\n\t * {@link @fluidframework/datastore-definitions#IChannelFactory.load}\n\t *\n\t * Should be loading the MigrationShim - it should just load the old tree as this makes the factory's\n\t * responsibility simple. Trying to follow the Single Responsibility Principle here.\n\t */\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes\n\t): Promise<MigrationShim> {\n\t\t// TODO: remove attributes check and move it to an automated test that constructing a MigrationShimFactory and checking its attributes/type matches the oldFactory.\n\t\tassert(attributesMatch(attributes, this.oldFactory.attributes), 0x7ea /* Attributes do not match */);\n\t\tconst migrationShim = new MigrationShim(\n\t\t\tid,\n\t\t\truntime,\n\t\t\tthis.oldFactory,\n\t\t\tthis.newFactory,\n\t\t\tthis.populateNewChannelFn\n\t\t);\n\t\tawait migrationShim.load(services);\n\t\treturn migrationShim;\n\t}\n\n\t/**\n\t * {@link @fluidframework/datastore-definitions#IChannelFactory.create}\n\t *\n\t * Create MigrationShim that can hot swap from one DDS to a new DDS. We want the capability of creating an old tree\n\t * as when this code rolls out, there may be clients on the v1 version of the code, and we may want to have a dark\n\t * rollout capability.\n\t */\n\tpublic create(runtime: IFluidDataStoreRuntime, id: string): MigrationShim {\n\t\t// Maybe this should throw an error.\n\t\tconst migrationShim = new MigrationShim(\n\t\t\tid,\n\t\t\truntime,\n\t\t\tthis.oldFactory,\n\t\t\tthis.newFactory,\n\t\t\tthis.populateNewChannelFn\n\t\t);\n\t\tmigrationShim.create();\n\t\treturn migrationShim;\n\t}\n}\n"]}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { type IFluidHandle, type IFluidLoadable } from '@fluidframework/core-interfaces';
|
|
6
|
-
import { type IChannelAttributes, type IChannelServices, type IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
|
|
6
|
+
import { type IChannelFactory, type IChannelAttributes, type IChannelServices, type IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
|
|
7
7
|
import { type IExperimentalIncrementalSummaryContext, type IGarbageCollectionData, type ITelemetryContext, type ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
|
|
8
|
-
import { type ITree
|
|
8
|
+
import { type ITree } from '@fluidframework/tree';
|
|
9
9
|
import { type IShim } from './types.js';
|
|
10
10
|
/**
|
|
11
11
|
* SharedTreeShim is loaded by clients that join after the migration completes, and holds the new SharedTree.
|
|
@@ -21,8 +21,8 @@ import { type IShim } from './types.js';
|
|
|
21
21
|
export declare class SharedTreeShim implements IShim {
|
|
22
22
|
readonly id: string;
|
|
23
23
|
readonly runtime: IFluidDataStoreRuntime;
|
|
24
|
-
readonly sharedTreeFactory:
|
|
25
|
-
constructor(id: string, runtime: IFluidDataStoreRuntime, sharedTreeFactory:
|
|
24
|
+
readonly sharedTreeFactory: IChannelFactory;
|
|
25
|
+
constructor(id: string, runtime: IFluidDataStoreRuntime, sharedTreeFactory: IChannelFactory);
|
|
26
26
|
private readonly newTreeShimDeltaHandler;
|
|
27
27
|
private services?;
|
|
28
28
|
private _currentTree?;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedTreeShim.d.ts","sourceRoot":"","sources":["../../src/migration-shim/sharedTreeShim.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACzF,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,KAAK,sCAAsC,EAC3C,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,KAAK,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"sharedTreeShim.d.ts","sourceRoot":"","sources":["../../src/migration-shim/sharedTreeShim.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACzF,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,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MnC,IAAI,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAerD,MAAM,IAAI,IAAI;IAIrB,OAAO,CAAC,wBAAwB;IAczB,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,sBAAsB;CAGtE"}
|
|
@@ -53,7 +53,7 @@ export class SharedTreeShim {
|
|
|
53
53
|
const shimServices = this.runtime.attachState === AttachState.Detached
|
|
54
54
|
? new NoDeltasChannelServices(services)
|
|
55
55
|
: this.generateShimServicesOnce(services);
|
|
56
|
-
this._currentTree = await this.sharedTreeFactory.load(this.runtime, this.id, shimServices, this.sharedTreeFactory.attributes);
|
|
56
|
+
this._currentTree = (await this.sharedTreeFactory.load(this.runtime, this.id, shimServices, this.sharedTreeFactory.attributes));
|
|
57
57
|
}
|
|
58
58
|
create() {
|
|
59
59
|
this._currentTree = this.sharedTreeFactory.create(this.runtime, this.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedTreeShim.js","sourceRoot":"","sources":["../../src/migration-shim/sharedTreeShim.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sharedTreeShim.js","sourceRoot":"","sources":["../../src/migration-shim/sharedTreeShim.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAA6B,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C;;;;;;;;;;GAUG;AACH,MAAM,OAAO,cAAc;IAC1B,YACiB,EAAU,EACV,OAA+B,EAC/B,iBAAkC;QAFlC,OAAE,GAAF,EAAE,CAAQ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Y,GACjB,IAAI,CAAC,OAAO,CAAC,WAAW,KAAK,WAAW,CAAC,QAAQ;YAChD,CAAC,CAAC,IAAI,uBAAuB,CAAC,QAAQ,CAAC;YACvC,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,CAAC,YAAY,GAAG,CAAC,MAAM,IAAI,CAAC,iBAAiB,CAAC,IAAI,CACrD,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,EAAE,EACP,YAAY,EACZ,IAAI,CAAC,iBAAiB,CAAC,UAAU,CACjC,CAAU,CAAC;IACb,CAAC;IAEM,MAAM;QACZ,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAU,CAAC;IACnF,CAAC;IAEO,wBAAwB,CAAC,QAA0B;QAC1D,MAAM,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,KAAK,CAAC,uBAAuB,CAAC,CAAC;QACnE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,MAAM,YAAY,GAAG;YACpB,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,aAAa;YAC1C,eAAe,EAAE,IAAI,oBAAoB,CACxC,IAAI,CAAC,QAAQ,CAAC,eAAe,EAC7B,IAAI,CAAC,uBAAuB,EAC5B,IAAI,CAAC,iBAAiB,CAAC,UAAU,CACjC;SACD,CAAC;QACF,OAAO,YAAY,CAAC;IACrB,CAAC;IAEM,SAAS,CAAC,MAA4B;QAC5C,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { type IFluidHandle, type IFluidLoadable } from '@fluidframework/core-interfaces';\nimport {\n\ttype IChannelFactory,\n\ttype IChannelAttributes,\n\ttype IChannelServices,\n\ttype IFluidDataStoreRuntime,\n} from '@fluidframework/datastore-definitions';\nimport {\n\ttype IExperimentalIncrementalSummaryContext,\n\ttype IGarbageCollectionData,\n\ttype ITelemetryContext,\n\ttype ISummaryTreeWithStats,\n} from '@fluidframework/runtime-definitions';\nimport { type ITree } from '@fluidframework/tree';\nimport { AttachState } from '@fluidframework/container-definitions';\nimport { assert } from '@fluidframework/core-utils';\nimport { type IShimChannelServices, NoDeltasChannelServices } from './shimChannelServices.js';\nimport { SharedTreeShimDeltaHandler } from './sharedTreeDeltaHandler.js';\nimport { StampDeltaConnection } from './shimDeltaConnection.js';\nimport { ShimHandle } from './shimHandle.js';\nimport { type IShim } from './types.js';\n\n/**\n * SharedTreeShim is loaded by clients that join after the migration completes, and holds the new SharedTree.\n *\n * @remarks\n *\n * Its sole responsibility should be to drop v1 & migrate ops. It should not be responsible for any other migration\n * logic. This should make the classes easier to reason about.\n * about.\n *\n * @internal\n */\nexport class SharedTreeShim implements IShim {\n\tpublic constructor(\n\t\tpublic readonly id: string,\n\t\tpublic readonly runtime: IFluidDataStoreRuntime,\n\t\tpublic readonly sharedTreeFactory: IChannelFactory\n\t) {\n\t\tthis.newTreeShimDeltaHandler = new SharedTreeShimDeltaHandler(sharedTreeFactory.attributes);\n\t\tthis.handle = new ShimHandle<SharedTreeShim>(this);\n\t}\n\n\tprivate readonly newTreeShimDeltaHandler: SharedTreeShimDeltaHandler;\n\tprivate services?: IChannelServices;\n\tprivate _currentTree?: ITree;\n\tpublic get currentTree(): ITree {\n\t\tassert(this._currentTree !== undefined, 0x7ed /* No current tree initialized */);\n\t\treturn this._currentTree;\n\t}\n\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn this.currentTree.attributes;\n\t}\n\n\tpublic handle: IFluidHandle<SharedTreeShim>;\n\tpublic get IFluidLoadable(): IFluidLoadable {\n\t\treturn this;\n\t}\n\tpublic getAttachSummary(\n\t\tfullTree?: boolean | undefined,\n\t\ttrackState?: boolean | undefined,\n\t\ttelemetryContext?: ITelemetryContext | undefined\n\t): ISummaryTreeWithStats {\n\t\treturn this.currentTree.getAttachSummary(fullTree, trackState, telemetryContext);\n\t}\n\tpublic async summarize(\n\t\tfullTree?: boolean | undefined,\n\t\ttrackState?: boolean | undefined,\n\t\ttelemetryContext?: ITelemetryContext | undefined,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext | undefined\n\t): Promise<ISummaryTreeWithStats> {\n\t\treturn this.currentTree.summarize(fullTree, trackState, telemetryContext, incrementalSummaryContext);\n\t}\n\tpublic isAttached(): boolean {\n\t\treturn this.currentTree.isAttached();\n\t}\n\tpublic connect(services: IChannelServices): void {\n\t\tconst shimServices = this.generateShimServicesOnce(services);\n\t\treturn this.currentTree.connect(shimServices);\n\t}\n\n\t// The goal here is to mimic the SharedObject.load functionality\n\tpublic async load(services: IChannelServices): Promise<void> {\n\t\t// This weird shimServices logic is to enable rehydration of the SharedTreeShim from a snapshot in a detached\n\t\t// state.\n\t\tconst shimServices =\n\t\t\tthis.runtime.attachState === AttachState.Detached\n\t\t\t\t? new NoDeltasChannelServices(services)\n\t\t\t\t: this.generateShimServicesOnce(services);\n\t\tthis._currentTree = (await this.sharedTreeFactory.load(\n\t\t\tthis.runtime,\n\t\t\tthis.id,\n\t\t\tshimServices,\n\t\t\tthis.sharedTreeFactory.attributes\n\t\t)) as ITree;\n\t}\n\n\tpublic create(): void {\n\t\tthis._currentTree = this.sharedTreeFactory.create(this.runtime, this.id) as ITree;\n\t}\n\n\tprivate generateShimServicesOnce(services: IChannelServices): IShimChannelServices {\n\t\tassert(this.services === undefined, 0x7ee /* Already connected */);\n\t\tthis.services = services;\n\t\tconst shimServices = {\n\t\t\tobjectStorage: this.services.objectStorage,\n\t\t\tdeltaConnection: new StampDeltaConnection(\n\t\t\t\tthis.services.deltaConnection,\n\t\t\t\tthis.newTreeShimDeltaHandler,\n\t\t\t\tthis.sharedTreeFactory.attributes\n\t\t\t),\n\t\t};\n\t\treturn shimServices;\n\t}\n\n\tpublic getGCData(fullGC?: boolean | undefined): IGarbageCollectionData {\n\t\treturn this.currentTree.getGCData(fullGC);\n\t}\n}\n"]}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { type IChannelAttributes, type IFluidDataStoreRuntime, type IChannelServices, type IChannelFactory } from '@fluidframework/datastore-definitions';
|
|
6
|
-
import { type TreeFactory } from '@fluid-experimental/tree2';
|
|
7
6
|
import { SharedTreeShim } from './sharedTreeShim.js';
|
|
8
7
|
/**
|
|
9
8
|
* {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedTreeShim}.
|
|
@@ -20,7 +19,7 @@ import { SharedTreeShim } from './sharedTreeShim.js';
|
|
|
20
19
|
*/
|
|
21
20
|
export declare class SharedTreeShimFactory implements IChannelFactory {
|
|
22
21
|
private readonly factory;
|
|
23
|
-
constructor(factory:
|
|
22
|
+
constructor(factory: IChannelFactory);
|
|
24
23
|
/**
|
|
25
24
|
* Can only load the new SharedTree - this allows our snapshots to be simple. We do not have to consider any new
|
|
26
25
|
* unique snapshot formats and how to load from them.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedTreeShimFactory.d.ts","sourceRoot":"","sources":["../../src/migration-shim/sharedTreeShimFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"sharedTreeShimFactory.d.ts","sourceRoot":"","sources":["../../src/migration-shim/sharedTreeShimFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;;;;;;;;;;;GAYG;AACH,qBAAa,qBAAsB,YAAW,eAAe;IACzC,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,eAAe;IAE5D;;;;;OAKG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;;;;OAKG;IACH,IAAW,UAAU,IAAI,kBAAkB,CAE1C;IAED;;;;OAIG;IACU,IAAI,CAChB,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAC5B,OAAO,CAAC,cAAc,CAAC;IAQ1B;;;;;OAKG;IACI,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,cAAc;CAK1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedTreeShimFactory.js","sourceRoot":"","sources":["../../src/migration-shim/sharedTreeShimFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"sharedTreeShimFactory.js","sourceRoot":"","sources":["../../src/migration-shim/sharedTreeShimFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAQpD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,qBAAqB;IACjC,YAAoC,OAAwB;QAAxB,YAAO,GAAP,OAAO,CAAiB;IAAG,CAAC;IAEhE;;;;;OAKG;IACH,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED;;;;;OAKG;IACH,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAE9B,oKAAoK;QACpK,MAAM,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAClG,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACrE,MAAM,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpC,OAAO,cAAc,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,OAA+B,EAAE,EAAU;QACxD,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACrE,cAAc,CAAC,MAAM,EAAE,CAAC;QACxB,OAAO,cAAc,CAAC;IACvB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from '@fluidframework/core-utils';\nimport {\n\ttype IChannelAttributes,\n\ttype IFluidDataStoreRuntime,\n\ttype IChannelServices,\n\ttype IChannelFactory,\n} from '@fluidframework/datastore-definitions';\n\nimport { SharedTreeShim } from './sharedTreeShim.js';\nimport { attributesMatch } from './utils.js';\n\n/**\n * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedTreeShim}.\n *\n * Creates the migration shim that allows a migration from legacy shared tree to shared tree.\n * Note: There may be a need for 3 different factories for different parts of the migration.\n * That or three different shims. Potentially we can just do 2 as 2 and 3 can be combined.\n * 1. pre-migration\n * 2. after a summary has been generated but there may still be potential v1 ops\n * 3. post-migration after a summary has been generated and the msn has moved far enough forward for only v2 ops\n *\n * @sealed\n * @internal\n */\nexport class SharedTreeShimFactory implements IChannelFactory {\n\tpublic constructor(private readonly factory: IChannelFactory) {}\n\n\t/**\n\t * Can only load the new SharedTree - this allows our snapshots to be simple. We do not have to consider any new\n\t * unique snapshot formats and how to load from them.\n\t *\n\t * {@link @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\tpublic get type(): string {\n\t\treturn this.factory.type;\n\t}\n\n\t/**\n\t * Should be the new SharedTree attributes - this should indicate what type of tree snapshot we are expecting or\n\t * are capable of loading from.\n\t *\n\t * {@link @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn this.factory.attributes;\n\t}\n\n\t/**\n\t * {@link @fluidframework/datastore-definitions#IChannelFactory.load}\n\t *\n\t * Should be loading the SharedTreeShim from a new SharedTree snapshot only.\n\t */\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes\n\t): Promise<SharedTreeShim> {\n\t\t// TODO: remove attributes check and move it to an automated test that constructing a SharedTreeShimFactory and checking its attributes/type matches the oldFactory.\n\t\tassert(attributesMatch(attributes, this.factory.attributes), 0x7ef /* Attributes do not match */);\n\t\tconst sharedTreeShim = new SharedTreeShim(id, runtime, this.factory);\n\t\tawait sharedTreeShim.load(services);\n\t\treturn sharedTreeShim;\n\t}\n\n\t/**\n\t * {@link @fluidframework/datastore-definitions#IChannelFactory.create}\n\t *\n\t * Should be only creating the SharedTreeShim, which will only generate a new SharedTree snapshot. That way we do\n\t * not have the capability of accidentally creating a LegacySharedTree snapshot.\n\t */\n\tpublic create(runtime: IFluidDataStoreRuntime, id: string): SharedTreeShim {\n\t\tconst sharedTreeShim = new SharedTreeShim(id, runtime, this.factory);\n\t\tsharedTreeShim.create();\n\t\treturn sharedTreeShim;\n\t}\n}\n"]}
|
|
@@ -25,6 +25,14 @@ export declare class PreMigrationDeltaConnection implements IDeltaConnection {
|
|
|
25
25
|
submit(messageContent: unknown, localOpMetadata: unknown): void;
|
|
26
26
|
attach(handler: IDeltaHandler): void;
|
|
27
27
|
dirty(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Passes through to the underlying delta connection.
|
|
30
|
+
*
|
|
31
|
+
* @deprecated There is no replacement for this, its functionality is no longer needed at this layer.
|
|
32
|
+
* It will be removed in a future release, sometime after 2.0.0-internal.8.0.0
|
|
33
|
+
*
|
|
34
|
+
* @privateRemarks This needs to be more thoroughly thought through. What happens when the source handle is changed?
|
|
35
|
+
*/
|
|
28
36
|
addedGCOutboundReference?(srcHandle: IFluidHandle, outboundHandle: IFluidHandle): void;
|
|
29
37
|
}
|
|
30
38
|
/**
|
|
@@ -48,6 +56,14 @@ export declare class StampDeltaConnection implements IDeltaConnection {
|
|
|
48
56
|
*/
|
|
49
57
|
attach(handler: IDeltaHandler): void;
|
|
50
58
|
dirty(): void;
|
|
59
|
+
/**
|
|
60
|
+
* Passes through to the underlying delta connection.
|
|
61
|
+
*
|
|
62
|
+
* @deprecated There is no replacement for this, its functionality is no longer needed at this layer.
|
|
63
|
+
* It will be removed in a future release, sometime after 2.0.0-internal.8.0.0
|
|
64
|
+
*
|
|
65
|
+
* @privateRemarks This needs to be more thoroughly thought through. What happens when the source handle is changed?
|
|
66
|
+
*/
|
|
51
67
|
addedGCOutboundReference?(srcHandle: IFluidHandle, outboundHandle: IFluidHandle): void;
|
|
52
68
|
}
|
|
53
69
|
//# sourceMappingURL=shimDeltaConnection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shimDeltaConnection.d.ts","sourceRoot":"","sources":["../../src/migration-shim/shimDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,MAAM,uCAAuC,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AAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAUpC,KAAK,IAAI,IAAI;IAIpB;;;;;;;OAOG;IACI,wBAAwB,CAAC,CAAC,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,GAAG,IAAI;CAG7F;AAED;;GAEG;AACH,qBAAa,oBAAqB,YAAW,gBAAgB;IAE3D,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAFV,eAAe,EAAE,gBAAgB,EACjC,gBAAgB,EAAE,iBAAiB,EACnC,UAAU,EAAE,kBAAkB;IAGhD,IAAW,SAAS,IAAI,OAAO,CAE9B;IAGM,MAAM,CAAC,cAAc,EAAE,kBAAkB,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAQjF;;;;;;;;OAQG;IACI,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IASpC,KAAK,IAAI,IAAI;IAIpB;;;;;;;OAOG;IACI,wBAAwB,CAAC,CAAC,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,GAAG,IAAI;CAG7F"}
|
|
@@ -47,7 +47,14 @@ export class PreMigrationDeltaConnection {
|
|
|
47
47
|
dirty() {
|
|
48
48
|
this.deltaConnection.dirty();
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Passes through to the underlying delta connection.
|
|
52
|
+
*
|
|
53
|
+
* @deprecated There is no replacement for this, its functionality is no longer needed at this layer.
|
|
54
|
+
* It will be removed in a future release, sometime after 2.0.0-internal.8.0.0
|
|
55
|
+
*
|
|
56
|
+
* @privateRemarks This needs to be more thoroughly thought through. What happens when the source handle is changed?
|
|
57
|
+
*/
|
|
51
58
|
addedGCOutboundReference(srcHandle, outboundHandle) {
|
|
52
59
|
this.deltaConnection.addedGCOutboundReference?.(srcHandle, outboundHandle);
|
|
53
60
|
}
|
|
@@ -92,7 +99,14 @@ export class StampDeltaConnection {
|
|
|
92
99
|
dirty() {
|
|
93
100
|
this.deltaConnection.dirty();
|
|
94
101
|
}
|
|
95
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Passes through to the underlying delta connection.
|
|
104
|
+
*
|
|
105
|
+
* @deprecated There is no replacement for this, its functionality is no longer needed at this layer.
|
|
106
|
+
* It will be removed in a future release, sometime after 2.0.0-internal.8.0.0
|
|
107
|
+
*
|
|
108
|
+
* @privateRemarks This needs to be more thoroughly thought through. What happens when the source handle is changed?
|
|
109
|
+
*/
|
|
96
110
|
addedGCOutboundReference(srcHandle, outboundHandle) {
|
|
97
111
|
this.deltaConnection.addedGCOutboundReference?.(srcHandle, outboundHandle);
|
|
98
112
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shimDeltaConnection.js","sourceRoot":"","sources":["../../src/migration-shim/shimDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGpD;;;;;;;;;GASG;AACH,MAAM,OAAO,2BAA2B;IACvC,YACkB,eAAiC,EACjC,gBAAmC;QADnC,oBAAe,GAAf,eAAe,CAAkB;QACjC,qBAAgB,GAAhB,gBAAgB,CAAmB;QAO7C,cAAS,GAAG,IAAI,CAAC;IANtB,CAAC;IAEJ,IAAW,SAAS;QACnB,OAAO,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC;IACvC,CAAC;IAGM,aAAa;QACnB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACxB,CAAC;IAED,gCAAgC;IACzB,MAAM,CAAC,cAAuB,EAAE,eAAwB;QAC9D,IAAI,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC;SAC7D;QACD,gFAAgF;IACjF,CAAC;IAED,mHAAmH;IACnH,uEAAuE;IAChE,MAAM,CAAC,OAAsB;QACnC,wGAAwG;QACxG,6GAA6G;QAC7G,+EAA+E;QAC/E,IAAI,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;QACtD,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE;YACpC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YACnD,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,CAAC;SACrC;IACF,CAAC;IACM,KAAK;QACX,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"shimDeltaConnection.js","sourceRoot":"","sources":["../../src/migration-shim/shimDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGpD;;;;;;;;;GASG;AACH,MAAM,OAAO,2BAA2B;IACvC,YACkB,eAAiC,EACjC,gBAAmC;QADnC,oBAAe,GAAf,eAAe,CAAkB;QACjC,qBAAgB,GAAhB,gBAAgB,CAAmB;QAO7C,cAAS,GAAG,IAAI,CAAC;IANtB,CAAC;IAEJ,IAAW,SAAS;QACnB,OAAO,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC;IACvC,CAAC;IAGM,aAAa;QACnB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACxB,CAAC;IAED,gCAAgC;IACzB,MAAM,CAAC,cAAuB,EAAE,eAAwB;QAC9D,IAAI,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC;SAC7D;QACD,gFAAgF;IACjF,CAAC;IAED,mHAAmH;IACnH,uEAAuE;IAChE,MAAM,CAAC,OAAsB;QACnC,wGAAwG;QACxG,6GAA6G;QAC7G,+EAA+E;QAC/E,IAAI,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;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I,CAAC,gBAAgB,CAAC,CAAC;YACnD,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,CAAC;SACrC;IACF,CAAC;IAEM,KAAK;QACX,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;IAED;;;;;;;OAOG;IACI,wBAAwB,CAAE,SAAuB,EAAE,cAA4B;QACrF,IAAI,CAAC,eAAe,CAAC,wBAAwB,EAAE,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;IAC5E,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type IFluidHandle } from '@fluidframework/core-interfaces';\nimport {\n\ttype IChannelAttributes,\n\ttype IDeltaConnection,\n\ttype IDeltaHandler,\n} from '@fluidframework/datastore-definitions';\nimport { assert } from '@fluidframework/core-utils';\nimport { type IUnstampedContents, type IShimDeltaHandler } from './types.js';\n\n/**\n * Represents a connection to a Shim data store that can receive and submit deltas.\n *\n * This allows the Shim class to swap out the delta handler on the fly.\n *\n * The PreMigrationDeltaConnection does not stamp ops so that those ops can be considered v1 ops.\n *\n * This special logic allows for connect to be called for the underlying new SharedObject without the need for\n * modifications on the current ChannelDeltaConnection.\n */\nexport class PreMigrationDeltaConnection implements IDeltaConnection {\n\tpublic constructor(\n\t\tprivate readonly deltaConnection: IDeltaConnection,\n\t\tprivate readonly shimDeltaHandler: IShimDeltaHandler\n\t) {}\n\n\tpublic get connected(): boolean {\n\t\treturn this.deltaConnection.connected;\n\t}\n\n\tprivate canSubmit = true;\n\tpublic disableSubmit(): void {\n\t\tthis.canSubmit = false;\n\t}\n\n\t// This is for submitting v1 ops\n\tpublic submit(messageContent: unknown, localOpMetadata: unknown): void {\n\t\tif (this.canSubmit) {\n\t\t\tthis.deltaConnection.submit(messageContent, localOpMetadata);\n\t\t}\n\t\t// We don't want to throw so we can revert local changes on the LegacySharedTree\n\t}\n\n\t// We only want to call attach on the underlying delta connection once, as we'll hit an assert if we call it twice.\n\t// Note: SharedObject.load calls attach as well as SharedObject.connect\n\tpublic attach(handler: IDeltaHandler): void {\n\t\t// There are essentially two delta handlers that process ops, the shim delta handler to process shim ops\n\t\t// preventing them from being processed by the tree delta handler, and the tree delta handler to process tree\n\t\t// ops. Post migration v1 ops can be considered \"shim\" ops as they are dropped.\n\t\tthis.shimDeltaHandler.attachTreeDeltaHandler(handler);\n\t\tif (!this.shimDeltaHandler.attached) {\n\t\t\tthis.deltaConnection.attach(this.shimDeltaHandler);\n\t\t\tthis.shimDeltaHandler.markAttached();\n\t\t}\n\t}\n\tpublic dirty(): void {\n\t\tthis.deltaConnection.dirty();\n\t}\n\n\t/**\n\t * Passes through to the underlying delta connection.\n\t *\n\t * @deprecated There is no replacement for this, its functionality is no longer needed at this layer.\n\t * It will be removed in a future release, sometime after 2.0.0-internal.8.0.0\n\t *\n\t * @privateRemarks This needs to be more thoroughly thought through. What happens when the source handle is changed?\n\t */\n\tpublic addedGCOutboundReference?(srcHandle: IFluidHandle, outboundHandle: IFluidHandle): void {\n\t\tthis.deltaConnection.addedGCOutboundReference?.(srcHandle, outboundHandle);\n\t}\n}\n\n/**\n * A delta connection that stamps ops with a particular channel attributes so that those ops won't get dropped\n */\nexport class StampDeltaConnection implements IDeltaConnection {\n\tpublic constructor(\n\t\tprivate readonly deltaConnection: IDeltaConnection,\n\t\tprivate readonly shimDeltaHandler: IShimDeltaHandler,\n\t\tprivate readonly attributes: IChannelAttributes\n\t) {}\n\n\tpublic get connected(): boolean {\n\t\treturn this.deltaConnection.connected;\n\t}\n\n\t// This is for submitting v2 ops\n\tpublic submit(messageContent: IUnstampedContents, localOpMetadata: unknown): void {\n\t\tassert(messageContent.fluidMigrationStamp === undefined, 0x835 /* Should not be stamping ops twice! */);\n\t\tmessageContent.fluidMigrationStamp = {\n\t\t\t...this.attributes,\n\t\t};\n\t\tthis.deltaConnection.submit(messageContent, localOpMetadata);\n\t}\n\n\t/**\n\t * For the MigrationShim because we only attach once to the actual delta connection, we store state in the\n\t * migrationDeltaHandler to know if we've already attached. We will call attach once on the\n\t * PreMigrationDeltaConnection and once on the StampDeltaConnection.\n\t *\n\t * The SharedTreeShim should not be swapping delta connections and thus the if statement should always be executed.\n\t *\n\t * @param handler - this delta handler can only connect once.\n\t */\n\tpublic attach(handler: IDeltaHandler): void {\n\t\t// Maybe put an assert here to only call attach once?\n\t\tthis.shimDeltaHandler.attachTreeDeltaHandler(handler);\n\t\tif (!this.shimDeltaHandler.attached) {\n\t\t\tthis.deltaConnection.attach(this.shimDeltaHandler);\n\t\t\tthis.shimDeltaHandler.markAttached();\n\t\t}\n\t}\n\n\tpublic dirty(): void {\n\t\tthis.deltaConnection.dirty();\n\t}\n\n\t/**\n\t * Passes through to the underlying delta connection.\n\t *\n\t * @deprecated There is no replacement for this, its functionality is no longer needed at this layer.\n\t * It will be removed in a future release, sometime after 2.0.0-internal.8.0.0\n\t *\n\t * @privateRemarks This needs to be more thoroughly thought through. What happens when the source handle is changed?\n\t */\n\tpublic addedGCOutboundReference?(srcHandle: IFluidHandle, outboundHandle: IFluidHandle): void {\n\t\tthis.deltaConnection.addedGCOutboundReference?.(srcHandle, outboundHandle);\n\t}\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { type ITree } from '@
|
|
5
|
+
import { type ITree } from '@fluidframework/tree';
|
|
6
6
|
import { type IChannel, type IChannelAttributes, type IChannelServices, type IDeltaHandler } from '@fluidframework/datastore-definitions';
|
|
7
7
|
import { type SharedTree as LegacySharedTree } from '../SharedTree';
|
|
8
8
|
import { type IMigrationOp } from './migrationShim.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/migration-shim/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,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C;CACtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/migration-shim/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type ITree } from '@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/migration-shim/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type ITree } from '@fluidframework/tree';\nimport {\n\ttype IChannel,\n\ttype IChannelAttributes,\n\ttype IChannelServices,\n\ttype IDeltaHandler,\n} from '@fluidframework/datastore-definitions';\nimport { type SharedTree as LegacySharedTree } from '../SharedTree';\nimport { type IMigrationOp } from './migrationShim.js';\n\n/**\n * An interface for a shim delta handler intercepts another delta handler.\n *\n * @internal\n */\nexport interface IShimDeltaHandler extends IDeltaHandler {\n\t/**\n\t * Provide the real tree delta handler (either legacy or new) to the shim that will be used to process the tree ops.\n\t * @param treeDeltaHandler - The appropriate tree delta handler.\n\t */\n\tattachTreeDeltaHandler(treeDeltaHandler: IDeltaHandler): void;\n\n\t/**\n\t * The delta handler needs to be attached to the IShimDeltaHandler before attaching it to the delta connection.\n\t * Otherwise the IShimDeltaHandler will not be able to process ops.\n\t */\n\thasTreeDeltaHandler(): boolean;\n\n\tattached: boolean;\n\n\tmarkAttached(): void;\n}\n\n/**\n * A v1 op or a v2 unstamped op\n */\nexport interface IUnstampedContents {\n\tfluidMigrationStamp?: IChannelAttributes;\n\t[key: string | number]: unknown;\n}\n\n/**\n * A v2 op will have a `fluidMigrationStamp` property. This is a type guard to check if the op is a v2 op.\n */\nexport interface IStampedContents {\n\tfluidMigrationStamp: IChannelAttributes;\n\t[key: string | number]: unknown;\n}\n\n/**\n * A type for interrogating ops to see if they are v2 stamped ops or migrate ops. Otherwise, we try not to care\n * what the contents of the op are. The contents could be of type `any` or `unknown`.\n *\n * If `type` specifically === \"barrier\", then we know we are dealing with a barrier op\n *\n * If `fluidMigrationStamp` is present, then we know we are dealing with a v2 op\n *\n * @internal\n */\nexport type IOpContents = IStampedContents | IUnstampedContents | IMigrationOp;\n\n/**\n * An interface for a shim channel that intercepts a LegacySharedTree or new SharedTree DDS.\n *\n * @internal\n */\nexport interface IShim extends IChannel {\n\tcreate(): void;\n\tload(channelServices: IChannelServices): Promise<void>;\n\tcurrentTree: ITree | LegacySharedTree;\n}\n"]}
|