@fluidframework/datastore 2.0.0-rc.1.0.3 → 2.0.0-rc.2.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/{.eslintrc.js → .eslintrc.cjs} +4 -1
- package/{.mocharc.js → .mocharc.cjs} +1 -1
- package/CHANGELOG.md +42 -0
- package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
- package/api-extractor-lint.json +1 -1
- package/api-extractor.json +1 -1
- package/api-report/datastore.api.md +5 -11
- package/dist/channelContext.d.ts +5 -4
- package/dist/channelContext.d.ts.map +1 -1
- package/dist/channelContext.js +6 -5
- package/dist/channelContext.js.map +1 -1
- package/dist/channelDeltaConnection.d.ts +6 -3
- package/dist/channelDeltaConnection.d.ts.map +1 -1
- package/dist/channelDeltaConnection.js +46 -7
- package/dist/channelDeltaConnection.js.map +1 -1
- package/dist/dataStoreRuntime.d.ts +24 -6
- package/dist/dataStoreRuntime.d.ts.map +1 -1
- package/dist/dataStoreRuntime.js +103 -36
- package/dist/dataStoreRuntime.js.map +1 -1
- package/dist/datastore-alpha.d.ts +22 -6
- package/dist/datastore-beta.d.ts +1 -2
- package/dist/datastore-public.d.ts +1 -2
- package/dist/datastore-untrimmed.d.ts +22 -6
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/localChannelContext.d.ts +18 -3
- package/dist/localChannelContext.d.ts.map +1 -1
- package/dist/localChannelContext.js +32 -10
- package/dist/localChannelContext.js.map +1 -1
- package/dist/package.json +3 -0
- package/dist/remoteChannelContext.d.ts +2 -2
- package/dist/remoteChannelContext.d.ts.map +1 -1
- package/dist/remoteChannelContext.js +6 -5
- package/dist/remoteChannelContext.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/{channelContext.d.mts → channelContext.d.ts} +6 -5
- package/lib/channelContext.d.ts.map +1 -0
- package/lib/{channelContext.mjs → channelContext.js} +6 -5
- package/lib/channelContext.js.map +1 -0
- package/lib/{channelDeltaConnection.d.mts → channelDeltaConnection.d.ts} +7 -4
- package/lib/channelDeltaConnection.d.ts.map +1 -0
- package/lib/channelDeltaConnection.js +92 -0
- package/lib/channelDeltaConnection.js.map +1 -0
- package/lib/{channelStorageService.d.mts → channelStorageService.d.ts} +1 -1
- package/lib/channelStorageService.d.ts.map +1 -0
- package/lib/{channelStorageService.mjs → channelStorageService.js} +1 -1
- package/lib/channelStorageService.js.map +1 -0
- package/lib/{dataStoreRuntime.d.mts → dataStoreRuntime.d.ts} +25 -7
- package/lib/dataStoreRuntime.d.ts.map +1 -0
- package/lib/{dataStoreRuntime.mjs → dataStoreRuntime.js} +100 -33
- package/lib/dataStoreRuntime.js.map +1 -0
- package/lib/{datastore-alpha.d.mts → datastore-alpha.d.ts} +22 -6
- package/lib/{datastore-public.d.mts → datastore-beta.d.ts} +1 -2
- package/lib/{datastore-beta.d.mts → datastore-public.d.ts} +1 -2
- package/lib/{datastore-untrimmed.d.mts → datastore-untrimmed.d.ts} +22 -6
- package/lib/{fluidHandle.d.mts → fluidHandle.d.ts} +1 -1
- package/lib/fluidHandle.d.ts.map +1 -0
- package/lib/{fluidHandle.mjs → fluidHandle.js} +1 -1
- package/lib/fluidHandle.js.map +1 -0
- package/lib/{index.d.mts → index.d.ts} +3 -3
- package/lib/index.d.ts.map +1 -0
- package/lib/{index.mjs → index.js} +3 -3
- package/lib/index.js.map +1 -0
- package/lib/{localChannelContext.d.mts → localChannelContext.d.ts} +19 -4
- package/lib/localChannelContext.d.ts.map +1 -0
- package/lib/{localChannelContext.mjs → localChannelContext.js} +29 -7
- package/lib/localChannelContext.js.map +1 -0
- package/lib/{localChannelStorageService.d.mts → localChannelStorageService.d.ts} +1 -1
- package/lib/localChannelStorageService.d.ts.map +1 -0
- package/lib/{localChannelStorageService.mjs → localChannelStorageService.js} +1 -1
- package/lib/localChannelStorageService.js.map +1 -0
- package/lib/{remoteChannelContext.d.mts → remoteChannelContext.d.ts} +3 -3
- package/lib/remoteChannelContext.d.ts.map +1 -0
- package/lib/{remoteChannelContext.mjs → remoteChannelContext.js} +4 -3
- package/lib/remoteChannelContext.js.map +1 -0
- package/lib/test/channelStorageService.spec.js +70 -0
- package/lib/test/channelStorageService.spec.js.map +1 -0
- package/lib/test/dataStoreRuntime.spec.js +121 -0
- package/lib/test/dataStoreRuntime.spec.js.map +1 -0
- package/lib/test/localChannelContext.spec.js +41 -0
- package/lib/test/localChannelContext.spec.js.map +1 -0
- package/lib/test/localChannelStorageService.spec.js +72 -0
- package/lib/test/localChannelStorageService.spec.js.map +1 -0
- package/lib/test/remoteChannelContext.spec.js +33 -0
- package/lib/test/remoteChannelContext.spec.js.map +1 -0
- package/lib/test/types/validateDatastorePrevious.generated.js +16 -0
- package/lib/test/types/validateDatastorePrevious.generated.js.map +1 -0
- package/package.json +48 -50
- package/src/channelContext.ts +6 -3
- package/src/channelDeltaConnection.ts +69 -5
- package/src/dataStoreRuntime.ts +127 -46
- package/src/index.ts +2 -2
- package/src/localChannelContext.ts +38 -5
- package/src/remoteChannelContext.ts +4 -2
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.json +2 -5
- package/lib/channelContext.d.mts.map +0 -1
- package/lib/channelContext.mjs.map +0 -1
- package/lib/channelDeltaConnection.d.mts.map +0 -1
- package/lib/channelDeltaConnection.mjs +0 -53
- package/lib/channelDeltaConnection.mjs.map +0 -1
- package/lib/channelStorageService.d.mts.map +0 -1
- package/lib/channelStorageService.mjs.map +0 -1
- package/lib/dataStoreRuntime.d.mts.map +0 -1
- package/lib/dataStoreRuntime.mjs.map +0 -1
- package/lib/fluidHandle.d.mts.map +0 -1
- package/lib/fluidHandle.mjs.map +0 -1
- package/lib/index.d.mts.map +0 -1
- package/lib/index.mjs.map +0 -1
- package/lib/localChannelContext.d.mts.map +0 -1
- package/lib/localChannelContext.mjs.map +0 -1
- package/lib/localChannelStorageService.d.mts.map +0 -1
- package/lib/localChannelStorageService.mjs.map +0 -1
- package/lib/remoteChannelContext.d.mts.map +0 -1
- package/lib/remoteChannelContext.mjs.map +0 -1
package/src/dataStoreRuntime.ts
CHANGED
|
@@ -23,12 +23,7 @@ import {
|
|
|
23
23
|
IResponse,
|
|
24
24
|
} from "@fluidframework/core-interfaces";
|
|
25
25
|
import { assert, Deferred, LazyPromise, unreachableCase } from "@fluidframework/core-utils";
|
|
26
|
-
import {
|
|
27
|
-
IAudience,
|
|
28
|
-
IDeltaManager,
|
|
29
|
-
AttachState,
|
|
30
|
-
ILoaderOptions,
|
|
31
|
-
} from "@fluidframework/container-definitions";
|
|
26
|
+
import { IAudience, IDeltaManager, AttachState } from "@fluidframework/container-definitions";
|
|
32
27
|
import { buildSnapshotTree } from "@fluidframework/driver-utils";
|
|
33
28
|
import {
|
|
34
29
|
IClientDetails,
|
|
@@ -51,7 +46,7 @@ import {
|
|
|
51
46
|
ISummaryTreeWithStats,
|
|
52
47
|
VisibilityState,
|
|
53
48
|
ITelemetryContext,
|
|
54
|
-
|
|
49
|
+
gcDataBlobKey,
|
|
55
50
|
} from "@fluidframework/runtime-definitions";
|
|
56
51
|
import {
|
|
57
52
|
convertSnapshotTreeToSummaryTree,
|
|
@@ -64,6 +59,9 @@ import {
|
|
|
64
59
|
exceptionToResponse,
|
|
65
60
|
GCDataBuilder,
|
|
66
61
|
unpackChildNodesUsedRoutes,
|
|
62
|
+
addBlobToSummary,
|
|
63
|
+
processAttachMessageGCData,
|
|
64
|
+
encodeCompactIdToString,
|
|
67
65
|
} from "@fluidframework/runtime-utils";
|
|
68
66
|
import {
|
|
69
67
|
IChannel,
|
|
@@ -72,14 +70,15 @@ import {
|
|
|
72
70
|
IChannelFactory,
|
|
73
71
|
} from "@fluidframework/datastore-definitions";
|
|
74
72
|
import { v4 as uuid } from "uuid";
|
|
75
|
-
import {
|
|
73
|
+
import { IIdCompressor } from "@fluidframework/id-compressor";
|
|
74
|
+
import { IChannelContext, summarizeChannel } from "./channelContext.js";
|
|
76
75
|
import {
|
|
77
76
|
LocalChannelContext,
|
|
78
77
|
LocalChannelContextBase,
|
|
79
78
|
RehydratedLocalChannelContext,
|
|
80
|
-
} from "./localChannelContext";
|
|
81
|
-
import { RemoteChannelContext } from "./remoteChannelContext";
|
|
82
|
-
import { FluidObjectHandle } from "./fluidHandle";
|
|
79
|
+
} from "./localChannelContext.js";
|
|
80
|
+
import { RemoteChannelContext } from "./remoteChannelContext.js";
|
|
81
|
+
import { FluidObjectHandle } from "./fluidHandle.js";
|
|
83
82
|
|
|
84
83
|
/**
|
|
85
84
|
* @alpha
|
|
@@ -176,7 +175,8 @@ export class FluidDataStoreRuntime
|
|
|
176
175
|
private readonly pendingHandlesToMakeVisible: Set<IFluidHandle> = new Set();
|
|
177
176
|
|
|
178
177
|
public readonly id: string;
|
|
179
|
-
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
179
|
+
public readonly options: Record<string | number, any>;
|
|
180
180
|
public readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;
|
|
181
181
|
private readonly quorum: IQuorumClients;
|
|
182
182
|
private readonly audience: IAudience;
|
|
@@ -403,6 +403,21 @@ export class FluidDataStoreRuntime
|
|
|
403
403
|
return context.getChannel();
|
|
404
404
|
}
|
|
405
405
|
|
|
406
|
+
/**
|
|
407
|
+
* Validate user provided channel ID
|
|
408
|
+
* Channel ID has limitations. "/" is not allowed as IDs in storage can not have slashes - we parse tree paths and use "/" as separator.
|
|
409
|
+
* IDs cannot start with "_" as it could result in collision of IDs with auto-assigned (by FF) short IDs.
|
|
410
|
+
* @param id - channel ID.
|
|
411
|
+
*/
|
|
412
|
+
protected validateChannelId(id: string) {
|
|
413
|
+
if (id.includes("/")) {
|
|
414
|
+
throw new UsageError(`Id cannot contain slashes: ${id}`);
|
|
415
|
+
}
|
|
416
|
+
if (id.startsWith("_")) {
|
|
417
|
+
throw new UsageError(`Id cannot start with underscore: ${id}`);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
406
421
|
/**
|
|
407
422
|
* Api which allows caller to create the channel first and then add it to the runtime.
|
|
408
423
|
* The channel type should be present in the registry, otherwise the runtime would reject
|
|
@@ -412,9 +427,7 @@ export class FluidDataStoreRuntime
|
|
|
412
427
|
*/
|
|
413
428
|
public addChannel(channel: IChannel): void {
|
|
414
429
|
const id = channel.id;
|
|
415
|
-
|
|
416
|
-
throw new UsageError(`Id cannot contain slashes: ${id}`);
|
|
417
|
-
}
|
|
430
|
+
this.validateChannelId(id);
|
|
418
431
|
|
|
419
432
|
this.verifyNotClosed();
|
|
420
433
|
|
|
@@ -431,9 +444,30 @@ export class FluidDataStoreRuntime
|
|
|
431
444
|
this.identifyLocalChangeInSummarizer("DDSCreatedInSummarizer", id, type);
|
|
432
445
|
}
|
|
433
446
|
|
|
434
|
-
public createChannel(
|
|
435
|
-
|
|
436
|
-
|
|
447
|
+
public createChannel(idArg: string | undefined, type: string): IChannel {
|
|
448
|
+
let id: string;
|
|
449
|
+
|
|
450
|
+
if (idArg !== undefined) {
|
|
451
|
+
id = idArg;
|
|
452
|
+
this.validateChannelId(id);
|
|
453
|
+
} else {
|
|
454
|
+
// We use three non-overlapping namespaces:
|
|
455
|
+
// - detached state: even numbers
|
|
456
|
+
// - attached state: odd numbers
|
|
457
|
+
// - uuids
|
|
458
|
+
// In first two cases we will encode result as strings in more compact form, with leading underscore,
|
|
459
|
+
// to ensure no overlap with user-provided DDS names (see validateChannelId())
|
|
460
|
+
if (this.visibilityState !== VisibilityState.GloballyVisible) {
|
|
461
|
+
// container is detached, only one client observes content, no way to hit collisions with other clients.
|
|
462
|
+
id = encodeCompactIdToString(2 * this.contexts.size, "_");
|
|
463
|
+
} else {
|
|
464
|
+
// Due to back-compat, we could not depend yet on generateDocumentUniqueId() being there.
|
|
465
|
+
// We can remove the need to leverage uuid() as fall-back in couple releases.
|
|
466
|
+
const res =
|
|
467
|
+
this.dataStoreContext.containerRuntime.generateDocumentUniqueId?.() ?? uuid();
|
|
468
|
+
id = typeof res === "number" ? encodeCompactIdToString(2 * res + 1, "_") : res;
|
|
469
|
+
}
|
|
470
|
+
assert(!id.includes("/"), 0x8fc /* slash */);
|
|
437
471
|
}
|
|
438
472
|
|
|
439
473
|
this.verifyNotClosed();
|
|
@@ -482,7 +516,7 @@ export class FluidDataStoreRuntime
|
|
|
482
516
|
this.notBoundedChannelContextSet.delete(channel.id);
|
|
483
517
|
// If our data store is attached, then attach the channel.
|
|
484
518
|
if (this.isAttached) {
|
|
485
|
-
this.
|
|
519
|
+
this.makeChannelLocallyVisible(channel);
|
|
486
520
|
return;
|
|
487
521
|
}
|
|
488
522
|
|
|
@@ -610,6 +644,13 @@ export class FluidDataStoreRuntime
|
|
|
610
644
|
const attachMessage = message.contents as IAttachMessage;
|
|
611
645
|
const id = attachMessage.id;
|
|
612
646
|
|
|
647
|
+
// We need to process the GC Data for both local and remote attach messages
|
|
648
|
+
processAttachMessageGCData(attachMessage.snapshot, (nodeId, toPath) => {
|
|
649
|
+
// Note: nodeId will be "/" unless and until we support sub-DDS GC Nodes
|
|
650
|
+
const fromPath = `/${this.id}/${id}${nodeId === "/" ? "" : nodeId}`;
|
|
651
|
+
this.dataStoreContext.addedGCOutboundRoute?.(fromPath, toPath);
|
|
652
|
+
});
|
|
653
|
+
|
|
613
654
|
// If a non-local operation then go and create the object
|
|
614
655
|
// Otherwise mark it as officially attached.
|
|
615
656
|
if (local) {
|
|
@@ -812,6 +853,64 @@ export class FluidDataStoreRuntime
|
|
|
812
853
|
}
|
|
813
854
|
|
|
814
855
|
public getAttachSummary(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats {
|
|
856
|
+
const summaryBuilder = new SummaryTreeBuilder();
|
|
857
|
+
this.visitLocalBoundContextsDuringAttach(
|
|
858
|
+
(contextId: string, context: LocalChannelContextBase) => {
|
|
859
|
+
let summaryTree: ISummaryTreeWithStats;
|
|
860
|
+
if (context.isLoaded) {
|
|
861
|
+
const contextSummary = context.getAttachSummary(telemetryContext);
|
|
862
|
+
assert(
|
|
863
|
+
contextSummary.summary.type === SummaryType.Tree,
|
|
864
|
+
0x180 /* "getAttachSummary should always return a tree" */,
|
|
865
|
+
);
|
|
866
|
+
|
|
867
|
+
summaryTree = { stats: contextSummary.stats, summary: contextSummary.summary };
|
|
868
|
+
} else {
|
|
869
|
+
// If this channel is not yet loaded, then there should be no changes in the snapshot from which
|
|
870
|
+
// it was created as it is detached container. So just use the previous snapshot.
|
|
871
|
+
assert(
|
|
872
|
+
!!this.dataStoreContext.baseSnapshot,
|
|
873
|
+
0x181 /* "BaseSnapshot should be there as detached container loaded from snapshot" */,
|
|
874
|
+
);
|
|
875
|
+
summaryTree = convertSnapshotTreeToSummaryTree(
|
|
876
|
+
this.dataStoreContext.baseSnapshot.trees[contextId],
|
|
877
|
+
);
|
|
878
|
+
}
|
|
879
|
+
summaryBuilder.addWithStats(contextId, summaryTree);
|
|
880
|
+
},
|
|
881
|
+
);
|
|
882
|
+
|
|
883
|
+
return summaryBuilder.getSummaryTree();
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* Get the GC Data for the initial state being attached so remote clients can learn of this DataStore's outbound routes
|
|
888
|
+
*/
|
|
889
|
+
public getAttachGCData(telemetryContext?: ITelemetryContext): IGarbageCollectionData {
|
|
890
|
+
const gcDataBuilder = new GCDataBuilder();
|
|
891
|
+
this.visitLocalBoundContextsDuringAttach(
|
|
892
|
+
(contextId: string, context: LocalChannelContextBase) => {
|
|
893
|
+
if (context.isLoaded) {
|
|
894
|
+
const contextGCData = context.getAttachGCData(telemetryContext);
|
|
895
|
+
|
|
896
|
+
// Incorporate the GC Data for this context
|
|
897
|
+
gcDataBuilder.prefixAndAddNodes(contextId, contextGCData.gcNodes);
|
|
898
|
+
}
|
|
899
|
+
// else: Rehydrating detached container case. GC doesn't run until the container is attached, so nothing to do here.
|
|
900
|
+
},
|
|
901
|
+
);
|
|
902
|
+
this.updateGCNodes(gcDataBuilder);
|
|
903
|
+
|
|
904
|
+
return gcDataBuilder.getGCData();
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* Helper method for preparing to attach this dataStore.
|
|
909
|
+
* Runs the callback for each bound context to incorporate its data however the caller specifies
|
|
910
|
+
*/
|
|
911
|
+
private visitLocalBoundContextsDuringAttach(
|
|
912
|
+
visitor: (contextId: string, context: LocalChannelContextBase) => void,
|
|
913
|
+
): void {
|
|
815
914
|
/**
|
|
816
915
|
* back-compat 0.59.1000 - getAttachSummary() is called when making a data store globally visible (previously
|
|
817
916
|
* attaching state). Ideally, attachGraph() should have already be called making it locally visible. However,
|
|
@@ -832,39 +931,15 @@ export class FluidDataStoreRuntime
|
|
|
832
931
|
// "The data store should be locally visible when generating attach summary",
|
|
833
932
|
// );
|
|
834
933
|
|
|
835
|
-
const summaryBuilder = new SummaryTreeBuilder();
|
|
836
|
-
|
|
837
|
-
// Craft the .attributes file for each shared object
|
|
838
934
|
for (const [contextId, context] of this.contexts) {
|
|
839
935
|
if (!(context instanceof LocalChannelContextBase)) {
|
|
840
936
|
throw new LoggingError("Should only be called with local channel handles");
|
|
841
937
|
}
|
|
842
938
|
|
|
843
939
|
if (!this.notBoundedChannelContextSet.has(contextId)) {
|
|
844
|
-
|
|
845
|
-
if (context.isLoaded) {
|
|
846
|
-
const contextSummary = context.getAttachSummary(telemetryContext);
|
|
847
|
-
assert(
|
|
848
|
-
contextSummary.summary.type === SummaryType.Tree,
|
|
849
|
-
0x180 /* "getAttachSummary should always return a tree" */,
|
|
850
|
-
);
|
|
851
|
-
summaryTree = { stats: contextSummary.stats, summary: contextSummary.summary };
|
|
852
|
-
} else {
|
|
853
|
-
// If this channel is not yet loaded, then there should be no changes in the snapshot from which
|
|
854
|
-
// it was created as it is detached container. So just use the previous snapshot.
|
|
855
|
-
assert(
|
|
856
|
-
!!this.dataStoreContext.baseSnapshot,
|
|
857
|
-
0x181 /* "BaseSnapshot should be there as detached container loaded from snapshot" */,
|
|
858
|
-
);
|
|
859
|
-
summaryTree = convertSnapshotTreeToSummaryTree(
|
|
860
|
-
this.dataStoreContext.baseSnapshot.trees[contextId],
|
|
861
|
-
);
|
|
862
|
-
}
|
|
863
|
-
summaryBuilder.addWithStats(contextId, summaryTree);
|
|
940
|
+
visitor(contextId, context);
|
|
864
941
|
}
|
|
865
942
|
}
|
|
866
|
-
|
|
867
|
-
return summaryBuilder.getSummaryTree();
|
|
868
943
|
}
|
|
869
944
|
|
|
870
945
|
public submitMessage(type: DataStoreMessageType, content: any, localOpMetadata: unknown) {
|
|
@@ -890,9 +965,10 @@ export class FluidDataStoreRuntime
|
|
|
890
965
|
}
|
|
891
966
|
|
|
892
967
|
/**
|
|
893
|
-
*
|
|
968
|
+
* Assuming this DataStore is already attached, this will make the given channel locally visible
|
|
969
|
+
* by submitting its attach op.
|
|
894
970
|
*/
|
|
895
|
-
private
|
|
971
|
+
private makeChannelLocallyVisible(channel: IChannel): void {
|
|
896
972
|
this.verifyNotClosed();
|
|
897
973
|
// If this handle is already attached no need to attach again.
|
|
898
974
|
if (channel.handle.isAttached) {
|
|
@@ -912,6 +988,11 @@ export class FluidDataStoreRuntime
|
|
|
912
988
|
true /* fullTree */,
|
|
913
989
|
false /* trackState */,
|
|
914
990
|
);
|
|
991
|
+
|
|
992
|
+
// We need to include the channel's GC Data so remote clients can learn of this channel's outbound routes
|
|
993
|
+
const gcData = channel.getGCData(/* fullGC: */ true);
|
|
994
|
+
addBlobToSummary(summarizeResult, gcDataBlobKey, JSON.stringify(gcData));
|
|
995
|
+
|
|
915
996
|
// Attach message needs the summary in ITree format. Convert the ISummaryTree into an ITree.
|
|
916
997
|
const snapshot = convertSummaryTreeToITree(summarizeResult.summary);
|
|
917
998
|
|
package/src/index.ts
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export { FluidObjectHandle } from "./fluidHandle";
|
|
6
|
+
export { FluidObjectHandle } from "./fluidHandle.js";
|
|
7
7
|
export {
|
|
8
8
|
DataStoreMessageType,
|
|
9
9
|
FluidDataStoreRuntime,
|
|
10
10
|
ISharedObjectRegistry,
|
|
11
11
|
mixinRequestHandler,
|
|
12
12
|
mixinSummaryHandler,
|
|
13
|
-
} from "./dataStoreRuntime";
|
|
13
|
+
} from "./dataStoreRuntime.js";
|
|
@@ -28,8 +28,8 @@ import {
|
|
|
28
28
|
loadChannelFactoryAndAttributes,
|
|
29
29
|
summarizeChannel,
|
|
30
30
|
summarizeChannelAsync,
|
|
31
|
-
} from "./channelContext";
|
|
32
|
-
import { ISharedObjectRegistry } from "./dataStoreRuntime";
|
|
31
|
+
} from "./channelContext.js";
|
|
32
|
+
import { ISharedObjectRegistry } from "./dataStoreRuntime.js";
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Channel context for a locally created channel
|
|
@@ -47,6 +47,10 @@ export abstract class LocalChannelContextBase implements IChannelContext {
|
|
|
47
47
|
assert(!this.id.includes("/"), 0x30f /* Channel context ID cannot contain slashes */);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
protected get isGloballyVisible() {
|
|
51
|
+
return this.globallyVisible;
|
|
52
|
+
}
|
|
53
|
+
|
|
50
54
|
public async getChannel(): Promise<IChannel> {
|
|
51
55
|
if (this._channel === undefined) {
|
|
52
56
|
return this.channelP.then((c) => (this._channel = c));
|
|
@@ -106,9 +110,7 @@ export abstract class LocalChannelContextBase implements IChannelContext {
|
|
|
106
110
|
this.services.value.deltaConnection.rollback(content, localOpMetadata);
|
|
107
111
|
}
|
|
108
112
|
|
|
109
|
-
public applyStashedOp()
|
|
110
|
-
throw new Error("no stashed ops on local channel");
|
|
111
|
-
}
|
|
113
|
+
public abstract applyStashedOp(content: unknown): unknown;
|
|
112
114
|
|
|
113
115
|
/**
|
|
114
116
|
* Returns a summary at the current sequence number.
|
|
@@ -125,6 +127,11 @@ export abstract class LocalChannelContextBase implements IChannelContext {
|
|
|
125
127
|
return summarizeChannelAsync(channel, fullTree, trackState, telemetryContext);
|
|
126
128
|
}
|
|
127
129
|
|
|
130
|
+
/**
|
|
131
|
+
* For crafting the DataStore attach op. Only to be called when the channel is loaded (if applicable).
|
|
132
|
+
*
|
|
133
|
+
* Synchronously generates the channel's attach summary to be joined with the same from the DataStore's other channels
|
|
134
|
+
*/
|
|
128
135
|
public getAttachSummary(telemetryContext?: ITelemetryContext): ISummarizeResult {
|
|
129
136
|
assert(
|
|
130
137
|
this._channel !== undefined,
|
|
@@ -138,6 +145,22 @@ export abstract class LocalChannelContextBase implements IChannelContext {
|
|
|
138
145
|
);
|
|
139
146
|
}
|
|
140
147
|
|
|
148
|
+
/**
|
|
149
|
+
* For crafting the DataStore attach op. Only to be called when the channel is loaded (if applicable).
|
|
150
|
+
*
|
|
151
|
+
* Synchronously generates the channel's attach GC data (set of outbound routes in the initial state)
|
|
152
|
+
* to be joined with the same from the DataStore's other channels
|
|
153
|
+
*/
|
|
154
|
+
public getAttachGCData(telemetryContext?: ITelemetryContext): IGarbageCollectionData {
|
|
155
|
+
assert(
|
|
156
|
+
this._channel !== undefined,
|
|
157
|
+
0x8fd /* Local Channel should be loaded before being attached */,
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
// We need the GC Data to detect references added in this attach op
|
|
161
|
+
return this._channel.getGCData(/* fullGC: */ true);
|
|
162
|
+
}
|
|
163
|
+
|
|
141
164
|
public makeVisible(): void {
|
|
142
165
|
if (this.globallyVisible) {
|
|
143
166
|
throw new Error("Channel is already globally visible");
|
|
@@ -201,6 +224,7 @@ export class RehydratedLocalChannelContext extends LocalChannelContextBase {
|
|
|
201
224
|
submitFn,
|
|
202
225
|
this.dirtyFn,
|
|
203
226
|
addedGCOutboundReferenceFn,
|
|
227
|
+
() => this.isGloballyVisible,
|
|
204
228
|
storageService,
|
|
205
229
|
logger,
|
|
206
230
|
clonedSnapshotTree,
|
|
@@ -247,6 +271,10 @@ export class RehydratedLocalChannelContext extends LocalChannelContextBase {
|
|
|
247
271
|
};
|
|
248
272
|
}
|
|
249
273
|
|
|
274
|
+
public override applyStashedOp(content) {
|
|
275
|
+
return this.services.value.deltaConnection.applyStashedOp(content);
|
|
276
|
+
}
|
|
277
|
+
|
|
250
278
|
private isSnapshotInOldFormatAndCollectBlobs(
|
|
251
279
|
snapshotTree: ISnapshotTreeWithBlobContents,
|
|
252
280
|
blobMap: Map<string, ArrayBufferLike>,
|
|
@@ -303,6 +331,7 @@ export class LocalChannelContext extends LocalChannelContextBase {
|
|
|
303
331
|
submitFn,
|
|
304
332
|
this.dirtyFn,
|
|
305
333
|
addedGCOutboundReferenceFn,
|
|
334
|
+
() => this.isGloballyVisible,
|
|
306
335
|
storageService,
|
|
307
336
|
logger,
|
|
308
337
|
);
|
|
@@ -316,4 +345,8 @@ export class LocalChannelContext extends LocalChannelContextBase {
|
|
|
316
345
|
dirtyFn(channel.id);
|
|
317
346
|
};
|
|
318
347
|
}
|
|
348
|
+
|
|
349
|
+
public applyStashedOp() {
|
|
350
|
+
throw new Error("no stashed ops on local channel");
|
|
351
|
+
}
|
|
319
352
|
}
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
ITelemetryLoggerExt,
|
|
24
24
|
ThresholdCounter,
|
|
25
25
|
} from "@fluidframework/telemetry-utils";
|
|
26
|
+
import { AttachState } from "@fluidframework/container-definitions";
|
|
26
27
|
import {
|
|
27
28
|
ChannelServiceEndpoints,
|
|
28
29
|
createChannelServiceEndpoints,
|
|
@@ -30,8 +31,8 @@ import {
|
|
|
30
31
|
loadChannel,
|
|
31
32
|
loadChannelFactoryAndAttributes,
|
|
32
33
|
summarizeChannelAsync,
|
|
33
|
-
} from "./channelContext";
|
|
34
|
-
import { ISharedObjectRegistry } from "./dataStoreRuntime";
|
|
34
|
+
} from "./channelContext.js";
|
|
35
|
+
import { ISharedObjectRegistry } from "./dataStoreRuntime.js";
|
|
35
36
|
|
|
36
37
|
export class RemoteChannelContext implements IChannelContext {
|
|
37
38
|
private isLoaded = false;
|
|
@@ -70,6 +71,7 @@ export class RemoteChannelContext implements IChannelContext {
|
|
|
70
71
|
submitFn,
|
|
71
72
|
() => dirtyFn(this.id),
|
|
72
73
|
addedGCOutboundReferenceFn,
|
|
74
|
+
() => runtime.attachState !== AttachState.Detached,
|
|
73
75
|
storageService,
|
|
74
76
|
this.subLogger,
|
|
75
77
|
baseSnapshot,
|
package/tsconfig.json
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends":
|
|
3
|
-
"../../../common/build/build-common/tsconfig.base.json",
|
|
4
|
-
"../../../common/build/build-common/tsconfig.cjs.json",
|
|
5
|
-
],
|
|
2
|
+
"extends": "../../../common/build/build-common/tsconfig.node16.json",
|
|
6
3
|
"include": ["src/**/*"],
|
|
7
4
|
"exclude": ["src/test/**/*"],
|
|
8
5
|
"compilerOptions": {
|
|
9
6
|
"rootDir": "./src",
|
|
10
|
-
"outDir": "./
|
|
7
|
+
"outDir": "./lib",
|
|
11
8
|
},
|
|
12
9
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"channelContext.d.mts","sourceRoot":"","sources":["../src/channelContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAEN,mBAAmB,EAEnB,MAAM,iCAAiC;OACjC,EAAE,YAAY,EAAE,MAAM,iCAAiC;OACvD,EACN,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,MAAM,uCAAuC;OACvC,EAAE,uBAAuB,EAAE,MAAM,oCAAoC;OACrE,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,sCAAsC;OACxF,EACN,sBAAsB,EACtB,sCAAsC,EACtC,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,MAAM,qCAAqC;OAGrC,EAAE,qBAAqB,EAAE;OACzB,EAAE,sBAAsB,EAAE;OAC1B,EAAE,qBAAqB,EAAE;AAEhC,eAA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,UAAU,EAAE,CAAC;AAChC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAChC,gBAAwC,EACxC,UAA8B,EAC9B,OAAwB,EACxB,QAAiC,EACjC,MAA2B,EAC3B,SAAiB;IAEjB,2DAA2D;IAC3D,IACC,UAAU,CAAC,qBAAqB,KAAK,SAAS;QAC9C,UAAU,CAAC,qBAAqB,KAAK,OAAO,CAAC,UAAU,CAAC,qBAAqB,EAC5E;QACD,MAAM,CAAC,kBAAkB,CAAC;YACzB,SAAS,EAAE,kCAAkC;YAC7C,GAAG,gBAAgB,CAAC;gBACnB,WAAW,EAAE,UAAU,CAAC,IAAI;gBAC5B,sBAAsB,EAAE,GAAG,UAAU,CAAC,qBAAqB,IAAI,UAAU,CAAC,cAAc,EAAE;gBAC1F,kBAAkB,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,qBAAqB,IAAI,OAAO,CAAC,UAAU,CAAC,cAAc,EAAE;aACtG,CAAC;SACF,CAAC,CAAC;KACH;IAED,OAAO,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AACxE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tDataCorruptionError,\n\tITelemetryLoggerExt,\n\ttagCodeArtifacts,\n} from \"@fluidframework/telemetry-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n\tIChannel,\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIGarbageCollectionData,\n\tIExperimentalIncrementalSummaryContext,\n\tISummarizeResult,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tIFluidDataStoreContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { addBlobToSummary } from \"@fluidframework/runtime-utils\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport { ChannelStorageService } from \"./channelStorageService\";\nimport { ChannelDeltaConnection } from \"./channelDeltaConnection\";\nimport { ISharedObjectRegistry } from \"./dataStoreRuntime\";\n\nexport const attributesBlobKey = \".attributes\";\n\nexport interface IChannelContext {\n\tgetChannel(): Promise<IChannel>;\n\n\tsetConnectionState(connected: boolean, clientId?: string);\n\n\tprocessOp(message: ISequencedDocumentMessage, local: boolean, localOpMetadata?: unknown): void;\n\n\tsummarize(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummarizeResult>;\n\n\treSubmit(content: any, localOpMetadata: unknown): void;\n\n\tapplyStashedOp(content: any): unknown;\n\n\trollback(message: any, localOpMetadata: unknown): void;\n\n\t/**\n\t * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context\n\t * including any of its children. Each node has a set of outbound routes to other GC nodes in the document.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tgetGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;\n\n\t/**\n\t * After GC has run, called to notify this context of routes that are used in it. These are used for the following:\n\t * 1. To identify if this context is being referenced in the document or not.\n\t * 2. To identify if this context or any of its children's used routes changed since last summary.\n\t * 3. They are added to the summary generated by this context.\n\t */\n\tupdateUsedRoutes(usedRoutes: string[]): void;\n}\n\nexport interface ChannelServiceEndpoints {\n\tdeltaConnection: ChannelDeltaConnection;\n\tobjectStorage: ChannelStorageService;\n}\n\nexport function createChannelServiceEndpoints(\n\tconnected: boolean,\n\tsubmitFn: (content: any, localOpMetadata: unknown) => void,\n\tdirtyFn: () => void,\n\taddedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n\tstorageService: IDocumentStorageService,\n\tlogger: ITelemetryLoggerExt,\n\ttree?: ISnapshotTree,\n\textraBlobs?: Map<string, ArrayBufferLike>,\n): ChannelServiceEndpoints {\n\tconst deltaConnection = new ChannelDeltaConnection(\n\t\tconnected,\n\t\t(message, localOpMetadata) => submitFn(message, localOpMetadata),\n\t\tdirtyFn,\n\t\taddedGCOutboundReferenceFn,\n\t);\n\tconst objectStorage = new ChannelStorageService(tree, storageService, logger, extraBlobs);\n\n\treturn {\n\t\tdeltaConnection,\n\t\tobjectStorage,\n\t};\n}\n\nexport function summarizeChannel(\n\tchannel: IChannel,\n\tfullTree: boolean = false,\n\ttrackState: boolean = false,\n\ttelemetryContext?: ITelemetryContext,\n): ISummaryTreeWithStats {\n\tconst summarizeResult = channel.getAttachSummary(fullTree, trackState, telemetryContext);\n\n\t// Add the channel attributes to the returned result.\n\taddBlobToSummary(summarizeResult, attributesBlobKey, JSON.stringify(channel.attributes));\n\treturn summarizeResult;\n}\n\nexport async function summarizeChannelAsync(\n\tchannel: IChannel,\n\tfullTree: boolean = false,\n\ttrackState: boolean = false,\n\ttelemetryContext?: ITelemetryContext,\n\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n): Promise<ISummaryTreeWithStats> {\n\tconst summarizeResult = await channel.summarize(\n\t\tfullTree,\n\t\ttrackState,\n\t\ttelemetryContext,\n\t\tincrementalSummaryContext,\n\t);\n\n\t// Add the channel attributes to the returned result.\n\taddBlobToSummary(summarizeResult, attributesBlobKey, JSON.stringify(channel.attributes));\n\treturn summarizeResult;\n}\n\nexport async function loadChannelFactoryAndAttributes(\n\tdataStoreContext: IFluidDataStoreContext,\n\tservices: ChannelServiceEndpoints,\n\tchannelId: string,\n\tregistry: ISharedObjectRegistry,\n\tattachMessageType?: string,\n): Promise<{ factory: IChannelFactory; attributes: IChannelAttributes }> {\n\tlet attributes: IChannelAttributes | undefined;\n\tif (await services.objectStorage.contains(attributesBlobKey)) {\n\t\tattributes = await readAndParse<IChannelAttributes | undefined>(\n\t\t\tservices.objectStorage,\n\t\t\tattributesBlobKey,\n\t\t);\n\t}\n\n\t// This is a backward compatibility case where the attach message doesn't include attributes. They must\n\t// include attach message type.\n\t// Since old attach messages will not have attributes, we need to keep this as long as we support old attach\n\t// messages.\n\tconst channelFactoryType = attributes ? attributes.type : attachMessageType;\n\tif (channelFactoryType === undefined) {\n\t\tthrow new DataCorruptionError(\n\t\t\t\"channelTypeNotAvailable\",\n\t\t\ttagCodeArtifacts({\n\t\t\t\tchannelId,\n\t\t\t\tdataStoreId: dataStoreContext.id,\n\t\t\t\tdataStorePackagePath: dataStoreContext.packagePath.join(\"/\"),\n\t\t\t\tchannelFactoryType,\n\t\t\t}),\n\t\t);\n\t}\n\tconst factory = registry.get(channelFactoryType);\n\tif (factory === undefined) {\n\t\tthrow new DataCorruptionError(\n\t\t\t\"channelFactoryNotRegisteredForGivenType\",\n\t\t\ttagCodeArtifacts({\n\t\t\t\tchannelId,\n\t\t\t\tdataStoreId: dataStoreContext.id,\n\t\t\t\tdataStorePackagePath: dataStoreContext.packagePath.join(\"/\"),\n\t\t\t\tchannelFactoryType,\n\t\t\t}),\n\t\t);\n\t}\n\t// This is a backward compatibility case where the attach message doesn't include attributes. Get the attributes\n\t// from the factory.\n\tattributes = attributes ?? factory.attributes;\n\treturn { factory, attributes };\n}\n\nexport async function loadChannel(\n\tdataStoreRuntime: IFluidDataStoreRuntime,\n\tattributes: IChannelAttributes,\n\tfactory: IChannelFactory,\n\tservices: ChannelServiceEndpoints,\n\tlogger: ITelemetryLoggerExt,\n\tchannelId: string,\n): Promise<IChannel> {\n\t// Compare snapshot version to collaborative object version\n\tif (\n\t\tattributes.snapshotFormatVersion !== undefined &&\n\t\tattributes.snapshotFormatVersion !== factory.attributes.snapshotFormatVersion\n\t) {\n\t\tlogger.sendTelemetryEvent({\n\t\t\teventName: \"ChannelAttributesVersionMismatch\",\n\t\t\t...tagCodeArtifacts({\n\t\t\t\tchannelType: attributes.type,\n\t\t\t\tchannelSnapshotVersion: `${attributes.snapshotFormatVersion}@${attributes.packageVersion}`,\n\t\t\t\tchannelCodeVersion: `${factory.attributes.snapshotFormatVersion}@${factory.attributes.packageVersion}`,\n\t\t\t}),\n\t\t});\n\t}\n\n\treturn factory.load(dataStoreRuntime, channelId, services, attributes);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"channelDeltaConnection.d.mts","sourceRoot":"","sources":["../src/channelDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAGI,EAAE,yBAAyB,EAAE,MAAM,sCAAsC;OACzE,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,uCAAuC;OAEhF,EAAE,YAAY,EAAE,MAAM,iCAAiC;AAE9D,qBAAa,sBAAuB,YAAW,gBAAgB;IAY7D,OAAO,CAAC,UAAU;aACF,MAAM,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,KAAK,IAAI;aACxD,KAAK,EAAE,MAAM,IAAI;IACjC,yGAAyG;aACzF,wBAAwB,EAAE,CACzC,SAAS,EAAE,YAAY,EACvB,cAAc,EAAE,YAAY,KACxB,IAAI;IAlBV,OAAO,CAAC,QAAQ,CAA4B;IAE5C,OAAO,KAAK,OAAO,GAGlB;IACD,IAAW,SAAS,IAAI,OAAO,CAE9B;gBAGQ,UAAU,EAAE,OAAO,EACX,MAAM,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,KAAK,IAAI,EACxD,KAAK,EAAE,MAAM,IAAI;IACjC,yGAAyG;IACzF,wBAAwB,EAAE,CACzC,SAAS,EAAE,YAAY,EACvB,cAAc,EAAE,YAAY,KACxB,IAAI;IAGH,MAAM,CAAC,OAAO,EAAE,aAAa;IAK7B,kBAAkB,CAAC,SAAS,EAAE,OAAO;IAKrC,OAAO,CAAC,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO;IAapF,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO;IAI/C,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO;IAO/C,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;CAG5C"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { assert } from "@fluidframework/core-utils";
|
|
6
|
-
import { DataProcessingError } from "@fluidframework/telemetry-utils";
|
|
7
|
-
export class ChannelDeltaConnection {
|
|
8
|
-
get handler() {
|
|
9
|
-
assert(!!this._handler, 0x177 /* "Missing delta handler" */);
|
|
10
|
-
return this._handler;
|
|
11
|
-
}
|
|
12
|
-
get connected() {
|
|
13
|
-
return this._connected;
|
|
14
|
-
}
|
|
15
|
-
constructor(_connected, submit, dirty,
|
|
16
|
-
/** @deprecated There is no replacement for this, its functionality is no longer needed at this layer. */
|
|
17
|
-
addedGCOutboundReference) {
|
|
18
|
-
this._connected = _connected;
|
|
19
|
-
this.submit = submit;
|
|
20
|
-
this.dirty = dirty;
|
|
21
|
-
this.addedGCOutboundReference = addedGCOutboundReference;
|
|
22
|
-
}
|
|
23
|
-
attach(handler) {
|
|
24
|
-
assert(this._handler === undefined, 0x178 /* "Missing delta handler on attach" */);
|
|
25
|
-
this._handler = handler;
|
|
26
|
-
}
|
|
27
|
-
setConnectionState(connected) {
|
|
28
|
-
this._connected = connected;
|
|
29
|
-
this.handler.setConnectionState(connected);
|
|
30
|
-
}
|
|
31
|
-
process(message, local, localOpMetadata) {
|
|
32
|
-
try {
|
|
33
|
-
// catches as data processing error whether or not they come from async pending queues
|
|
34
|
-
this.handler.process(message, local, localOpMetadata);
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
throw DataProcessingError.wrapIfUnrecognized(error, "channelDeltaConnectionFailedToProcessMessage", message);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
reSubmit(content, localOpMetadata) {
|
|
41
|
-
this.handler.reSubmit(content, localOpMetadata);
|
|
42
|
-
}
|
|
43
|
-
rollback(content, localOpMetadata) {
|
|
44
|
-
if (this.handler.rollback === undefined) {
|
|
45
|
-
throw new Error("Handler doesn't support rollback");
|
|
46
|
-
}
|
|
47
|
-
this.handler.rollback(content, localOpMetadata);
|
|
48
|
-
}
|
|
49
|
-
applyStashedOp(content) {
|
|
50
|
-
return this.handler.applyStashedOp(content);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=channelDeltaConnection.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"channelDeltaConnection.mjs","sourceRoot":"","sources":["../src/channelDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,MAAM,EAAE,MAAM,4BAA4B;OAG5C,EAAE,mBAAmB,EAAE,MAAM,iCAAiC;AAGrE,MAAM,OAAO,sBAAsB;IAGlC,IAAY,OAAO;QAClB,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAC7D,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IACD,IAAW,SAAS;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAED,YACS,UAAmB,EACX,MAAwD,EACxD,KAAiB;IACjC,yGAAyG;IACzF,wBAGP;QAPD,eAAU,GAAV,UAAU,CAAS;QACX,WAAM,GAAN,MAAM,CAAkD;QACxD,UAAK,GAAL,KAAK,CAAY;QAEjB,6BAAwB,GAAxB,wBAAwB,CAG/B;IACP,CAAC;IAEG,MAAM,CAAC,OAAsB;QACnC,MAAM,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,KAAK,CAAC,uCAAuC,CAAC,CAAC;QACnF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IACzB,CAAC;IAEM,kBAAkB,CAAC,SAAkB;QAC3C,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAEM,OAAO,CAAC,OAAkC,EAAE,KAAc,EAAE,eAAwB;QAC1F,IAAI;YACH,sFAAsF;YACtF,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;SACtD;QAAC,OAAO,KAAK,EAAE;YACf,MAAM,mBAAmB,CAAC,kBAAkB,CAC3C,KAAK,EACL,8CAA8C,EAC9C,OAAO,CACP,CAAC;SACF;IACF,CAAC;IAEM,QAAQ,CAAC,OAAY,EAAE,eAAwB;QACrD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IACjD,CAAC;IAEM,QAAQ,CAAC,OAAY,EAAE,eAAwB;QACrD,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE;YACxC,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACpD;QACD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IACjD,CAAC;IAEM,cAAc,CAAC,OAAY;QACjC,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAC7C,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 { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { IDeltaConnection, IDeltaHandler } from \"@fluidframework/datastore-definitions\";\nimport { DataProcessingError } from \"@fluidframework/telemetry-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\n\nexport class ChannelDeltaConnection implements IDeltaConnection {\n\tprivate _handler: IDeltaHandler | undefined;\n\n\tprivate get handler(): IDeltaHandler {\n\t\tassert(!!this._handler, 0x177 /* \"Missing delta handler\" */);\n\t\treturn this._handler;\n\t}\n\tpublic get connected(): boolean {\n\t\treturn this._connected;\n\t}\n\n\tconstructor(\n\t\tprivate _connected: boolean,\n\t\tpublic readonly submit: (content: any, localOpMetadata: unknown) => void,\n\t\tpublic readonly dirty: () => void,\n\t\t/** @deprecated There is no replacement for this, its functionality is no longer needed at this layer. */\n\t\tpublic readonly addedGCOutboundReference: (\n\t\t\tsrcHandle: IFluidHandle,\n\t\t\toutboundHandle: IFluidHandle,\n\t\t) => void,\n\t) {}\n\n\tpublic attach(handler: IDeltaHandler) {\n\t\tassert(this._handler === undefined, 0x178 /* \"Missing delta handler on attach\" */);\n\t\tthis._handler = handler;\n\t}\n\n\tpublic setConnectionState(connected: boolean) {\n\t\tthis._connected = connected;\n\t\tthis.handler.setConnectionState(connected);\n\t}\n\n\tpublic process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n\t\ttry {\n\t\t\t// catches as data processing error whether or not they come from async pending queues\n\t\t\tthis.handler.process(message, local, localOpMetadata);\n\t\t} catch (error) {\n\t\t\tthrow DataProcessingError.wrapIfUnrecognized(\n\t\t\t\terror,\n\t\t\t\t\"channelDeltaConnectionFailedToProcessMessage\",\n\t\t\t\tmessage,\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic reSubmit(content: any, localOpMetadata: unknown) {\n\t\tthis.handler.reSubmit(content, localOpMetadata);\n\t}\n\n\tpublic rollback(content: any, localOpMetadata: unknown) {\n\t\tif (this.handler.rollback === undefined) {\n\t\t\tthrow new Error(\"Handler doesn't support rollback\");\n\t\t}\n\t\tthis.handler.rollback(content, localOpMetadata);\n\t}\n\n\tpublic applyStashedOp(content: any): unknown {\n\t\treturn this.handler.applyStashedOp(content);\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"channelStorageService.d.mts","sourceRoot":"","sources":["../src/channelStorageService.ts"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E,CACrB,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,yBAAyB,EAAE,EAAE,KAAK,CAAC,CAC3E,CAAC;QAEF,OAAO,KAAK,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,IAAY;QAC7B,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACrB,MAAM,SAAS,GAAG,mCAAmC,CAAC,IAAI,CAAC,CAAC;QAC5D,OAAO,IAAI,KAAK,SAAS,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;YAClD,oEAAoE;YACpE,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,EAAG,CAAC;YAChC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACxB;QACD,IAAI,IAAI,KAAK,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;YACjD,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;SACvC;QAED,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;IAEO,KAAK,CAAC,YAAY,CAAC,IAAY;QACtC,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { IChannelStorageService } from \"@fluidframework/datastore-definitions\";\nimport { getNormalizedObjectStoragePathParts } from \"@fluidframework/runtime-utils\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\n\nexport class ChannelStorageService implements IChannelStorageService {\n\tprivate static flattenTree(\n\t\tbase: string,\n\t\ttree: ISnapshotTree,\n\t\tresults: { [path: string]: string },\n\t) {\n\t\t// eslint-disable-next-line guard-for-in, no-restricted-syntax\n\t\tfor (const path in tree.trees) {\n\t\t\tChannelStorageService.flattenTree(`${base}${path}/`, tree.trees[path], results);\n\t\t}\n\n\t\t// eslint-disable-next-line guard-for-in, no-restricted-syntax\n\t\tfor (const blob in tree.blobs) {\n\t\t\tresults[`${base}${blob}`] = tree.blobs[blob];\n\t\t}\n\t}\n\n\tprivate readonly flattenedTree: { [path: string]: string };\n\n\tconstructor(\n\t\tprivate readonly tree: ISnapshotTree | undefined,\n\t\tprivate readonly storage: Pick<IDocumentStorageService, \"readBlob\">,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly extraBlobs?: Map<string, ArrayBufferLike>,\n\t) {\n\t\tthis.flattenedTree = {};\n\t\t// Create a map from paths to blobs\n\t\tif (tree !== undefined) {\n\t\t\tChannelStorageService.flattenTree(\"\", tree, this.flattenedTree);\n\t\t}\n\t}\n\n\tpublic async contains(path: string): Promise<boolean> {\n\t\treturn this.flattenedTree[path] !== undefined;\n\t}\n\n\tpublic async readBlob(path: string): Promise<ArrayBufferLike> {\n\t\tconst id = await this.getIdForPath(path);\n\t\tconst blob = this.extraBlobs !== undefined ? this.extraBlobs.get(id) : undefined;\n\n\t\tif (blob !== undefined) {\n\t\t\treturn blob;\n\t\t}\n\t\tconst blobP = this.storage.readBlob(id);\n\t\tblobP.catch((error) =>\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"ChannelStorageBlobError\" }, error),\n\t\t);\n\n\t\treturn blobP;\n\t}\n\n\tpublic async list(path: string): Promise<string[]> {\n\t\tlet tree = this.tree;\n\t\tconst pathParts = getNormalizedObjectStoragePathParts(path);\n\t\twhile (tree !== undefined && pathParts.length > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst part = pathParts.shift()!;\n\t\t\ttree = tree.trees[part];\n\t\t}\n\t\tif (tree === undefined || pathParts.length !== 0) {\n\t\t\tthrow new Error(\"path does not exist\");\n\t\t}\n\n\t\treturn Object.keys(tree?.blobs ?? {});\n\t}\n\n\tprivate async getIdForPath(path: string): Promise<string> {\n\t\treturn this.flattenedTree[path];\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dataStoreRuntime.d.mts","sourceRoot":"","sources":["../src/dataStoreRuntime.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,iBAAiB,EAAE,MAAM,8BAA8B;OACzD,EAEN,mBAAmB,EAQnB,MAAM,iCAAiC;OACjC,EACN,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,QAAQ,EACR,SAAS,EACT,MAAM,iCAAiC;OAEjC,EACN,SAAS,EACT,aAAa,EACb,WAAW,EACX,cAAc,EACd,MAAM,uCAAuC;OAEvC,EACN,cAAc,EACd,gBAAgB,EAChB,yBAAyB,EAIzB,cAAc,EACd,MAAM,sCAAsC;OACtC,EAKN,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,MAAM,qCAAqC;OAarC,EACN,QAAQ,EACR,sBAAsB,EACtB,4BAA4B,EAC5B,eAAe,EACf,MAAM,uCAAuC;AAW9C;;GAEG;AACH,oBAAY,oBAAoB;IAE/B,MAAM,WAAW;IACjB,SAAS,OAAO;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAGrC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAAC;CAC/C;AAED;;;GAGG;AACH,qBAAa,qBACZ,SAAQ,iBAAiB,CAAC,4BAA4B,CACtD,YAAW,sBAAsB,EAAE,sBAAsB,EAAE,mBAAmB;IAkH7E,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IAjHtC;;OAEG;IACH,SAAgB,UAAU,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;IAEtD,IAAW,S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