@fluidframework/register-collection 2.90.0 → 2.92.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 +8 -0
- package/dist/consensusRegisterCollection.d.ts +6 -4
- package/dist/consensusRegisterCollection.d.ts.map +1 -1
- package/dist/consensusRegisterCollection.js +4 -3
- package/dist/consensusRegisterCollection.js.map +1 -1
- package/dist/consensusRegisterCollectionFactory.d.ts +2 -2
- package/dist/consensusRegisterCollectionFactory.d.ts.map +1 -1
- package/dist/consensusRegisterCollectionFactory.js +3 -0
- package/dist/consensusRegisterCollectionFactory.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +2 -2
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/legacy.d.ts +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +1 -1
- package/eslint.config.mts +12 -2
- package/internal.d.ts +1 -1
- package/legacy.d.ts +1 -1
- package/lib/consensusRegisterCollection.d.ts +6 -4
- package/lib/consensusRegisterCollection.d.ts.map +1 -1
- package/lib/consensusRegisterCollection.js +5 -4
- package/lib/consensusRegisterCollection.js.map +1 -1
- package/lib/consensusRegisterCollectionFactory.d.ts +2 -2
- package/lib/consensusRegisterCollectionFactory.d.ts.map +1 -1
- package/lib/consensusRegisterCollectionFactory.js +3 -0
- package/lib/consensusRegisterCollectionFactory.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/interfaces.d.ts +2 -2
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/legacy.d.ts +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +1 -1
- package/package.json +19 -19
- package/src/consensusRegisterCollection.ts +9 -8
- package/src/consensusRegisterCollectionFactory.ts +7 -4
- package/src/index.ts +3 -3
- package/src/interfaces.ts +2 -2
- package/src/packageVersion.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IChannelAttributes, IFluidDataStoreRuntime, IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
|
|
6
|
-
import { ISummaryTreeWithStats, IRuntimeMessageCollection } from "@fluidframework/runtime-definitions/internal";
|
|
7
|
-
import { IFluidSerializer
|
|
8
|
-
import {
|
|
5
|
+
import type { IChannelAttributes, IFluidDataStoreRuntime, IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
|
|
6
|
+
import type { ISummaryTreeWithStats, IRuntimeMessageCollection } from "@fluidframework/runtime-definitions/internal";
|
|
7
|
+
import type { IFluidSerializer } from "@fluidframework/shared-object-base/internal";
|
|
8
|
+
import { SharedObject } from "@fluidframework/shared-object-base/internal";
|
|
9
|
+
import type { IConsensusRegisterCollection, IConsensusRegisterCollectionEvents } from "./interfaces.js";
|
|
10
|
+
import { ReadPolicy } from "./interfaces.js";
|
|
9
11
|
/**
|
|
10
12
|
* {@inheritDoc IConsensusRegisterCollection}
|
|
11
13
|
* @deprecated Use {@link IConsensusRegisterCollection} for typing and {@link ConsensusRegisterCollectionFactory} to create instances. This implementation class will be removed in a future release.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consensusRegisterCollection.d.ts","sourceRoot":"","sources":["../src/consensusRegisterCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,
|
|
1
|
+
{"version":3,"file":"consensusRegisterCollection.d.ts","sourceRoot":"","sources":["../src/consensusRegisterCollection.ts"],"names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C,YAAY,IAAI,IAAI;cAEX,mBAAmB,CAAC,kBAAkB,EAAE,yBAAyB,GAAG,IAAI;IAO3F,OAAO,CAAC,cAAc;IAsDtB,OAAO,CAAC,UAAU;IAKlB;;;;;;;OAOG;IACH,OAAO,CAAC,mBAAmB;IA2D3B,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,KAAK;IAIb;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAWpE,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;CAQhD"}
|
|
@@ -121,9 +121,9 @@ class ConsensusRegisterCollection extends internal_3.SharedObject {
|
|
|
121
121
|
}
|
|
122
122
|
summarizeCore(serializer) {
|
|
123
123
|
const dataObj = {};
|
|
124
|
-
this.data.
|
|
124
|
+
for (const [k, v] of this.data.entries()) {
|
|
125
125
|
dataObj[k] = v;
|
|
126
|
-
}
|
|
126
|
+
}
|
|
127
127
|
return (0, internal_3.createSingleBlobSummary)(snapshotFileName, this.stringify(dataObj, serializer));
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
@@ -171,8 +171,9 @@ class ConsensusRegisterCollection extends internal_3.SharedObject {
|
|
|
171
171
|
}
|
|
172
172
|
break;
|
|
173
173
|
}
|
|
174
|
-
default:
|
|
174
|
+
default: {
|
|
175
175
|
(0, internal_1.unreachableCase)(op.type);
|
|
176
|
+
}
|
|
176
177
|
}
|
|
177
178
|
}
|
|
178
179
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consensusRegisterCollection.js","sourceRoot":"","sources":["../src/consensusRegisterCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA6E;AAC7E,kEAA8E;AAM9E,0EAA0E;AAO1E,0EAIqD;AAErD,mDAIyB;AAqBzB,MAAM,gBAAgB,GAAG,CAAI,cAAsB,EAAE,KAAQ,EAAqB,EAAE,CAAC,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BAAgB,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;QACrD,IAAI,CAAC,kBAAkB,CAAC,EAAE,EAAE,gBAAgB,CAAC,CAAC;IAC/C,CAAC;CACD;AAzTD,kEAyTC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString, createEmitter } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tIFluidSerializer,\n\tSharedObject,\n\tcreateSingleBlobSummary,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport {\n\tIConsensusRegisterCollection,\n\tIConsensusRegisterCollectionEvents,\n\tReadPolicy,\n} from \"./interfaces.js\";\n\ninterface ILocalData<T> {\n\t// Atomic version\n\tatomic: ILocalRegister<T>;\n\n\t// All concurrent versions awaiting consensus\n\tversions: ILocalRegister<T>[];\n}\n\ninterface ILocalRegister<T> {\n\t// Register value, wrapped for backwards compatibility with < 0.17\n\tvalue: {\n\t\ttype: \"Plain\";\n\t\tvalue: T;\n\t};\n\n\t// The sequence number when last consensus was reached\n\tsequenceNumber: number;\n}\n\nconst newLocalRegister = <T>(sequenceNumber: number, value: T): ILocalRegister<T> => ({\n\tsequenceNumber,\n\tvalue: {\n\t\ttype: \"Plain\",\n\t\tvalue,\n\t},\n});\n\n/**\n * An operation for consensus register collection\n *\n * The value stored in this op is serialized as a string and must be deserialized\n */\ninterface IRegisterOperationSerialized {\n\tkey: string;\n\ttype: \"write\";\n\tserializedValue: string;\n\n\t// Message can be delivered with delay - resubmitted on reconnect.\n\t// As such, refSeq needs to reference seq # at the time op was created,\n\t// not when op was actually sent over wire (ISequencedDocumentMessage.referenceSequenceNumber),\n\t// as client can ingest ops in between.\n\trefSeq: number | undefined;\n}\n\n/**\n * IRegisterOperation format in versions \\< 0.17 and \\>=2.0.0-rc.2.0.0\n *\n * The value stored in this op is _not_ serialized and is stored literally as `T`\n */\ninterface IRegisterOperationPlain<T> {\n\tkey: string;\n\ttype: \"write\";\n\n\tvalue: {\n\t\ttype: \"Plain\";\n\t\tvalue: T;\n\t};\n\n\t// back-compat: for clients prior to 2.0.0-rc.2.0.0, we must also pass in\n\t// the serialized value for them to parse handles correctly. we do not have\n\t// to pay the cost of deserializing this value in newer clients\n\tserializedValue: string;\n\n\t// back-compat: files at rest written with runtime <= 0.13 do not have refSeq\n\trefSeq: number | undefined;\n}\n\n/** Incoming ops could match any of these types */\ntype IIncomingRegisterOperation<T> = IRegisterOperationSerialized | IRegisterOperationPlain<T>;\n\n/** Distinguish between incoming op formats so we know which type it is */\nconst incomingOpMatchesPlainFormat = <T>(op): op is IRegisterOperationPlain<T> =>\n\t\"value\" in op;\n\nconst snapshotFileName = \"header\";\n\ninterface IConsensusRegisterCollectionInternalEvents {\n\t/**\n\t * Emitted when a pending message is rolled back.\n\t * @param rollbackMessageId - A unique identifying number for the pending message.\n\t */\n\tpendingMessageRollback: (rollbackMessageId: number) => void;\n\n\t/**\n\t * Emitted when a pending message is acknowledged.\n\t * @param ackMessageId - A unique identifying number for the pending message.\n\t * @param isWinner - Whether the message won the FWW race to modify the value.\n\t */\n\tpendingMessageAck: (ackMessageId: number, isWinner: boolean) => void;\n}\n\n/**\n * {@inheritDoc IConsensusRegisterCollection}\n * @deprecated Use {@link IConsensusRegisterCollection} for typing and {@link ConsensusRegisterCollectionFactory} to create instances. This implementation class will be removed in a future release.\n * @legacy @beta\n */\nexport class ConsensusRegisterCollection<T>\n\textends SharedObject<IConsensusRegisterCollectionEvents>\n\timplements IConsensusRegisterCollection<T>\n{\n\tprivate readonly data = new Map<string, ILocalData<T>>();\n\tprivate readonly internalEvents =\n\t\tcreateEmitter<IConsensusRegisterCollectionInternalEvents>();\n\n\tprivate nextPendingMessageId: number = 0;\n\n\t/**\n\t * Constructs a new consensus register collection. If the object is non-local an id and service interfaces will\n\t * be provided\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_consensusRegisterCollection_\");\n\t}\n\n\t/**\n\t * Creates a new register or writes a new value.\n\t * Returns a promise that will resolve when the write is acked.\n\t *\n\t * @returns Promise<true> if write was non-concurrent\n\t */\n\tpublic async write(key: string, value: T): Promise<boolean> {\n\t\tif (this.runtime.disposed) {\n\t\t\t// Return false if disposed to signify that we did not write.\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!this.isAttached()) {\n\t\t\tthis.processInboundWrite(key, value, 0, 0, true);\n\t\t\treturn true;\n\t\t}\n\n\t\tconst message: IRegisterOperationPlain<T> = {\n\t\t\tkey,\n\t\t\ttype: \"write\",\n\t\t\tserializedValue: this.stringify(value, this.serializer),\n\t\t\tvalue: {\n\t\t\t\ttype: \"Plain\",\n\t\t\t\tvalue,\n\t\t\t},\n\t\t\trefSeq: this.deltaManager.lastSequenceNumber,\n\t\t};\n\n\t\tconst pendingMessageId = this.nextPendingMessageId++;\n\n\t\t// There are three ways the write promise can resolve:\n\t\t// 1. The write is acked\n\t\t// 2. The write is rolled back\n\t\t// 3. The runtime is disposed\n\t\t// The boolean value returned by the promise is true if the attempted write was ack'd and won, false otherwise.\n\t\treturn new Promise<boolean>((resolve) => {\n\t\t\tconst handleAck = (ackMessageId: number, isWinner: boolean): void => {\n\t\t\t\tif (ackMessageId === pendingMessageId) {\n\t\t\t\t\tresolve(isWinner);\n\t\t\t\t\tremoveListeners();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst handleRollback = (rollbackMessageId: number): void => {\n\t\t\t\tif (rollbackMessageId === pendingMessageId) {\n\t\t\t\t\t// If we rolled back the pending message, resolve the promise with false.\n\t\t\t\t\tresolve(false);\n\t\t\t\t\tremoveListeners();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst handleDisposed = (): void => {\n\t\t\t\tresolve(false);\n\t\t\t\tremoveListeners();\n\t\t\t};\n\n\t\t\tconst removeListeners = (): void => {\n\t\t\t\tthis.internalEvents.off(\"pendingMessageAck\", handleAck);\n\t\t\t\tthis.internalEvents.off(\"pendingMessageRollback\", handleRollback);\n\t\t\t\tthis.runtime.off(\"dispose\", handleDisposed);\n\t\t\t};\n\n\t\t\tthis.internalEvents.on(\"pendingMessageAck\", handleAck);\n\t\t\tthis.internalEvents.on(\"pendingMessageRollback\", handleRollback);\n\t\t\tthis.runtime.on(\"dispose\", handleDisposed);\n\n\t\t\tthis.submitLocalMessage(message, pendingMessageId);\n\t\t});\n\t}\n\n\t/**\n\t * Returns the most recent local value of a register.\n\t * @param key - The key to read\n\t * @param readPolicy - The ReadPolicy to apply. Defaults to Atomic.\n\t */\n\tpublic read(key: string, readPolicy: ReadPolicy = ReadPolicy.Atomic): T | undefined {\n\t\tif (readPolicy === ReadPolicy.Atomic) {\n\t\t\treturn this.readAtomic(key);\n\t\t}\n\n\t\tconst versions = this.readVersions(key);\n\n\t\tif (versions !== undefined) {\n\t\t\t// We don't support deletion. So there should be at least one value.\n\t\t\tassert(versions.length > 0, 0x06c /* \"Value should be undefined or non-empty\" */);\n\n\t\t\treturn versions[versions.length - 1];\n\t\t}\n\t}\n\n\tpublic readVersions(key: string): T[] | undefined {\n\t\tconst data = this.data.get(key);\n\t\treturn data?.versions.map((element: ILocalRegister<T>) => element.value.value);\n\t}\n\n\tpublic keys(): string[] {\n\t\treturn [...this.data.keys()];\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst dataObj: { [key: string]: ILocalData<T> } = {};\n\t\tthis.data.forEach((v, k) => {\n\t\t\tdataObj[k] = v;\n\t\t});\n\n\t\treturn createSingleBlobSummary(snapshotFileName, this.stringify(dataObj, serializer));\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst blob = await storage.readBlob(snapshotFileName);\n\t\tconst header = bufferToString(blob, \"utf8\");\n\t\tconst dataObj = this.parse(header, this.serializer);\n\n\t\tfor (const key of Object.keys(dataObj)) {\n\t\t\tassert(\n\t\t\t\tdataObj[key].atomic?.value.type !== \"Shared\",\n\t\t\t\t0x06d /* \"SharedObjects contained in ConsensusRegisterCollection can no longer be deserialized as of 0.17\" */,\n\t\t\t);\n\n\t\t\tthis.data.set(key, dataObj[key]);\n\t\t}\n\t}\n\n\tprotected onDisconnect(): void {}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\tif (messageEnvelope.type === MessageType.Operation) {\n\t\t\tconst op = messageContent.contents as IIncomingRegisterOperation<T>;\n\t\t\tswitch (op.type) {\n\t\t\t\tcase \"write\": {\n\t\t\t\t\t// backward compatibility: File at rest written with runtime <= 0.13 do not have refSeq\n\t\t\t\t\t// when the refSeq property didn't exist\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy\n\t\t\t\t\tif (op.refSeq === undefined) {\n\t\t\t\t\t\top.refSeq = messageEnvelope.referenceSequenceNumber;\n\t\t\t\t\t}\n\t\t\t\t\t// Message can be delivered with delay - e.g. resubmitted on reconnect.\n\t\t\t\t\t// Use the refSeq from when the op was created, not when it was transmitted\n\t\t\t\t\tconst refSeqWhenCreated = op.refSeq;\n\t\t\t\t\tassert(\n\t\t\t\t\t\trefSeqWhenCreated <= messageEnvelope.referenceSequenceNumber,\n\t\t\t\t\t\t0x06e /* \"Message's reference sequence number < op's reference sequence number!\" */,\n\t\t\t\t\t);\n\n\t\t\t\t\tconst value = incomingOpMatchesPlainFormat<T>(op)\n\t\t\t\t\t\t? op.value.value\n\t\t\t\t\t\t: (this.parse(op.serializedValue, this.serializer) as T);\n\t\t\t\t\tconst isWinner = this.processInboundWrite(\n\t\t\t\t\t\top.key,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\trefSeqWhenCreated,\n\t\t\t\t\t\tmessageEnvelope.sequenceNumber,\n\t\t\t\t\t\tlocal,\n\t\t\t\t\t);\n\t\t\t\t\tif (local) {\n\t\t\t\t\t\t// Resolve the pending promise for this operation now that we have received an ack for it.\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\ttypeof messageContent.localOpMetadata === \"number\",\n\t\t\t\t\t\t\t0xc0e /* Expect localOpMetadata to be a number */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.internalEvents.emit(\n\t\t\t\t\t\t\t\"pendingMessageAck\",\n\t\t\t\t\t\t\tmessageContent.localOpMetadata,\n\t\t\t\t\t\t\tisWinner,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(op.type);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate readAtomic(key: string): T | undefined {\n\t\tconst data = this.data.get(key);\n\t\treturn data?.atomic.value.value;\n\t}\n\n\t/**\n\t * Process an inbound write op\n\t * @param key - Key that was written to\n\t * @param value - Incoming value\n\t * @param refSeq - RefSeq at the time of write on the remote client\n\t * @param sequenceNumber - Sequence Number of this write op\n\t * @param local - Did this write originate on this client\n\t */\n\tprivate processInboundWrite(\n\t\tkey: string,\n\t\tvalue: T,\n\t\trefSeq: number,\n\t\tsequenceNumber: number,\n\t\tlocal: boolean,\n\t): boolean {\n\t\tlet data = this.data.get(key);\n\t\t// Atomic update if it's a new register or the write was not concurrent,\n\t\t// meaning our state was known to the remote client at the time of write\n\t\tconst isWinner = data === undefined || refSeq >= data.atomic.sequenceNumber;\n\t\tif (isWinner) {\n\t\t\tconst atomicUpdate = newLocalRegister<T>(sequenceNumber, value);\n\t\t\tif (data === undefined) {\n\t\t\t\tdata = {\n\t\t\t\t\tatomic: atomicUpdate,\n\t\t\t\t\tversions: [], // we'll update versions next, leave it empty for now\n\t\t\t\t};\n\t\t\t\tthis.data.set(key, data);\n\t\t\t} else {\n\t\t\t\tdata.atomic = atomicUpdate;\n\t\t\t}\n\t\t} else {\n\t\t\tassert(!!data, 0x06f /* \"data missing for non-atomic inbound update!\" */);\n\t\t}\n\n\t\t// Remove versions that were known to the remote client at the time of write\n\t\twhile (data.versions.length > 0 && refSeq >= data.versions[0].sequenceNumber) {\n\t\t\tdata.versions.shift();\n\t\t}\n\n\t\tconst versionUpdate = newLocalRegister<T>(sequenceNumber, value);\n\n\t\t// Asserts for data integrity\n\t\tif (!this.isAttached()) {\n\t\t\tassert(\n\t\t\t\trefSeq === 0 && sequenceNumber === 0,\n\t\t\t\t0x070 /* \"sequence numbers are expected to be 0 when unattached\" */,\n\t\t\t);\n\t\t} else if (data.versions.length > 0) {\n\t\t\tassert(\n\t\t\t\t// seqNum should always be increasing, except for the case of grouped batches (seqNum will be the same)\n\t\t\t\tsequenceNumber >= data.versions[data.versions.length - 1].sequenceNumber,\n\t\t\t\t0x071 /* \"Versions should naturally be ordered by sequenceNumber\" */,\n\t\t\t);\n\t\t}\n\n\t\t// Push the new element.\n\t\tdata.versions.push(versionUpdate);\n\n\t\t// Raise events at the end, to avoid reentrancy issues\n\t\tif (isWinner) {\n\t\t\tthis.emit(\"atomicChanged\", key, value, local);\n\t\t}\n\t\tthis.emit(\"versionChanged\", key, value, local);\n\n\t\treturn isWinner;\n\t}\n\n\tprivate stringify(value: any, serializer: IFluidSerializer): string {\n\t\treturn serializer.stringify(value, this.handle);\n\t}\n\n\tprivate parse(content: string, serializer: IFluidSerializer): any {\n\t\treturn serializer.parse(content);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n\t * @sealed\n\t */\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\t// We don't need to do anything to roll back CRC, it's safe to just drop\n\t\t// the op on the floor since we don't modify the DDS until the ack.\n\t\t// We emit an internal event so we know to resolve the pending promise.\n\t\tassert(\n\t\t\ttypeof localOpMetadata === \"number\",\n\t\t\t0xc0f /* Expect localOpMetadata to be a number */,\n\t\t);\n\t\tthis.internalEvents.emit(\"pendingMessageRollback\", localOpMetadata);\n\t}\n\n\tprotected applyStashedOp(content: unknown): void {\n\t\tconst op = content as IIncomingRegisterOperation<T>;\n\t\tassert(op.type === \"write\", 0xccc /* Only write ops should be stashed */);\n\t\t// Submit the original op (preserving its refSeq) so we can match the ACK\n\t\t// when it arrives during remote op processing.\n\t\tconst pendingMessageId = this.nextPendingMessageId++;\n\t\tthis.submitLocalMessage(op, pendingMessageId);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"consensusRegisterCollection.js","sourceRoot":"","sources":["../src/consensusRegisterCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA6E;AAC7E,kEAA8E;AAM9E,0EAA0E;AAQ1E,0EAGqD;AAMrD,mDAA6C;AAqB7C,MAAM,gBAAgB,GAAG,CAAI,cAAsB,EAAE,KAAQ,EAAqB,EAAE,CAAC,CAAC;IACrF,cAAc;IACd,KAAK,EAAE;QACN,IAAI,EAAE,OAAO;QACb,KAAK;KACL;CACD,CAAC,CAAC;AA6CH,0EAA0E;AAC1E,MAAM,4BAA4B,GAAG,CAAI,EAAE,EAAoC,EAAE,CAChF,OAAO,IAAI,EAAE,CAAC;AAEf,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAiB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All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString, createEmitter } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport {\n\tSharedObject,\n\tcreateSingleBlobSummary,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type {\n\tIConsensusRegisterCollection,\n\tIConsensusRegisterCollectionEvents,\n} from \"./interfaces.js\";\nimport { ReadPolicy } from \"./interfaces.js\";\n\ninterface ILocalData<T> {\n\t// Atomic version\n\tatomic: ILocalRegister<T>;\n\n\t// All concurrent versions awaiting consensus\n\tversions: ILocalRegister<T>[];\n}\n\ninterface ILocalRegister<T> {\n\t// Register value, wrapped for backwards compatibility with < 0.17\n\tvalue: {\n\t\ttype: \"Plain\";\n\t\tvalue: T;\n\t};\n\n\t// The sequence number when last consensus was reached\n\tsequenceNumber: number;\n}\n\nconst newLocalRegister = <T>(sequenceNumber: number, value: T): ILocalRegister<T> => ({\n\tsequenceNumber,\n\tvalue: {\n\t\ttype: \"Plain\",\n\t\tvalue,\n\t},\n});\n\n/**\n * An operation for consensus register collection\n *\n * The value stored in this op is serialized as a string and must be deserialized\n */\ninterface IRegisterOperationSerialized {\n\tkey: string;\n\ttype: \"write\";\n\tserializedValue: string;\n\n\t// Message can be delivered with delay - resubmitted on reconnect.\n\t// As such, refSeq needs to reference seq # at the time op was created,\n\t// not when op was actually sent over wire (ISequencedDocumentMessage.referenceSequenceNumber),\n\t// as client can ingest ops in between.\n\trefSeq: number | undefined;\n}\n\n/**\n * IRegisterOperation format in versions \\< 0.17 and \\>=2.0.0-rc.2.0.0\n *\n * The value stored in this op is _not_ serialized and is stored literally as `T`\n */\ninterface IRegisterOperationPlain<T> {\n\tkey: string;\n\ttype: \"write\";\n\n\tvalue: {\n\t\ttype: \"Plain\";\n\t\tvalue: T;\n\t};\n\n\t// back-compat: for clients prior to 2.0.0-rc.2.0.0, we must also pass in\n\t// the serialized value for them to parse handles correctly. we do not have\n\t// to pay the cost of deserializing this value in newer clients\n\tserializedValue: string;\n\n\t// back-compat: files at rest written with runtime <= 0.13 do not have refSeq\n\trefSeq: number | undefined;\n}\n\n/** Incoming ops could match any of these types */\ntype IIncomingRegisterOperation<T> = IRegisterOperationSerialized | IRegisterOperationPlain<T>;\n\n/** Distinguish between incoming op formats so we know which type it is */\nconst incomingOpMatchesPlainFormat = <T>(op): op is IRegisterOperationPlain<T> =>\n\t\"value\" in op;\n\nconst snapshotFileName = \"header\";\n\ninterface IConsensusRegisterCollectionInternalEvents {\n\t/**\n\t * Emitted when a pending message is rolled back.\n\t * @param rollbackMessageId - A unique identifying number for the pending message.\n\t */\n\tpendingMessageRollback: (rollbackMessageId: number) => void;\n\n\t/**\n\t * Emitted when a pending message is acknowledged.\n\t * @param ackMessageId - A unique identifying number for the pending message.\n\t * @param isWinner - Whether the message won the FWW race to modify the value.\n\t */\n\tpendingMessageAck: (ackMessageId: number, isWinner: boolean) => void;\n}\n\n/**\n * {@inheritDoc IConsensusRegisterCollection}\n * @deprecated Use {@link IConsensusRegisterCollection} for typing and {@link ConsensusRegisterCollectionFactory} to create instances. This implementation class will be removed in a future release.\n * @legacy @beta\n */\nexport class ConsensusRegisterCollection<T>\n\textends SharedObject<IConsensusRegisterCollectionEvents>\n\timplements IConsensusRegisterCollection<T>\n{\n\tprivate readonly data = new Map<string, ILocalData<T>>();\n\tprivate readonly internalEvents =\n\t\tcreateEmitter<IConsensusRegisterCollectionInternalEvents>();\n\n\tprivate nextPendingMessageId: number = 0;\n\n\t/**\n\t * Constructs a new consensus register collection. If the object is non-local an id and service interfaces will\n\t * be provided\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_consensusRegisterCollection_\");\n\t}\n\n\t/**\n\t * Creates a new register or writes a new value.\n\t * Returns a promise that will resolve when the write is acked.\n\t *\n\t * @returns Promise<true> if write was non-concurrent\n\t */\n\tpublic async write(key: string, value: T): Promise<boolean> {\n\t\tif (this.runtime.disposed) {\n\t\t\t// Return false if disposed to signify that we did not write.\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!this.isAttached()) {\n\t\t\tthis.processInboundWrite(key, value, 0, 0, true);\n\t\t\treturn true;\n\t\t}\n\n\t\tconst message: IRegisterOperationPlain<T> = {\n\t\t\tkey,\n\t\t\ttype: \"write\",\n\t\t\tserializedValue: this.stringify(value, this.serializer),\n\t\t\tvalue: {\n\t\t\t\ttype: \"Plain\",\n\t\t\t\tvalue,\n\t\t\t},\n\t\t\trefSeq: this.deltaManager.lastSequenceNumber,\n\t\t};\n\n\t\tconst pendingMessageId = this.nextPendingMessageId++;\n\n\t\t// There are three ways the write promise can resolve:\n\t\t// 1. The write is acked\n\t\t// 2. The write is rolled back\n\t\t// 3. The runtime is disposed\n\t\t// The boolean value returned by the promise is true if the attempted write was ack'd and won, false otherwise.\n\t\treturn new Promise<boolean>((resolve) => {\n\t\t\tconst handleAck = (ackMessageId: number, isWinner: boolean): void => {\n\t\t\t\tif (ackMessageId === pendingMessageId) {\n\t\t\t\t\tresolve(isWinner);\n\t\t\t\t\tremoveListeners();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst handleRollback = (rollbackMessageId: number): void => {\n\t\t\t\tif (rollbackMessageId === pendingMessageId) {\n\t\t\t\t\t// If we rolled back the pending message, resolve the promise with false.\n\t\t\t\t\tresolve(false);\n\t\t\t\t\tremoveListeners();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst handleDisposed = (): void => {\n\t\t\t\tresolve(false);\n\t\t\t\tremoveListeners();\n\t\t\t};\n\n\t\t\tconst removeListeners = (): void => {\n\t\t\t\tthis.internalEvents.off(\"pendingMessageAck\", handleAck);\n\t\t\t\tthis.internalEvents.off(\"pendingMessageRollback\", handleRollback);\n\t\t\t\tthis.runtime.off(\"dispose\", handleDisposed);\n\t\t\t};\n\n\t\t\tthis.internalEvents.on(\"pendingMessageAck\", handleAck);\n\t\t\tthis.internalEvents.on(\"pendingMessageRollback\", handleRollback);\n\t\t\tthis.runtime.on(\"dispose\", handleDisposed);\n\n\t\t\tthis.submitLocalMessage(message, pendingMessageId);\n\t\t});\n\t}\n\n\t/**\n\t * Returns the most recent local value of a register.\n\t * @param key - The key to read\n\t * @param readPolicy - The ReadPolicy to apply. Defaults to Atomic.\n\t */\n\tpublic read(key: string, readPolicy: ReadPolicy = ReadPolicy.Atomic): T | undefined {\n\t\tif (readPolicy === ReadPolicy.Atomic) {\n\t\t\treturn this.readAtomic(key);\n\t\t}\n\n\t\tconst versions = this.readVersions(key);\n\n\t\tif (versions !== undefined) {\n\t\t\t// We don't support deletion. So there should be at least one value.\n\t\t\tassert(versions.length > 0, 0x06c /* \"Value should be undefined or non-empty\" */);\n\n\t\t\treturn versions[versions.length - 1];\n\t\t}\n\t}\n\n\tpublic readVersions(key: string): T[] | undefined {\n\t\tconst data = this.data.get(key);\n\t\treturn data?.versions.map((element: ILocalRegister<T>) => element.value.value);\n\t}\n\n\tpublic keys(): string[] {\n\t\treturn [...this.data.keys()];\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst dataObj: { [key: string]: ILocalData<T> } = {};\n\t\tfor (const [k, v] of this.data.entries()) {\n\t\t\tdataObj[k] = v;\n\t\t}\n\n\t\treturn createSingleBlobSummary(snapshotFileName, this.stringify(dataObj, serializer));\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst blob = await storage.readBlob(snapshotFileName);\n\t\tconst header = bufferToString(blob, \"utf8\");\n\t\tconst dataObj = this.parse(header, this.serializer);\n\n\t\tfor (const key of Object.keys(dataObj)) {\n\t\t\tassert(\n\t\t\t\tdataObj[key].atomic?.value.type !== \"Shared\",\n\t\t\t\t0x06d /* \"SharedObjects contained in ConsensusRegisterCollection can no longer be deserialized as of 0.17\" */,\n\t\t\t);\n\n\t\t\tthis.data.set(key, dataObj[key]);\n\t\t}\n\t}\n\n\tprotected onDisconnect(): void {}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\tif (messageEnvelope.type === MessageType.Operation) {\n\t\t\tconst op = messageContent.contents as IIncomingRegisterOperation<T>;\n\t\t\tswitch (op.type) {\n\t\t\t\tcase \"write\": {\n\t\t\t\t\t// backward compatibility: File at rest written with runtime <= 0.13 do not have refSeq\n\t\t\t\t\t// when the refSeq property didn't exist\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy\n\t\t\t\t\tif (op.refSeq === undefined) {\n\t\t\t\t\t\top.refSeq = messageEnvelope.referenceSequenceNumber;\n\t\t\t\t\t}\n\t\t\t\t\t// Message can be delivered with delay - e.g. resubmitted on reconnect.\n\t\t\t\t\t// Use the refSeq from when the op was created, not when it was transmitted\n\t\t\t\t\tconst refSeqWhenCreated = op.refSeq;\n\t\t\t\t\tassert(\n\t\t\t\t\t\trefSeqWhenCreated <= messageEnvelope.referenceSequenceNumber,\n\t\t\t\t\t\t0x06e /* \"Message's reference sequence number < op's reference sequence number!\" */,\n\t\t\t\t\t);\n\n\t\t\t\t\tconst value = incomingOpMatchesPlainFormat<T>(op)\n\t\t\t\t\t\t? op.value.value\n\t\t\t\t\t\t: (this.parse(op.serializedValue, this.serializer) as T);\n\t\t\t\t\tconst isWinner = this.processInboundWrite(\n\t\t\t\t\t\top.key,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\trefSeqWhenCreated,\n\t\t\t\t\t\tmessageEnvelope.sequenceNumber,\n\t\t\t\t\t\tlocal,\n\t\t\t\t\t);\n\t\t\t\t\tif (local) {\n\t\t\t\t\t\t// Resolve the pending promise for this operation now that we have received an ack for it.\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\ttypeof messageContent.localOpMetadata === \"number\",\n\t\t\t\t\t\t\t0xc0e /* Expect localOpMetadata to be a number */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.internalEvents.emit(\n\t\t\t\t\t\t\t\"pendingMessageAck\",\n\t\t\t\t\t\t\tmessageContent.localOpMetadata,\n\t\t\t\t\t\t\tisWinner,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(op.type);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate readAtomic(key: string): T | undefined {\n\t\tconst data = this.data.get(key);\n\t\treturn data?.atomic.value.value;\n\t}\n\n\t/**\n\t * Process an inbound write op\n\t * @param key - Key that was written to\n\t * @param value - Incoming value\n\t * @param refSeq - RefSeq at the time of write on the remote client\n\t * @param sequenceNumber - Sequence Number of this write op\n\t * @param local - Did this write originate on this client\n\t */\n\tprivate processInboundWrite(\n\t\tkey: string,\n\t\tvalue: T,\n\t\trefSeq: number,\n\t\tsequenceNumber: number,\n\t\tlocal: boolean,\n\t): boolean {\n\t\tlet data = this.data.get(key);\n\t\t// Atomic update if it's a new register or the write was not concurrent,\n\t\t// meaning our state was known to the remote client at the time of write\n\t\tconst isWinner = data === undefined || refSeq >= data.atomic.sequenceNumber;\n\t\tif (isWinner) {\n\t\t\tconst atomicUpdate = newLocalRegister<T>(sequenceNumber, value);\n\t\t\tif (data === undefined) {\n\t\t\t\tdata = {\n\t\t\t\t\tatomic: atomicUpdate,\n\t\t\t\t\tversions: [], // we'll update versions next, leave it empty for now\n\t\t\t\t};\n\t\t\t\tthis.data.set(key, data);\n\t\t\t} else {\n\t\t\t\tdata.atomic = atomicUpdate;\n\t\t\t}\n\t\t} else {\n\t\t\tassert(!!data, 0x06f /* \"data missing for non-atomic inbound update!\" */);\n\t\t}\n\n\t\t// Remove versions that were known to the remote client at the time of write\n\t\twhile (data.versions.length > 0 && refSeq >= data.versions[0].sequenceNumber) {\n\t\t\tdata.versions.shift();\n\t\t}\n\n\t\tconst versionUpdate = newLocalRegister<T>(sequenceNumber, value);\n\n\t\t// Asserts for data integrity\n\t\tif (!this.isAttached()) {\n\t\t\tassert(\n\t\t\t\trefSeq === 0 && sequenceNumber === 0,\n\t\t\t\t0x070 /* \"sequence numbers are expected to be 0 when unattached\" */,\n\t\t\t);\n\t\t} else if (data.versions.length > 0) {\n\t\t\tassert(\n\t\t\t\t// seqNum should always be increasing, except for the case of grouped batches (seqNum will be the same)\n\t\t\t\tsequenceNumber >= data.versions[data.versions.length - 1].sequenceNumber,\n\t\t\t\t0x071 /* \"Versions should naturally be ordered by sequenceNumber\" */,\n\t\t\t);\n\t\t}\n\n\t\t// Push the new element.\n\t\tdata.versions.push(versionUpdate);\n\n\t\t// Raise events at the end, to avoid reentrancy issues\n\t\tif (isWinner) {\n\t\t\tthis.emit(\"atomicChanged\", key, value, local);\n\t\t}\n\t\tthis.emit(\"versionChanged\", key, value, local);\n\n\t\treturn isWinner;\n\t}\n\n\tprivate stringify(value: any, serializer: IFluidSerializer): string {\n\t\treturn serializer.stringify(value, this.handle);\n\t}\n\n\tprivate parse(content: string, serializer: IFluidSerializer): any {\n\t\treturn serializer.parse(content);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n\t * @sealed\n\t */\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\t// We don't need to do anything to roll back CRC, it's safe to just drop\n\t\t// the op on the floor since we don't modify the DDS until the ack.\n\t\t// We emit an internal event so we know to resolve the pending promise.\n\t\tassert(\n\t\t\ttypeof localOpMetadata === \"number\",\n\t\t\t0xc0f /* Expect localOpMetadata to be a number */,\n\t\t);\n\t\tthis.internalEvents.emit(\"pendingMessageRollback\", localOpMetadata);\n\t}\n\n\tprotected applyStashedOp(content: unknown): void {\n\t\tconst op = content as IIncomingRegisterOperation<T>;\n\t\tassert(op.type === \"write\", 0xccc /* Only write ops should be stashed */);\n\t\t// Submit the original op (preserving its refSeq) so we can match the ACK\n\t\t// when it arrives during remote op processing.\n\t\tconst pendingMessageId = this.nextPendingMessageId++;\n\t\tthis.submitLocalMessage(op, pendingMessageId);\n\t}\n}\n"]}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IChannelAttributes,
|
|
6
|
-
import { IConsensusRegisterCollection } from "./interfaces.js";
|
|
5
|
+
import type { IChannelAttributes, IChannelFactory, IChannelServices, IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions/internal";
|
|
6
|
+
import type { IConsensusRegisterCollection } from "./interfaces.js";
|
|
7
7
|
/**
|
|
8
8
|
* The factory that defines the consensus queue.
|
|
9
9
|
* @legacy @beta
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consensusRegisterCollectionFactory.d.ts","sourceRoot":"","sources":["../src/consensusRegisterCollectionFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"consensusRegisterCollectionFactory.d.ts","sourceRoot":"","sources":["../src/consensusRegisterCollectionFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AAKxD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAGpE;;;GAGG;AACH,qBAAa,kCACZ,YAAW,eAAe,CAAC,4BAA4B,CAAC;IAKxD,OAAc,IAAI,SAAqE;IAEvF,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,UAAU,IAAI,kBAAkB,CAE1C;IAED;;OAEG;IACU,IAAI,CAChB,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAC5B,OAAO,CAAC,4BAA4B,CAAC;IAOjC,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,4BAA4B;CAUzF;AAED;;;GAGG;AACH,eAAO,MAAM,2BAA2B,wNAEvC,CAAC;AACF;;;GAGG;AACH,MAAM,MAAM,2BAA2B,CAAC,CAAC,IAAI,4BAA4B,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -37,6 +37,9 @@ class ConsensusRegisterCollectionFactory {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
exports.ConsensusRegisterCollectionFactory = ConsensusRegisterCollectionFactory;
|
|
40
|
+
// New type string, to be activated once the migration has been fully shipped dark and is safe to flip.
|
|
41
|
+
// See LegacyTypeAwareRegistry in packages/runtime/datastore/src/dataStoreRuntime.ts.
|
|
42
|
+
// public static Type = "consensus-register-collection";
|
|
40
43
|
ConsensusRegisterCollectionFactory.Type = "https://graph.microsoft.com/types/consensus-register-collection";
|
|
41
44
|
ConsensusRegisterCollectionFactory.Attributes = {
|
|
42
45
|
type: ConsensusRegisterCollectionFactory.Type,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consensusRegisterCollectionFactory.js","sourceRoot":"","sources":["../src/consensusRegisterCollectionFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,0EAAqF;AAErF,mGAAmG;AACnG,qFAAmH;AAEnH,2DAAiD;AAEjD;;;GAGG;AACH,MAAa,kCAAkC;
|
|
1
|
+
{"version":3,"file":"consensusRegisterCollectionFactory.js","sourceRoot":"","sources":["../src/consensusRegisterCollectionFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,0EAAqF;AAErF,mGAAmG;AACnG,qFAAmH;AAEnH,2DAAiD;AAEjD;;;GAGG;AACH,MAAa,kCAAkC;IAc9C,IAAW,IAAI;QACd,OAAO,kCAAkC,CAAC,IAAI,CAAC;IAChD,CAAC;IAED,IAAW,UAAU;QACpB,OAAO,kCAAkC,CAAC,UAAU,CAAC;IACtD,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAE9B,wFAAwF;QACxF,MAAM,UAAU,GAAG,IAAI,4DAAgC,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QACjF,MAAM,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChC,OAAO,UAAU,CAAC;IACnB,CAAC;IAEM,MAAM,CAAC,QAAgC,EAAE,EAAU;QACzD,wFAAwF;QACxF,MAAM,UAAU,GAAG,IAAI,4DAAgC,CACtD,EAAE,EACF,QAAQ,EACR,kCAAkC,CAAC,UAAU,CAC7C,CAAC;QACF,UAAU,CAAC,eAAe,EAAE,CAAC;QAC7B,OAAO,UAAU,CAAC;IACnB,CAAC;;AA9CF,gFA+CC;AA5CA,uGAAuG;AACvG,qFAAqF;AACrF,wDAAwD;AAC1C,uCAAI,GAAG,iEAAiE,CAAC;AAEhE,6CAAU,GAAuB;IACvD,IAAI,EAAE,kCAAkC,CAAC,IAAI;IAC7C,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,8BAAU;CAC1B,CAAC;AAqCH;;;GAGG;AACU,QAAA,2BAA2B,GAAG,IAAA,iCAAsB,EAChE,kCAAkC,CAClC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIChannelServices,\n\tIFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { createSharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\n\n// eslint-disable-next-line import-x/no-deprecated -- Internal usage of deprecated class in factory\nimport { ConsensusRegisterCollection as ConsensusRegisterCollectionClass } from \"./consensusRegisterCollection.js\";\nimport type { IConsensusRegisterCollection } from \"./interfaces.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * The factory that defines the consensus queue.\n * @legacy @beta\n */\nexport class ConsensusRegisterCollectionFactory\n\timplements IChannelFactory<IConsensusRegisterCollection>\n{\n\t// New type string, to be activated once the migration has been fully shipped dark and is safe to flip.\n\t// See LegacyTypeAwareRegistry in packages/runtime/datastore/src/dataStoreRuntime.ts.\n\t// public static Type = \"consensus-register-collection\";\n\tpublic static Type = \"https://graph.microsoft.com/types/consensus-register-collection\";\n\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: ConsensusRegisterCollectionFactory.Type,\n\t\tsnapshotFormatVersion: \"0.1\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\tpublic get type(): string {\n\t\treturn ConsensusRegisterCollectionFactory.Type;\n\t}\n\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn ConsensusRegisterCollectionFactory.Attributes;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\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<IConsensusRegisterCollection> {\n\t\t// eslint-disable-next-line import-x/no-deprecated -- Internal usage of deprecated class\n\t\tconst collection = new ConsensusRegisterCollectionClass(id, runtime, attributes);\n\t\tawait collection.load(services);\n\t\treturn collection;\n\t}\n\n\tpublic create(document: IFluidDataStoreRuntime, id: string): IConsensusRegisterCollection {\n\t\t// eslint-disable-next-line import-x/no-deprecated -- Internal usage of deprecated class\n\t\tconst collection = new ConsensusRegisterCollectionClass(\n\t\t\tid,\n\t\t\tdocument,\n\t\t\tConsensusRegisterCollectionFactory.Attributes,\n\t\t);\n\t\tcollection.initializeLocal();\n\t\treturn collection;\n\t}\n}\n\n/**\n * {@inheritDoc IConsensusRegisterCollection}\n * @legacy @beta\n */\nexport const ConsensusRegisterCollection = createSharedObjectKind(\n\tConsensusRegisterCollectionFactory,\n);\n/**\n * Compatibility alias for {@link IConsensusRegisterCollection}.\n * @legacy @beta\n */\nexport type ConsensusRegisterCollection<T> = IConsensusRegisterCollection<T>;\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export { ConsensusRegisterCollection as ConsensusRegisterCollectionClass } from "./consensusRegisterCollection.js";
|
|
6
6
|
export { ConsensusRegisterCollectionFactory, ConsensusRegisterCollection, } from "./consensusRegisterCollectionFactory.js";
|
|
7
|
-
export { IConsensusRegisterCollection, IConsensusRegisterCollectionEvents, IConsensusRegisterCollectionFactory, ReadPolicy, } from "./interfaces.js";
|
|
7
|
+
export { type IConsensusRegisterCollection, type IConsensusRegisterCollectionEvents, type IConsensusRegisterCollectionFactory, ReadPolicy, } from "./interfaces.js";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,2BAA2B,IAAI,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AACnH,OAAO,EACN,kCAAkC,EAClC,2BAA2B,GAC3B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACN,4BAA4B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,2BAA2B,IAAI,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AACnH,OAAO,EACN,kCAAkC,EAClC,2BAA2B,GAC3B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACN,KAAK,4BAA4B,EACjC,KAAK,kCAAkC,EACvC,KAAK,mCAAmC,EACxC,UAAU,GACV,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mFAAmH;AAA1G,kJAAA,2BAA2B,OAAoC;AACxE,iGAGiD;AAFhD,2JAAA,kCAAkC,OAAA;AAClC,oJAAA,2BAA2B,OAAA;AAE5B,iDAKyB;AADxB,2GAAA,UAAU,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ConsensusRegisterCollection as ConsensusRegisterCollectionClass } from \"./consensusRegisterCollection.js\";\nexport {\n\tConsensusRegisterCollectionFactory,\n\tConsensusRegisterCollection,\n} from \"./consensusRegisterCollectionFactory.js\";\nexport {\n\
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mFAAmH;AAA1G,kJAAA,2BAA2B,OAAoC;AACxE,iGAGiD;AAFhD,2JAAA,kCAAkC,OAAA;AAClC,oJAAA,2BAA2B,OAAA;AAE5B,iDAKyB;AADxB,2GAAA,UAAU,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ConsensusRegisterCollection as ConsensusRegisterCollectionClass } from \"./consensusRegisterCollection.js\";\nexport {\n\tConsensusRegisterCollectionFactory,\n\tConsensusRegisterCollection,\n} from \"./consensusRegisterCollectionFactory.js\";\nexport {\n\ttype IConsensusRegisterCollection,\n\ttype IConsensusRegisterCollectionEvents,\n\ttype IConsensusRegisterCollectionFactory,\n\tReadPolicy,\n} from \"./interfaces.js\";\n"]}
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IChannelFactory } from "@fluidframework/datastore-definitions/internal";
|
|
6
|
-
import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base/internal";
|
|
5
|
+
import type { IChannelFactory } from "@fluidframework/datastore-definitions/internal";
|
|
6
|
+
import type { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base/internal";
|
|
7
7
|
/**
|
|
8
8
|
* Consensus Register Collection channel factory interface
|
|
9
9
|
*
|
package/dist/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,KAAK,EACX,aAAa,EACb,mBAAmB,EACnB,MAAM,6CAA6C,CAAC;AAErD;;;;;;;GAOG;AACH,MAAM,MAAM,mCAAmC,GAC9C,eAAe,CAAC,4BAA4B,CAAC,CAAC;AAE/C;;;GAGG;AACH,MAAM,WAAW,kCAAmC,SAAQ,mBAAmB;IAC9E,CACC,KAAK,EAAE,eAAe,GAAG,gBAAgB,EACzC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,OAC1D;CACF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,4BAA4B,CAAC,CAAC,GAAG,GAAG,CACpD,SAAQ,aAAa,CAAC,kCAAkC,CAAC;IACzD;;;;;OAKG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE/C;;OAEG;IACH,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,CAAC,GAAG,SAAS,CAAC;IAEtD;;OAEG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,EAAE,GAAG,SAAS,CAAC;IAE3C;;OAEG;IACH,IAAI,IAAI,MAAM,EAAE,CAAC;CACjB;AAED;;;GAGG;AACH,oBAAY,UAAU;IAErB,MAAM,IAAA;IAGN,GAAG,IAAA;CACH"}
|
package/dist/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA0EH;;;GAGG;AACH,IAAY,UAMX;AAND,WAAY,UAAU;IACrB,mFAAmF;IACnF,+CAAM,CAAA;IAEN,2DAA2D;IAC3D,yCAAG,CAAA;AACJ,CAAC,EANW,UAAU,0BAAV,UAAU,QAMrB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IChannelFactory } from \"@fluidframework/datastore-definitions/internal\";\nimport {\n\tISharedObject,\n\tISharedObjectEvents,\n} from \"@fluidframework/shared-object-base/internal\";\n\n/**\n * Consensus Register Collection channel factory interface\n *\n * Extends the base IChannelFactory to return a more definite type of IConsensusRegisterCollection\n * Use for the runtime to create and load distributed data structure by type name of each channel.\n * @legacy @beta\n * @deprecated Use `IChannelFactory<IConsensusRegisterCollection>`.\n */\nexport type IConsensusRegisterCollectionFactory =\n\tIChannelFactory<IConsensusRegisterCollection>;\n\n/**\n * Events emitted by {@link IConsensusRegisterCollection}.\n * @legacy @beta\n */\nexport interface IConsensusRegisterCollectionEvents extends ISharedObjectEvents {\n\t(\n\t\tevent: \"atomicChanged\" | \"versionChanged\",\n\t\tlistener: (key: string, value: any, local: boolean) => void,\n\t);\n}\n\n/**\n * A distributed data structure that holds a set of registers with update\n * versions. On concurrent updates, a register internally stores all possible versions of a value by using reference\n * sequence number of the incoming update.\n *\n * Using all the stored versions, we can then distinguish amongst different read policies. Below are the policies\n * we support:\n *\n * Atomic: Atomicity requires a linearizable register. A linearizable register behaves as if there is only a single\n * copy of the data, and that every operation appears to take effect atomically at one point in time. This definition\n * implies that operations are executed in an well-defined order. On a concurrent update, we perform a compare-and-set\n * operation, where we compare a register sequence number with the incoming reference sequence number.\n * The earliest operation overwriting prior sequence numbers wins since every client reaches to an agreement on\n * the value. So we can safely return the first value.\n *\n * LWW: The last write to a key always wins.\n * @legacy @beta\n */\nexport interface IConsensusRegisterCollection<T = any>\n\textends ISharedObject<IConsensusRegisterCollectionEvents> {\n\t/**\n\t * Attempts to write a register with a value. Returns a promise to indicate the roundtrip completion.\n\t * For a non existent register, it will attempt to create a new register with the specified value.\n\t *\n\t * @returns Promise<true> if write was non-concurrent\n\t */\n\twrite(key: string, value: T): Promise<boolean>;\n\n\t/**\n\t * Retrieves the agreed upon value for the register based on policy. Returns undefined if not present.\n\t */\n\tread(key: string, policy?: ReadPolicy): T | undefined;\n\n\t/**\n\t * Retrives all concurrent versions. Undefined if not present.\n\t */\n\treadVersions(key: string): T[] | undefined;\n\n\t/**\n\t * Returns the keys.\n\t */\n\tkeys(): string[];\n}\n\n/**\n * Read policies used when reading the map value.\n * @legacy @beta\n */\nexport enum ReadPolicy {\n\t// On a concurrent update, returns the first agreed upon value amongst all clients.\n\tAtomic,\n\n\t// Last writer wins. Simply returns the last written value.\n\tLWW,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA0EH;;;GAGG;AACH,IAAY,UAMX;AAND,WAAY,UAAU;IACrB,mFAAmF;IACnF,+CAAM,CAAA;IAEN,2DAA2D;IAC3D,yCAAG,CAAA;AACJ,CAAC,EANW,UAAU,0BAAV,UAAU,QAMrB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IChannelFactory } from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tISharedObject,\n\tISharedObjectEvents,\n} from \"@fluidframework/shared-object-base/internal\";\n\n/**\n * Consensus Register Collection channel factory interface\n *\n * Extends the base IChannelFactory to return a more definite type of IConsensusRegisterCollection\n * Use for the runtime to create and load distributed data structure by type name of each channel.\n * @legacy @beta\n * @deprecated Use `IChannelFactory<IConsensusRegisterCollection>`.\n */\nexport type IConsensusRegisterCollectionFactory =\n\tIChannelFactory<IConsensusRegisterCollection>;\n\n/**\n * Events emitted by {@link IConsensusRegisterCollection}.\n * @legacy @beta\n */\nexport interface IConsensusRegisterCollectionEvents extends ISharedObjectEvents {\n\t(\n\t\tevent: \"atomicChanged\" | \"versionChanged\",\n\t\tlistener: (key: string, value: any, local: boolean) => void,\n\t);\n}\n\n/**\n * A distributed data structure that holds a set of registers with update\n * versions. On concurrent updates, a register internally stores all possible versions of a value by using reference\n * sequence number of the incoming update.\n *\n * Using all the stored versions, we can then distinguish amongst different read policies. Below are the policies\n * we support:\n *\n * Atomic: Atomicity requires a linearizable register. A linearizable register behaves as if there is only a single\n * copy of the data, and that every operation appears to take effect atomically at one point in time. This definition\n * implies that operations are executed in an well-defined order. On a concurrent update, we perform a compare-and-set\n * operation, where we compare a register sequence number with the incoming reference sequence number.\n * The earliest operation overwriting prior sequence numbers wins since every client reaches to an agreement on\n * the value. So we can safely return the first value.\n *\n * LWW: The last write to a key always wins.\n * @legacy @beta\n */\nexport interface IConsensusRegisterCollection<T = any>\n\textends ISharedObject<IConsensusRegisterCollectionEvents> {\n\t/**\n\t * Attempts to write a register with a value. Returns a promise to indicate the roundtrip completion.\n\t * For a non existent register, it will attempt to create a new register with the specified value.\n\t *\n\t * @returns Promise<true> if write was non-concurrent\n\t */\n\twrite(key: string, value: T): Promise<boolean>;\n\n\t/**\n\t * Retrieves the agreed upon value for the register based on policy. Returns undefined if not present.\n\t */\n\tread(key: string, policy?: ReadPolicy): T | undefined;\n\n\t/**\n\t * Retrives all concurrent versions. Undefined if not present.\n\t */\n\treadVersions(key: string): T[] | undefined;\n\n\t/**\n\t * Returns the keys.\n\t */\n\tkeys(): string[];\n}\n\n/**\n * Read policies used when reading the map value.\n * @legacy @beta\n */\nexport enum ReadPolicy {\n\t// On a concurrent update, returns the first agreed upon value amongst all clients.\n\tAtomic,\n\n\t// Last writer wins. Simply returns the last written value.\n\tLWW,\n}\n"]}
|
package/dist/legacy.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
-
* Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
|
|
8
|
+
* Generated by "flub generate entrypoints --resolutionConditions require --outFileLegacyBeta legacy --outDir ./dist" in @fluid-tools/build-cli.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export {
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/register-collection";
|
|
8
|
-
export declare const pkgVersion = "2.
|
|
8
|
+
export declare const pkgVersion = "2.92.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/register-collection";
|
|
11
|
-
exports.pkgVersion = "2.
|
|
11
|
+
exports.pkgVersion = "2.92.0";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,qCAAqC,CAAC;AAChD,QAAA,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/register-collection\";\nexport const pkgVersion = \"2.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,qCAAqC,CAAC;AAChD,QAAA,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/register-collection\";\nexport const pkgVersion = \"2.92.0\";\n"]}
|
package/dist/public.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
-
* Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
|
|
8
|
+
* Generated by "flub generate entrypoints --resolutionConditions require --outFileLegacyBeta legacy --outDir ./dist" in @fluid-tools/build-cli.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export {}
|
package/eslint.config.mts
CHANGED
|
@@ -4,8 +4,18 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { Linter } from "eslint";
|
|
7
|
-
import {
|
|
7
|
+
import { recommended } from "../../../common/build/eslint-config-fluid/flat.mts";
|
|
8
8
|
|
|
9
|
-
const config: Linter.Config[] = [
|
|
9
|
+
const config: Linter.Config[] = [
|
|
10
|
+
...recommended,
|
|
11
|
+
{
|
|
12
|
+
rules: {
|
|
13
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
14
|
+
"@typescript-eslint/no-unsafe-argument": "off",
|
|
15
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
16
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
];
|
|
10
20
|
|
|
11
21
|
export default config;
|
package/internal.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
-
* Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
|
|
8
|
+
* Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat" in @fluid-tools/build-cli.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export * from "./lib/index.js";
|
package/legacy.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
-
* Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
|
|
8
|
+
* Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat" in @fluid-tools/build-cli.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export * from "./lib/legacy.js";
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IChannelAttributes, IFluidDataStoreRuntime, IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
|
|
6
|
-
import { ISummaryTreeWithStats, IRuntimeMessageCollection } from "@fluidframework/runtime-definitions/internal";
|
|
7
|
-
import { IFluidSerializer
|
|
8
|
-
import {
|
|
5
|
+
import type { IChannelAttributes, IFluidDataStoreRuntime, IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
|
|
6
|
+
import type { ISummaryTreeWithStats, IRuntimeMessageCollection } from "@fluidframework/runtime-definitions/internal";
|
|
7
|
+
import type { IFluidSerializer } from "@fluidframework/shared-object-base/internal";
|
|
8
|
+
import { SharedObject } from "@fluidframework/shared-object-base/internal";
|
|
9
|
+
import type { IConsensusRegisterCollection, IConsensusRegisterCollectionEvents } from "./interfaces.js";
|
|
10
|
+
import { ReadPolicy } from "./interfaces.js";
|
|
9
11
|
/**
|
|
10
12
|
* {@inheritDoc IConsensusRegisterCollection}
|
|
11
13
|
* @deprecated Use {@link IConsensusRegisterCollection} for typing and {@link ConsensusRegisterCollectionFactory} to create instances. This implementation class will be removed in a future release.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consensusRegisterCollection.d.ts","sourceRoot":"","sources":["../src/consensusRegisterCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,
|
|
1
|
+
{"version":3,"file":"consensusRegisterCollection.d.ts","sourceRoot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AAC,IAAI,CAAC;IAexE,SAAS,CAAC,YAAY,IAAI,IAAI;cAEX,mBAAmB,CAAC,kBAAkB,EAAE,yBAAyB,GAAG,IAAI;IAO3F,OAAO,CAAC,cAAc;IAsDtB,OAAO,CAAC,UAAU;IAKlB;;;;;;;OAOG;IACH,OAAO,CAAC,mBAAmB;IA2D3B,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,KAAK;IAIb;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAWpE,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;CAQhD"}
|
|
@@ -6,7 +6,7 @@ import { bufferToString, createEmitter } from "@fluid-internal/client-utils";
|
|
|
6
6
|
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { MessageType } from "@fluidframework/driver-definitions/internal";
|
|
8
8
|
import { SharedObject, createSingleBlobSummary, } from "@fluidframework/shared-object-base/internal";
|
|
9
|
-
import { ReadPolicy
|
|
9
|
+
import { ReadPolicy } from "./interfaces.js";
|
|
10
10
|
const newLocalRegister = (sequenceNumber, value) => ({
|
|
11
11
|
sequenceNumber,
|
|
12
12
|
value: {
|
|
@@ -118,9 +118,9 @@ export class ConsensusRegisterCollection extends SharedObject {
|
|
|
118
118
|
}
|
|
119
119
|
summarizeCore(serializer) {
|
|
120
120
|
const dataObj = {};
|
|
121
|
-
this.data.
|
|
121
|
+
for (const [k, v] of this.data.entries()) {
|
|
122
122
|
dataObj[k] = v;
|
|
123
|
-
}
|
|
123
|
+
}
|
|
124
124
|
return createSingleBlobSummary(snapshotFileName, this.stringify(dataObj, serializer));
|
|
125
125
|
}
|
|
126
126
|
/**
|
|
@@ -168,8 +168,9 @@ export class ConsensusRegisterCollection extends SharedObject {
|
|
|
168
168
|
}
|
|
169
169
|
break;
|
|
170
170
|
}
|
|
171
|
-
default:
|
|
171
|
+
default: {
|
|
172
172
|
unreachableCase(op.type);
|
|
173
|
+
}
|
|
173
174
|
}
|
|
174
175
|
}
|
|
175
176
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consensusRegisterCollection.js","sourceRoot":"","sources":["../src/consensusRegisterCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAM9E,OAAO,EAAE,WAAW,EAAE,MAAM,6CAA6C,CAAC;AAO1E,OAAO,EAEN,YAAY,EACZ,uBAAuB,GACvB,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAGN,UAAU,GACV,MAAM,iBAAiB,CAAC;AAqBzB,MAAM,gBAAgB,GAAG,CAAI,cAAsB,EAAE,KAAQ,EAAqB,EAAE,CAAC,CAAC;IACrF,cAAc;IACd,KAAK,EAAE;QACN,IAAI,EAAE,OAAO;QACb,KAAK;KACL;CACD,CAAC,CAAC;AA6CH,0EAA0E;AAC1E,MAAM,4BAA4B,GAAG,CAAI,EAAE,EAAoC,EAAE,CAChF,OAAO,IAAI,EAAE,CAAC;AAEf,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAiBlC;;;;GAIG;AACH,MAAM,OAAO,2BACZ,SAAQ,YAAgD;IASxD;;;OAGG;IACH,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B;QAE9B,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,oCAAoC,CAAC,CAAC;QAfrD,SAAI,GAAG,IAAI,GAAG,EAAyB,CAAC;QACxC,mBAAc,GAC9B,aAAa,EAA8C,CAAC;QAErD,yBAAoB,GAAW,CAAC,CAAC;IAYzC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,KAAK,CAAC,GAAW,EAAE,KAAQ;QACvC,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAA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AO,CAAC,CAAC;IAClC,CAAC;IAED;;;OAGG;IACO,QAAQ,CAAC,OAAgB,EAAE,eAAwB;QAC5D,wEAAwE;QACxE,mEAAmE;QACnE,uEAAuE;QACvE,MAAM,CACL,OAAO,eAAe,KAAK,QAAQ,EACnC,KAAK,CAAC,2CAA2C,CACjD,CAAC;QACF,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,wBAAwB,EAAE,eAAe,CAAC,CAAC;IACrE,CAAC;IAES,cAAc,CAAC,OAAgB;QACxC,MAAM,EAAE,GAAG,OAAwC,CAAC;QACpD,MAAM,CAAC,EAAE,CAAC,IAAI,KAAK,OAAO,EAAE,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC1E,yEAAyE;QACzE,+CAA+C;QAC/C,MAAM,gBAAgB,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;QACrD,IAAI,CAAC,kBAAkB,CAAC,EAAE,EAAE,gBAAgB,CAAC,CAAC;IAC/C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString, createEmitter } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tIFluidSerializer,\n\tSharedObject,\n\tcreateSingleBlobSummary,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport {\n\tIConsensusRegisterCollection,\n\tIConsensusRegisterCollectionEvents,\n\tReadPolicy,\n} from \"./interfaces.js\";\n\ninterface ILocalData<T> {\n\t// Atomic version\n\tatomic: ILocalRegister<T>;\n\n\t// All concurrent versions awaiting consensus\n\tversions: ILocalRegister<T>[];\n}\n\ninterface ILocalRegister<T> {\n\t// Register value, wrapped for backwards compatibility with < 0.17\n\tvalue: {\n\t\ttype: \"Plain\";\n\t\tvalue: T;\n\t};\n\n\t// The sequence number when last consensus was reached\n\tsequenceNumber: number;\n}\n\nconst newLocalRegister = <T>(sequenceNumber: number, value: T): ILocalRegister<T> => ({\n\tsequenceNumber,\n\tvalue: {\n\t\ttype: \"Plain\",\n\t\tvalue,\n\t},\n});\n\n/**\n * An operation for consensus register collection\n *\n * The value stored in this op is serialized as a string and must be deserialized\n */\ninterface IRegisterOperationSerialized {\n\tkey: string;\n\ttype: \"write\";\n\tserializedValue: string;\n\n\t// Message can be delivered with delay - resubmitted on reconnect.\n\t// As such, refSeq needs to reference seq # at the time op was created,\n\t// not when op was actually sent over wire (ISequencedDocumentMessage.referenceSequenceNumber),\n\t// as client can ingest ops in between.\n\trefSeq: number | undefined;\n}\n\n/**\n * IRegisterOperation format in versions \\< 0.17 and \\>=2.0.0-rc.2.0.0\n *\n * The value stored in this op is _not_ serialized and is stored literally as `T`\n */\ninterface IRegisterOperationPlain<T> {\n\tkey: string;\n\ttype: \"write\";\n\n\tvalue: {\n\t\ttype: \"Plain\";\n\t\tvalue: T;\n\t};\n\n\t// back-compat: for clients prior to 2.0.0-rc.2.0.0, we must also pass in\n\t// the serialized value for them to parse handles correctly. we do not have\n\t// to pay the cost of deserializing this value in newer clients\n\tserializedValue: string;\n\n\t// back-compat: files at rest written with runtime <= 0.13 do not have refSeq\n\trefSeq: number | undefined;\n}\n\n/** Incoming ops could match any of these types */\ntype IIncomingRegisterOperation<T> = IRegisterOperationSerialized | IRegisterOperationPlain<T>;\n\n/** Distinguish between incoming op formats so we know which type it is */\nconst incomingOpMatchesPlainFormat = <T>(op): op is IRegisterOperationPlain<T> =>\n\t\"value\" in op;\n\nconst snapshotFileName = \"header\";\n\ninterface IConsensusRegisterCollectionInternalEvents {\n\t/**\n\t * Emitted when a pending message is rolled back.\n\t * @param rollbackMessageId - A unique identifying number for the pending message.\n\t */\n\tpendingMessageRollback: (rollbackMessageId: number) => void;\n\n\t/**\n\t * Emitted when a pending message is acknowledged.\n\t * @param ackMessageId - A unique identifying number for the pending message.\n\t * @param isWinner - Whether the message won the FWW race to modify the value.\n\t */\n\tpendingMessageAck: (ackMessageId: number, isWinner: boolean) => void;\n}\n\n/**\n * {@inheritDoc IConsensusRegisterCollection}\n * @deprecated Use {@link IConsensusRegisterCollection} for typing and {@link ConsensusRegisterCollectionFactory} to create instances. This implementation class will be removed in a future release.\n * @legacy @beta\n */\nexport class ConsensusRegisterCollection<T>\n\textends SharedObject<IConsensusRegisterCollectionEvents>\n\timplements IConsensusRegisterCollection<T>\n{\n\tprivate readonly data = new Map<string, ILocalData<T>>();\n\tprivate readonly internalEvents =\n\t\tcreateEmitter<IConsensusRegisterCollectionInternalEvents>();\n\n\tprivate nextPendingMessageId: number = 0;\n\n\t/**\n\t * Constructs a new consensus register collection. If the object is non-local an id and service interfaces will\n\t * be provided\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_consensusRegisterCollection_\");\n\t}\n\n\t/**\n\t * Creates a new register or writes a new value.\n\t * Returns a promise that will resolve when the write is acked.\n\t *\n\t * @returns Promise<true> if write was non-concurrent\n\t */\n\tpublic async write(key: string, value: T): Promise<boolean> {\n\t\tif (this.runtime.disposed) {\n\t\t\t// Return false if disposed to signify that we did not write.\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!this.isAttached()) {\n\t\t\tthis.processInboundWrite(key, value, 0, 0, true);\n\t\t\treturn true;\n\t\t}\n\n\t\tconst message: IRegisterOperationPlain<T> = {\n\t\t\tkey,\n\t\t\ttype: \"write\",\n\t\t\tserializedValue: this.stringify(value, this.serializer),\n\t\t\tvalue: {\n\t\t\t\ttype: \"Plain\",\n\t\t\t\tvalue,\n\t\t\t},\n\t\t\trefSeq: this.deltaManager.lastSequenceNumber,\n\t\t};\n\n\t\tconst pendingMessageId = this.nextPendingMessageId++;\n\n\t\t// There are three ways the write promise can resolve:\n\t\t// 1. The write is acked\n\t\t// 2. The write is rolled back\n\t\t// 3. The runtime is disposed\n\t\t// The boolean value returned by the promise is true if the attempted write was ack'd and won, false otherwise.\n\t\treturn new Promise<boolean>((resolve) => {\n\t\t\tconst handleAck = (ackMessageId: number, isWinner: boolean): void => {\n\t\t\t\tif (ackMessageId === pendingMessageId) {\n\t\t\t\t\tresolve(isWinner);\n\t\t\t\t\tremoveListeners();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst handleRollback = (rollbackMessageId: number): void => {\n\t\t\t\tif (rollbackMessageId === pendingMessageId) {\n\t\t\t\t\t// If we rolled back the pending message, resolve the promise with false.\n\t\t\t\t\tresolve(false);\n\t\t\t\t\tremoveListeners();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst handleDisposed = (): void => {\n\t\t\t\tresolve(false);\n\t\t\t\tremoveListeners();\n\t\t\t};\n\n\t\t\tconst removeListeners = (): void => {\n\t\t\t\tthis.internalEvents.off(\"pendingMessageAck\", handleAck);\n\t\t\t\tthis.internalEvents.off(\"pendingMessageRollback\", handleRollback);\n\t\t\t\tthis.runtime.off(\"dispose\", handleDisposed);\n\t\t\t};\n\n\t\t\tthis.internalEvents.on(\"pendingMessageAck\", handleAck);\n\t\t\tthis.internalEvents.on(\"pendingMessageRollback\", handleRollback);\n\t\t\tthis.runtime.on(\"dispose\", handleDisposed);\n\n\t\t\tthis.submitLocalMessage(message, pendingMessageId);\n\t\t});\n\t}\n\n\t/**\n\t * Returns the most recent local value of a register.\n\t * @param key - The key to read\n\t * @param readPolicy - The ReadPolicy to apply. Defaults to Atomic.\n\t */\n\tpublic read(key: string, readPolicy: ReadPolicy = ReadPolicy.Atomic): T | undefined {\n\t\tif (readPolicy === ReadPolicy.Atomic) {\n\t\t\treturn this.readAtomic(key);\n\t\t}\n\n\t\tconst versions = this.readVersions(key);\n\n\t\tif (versions !== undefined) {\n\t\t\t// We don't support deletion. So there should be at least one value.\n\t\t\tassert(versions.length > 0, 0x06c /* \"Value should be undefined or non-empty\" */);\n\n\t\t\treturn versions[versions.length - 1];\n\t\t}\n\t}\n\n\tpublic readVersions(key: string): T[] | undefined {\n\t\tconst data = this.data.get(key);\n\t\treturn data?.versions.map((element: ILocalRegister<T>) => element.value.value);\n\t}\n\n\tpublic keys(): string[] {\n\t\treturn [...this.data.keys()];\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst dataObj: { [key: string]: ILocalData<T> } = {};\n\t\tthis.data.forEach((v, k) => {\n\t\t\tdataObj[k] = v;\n\t\t});\n\n\t\treturn createSingleBlobSummary(snapshotFileName, this.stringify(dataObj, serializer));\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst blob = await storage.readBlob(snapshotFileName);\n\t\tconst header = bufferToString(blob, \"utf8\");\n\t\tconst dataObj = this.parse(header, this.serializer);\n\n\t\tfor (const key of Object.keys(dataObj)) {\n\t\t\tassert(\n\t\t\t\tdataObj[key].atomic?.value.type !== \"Shared\",\n\t\t\t\t0x06d /* \"SharedObjects contained in ConsensusRegisterCollection can no longer be deserialized as of 0.17\" */,\n\t\t\t);\n\n\t\t\tthis.data.set(key, dataObj[key]);\n\t\t}\n\t}\n\n\tprotected onDisconnect(): void {}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\tif (messageEnvelope.type === MessageType.Operation) {\n\t\t\tconst op = messageContent.contents as IIncomingRegisterOperation<T>;\n\t\t\tswitch (op.type) {\n\t\t\t\tcase \"write\": {\n\t\t\t\t\t// backward compatibility: File at rest written with runtime <= 0.13 do not have refSeq\n\t\t\t\t\t// when the refSeq property didn't exist\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy\n\t\t\t\t\tif (op.refSeq === undefined) {\n\t\t\t\t\t\top.refSeq = messageEnvelope.referenceSequenceNumber;\n\t\t\t\t\t}\n\t\t\t\t\t// Message can be delivered with delay - e.g. resubmitted on reconnect.\n\t\t\t\t\t// Use the refSeq from when the op was created, not when it was transmitted\n\t\t\t\t\tconst refSeqWhenCreated = op.refSeq;\n\t\t\t\t\tassert(\n\t\t\t\t\t\trefSeqWhenCreated <= messageEnvelope.referenceSequenceNumber,\n\t\t\t\t\t\t0x06e /* \"Message's reference sequence number < op's reference sequence number!\" */,\n\t\t\t\t\t);\n\n\t\t\t\t\tconst value = incomingOpMatchesPlainFormat<T>(op)\n\t\t\t\t\t\t? op.value.value\n\t\t\t\t\t\t: (this.parse(op.serializedValue, this.serializer) as T);\n\t\t\t\t\tconst isWinner = this.processInboundWrite(\n\t\t\t\t\t\top.key,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\trefSeqWhenCreated,\n\t\t\t\t\t\tmessageEnvelope.sequenceNumber,\n\t\t\t\t\t\tlocal,\n\t\t\t\t\t);\n\t\t\t\t\tif (local) {\n\t\t\t\t\t\t// Resolve the pending promise for this operation now that we have received an ack for it.\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\ttypeof messageContent.localOpMetadata === \"number\",\n\t\t\t\t\t\t\t0xc0e /* Expect localOpMetadata to be a number */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.internalEvents.emit(\n\t\t\t\t\t\t\t\"pendingMessageAck\",\n\t\t\t\t\t\t\tmessageContent.localOpMetadata,\n\t\t\t\t\t\t\tisWinner,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(op.type);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate readAtomic(key: string): T | undefined {\n\t\tconst data = this.data.get(key);\n\t\treturn data?.atomic.value.value;\n\t}\n\n\t/**\n\t * Process an inbound write op\n\t * @param key - Key that was written to\n\t * @param value - Incoming value\n\t * @param refSeq - RefSeq at the time of write on the remote client\n\t * @param sequenceNumber - Sequence Number of this write op\n\t * @param local - Did this write originate on this client\n\t */\n\tprivate processInboundWrite(\n\t\tkey: string,\n\t\tvalue: T,\n\t\trefSeq: number,\n\t\tsequenceNumber: number,\n\t\tlocal: boolean,\n\t): boolean {\n\t\tlet data = this.data.get(key);\n\t\t// Atomic update if it's a new register or the write was not concurrent,\n\t\t// meaning our state was known to the remote client at the time of write\n\t\tconst isWinner = data === undefined || refSeq >= data.atomic.sequenceNumber;\n\t\tif (isWinner) {\n\t\t\tconst atomicUpdate = newLocalRegister<T>(sequenceNumber, value);\n\t\t\tif (data === undefined) {\n\t\t\t\tdata = {\n\t\t\t\t\tatomic: atomicUpdate,\n\t\t\t\t\tversions: [], // we'll update versions next, leave it empty for now\n\t\t\t\t};\n\t\t\t\tthis.data.set(key, data);\n\t\t\t} else {\n\t\t\t\tdata.atomic = atomicUpdate;\n\t\t\t}\n\t\t} else {\n\t\t\tassert(!!data, 0x06f /* \"data missing for non-atomic inbound update!\" */);\n\t\t}\n\n\t\t// Remove versions that were known to the remote client at the time of write\n\t\twhile (data.versions.length > 0 && refSeq >= data.versions[0].sequenceNumber) {\n\t\t\tdata.versions.shift();\n\t\t}\n\n\t\tconst versionUpdate = newLocalRegister<T>(sequenceNumber, value);\n\n\t\t// Asserts for data integrity\n\t\tif (!this.isAttached()) {\n\t\t\tassert(\n\t\t\t\trefSeq === 0 && sequenceNumber === 0,\n\t\t\t\t0x070 /* \"sequence numbers are expected to be 0 when unattached\" */,\n\t\t\t);\n\t\t} else if (data.versions.length > 0) {\n\t\t\tassert(\n\t\t\t\t// seqNum should always be increasing, except for the case of grouped batches (seqNum will be the same)\n\t\t\t\tsequenceNumber >= data.versions[data.versions.length - 1].sequenceNumber,\n\t\t\t\t0x071 /* \"Versions should naturally be ordered by sequenceNumber\" */,\n\t\t\t);\n\t\t}\n\n\t\t// Push the new element.\n\t\tdata.versions.push(versionUpdate);\n\n\t\t// Raise events at the end, to avoid reentrancy issues\n\t\tif (isWinner) {\n\t\t\tthis.emit(\"atomicChanged\", key, value, local);\n\t\t}\n\t\tthis.emit(\"versionChanged\", key, value, local);\n\n\t\treturn isWinner;\n\t}\n\n\tprivate stringify(value: any, serializer: IFluidSerializer): string {\n\t\treturn serializer.stringify(value, this.handle);\n\t}\n\n\tprivate parse(content: string, serializer: IFluidSerializer): any {\n\t\treturn serializer.parse(content);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n\t * @sealed\n\t */\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\t// We don't need to do anything to roll back CRC, it's safe to just drop\n\t\t// the op on the floor since we don't modify the DDS until the ack.\n\t\t// We emit an internal event so we know to resolve the pending promise.\n\t\tassert(\n\t\t\ttypeof localOpMetadata === \"number\",\n\t\t\t0xc0f /* Expect localOpMetadata to be a number */,\n\t\t);\n\t\tthis.internalEvents.emit(\"pendingMessageRollback\", localOpMetadata);\n\t}\n\n\tprotected applyStashedOp(content: unknown): void {\n\t\tconst op = content as IIncomingRegisterOperation<T>;\n\t\tassert(op.type === \"write\", 0xccc /* Only write ops should be stashed */);\n\t\t// Submit the original op (preserving its refSeq) so we can match the ACK\n\t\t// when it arrives during remote op processing.\n\t\tconst pendingMessageId = this.nextPendingMessageId++;\n\t\tthis.submitLocalMessage(op, pendingMessageId);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"consens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;QAC5D,wEAAwE;QACxE,mEAAmE;QACnE,uEAAuE;QACvE,MAAM,CACL,OAAO,eAAe,KAAK,QAAQ,EACnC,KAAK,CAAC,2CAA2C,CACjD,CAAC;QACF,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,wBAAwB,EAAE,eAAe,CAAC,CAAC;IACrE,CAAC;IAES,cAAc,CAAC,OAAgB;QACxC,MAAM,EAAE,GAAG,OAAwC,CAAC;QACpD,MAAM,CAAC,EAAE,CAAC,IAAI,KAAK,OAAO,EAAE,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC1E,yEAAyE;QACzE,+CAA+C;QAC/C,MAAM,gBAAgB,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;QACrD,IAAI,CAAC,kBAAkB,CAAC,EAAE,EAAE,gBAAgB,CAAC,CAAC;IAC/C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString, createEmitter } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport {\n\tSharedObject,\n\tcreateSingleBlobSummary,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type {\n\tIConsensusRegisterCollection,\n\tIConsensusRegisterCollectionEvents,\n} from \"./interfaces.js\";\nimport { ReadPolicy } from \"./interfaces.js\";\n\ninterface ILocalData<T> {\n\t// Atomic version\n\tatomic: ILocalRegister<T>;\n\n\t// All concurrent versions awaiting consensus\n\tversions: ILocalRegister<T>[];\n}\n\ninterface ILocalRegister<T> {\n\t// Register value, wrapped for backwards compatibility with < 0.17\n\tvalue: {\n\t\ttype: \"Plain\";\n\t\tvalue: T;\n\t};\n\n\t// The sequence number when last consensus was reached\n\tsequenceNumber: number;\n}\n\nconst newLocalRegister = <T>(sequenceNumber: number, value: T): ILocalRegister<T> => ({\n\tsequenceNumber,\n\tvalue: {\n\t\ttype: \"Plain\",\n\t\tvalue,\n\t},\n});\n\n/**\n * An operation for consensus register collection\n *\n * The value stored in this op is serialized as a string and must be deserialized\n */\ninterface IRegisterOperationSerialized {\n\tkey: string;\n\ttype: \"write\";\n\tserializedValue: string;\n\n\t// Message can be delivered with delay - resubmitted on reconnect.\n\t// As such, refSeq needs to reference seq # at the time op was created,\n\t// not when op was actually sent over wire (ISequencedDocumentMessage.referenceSequenceNumber),\n\t// as client can ingest ops in between.\n\trefSeq: number | undefined;\n}\n\n/**\n * IRegisterOperation format in versions \\< 0.17 and \\>=2.0.0-rc.2.0.0\n *\n * The value stored in this op is _not_ serialized and is stored literally as `T`\n */\ninterface IRegisterOperationPlain<T> {\n\tkey: string;\n\ttype: \"write\";\n\n\tvalue: {\n\t\ttype: \"Plain\";\n\t\tvalue: T;\n\t};\n\n\t// back-compat: for clients prior to 2.0.0-rc.2.0.0, we must also pass in\n\t// the serialized value for them to parse handles correctly. we do not have\n\t// to pay the cost of deserializing this value in newer clients\n\tserializedValue: string;\n\n\t// back-compat: files at rest written with runtime <= 0.13 do not have refSeq\n\trefSeq: number | undefined;\n}\n\n/** Incoming ops could match any of these types */\ntype IIncomingRegisterOperation<T> = IRegisterOperationSerialized | IRegisterOperationPlain<T>;\n\n/** Distinguish between incoming op formats so we know which type it is */\nconst incomingOpMatchesPlainFormat = <T>(op): op is IRegisterOperationPlain<T> =>\n\t\"value\" in op;\n\nconst snapshotFileName = \"header\";\n\ninterface IConsensusRegisterCollectionInternalEvents {\n\t/**\n\t * Emitted when a pending message is rolled back.\n\t * @param rollbackMessageId - A unique identifying number for the pending message.\n\t */\n\tpendingMessageRollback: (rollbackMessageId: number) => void;\n\n\t/**\n\t * Emitted when a pending message is acknowledged.\n\t * @param ackMessageId - A unique identifying number for the pending message.\n\t * @param isWinner - Whether the message won the FWW race to modify the value.\n\t */\n\tpendingMessageAck: (ackMessageId: number, isWinner: boolean) => void;\n}\n\n/**\n * {@inheritDoc IConsensusRegisterCollection}\n * @deprecated Use {@link IConsensusRegisterCollection} for typing and {@link ConsensusRegisterCollectionFactory} to create instances. This implementation class will be removed in a future release.\n * @legacy @beta\n */\nexport class ConsensusRegisterCollection<T>\n\textends SharedObject<IConsensusRegisterCollectionEvents>\n\timplements IConsensusRegisterCollection<T>\n{\n\tprivate readonly data = new Map<string, ILocalData<T>>();\n\tprivate readonly internalEvents =\n\t\tcreateEmitter<IConsensusRegisterCollectionInternalEvents>();\n\n\tprivate nextPendingMessageId: number = 0;\n\n\t/**\n\t * Constructs a new consensus register collection. If the object is non-local an id and service interfaces will\n\t * be provided\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_consensusRegisterCollection_\");\n\t}\n\n\t/**\n\t * Creates a new register or writes a new value.\n\t * Returns a promise that will resolve when the write is acked.\n\t *\n\t * @returns Promise<true> if write was non-concurrent\n\t */\n\tpublic async write(key: string, value: T): Promise<boolean> {\n\t\tif (this.runtime.disposed) {\n\t\t\t// Return false if disposed to signify that we did not write.\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!this.isAttached()) {\n\t\t\tthis.processInboundWrite(key, value, 0, 0, true);\n\t\t\treturn true;\n\t\t}\n\n\t\tconst message: IRegisterOperationPlain<T> = {\n\t\t\tkey,\n\t\t\ttype: \"write\",\n\t\t\tserializedValue: this.stringify(value, this.serializer),\n\t\t\tvalue: {\n\t\t\t\ttype: \"Plain\",\n\t\t\t\tvalue,\n\t\t\t},\n\t\t\trefSeq: this.deltaManager.lastSequenceNumber,\n\t\t};\n\n\t\tconst pendingMessageId = this.nextPendingMessageId++;\n\n\t\t// There are three ways the write promise can resolve:\n\t\t// 1. The write is acked\n\t\t// 2. The write is rolled back\n\t\t// 3. The runtime is disposed\n\t\t// The boolean value returned by the promise is true if the attempted write was ack'd and won, false otherwise.\n\t\treturn new Promise<boolean>((resolve) => {\n\t\t\tconst handleAck = (ackMessageId: number, isWinner: boolean): void => {\n\t\t\t\tif (ackMessageId === pendingMessageId) {\n\t\t\t\t\tresolve(isWinner);\n\t\t\t\t\tremoveListeners();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst handleRollback = (rollbackMessageId: number): void => {\n\t\t\t\tif (rollbackMessageId === pendingMessageId) {\n\t\t\t\t\t// If we rolled back the pending message, resolve the promise with false.\n\t\t\t\t\tresolve(false);\n\t\t\t\t\tremoveListeners();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst handleDisposed = (): void => {\n\t\t\t\tresolve(false);\n\t\t\t\tremoveListeners();\n\t\t\t};\n\n\t\t\tconst removeListeners = (): void => {\n\t\t\t\tthis.internalEvents.off(\"pendingMessageAck\", handleAck);\n\t\t\t\tthis.internalEvents.off(\"pendingMessageRollback\", handleRollback);\n\t\t\t\tthis.runtime.off(\"dispose\", handleDisposed);\n\t\t\t};\n\n\t\t\tthis.internalEvents.on(\"pendingMessageAck\", handleAck);\n\t\t\tthis.internalEvents.on(\"pendingMessageRollback\", handleRollback);\n\t\t\tthis.runtime.on(\"dispose\", handleDisposed);\n\n\t\t\tthis.submitLocalMessage(message, pendingMessageId);\n\t\t});\n\t}\n\n\t/**\n\t * Returns the most recent local value of a register.\n\t * @param key - The key to read\n\t * @param readPolicy - The ReadPolicy to apply. Defaults to Atomic.\n\t */\n\tpublic read(key: string, readPolicy: ReadPolicy = ReadPolicy.Atomic): T | undefined {\n\t\tif (readPolicy === ReadPolicy.Atomic) {\n\t\t\treturn this.readAtomic(key);\n\t\t}\n\n\t\tconst versions = this.readVersions(key);\n\n\t\tif (versions !== undefined) {\n\t\t\t// We don't support deletion. So there should be at least one value.\n\t\t\tassert(versions.length > 0, 0x06c /* \"Value should be undefined or non-empty\" */);\n\n\t\t\treturn versions[versions.length - 1];\n\t\t}\n\t}\n\n\tpublic readVersions(key: string): T[] | undefined {\n\t\tconst data = this.data.get(key);\n\t\treturn data?.versions.map((element: ILocalRegister<T>) => element.value.value);\n\t}\n\n\tpublic keys(): string[] {\n\t\treturn [...this.data.keys()];\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst dataObj: { [key: string]: ILocalData<T> } = {};\n\t\tfor (const [k, v] of this.data.entries()) {\n\t\t\tdataObj[k] = v;\n\t\t}\n\n\t\treturn createSingleBlobSummary(snapshotFileName, this.stringify(dataObj, serializer));\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst blob = await storage.readBlob(snapshotFileName);\n\t\tconst header = bufferToString(blob, \"utf8\");\n\t\tconst dataObj = this.parse(header, this.serializer);\n\n\t\tfor (const key of Object.keys(dataObj)) {\n\t\t\tassert(\n\t\t\t\tdataObj[key].atomic?.value.type !== \"Shared\",\n\t\t\t\t0x06d /* \"SharedObjects contained in ConsensusRegisterCollection can no longer be deserialized as of 0.17\" */,\n\t\t\t);\n\n\t\t\tthis.data.set(key, dataObj[key]);\n\t\t}\n\t}\n\n\tprotected onDisconnect(): void {}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\tif (messageEnvelope.type === MessageType.Operation) {\n\t\t\tconst op = messageContent.contents as IIncomingRegisterOperation<T>;\n\t\t\tswitch (op.type) {\n\t\t\t\tcase \"write\": {\n\t\t\t\t\t// backward compatibility: File at rest written with runtime <= 0.13 do not have refSeq\n\t\t\t\t\t// when the refSeq property didn't exist\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy\n\t\t\t\t\tif (op.refSeq === undefined) {\n\t\t\t\t\t\top.refSeq = messageEnvelope.referenceSequenceNumber;\n\t\t\t\t\t}\n\t\t\t\t\t// Message can be delivered with delay - e.g. resubmitted on reconnect.\n\t\t\t\t\t// Use the refSeq from when the op was created, not when it was transmitted\n\t\t\t\t\tconst refSeqWhenCreated = op.refSeq;\n\t\t\t\t\tassert(\n\t\t\t\t\t\trefSeqWhenCreated <= messageEnvelope.referenceSequenceNumber,\n\t\t\t\t\t\t0x06e /* \"Message's reference sequence number < op's reference sequence number!\" */,\n\t\t\t\t\t);\n\n\t\t\t\t\tconst value = incomingOpMatchesPlainFormat<T>(op)\n\t\t\t\t\t\t? op.value.value\n\t\t\t\t\t\t: (this.parse(op.serializedValue, this.serializer) as T);\n\t\t\t\t\tconst isWinner = this.processInboundWrite(\n\t\t\t\t\t\top.key,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\trefSeqWhenCreated,\n\t\t\t\t\t\tmessageEnvelope.sequenceNumber,\n\t\t\t\t\t\tlocal,\n\t\t\t\t\t);\n\t\t\t\t\tif (local) {\n\t\t\t\t\t\t// Resolve the pending promise for this operation now that we have received an ack for it.\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\ttypeof messageContent.localOpMetadata === \"number\",\n\t\t\t\t\t\t\t0xc0e /* Expect localOpMetadata to be a number */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.internalEvents.emit(\n\t\t\t\t\t\t\t\"pendingMessageAck\",\n\t\t\t\t\t\t\tmessageContent.localOpMetadata,\n\t\t\t\t\t\t\tisWinner,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(op.type);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate readAtomic(key: string): T | undefined {\n\t\tconst data = this.data.get(key);\n\t\treturn data?.atomic.value.value;\n\t}\n\n\t/**\n\t * Process an inbound write op\n\t * @param key - Key that was written to\n\t * @param value - Incoming value\n\t * @param refSeq - RefSeq at the time of write on the remote client\n\t * @param sequenceNumber - Sequence Number of this write op\n\t * @param local - Did this write originate on this client\n\t */\n\tprivate processInboundWrite(\n\t\tkey: string,\n\t\tvalue: T,\n\t\trefSeq: number,\n\t\tsequenceNumber: number,\n\t\tlocal: boolean,\n\t): boolean {\n\t\tlet data = this.data.get(key);\n\t\t// Atomic update if it's a new register or the write was not concurrent,\n\t\t// meaning our state was known to the remote client at the time of write\n\t\tconst isWinner = data === undefined || refSeq >= data.atomic.sequenceNumber;\n\t\tif (isWinner) {\n\t\t\tconst atomicUpdate = newLocalRegister<T>(sequenceNumber, value);\n\t\t\tif (data === undefined) {\n\t\t\t\tdata = {\n\t\t\t\t\tatomic: atomicUpdate,\n\t\t\t\t\tversions: [], // we'll update versions next, leave it empty for now\n\t\t\t\t};\n\t\t\t\tthis.data.set(key, data);\n\t\t\t} else {\n\t\t\t\tdata.atomic = atomicUpdate;\n\t\t\t}\n\t\t} else {\n\t\t\tassert(!!data, 0x06f /* \"data missing for non-atomic inbound update!\" */);\n\t\t}\n\n\t\t// Remove versions that were known to the remote client at the time of write\n\t\twhile (data.versions.length > 0 && refSeq >= data.versions[0].sequenceNumber) {\n\t\t\tdata.versions.shift();\n\t\t}\n\n\t\tconst versionUpdate = newLocalRegister<T>(sequenceNumber, value);\n\n\t\t// Asserts for data integrity\n\t\tif (!this.isAttached()) {\n\t\t\tassert(\n\t\t\t\trefSeq === 0 && sequenceNumber === 0,\n\t\t\t\t0x070 /* \"sequence numbers are expected to be 0 when unattached\" */,\n\t\t\t);\n\t\t} else if (data.versions.length > 0) {\n\t\t\tassert(\n\t\t\t\t// seqNum should always be increasing, except for the case of grouped batches (seqNum will be the same)\n\t\t\t\tsequenceNumber >= data.versions[data.versions.length - 1].sequenceNumber,\n\t\t\t\t0x071 /* \"Versions should naturally be ordered by sequenceNumber\" */,\n\t\t\t);\n\t\t}\n\n\t\t// Push the new element.\n\t\tdata.versions.push(versionUpdate);\n\n\t\t// Raise events at the end, to avoid reentrancy issues\n\t\tif (isWinner) {\n\t\t\tthis.emit(\"atomicChanged\", key, value, local);\n\t\t}\n\t\tthis.emit(\"versionChanged\", key, value, local);\n\n\t\treturn isWinner;\n\t}\n\n\tprivate stringify(value: any, serializer: IFluidSerializer): string {\n\t\treturn serializer.stringify(value, this.handle);\n\t}\n\n\tprivate parse(content: string, serializer: IFluidSerializer): any {\n\t\treturn serializer.parse(content);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n\t * @sealed\n\t */\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\t// We don't need to do anything to roll back CRC, it's safe to just drop\n\t\t// the op on the floor since we don't modify the DDS until the ack.\n\t\t// We emit an internal event so we know to resolve the pending promise.\n\t\tassert(\n\t\t\ttypeof localOpMetadata === \"number\",\n\t\t\t0xc0f /* Expect localOpMetadata to be a number */,\n\t\t);\n\t\tthis.internalEvents.emit(\"pendingMessageRollback\", localOpMetadata);\n\t}\n\n\tprotected applyStashedOp(content: unknown): void {\n\t\tconst op = content as IIncomingRegisterOperation<T>;\n\t\tassert(op.type === \"write\", 0xccc /* Only write ops should be stashed */);\n\t\t// Submit the original op (preserving its refSeq) so we can match the ACK\n\t\t// when it arrives during remote op processing.\n\t\tconst pendingMessageId = this.nextPendingMessageId++;\n\t\tthis.submitLocalMessage(op, pendingMessageId);\n\t}\n}\n"]}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IChannelAttributes,
|
|
6
|
-
import { IConsensusRegisterCollection } from "./interfaces.js";
|
|
5
|
+
import type { IChannelAttributes, IChannelFactory, IChannelServices, IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions/internal";
|
|
6
|
+
import type { IConsensusRegisterCollection } from "./interfaces.js";
|
|
7
7
|
/**
|
|
8
8
|
* The factory that defines the consensus queue.
|
|
9
9
|
* @legacy @beta
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consensusRegisterCollectionFactory.d.ts","sourceRoot":"","sources":["../src/consensusRegisterCollectionFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"consensusRegisterCollectionFactory.d.ts","sourceRoot":"","sources":["../src/consensusRegisterCollectionFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AAKxD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAGpE;;;GAGG;AACH,qBAAa,kCACZ,YAAW,eAAe,CAAC,4BAA4B,CAAC;IAKxD,OAAc,IAAI,SAAqE;IAEvF,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,UAAU,IAAI,kBAAkB,CAE1C;IAED;;OAEG;IACU,IAAI,CAChB,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAC5B,OAAO,CAAC,4BAA4B,CAAC;IAOjC,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,4BAA4B;CAUzF;AAED;;;GAGG;AACH,eAAO,MAAM,2BAA2B,wNAEvC,CAAC;AACF;;;GAGG;AACH,MAAM,MAAM,2BAA2B,CAAC,CAAC,IAAI,4BAA4B,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -33,6 +33,9 @@ export class ConsensusRegisterCollectionFactory {
|
|
|
33
33
|
return collection;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
// New type string, to be activated once the migration has been fully shipped dark and is safe to flip.
|
|
37
|
+
// See LegacyTypeAwareRegistry in packages/runtime/datastore/src/dataStoreRuntime.ts.
|
|
38
|
+
// public static Type = "consensus-register-collection";
|
|
36
39
|
ConsensusRegisterCollectionFactory.Type = "https://graph.microsoft.com/types/consensus-register-collection";
|
|
37
40
|
ConsensusRegisterCollectionFactory.Attributes = {
|
|
38
41
|
type: ConsensusRegisterCollectionFactory.Type,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consensusRegisterCollectionFactory.js","sourceRoot":"","sources":["../src/consensusRegisterCollectionFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAErF,mGAAmG;AACnG,OAAO,EAAE,2BAA2B,IAAI,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AAEnH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;GAGG;AACH,MAAM,OAAO,kCAAkC;
|
|
1
|
+
{"version":3,"file":"consensusRegisterCollectionFactory.js","sourceRoot":"","sources":["../src/consensusRegisterCollectionFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAErF,mGAAmG;AACnG,OAAO,EAAE,2BAA2B,IAAI,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AAEnH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;GAGG;AACH,MAAM,OAAO,kCAAkC;IAc9C,IAAW,IAAI;QACd,OAAO,kCAAkC,CAAC,IAAI,CAAC;IAChD,CAAC;IAED,IAAW,UAAU;QACpB,OAAO,kCAAkC,CAAC,UAAU,CAAC;IACtD,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAE9B,wFAAwF;QACxF,MAAM,UAAU,GAAG,IAAI,gCAAgC,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QACjF,MAAM,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChC,OAAO,UAAU,CAAC;IACnB,CAAC;IAEM,MAAM,CAAC,QAAgC,EAAE,EAAU;QACzD,wFAAwF;QACxF,MAAM,UAAU,GAAG,IAAI,gCAAgC,CACtD,EAAE,EACF,QAAQ,EACR,kCAAkC,CAAC,UAAU,CAC7C,CAAC;QACF,UAAU,CAAC,eAAe,EAAE,CAAC;QAC7B,OAAO,UAAU,CAAC;IACnB,CAAC;;AA3CD,uGAAuG;AACvG,qFAAqF;AACrF,wDAAwD;AAC1C,uCAAI,GAAG,iEAAiE,CAAC;AAEhE,6CAAU,GAAuB;IACvD,IAAI,EAAE,kCAAkC,CAAC,IAAI;IAC7C,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,UAAU;CAC1B,CAAC;AAqCH;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,sBAAsB,CAChE,kCAAkC,CAClC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIChannelServices,\n\tIFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { createSharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\n\n// eslint-disable-next-line import-x/no-deprecated -- Internal usage of deprecated class in factory\nimport { ConsensusRegisterCollection as ConsensusRegisterCollectionClass } from \"./consensusRegisterCollection.js\";\nimport type { IConsensusRegisterCollection } from \"./interfaces.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * The factory that defines the consensus queue.\n * @legacy @beta\n */\nexport class ConsensusRegisterCollectionFactory\n\timplements IChannelFactory<IConsensusRegisterCollection>\n{\n\t// New type string, to be activated once the migration has been fully shipped dark and is safe to flip.\n\t// See LegacyTypeAwareRegistry in packages/runtime/datastore/src/dataStoreRuntime.ts.\n\t// public static Type = \"consensus-register-collection\";\n\tpublic static Type = \"https://graph.microsoft.com/types/consensus-register-collection\";\n\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: ConsensusRegisterCollectionFactory.Type,\n\t\tsnapshotFormatVersion: \"0.1\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\tpublic get type(): string {\n\t\treturn ConsensusRegisterCollectionFactory.Type;\n\t}\n\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn ConsensusRegisterCollectionFactory.Attributes;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\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<IConsensusRegisterCollection> {\n\t\t// eslint-disable-next-line import-x/no-deprecated -- Internal usage of deprecated class\n\t\tconst collection = new ConsensusRegisterCollectionClass(id, runtime, attributes);\n\t\tawait collection.load(services);\n\t\treturn collection;\n\t}\n\n\tpublic create(document: IFluidDataStoreRuntime, id: string): IConsensusRegisterCollection {\n\t\t// eslint-disable-next-line import-x/no-deprecated -- Internal usage of deprecated class\n\t\tconst collection = new ConsensusRegisterCollectionClass(\n\t\t\tid,\n\t\t\tdocument,\n\t\t\tConsensusRegisterCollectionFactory.Attributes,\n\t\t);\n\t\tcollection.initializeLocal();\n\t\treturn collection;\n\t}\n}\n\n/**\n * {@inheritDoc IConsensusRegisterCollection}\n * @legacy @beta\n */\nexport const ConsensusRegisterCollection = createSharedObjectKind(\n\tConsensusRegisterCollectionFactory,\n);\n/**\n * Compatibility alias for {@link IConsensusRegisterCollection}.\n * @legacy @beta\n */\nexport type ConsensusRegisterCollection<T> = IConsensusRegisterCollection<T>;\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export { ConsensusRegisterCollection as ConsensusRegisterCollectionClass } from "./consensusRegisterCollection.js";
|
|
6
6
|
export { ConsensusRegisterCollectionFactory, ConsensusRegisterCollection, } from "./consensusRegisterCollectionFactory.js";
|
|
7
|
-
export { IConsensusRegisterCollection, IConsensusRegisterCollectionEvents, IConsensusRegisterCollectionFactory, ReadPolicy, } from "./interfaces.js";
|
|
7
|
+
export { type IConsensusRegisterCollection, type IConsensusRegisterCollectionEvents, type IConsensusRegisterCollectionFactory, ReadPolicy, } from "./interfaces.js";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,2BAA2B,IAAI,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AACnH,OAAO,EACN,kCAAkC,EAClC,2BAA2B,GAC3B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACN,4BAA4B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,2BAA2B,IAAI,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AACnH,OAAO,EACN,kCAAkC,EAClC,2BAA2B,GAC3B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACN,KAAK,4BAA4B,EACjC,KAAK,kCAAkC,EACvC,KAAK,mCAAmC,EACxC,UAAU,GACV,MAAM,iBAAiB,CAAC"}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,2BAA2B,IAAI,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AACnH,OAAO,EACN,kCAAkC,EAClC,2BAA2B,GAC3B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAIN,UAAU,GACV,MAAM,iBAAiB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ConsensusRegisterCollection as ConsensusRegisterCollectionClass } from \"./consensusRegisterCollection.js\";\nexport {\n\tConsensusRegisterCollectionFactory,\n\tConsensusRegisterCollection,\n} from \"./consensusRegisterCollectionFactory.js\";\nexport {\n\
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,2BAA2B,IAAI,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AACnH,OAAO,EACN,kCAAkC,EAClC,2BAA2B,GAC3B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAIN,UAAU,GACV,MAAM,iBAAiB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ConsensusRegisterCollection as ConsensusRegisterCollectionClass } from \"./consensusRegisterCollection.js\";\nexport {\n\tConsensusRegisterCollectionFactory,\n\tConsensusRegisterCollection,\n} from \"./consensusRegisterCollectionFactory.js\";\nexport {\n\ttype IConsensusRegisterCollection,\n\ttype IConsensusRegisterCollectionEvents,\n\ttype IConsensusRegisterCollectionFactory,\n\tReadPolicy,\n} from \"./interfaces.js\";\n"]}
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IChannelFactory } from "@fluidframework/datastore-definitions/internal";
|
|
6
|
-
import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base/internal";
|
|
5
|
+
import type { IChannelFactory } from "@fluidframework/datastore-definitions/internal";
|
|
6
|
+
import type { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base/internal";
|
|
7
7
|
/**
|
|
8
8
|
* Consensus Register Collection channel factory interface
|
|
9
9
|
*
|
package/lib/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,KAAK,EACX,aAAa,EACb,mBAAmB,EACnB,MAAM,6CAA6C,CAAC;AAErD;;;;;;;GAOG;AACH,MAAM,MAAM,mCAAmC,GAC9C,eAAe,CAAC,4BAA4B,CAAC,CAAC;AAE/C;;;GAGG;AACH,MAAM,WAAW,kCAAmC,SAAQ,mBAAmB;IAC9E,CACC,KAAK,EAAE,eAAe,GAAG,gBAAgB,EACzC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,OAC1D;CACF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,4BAA4B,CAAC,CAAC,GAAG,GAAG,CACpD,SAAQ,aAAa,CAAC,kCAAkC,CAAC;IACzD;;;;;OAKG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE/C;;OAEG;IACH,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,CAAC,GAAG,SAAS,CAAC;IAEtD;;OAEG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,EAAE,GAAG,SAAS,CAAC;IAE3C;;OAEG;IACH,IAAI,IAAI,MAAM,EAAE,CAAC;CACjB;AAED;;;GAGG;AACH,oBAAY,UAAU;IAErB,MAAM,IAAA;IAGN,GAAG,IAAA;CACH"}
|
package/lib/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA0EH;;;GAGG;AACH,MAAM,CAAN,IAAY,UAMX;AAND,WAAY,UAAU;IACrB,mFAAmF;IACnF,+CAAM,CAAA;IAEN,2DAA2D;IAC3D,yCAAG,CAAA;AACJ,CAAC,EANW,UAAU,KAAV,UAAU,QAMrB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IChannelFactory } from \"@fluidframework/datastore-definitions/internal\";\nimport {\n\tISharedObject,\n\tISharedObjectEvents,\n} from \"@fluidframework/shared-object-base/internal\";\n\n/**\n * Consensus Register Collection channel factory interface\n *\n * Extends the base IChannelFactory to return a more definite type of IConsensusRegisterCollection\n * Use for the runtime to create and load distributed data structure by type name of each channel.\n * @legacy @beta\n * @deprecated Use `IChannelFactory<IConsensusRegisterCollection>`.\n */\nexport type IConsensusRegisterCollectionFactory =\n\tIChannelFactory<IConsensusRegisterCollection>;\n\n/**\n * Events emitted by {@link IConsensusRegisterCollection}.\n * @legacy @beta\n */\nexport interface IConsensusRegisterCollectionEvents extends ISharedObjectEvents {\n\t(\n\t\tevent: \"atomicChanged\" | \"versionChanged\",\n\t\tlistener: (key: string, value: any, local: boolean) => void,\n\t);\n}\n\n/**\n * A distributed data structure that holds a set of registers with update\n * versions. On concurrent updates, a register internally stores all possible versions of a value by using reference\n * sequence number of the incoming update.\n *\n * Using all the stored versions, we can then distinguish amongst different read policies. Below are the policies\n * we support:\n *\n * Atomic: Atomicity requires a linearizable register. A linearizable register behaves as if there is only a single\n * copy of the data, and that every operation appears to take effect atomically at one point in time. This definition\n * implies that operations are executed in an well-defined order. On a concurrent update, we perform a compare-and-set\n * operation, where we compare a register sequence number with the incoming reference sequence number.\n * The earliest operation overwriting prior sequence numbers wins since every client reaches to an agreement on\n * the value. So we can safely return the first value.\n *\n * LWW: The last write to a key always wins.\n * @legacy @beta\n */\nexport interface IConsensusRegisterCollection<T = any>\n\textends ISharedObject<IConsensusRegisterCollectionEvents> {\n\t/**\n\t * Attempts to write a register with a value. Returns a promise to indicate the roundtrip completion.\n\t * For a non existent register, it will attempt to create a new register with the specified value.\n\t *\n\t * @returns Promise<true> if write was non-concurrent\n\t */\n\twrite(key: string, value: T): Promise<boolean>;\n\n\t/**\n\t * Retrieves the agreed upon value for the register based on policy. Returns undefined if not present.\n\t */\n\tread(key: string, policy?: ReadPolicy): T | undefined;\n\n\t/**\n\t * Retrives all concurrent versions. Undefined if not present.\n\t */\n\treadVersions(key: string): T[] | undefined;\n\n\t/**\n\t * Returns the keys.\n\t */\n\tkeys(): string[];\n}\n\n/**\n * Read policies used when reading the map value.\n * @legacy @beta\n */\nexport enum ReadPolicy {\n\t// On a concurrent update, returns the first agreed upon value amongst all clients.\n\tAtomic,\n\n\t// Last writer wins. Simply returns the last written value.\n\tLWW,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA0EH;;;GAGG;AACH,MAAM,CAAN,IAAY,UAMX;AAND,WAAY,UAAU;IACrB,mFAAmF;IACnF,+CAAM,CAAA;IAEN,2DAA2D;IAC3D,yCAAG,CAAA;AACJ,CAAC,EANW,UAAU,KAAV,UAAU,QAMrB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IChannelFactory } from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tISharedObject,\n\tISharedObjectEvents,\n} from \"@fluidframework/shared-object-base/internal\";\n\n/**\n * Consensus Register Collection channel factory interface\n *\n * Extends the base IChannelFactory to return a more definite type of IConsensusRegisterCollection\n * Use for the runtime to create and load distributed data structure by type name of each channel.\n * @legacy @beta\n * @deprecated Use `IChannelFactory<IConsensusRegisterCollection>`.\n */\nexport type IConsensusRegisterCollectionFactory =\n\tIChannelFactory<IConsensusRegisterCollection>;\n\n/**\n * Events emitted by {@link IConsensusRegisterCollection}.\n * @legacy @beta\n */\nexport interface IConsensusRegisterCollectionEvents extends ISharedObjectEvents {\n\t(\n\t\tevent: \"atomicChanged\" | \"versionChanged\",\n\t\tlistener: (key: string, value: any, local: boolean) => void,\n\t);\n}\n\n/**\n * A distributed data structure that holds a set of registers with update\n * versions. On concurrent updates, a register internally stores all possible versions of a value by using reference\n * sequence number of the incoming update.\n *\n * Using all the stored versions, we can then distinguish amongst different read policies. Below are the policies\n * we support:\n *\n * Atomic: Atomicity requires a linearizable register. A linearizable register behaves as if there is only a single\n * copy of the data, and that every operation appears to take effect atomically at one point in time. This definition\n * implies that operations are executed in an well-defined order. On a concurrent update, we perform a compare-and-set\n * operation, where we compare a register sequence number with the incoming reference sequence number.\n * The earliest operation overwriting prior sequence numbers wins since every client reaches to an agreement on\n * the value. So we can safely return the first value.\n *\n * LWW: The last write to a key always wins.\n * @legacy @beta\n */\nexport interface IConsensusRegisterCollection<T = any>\n\textends ISharedObject<IConsensusRegisterCollectionEvents> {\n\t/**\n\t * Attempts to write a register with a value. Returns a promise to indicate the roundtrip completion.\n\t * For a non existent register, it will attempt to create a new register with the specified value.\n\t *\n\t * @returns Promise<true> if write was non-concurrent\n\t */\n\twrite(key: string, value: T): Promise<boolean>;\n\n\t/**\n\t * Retrieves the agreed upon value for the register based on policy. Returns undefined if not present.\n\t */\n\tread(key: string, policy?: ReadPolicy): T | undefined;\n\n\t/**\n\t * Retrives all concurrent versions. Undefined if not present.\n\t */\n\treadVersions(key: string): T[] | undefined;\n\n\t/**\n\t * Returns the keys.\n\t */\n\tkeys(): string[];\n}\n\n/**\n * Read policies used when reading the map value.\n * @legacy @beta\n */\nexport enum ReadPolicy {\n\t// On a concurrent update, returns the first agreed upon value amongst all clients.\n\tAtomic,\n\n\t// Last writer wins. Simply returns the last written value.\n\tLWW,\n}\n"]}
|
package/lib/legacy.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
-
* Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
|
|
8
|
+
* Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat" in @fluid-tools/build-cli.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export {
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/register-collection";
|
|
8
|
-
export declare const pkgVersion = "2.
|
|
8
|
+
export declare const pkgVersion = "2.92.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,qCAAqC,CAAC;AAC7D,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/register-collection\";\nexport const pkgVersion = \"2.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,qCAAqC,CAAC;AAC7D,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/register-collection\";\nexport const pkgVersion = \"2.92.0\";\n"]}
|
package/lib/public.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
-
* Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
|
|
8
|
+
* Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat" in @fluid-tools/build-cli.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/register-collection",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.92.0",
|
|
4
4
|
"description": "Consensus Register",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -81,27 +81,27 @@
|
|
|
81
81
|
"temp-directory": "nyc/.nyc_output"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@fluid-internal/client-utils": "~2.
|
|
85
|
-
"@fluidframework/core-interfaces": "~2.
|
|
86
|
-
"@fluidframework/core-utils": "~2.
|
|
87
|
-
"@fluidframework/datastore-definitions": "~2.
|
|
88
|
-
"@fluidframework/driver-definitions": "~2.
|
|
89
|
-
"@fluidframework/driver-utils": "~2.
|
|
90
|
-
"@fluidframework/runtime-definitions": "~2.
|
|
91
|
-
"@fluidframework/shared-object-base": "~2.
|
|
84
|
+
"@fluid-internal/client-utils": "~2.92.0",
|
|
85
|
+
"@fluidframework/core-interfaces": "~2.92.0",
|
|
86
|
+
"@fluidframework/core-utils": "~2.92.0",
|
|
87
|
+
"@fluidframework/datastore-definitions": "~2.92.0",
|
|
88
|
+
"@fluidframework/driver-definitions": "~2.92.0",
|
|
89
|
+
"@fluidframework/driver-utils": "~2.92.0",
|
|
90
|
+
"@fluidframework/runtime-definitions": "~2.92.0",
|
|
91
|
+
"@fluidframework/shared-object-base": "~2.92.0"
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
94
94
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
95
|
-
"@biomejs/biome": "~
|
|
96
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
97
|
-
"@fluid-private/stochastic-test-utils": "~2.
|
|
98
|
-
"@fluid-private/test-dds-utils": "~2.
|
|
99
|
-
"@fluid-tools/build-cli": "^0.
|
|
95
|
+
"@biomejs/biome": "~2.4.5",
|
|
96
|
+
"@fluid-internal/mocha-test-setup": "~2.92.0",
|
|
97
|
+
"@fluid-private/stochastic-test-utils": "~2.92.0",
|
|
98
|
+
"@fluid-private/test-dds-utils": "~2.92.0",
|
|
99
|
+
"@fluid-tools/build-cli": "^0.64.0",
|
|
100
100
|
"@fluidframework/build-common": "^2.0.3",
|
|
101
|
-
"@fluidframework/build-tools": "^0.
|
|
102
|
-
"@fluidframework/eslint-config-fluid": "
|
|
103
|
-
"@fluidframework/register-collection-previous": "npm:@fluidframework/register-collection@2.
|
|
104
|
-
"@fluidframework/test-runtime-utils": "~2.
|
|
101
|
+
"@fluidframework/build-tools": "^0.64.0",
|
|
102
|
+
"@fluidframework/eslint-config-fluid": "^9.0.0",
|
|
103
|
+
"@fluidframework/register-collection-previous": "npm:@fluidframework/register-collection@2.91.0",
|
|
104
|
+
"@fluidframework/test-runtime-utils": "~2.92.0",
|
|
105
105
|
"@microsoft/api-extractor": "7.52.11",
|
|
106
106
|
"@types/mocha": "^10.0.10",
|
|
107
107
|
"@types/node": "~20.19.30",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
},
|
|
123
123
|
"scripts": {
|
|
124
124
|
"api": "fluid-build . --task api",
|
|
125
|
-
"api-extractor:commonjs": "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./dist",
|
|
125
|
+
"api-extractor:commonjs": "flub generate entrypoints --resolutionConditions require --outFileLegacyBeta legacy --outDir ./dist",
|
|
126
126
|
"api-extractor:esnext": "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat",
|
|
127
127
|
"build": "fluid-build . --task build",
|
|
128
128
|
"build:api-reports": "concurrently \"npm:build:api-reports:*\"",
|
|
@@ -5,29 +5,29 @@
|
|
|
5
5
|
|
|
6
6
|
import { bufferToString, createEmitter } from "@fluid-internal/client-utils";
|
|
7
7
|
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
8
|
-
import {
|
|
8
|
+
import type {
|
|
9
9
|
IChannelAttributes,
|
|
10
10
|
IFluidDataStoreRuntime,
|
|
11
11
|
IChannelStorageService,
|
|
12
12
|
} from "@fluidframework/datastore-definitions/internal";
|
|
13
13
|
import { MessageType } from "@fluidframework/driver-definitions/internal";
|
|
14
|
-
import {
|
|
14
|
+
import type {
|
|
15
15
|
ISummaryTreeWithStats,
|
|
16
16
|
IRuntimeMessageCollection,
|
|
17
17
|
IRuntimeMessagesContent,
|
|
18
18
|
ISequencedMessageEnvelope,
|
|
19
19
|
} from "@fluidframework/runtime-definitions/internal";
|
|
20
|
+
import type { IFluidSerializer } from "@fluidframework/shared-object-base/internal";
|
|
20
21
|
import {
|
|
21
|
-
IFluidSerializer,
|
|
22
22
|
SharedObject,
|
|
23
23
|
createSingleBlobSummary,
|
|
24
24
|
} from "@fluidframework/shared-object-base/internal";
|
|
25
25
|
|
|
26
|
-
import {
|
|
26
|
+
import type {
|
|
27
27
|
IConsensusRegisterCollection,
|
|
28
28
|
IConsensusRegisterCollectionEvents,
|
|
29
|
-
ReadPolicy,
|
|
30
29
|
} from "./interfaces.js";
|
|
30
|
+
import { ReadPolicy } from "./interfaces.js";
|
|
31
31
|
|
|
32
32
|
interface ILocalData<T> {
|
|
33
33
|
// Atomic version
|
|
@@ -248,9 +248,9 @@ export class ConsensusRegisterCollection<T>
|
|
|
248
248
|
|
|
249
249
|
protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {
|
|
250
250
|
const dataObj: { [key: string]: ILocalData<T> } = {};
|
|
251
|
-
this.data.
|
|
251
|
+
for (const [k, v] of this.data.entries()) {
|
|
252
252
|
dataObj[k] = v;
|
|
253
|
-
}
|
|
253
|
+
}
|
|
254
254
|
|
|
255
255
|
return createSingleBlobSummary(snapshotFileName, this.stringify(dataObj, serializer));
|
|
256
256
|
}
|
|
@@ -329,8 +329,9 @@ export class ConsensusRegisterCollection<T>
|
|
|
329
329
|
}
|
|
330
330
|
break;
|
|
331
331
|
}
|
|
332
|
-
default:
|
|
332
|
+
default: {
|
|
333
333
|
unreachableCase(op.type);
|
|
334
|
+
}
|
|
334
335
|
}
|
|
335
336
|
}
|
|
336
337
|
}
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import type {
|
|
7
7
|
IChannelAttributes,
|
|
8
|
-
|
|
9
|
-
type IChannelFactory,
|
|
8
|
+
IChannelFactory,
|
|
10
9
|
IChannelServices,
|
|
10
|
+
IFluidDataStoreRuntime,
|
|
11
11
|
} from "@fluidframework/datastore-definitions/internal";
|
|
12
12
|
import { createSharedObjectKind } from "@fluidframework/shared-object-base/internal";
|
|
13
13
|
|
|
14
14
|
// eslint-disable-next-line import-x/no-deprecated -- Internal usage of deprecated class in factory
|
|
15
15
|
import { ConsensusRegisterCollection as ConsensusRegisterCollectionClass } from "./consensusRegisterCollection.js";
|
|
16
|
-
import { IConsensusRegisterCollection } from "./interfaces.js";
|
|
16
|
+
import type { IConsensusRegisterCollection } from "./interfaces.js";
|
|
17
17
|
import { pkgVersion } from "./packageVersion.js";
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -23,6 +23,9 @@ import { pkgVersion } from "./packageVersion.js";
|
|
|
23
23
|
export class ConsensusRegisterCollectionFactory
|
|
24
24
|
implements IChannelFactory<IConsensusRegisterCollection>
|
|
25
25
|
{
|
|
26
|
+
// New type string, to be activated once the migration has been fully shipped dark and is safe to flip.
|
|
27
|
+
// See LegacyTypeAwareRegistry in packages/runtime/datastore/src/dataStoreRuntime.ts.
|
|
28
|
+
// public static Type = "consensus-register-collection";
|
|
26
29
|
public static Type = "https://graph.microsoft.com/types/consensus-register-collection";
|
|
27
30
|
|
|
28
31
|
public static readonly Attributes: IChannelAttributes = {
|
package/src/index.ts
CHANGED
|
@@ -9,8 +9,8 @@ export {
|
|
|
9
9
|
ConsensusRegisterCollection,
|
|
10
10
|
} from "./consensusRegisterCollectionFactory.js";
|
|
11
11
|
export {
|
|
12
|
-
IConsensusRegisterCollection,
|
|
13
|
-
IConsensusRegisterCollectionEvents,
|
|
14
|
-
IConsensusRegisterCollectionFactory,
|
|
12
|
+
type IConsensusRegisterCollection,
|
|
13
|
+
type IConsensusRegisterCollectionEvents,
|
|
14
|
+
type IConsensusRegisterCollectionFactory,
|
|
15
15
|
ReadPolicy,
|
|
16
16
|
} from "./interfaces.js";
|
package/src/interfaces.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { IChannelFactory } from "@fluidframework/datastore-definitions/internal";
|
|
7
|
-
import {
|
|
6
|
+
import type { IChannelFactory } from "@fluidframework/datastore-definitions/internal";
|
|
7
|
+
import type {
|
|
8
8
|
ISharedObject,
|
|
9
9
|
ISharedObjectEvents,
|
|
10
10
|
} from "@fluidframework/shared-object-base/internal";
|
package/src/packageVersion.ts
CHANGED