@fluid-experimental/pact-map 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.js CHANGED
@@ -4,23 +4,22 @@
4
4
  */
5
5
 
6
6
  module.exports = {
7
- extends: ["@fluidframework/eslint-config-fluid/strict", "prettier"],
8
- parserOptions: {
9
- project: ["./tsconfig.json", "./src/test/tsconfig.json"],
10
- },
11
- rules: {
12
- // This library is used in the browser, so we don't want dependencies on most node libraries.
13
- "import/no-nodejs-modules": ["error", { allow: ["events"] }],
14
- },
15
- overrides: [
16
- {
17
- // Rules only for test files
18
- files: ["*.spec.ts", "src/test/**"],
19
- rules: {
20
- // Test files are run in node only so additional node libraries can be used.
21
- "import/no-nodejs-modules": ["error", { allow: ["assert", "events"] }],
22
-
23
- },
24
- },
25
- ],
7
+ extends: ["@fluidframework/eslint-config-fluid/strict", "prettier"],
8
+ parserOptions: {
9
+ project: ["./tsconfig.json", "./src/test/tsconfig.json"],
10
+ },
11
+ rules: {
12
+ // This library is used in the browser, so we don't want dependencies on most node libraries.
13
+ "import/no-nodejs-modules": ["error", { allow: ["events"] }],
14
+ },
15
+ overrides: [
16
+ {
17
+ // Rules only for test files
18
+ files: ["*.spec.ts", "src/test/**"],
19
+ rules: {
20
+ // Test files are run in node only so additional node libraries can be used.
21
+ "import/no-nodejs-modules": ["error", { allow: ["assert", "events"] }],
22
+ },
23
+ },
24
+ ],
26
25
  };
package/.mocharc.js CHANGED
@@ -3,9 +3,9 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- 'use strict';
6
+ "use strict";
7
7
 
8
- const getFluidTestMochaConfig = require('@fluidframework/mocha-test-setup/mocharc-common');
8
+ const getFluidTestMochaConfig = require("@fluidframework/mocha-test-setup/mocharc-common");
9
9
 
10
10
  const packageDir = __dirname;
11
11
  const config = getFluidTestMochaConfig(packageDir);
@@ -1,4 +1,4 @@
1
1
  {
2
- "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
- "extends": "@fluidframework/build-common/api-extractor-common-report.json"
2
+ "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
+ "extends": "@fluidframework/build-common/api-extractor-common-report.json"
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAExF;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,mBAAmB;IACvD;;OAEG;IACH,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,OAAE;CACpE;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,aAAa,CAAC,cAAc,CAAC;IACxE;;;OAGG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IAEhC;;;;OAIG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAEhC;;;OAGG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IAEvC;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;IAE7C;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B"}
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAExF;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,mBAAmB;IAC1D;;OAEG;IACH,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,OAAE;CACjE;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,aAAa,CAAC,cAAc,CAAC;IAC3E;;;OAGG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IAEhC;;;;OAIG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAEhC;;;OAGG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IAEvC;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;IAE7C;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISharedObject, ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\n\n/**\n * IPactMapEvents are the events fired by an IPactMap.\n */\nexport interface IPactMapEvents extends ISharedObjectEvents {\n /**\n * Notifies when a new value goes pending or has been accepted.\n */\n (event: \"pending\" | \"accepted\", listener: (key: string) => void);\n}\n\n/**\n * An IPactMap is a key-value storage, in which setting a value is done via a proposal system. All collaborators\n * who were connected at the time of the proposal must accept the change before it is considered accepted (or, if\n * those clients disconnect they are considered to have implicitly accepted). As a result, the value goes through\n * two phases:\n * 1. \"pending\" state where the proposal has been sequenced, but there are still outstanding acceptances\n * 2. \"accepted\" state where all clients who were connected at the time the proposal was made have either accepted\n * or disconnected.\n */\nexport interface IPactMap<T = unknown> extends ISharedObject<IPactMapEvents> {\n /**\n * Gets the accepted value for the given key.\n * @param key - The key to retrieve from\n */\n get(key: string): T | undefined;\n\n /**\n * Returns whether there is a pending value for the given key. Can be used to distinguish a pending delete vs.\n * nothing pending when getPending would just return undefined.\n * @param key - The key to check\n */\n isPending(key: string): boolean;\n\n /**\n * Gets the pending value for the given key.\n * @param key - The key to retrieve from\n */\n getPending(key: string): T | undefined;\n\n /**\n * Sets the value for the given key. After setting the value, it will be in \"pending\" state until all connected\n * clients have approved the change. The accepted value remains unchanged until that time.\n * @param key - The key to set\n * @param value - The value to store\n */\n set(key: string, value: T | undefined): void;\n\n /**\n * Deletes the key/value pair at the given key. After issuing the delete, the delete is in \"pending\" state until\n * all connected clients have approved the delete. The accepted value remains unchanged until that time.\n * @param key - the key to delete\n */\n delete(key: string): void;\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISharedObject, ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\n\n/**\n * IPactMapEvents are the events fired by an IPactMap.\n */\nexport interface IPactMapEvents extends ISharedObjectEvents {\n\t/**\n\t * Notifies when a new value goes pending or has been accepted.\n\t */\n\t(event: \"pending\" | \"accepted\", listener: (key: string) => void);\n}\n\n/**\n * An IPactMap is a key-value storage, in which setting a value is done via a proposal system. All collaborators\n * who were connected at the time of the proposal must accept the change before it is considered accepted (or, if\n * those clients disconnect they are considered to have implicitly accepted). As a result, the value goes through\n * two phases:\n * 1. \"pending\" state where the proposal has been sequenced, but there are still outstanding acceptances\n * 2. \"accepted\" state where all clients who were connected at the time the proposal was made have either accepted\n * or disconnected.\n */\nexport interface IPactMap<T = unknown> extends ISharedObject<IPactMapEvents> {\n\t/**\n\t * Gets the accepted value for the given key.\n\t * @param key - The key to retrieve from\n\t */\n\tget(key: string): T | undefined;\n\n\t/**\n\t * Returns whether there is a pending value for the given key. Can be used to distinguish a pending delete vs.\n\t * nothing pending when getPending would just return undefined.\n\t * @param key - The key to check\n\t */\n\tisPending(key: string): boolean;\n\n\t/**\n\t * Gets the pending value for the given key.\n\t * @param key - The key to retrieve from\n\t */\n\tgetPending(key: string): T | undefined;\n\n\t/**\n\t * Sets the value for the given key. After setting the value, it will be in \"pending\" state until all connected\n\t * clients have approved the change. The accepted value remains unchanged until that time.\n\t * @param key - The key to set\n\t * @param value - The value to store\n\t */\n\tset(key: string, value: T | undefined): void;\n\n\t/**\n\t * Deletes the key/value pair at the given key. After issuing the delete, the delete is in \"pending\" state until\n\t * all connected clients have approved the delete. The accepted value remains unchanged until that time.\n\t * @param key - the key to delete\n\t */\n\tdelete(key: string): void;\n}\n"]}
@@ -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 = "@fluid-experimental/pact-map";
8
- export declare const pkgVersion = "2.0.0-internal.3.0.2";
8
+ export declare const pkgVersion = "2.0.0-internal.3.2.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluid-experimental/pact-map";
11
- exports.pkgVersion = "2.0.0-internal.3.0.2";
11
+ exports.pkgVersion = "2.0.0-internal.3.2.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,8BAA8B,CAAC;AACzC,QAAA,UAAU,GAAG,sBAAsB,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 = \"@fluid-experimental/pact-map\";\nexport const pkgVersion = \"2.0.0-internal.3.0.2\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,8BAA8B,CAAC;AACzC,QAAA,UAAU,GAAG,sBAAsB,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 = \"@fluid-experimental/pact-map\";\nexport const pkgVersion = \"2.0.0-internal.3.2.0\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"pactMap.d.ts","sourceRoot":"","sources":["../src/pactMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EACH,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EAClB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E,OAAO,EAA2B,gBAAgB,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAE7G,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AA2ExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,qBAAa,OAAO,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,YAAY,CAAC,cAAc,CAAE,YAAW,QAAQ,CAAC,CAAC,CAAC;IACzF;;;;;;OAMG;WACW,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AItC;;OAEG;IACI,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAI7C;;OAEG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,IAAI;IA4BnD;;OAEG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAiBhC;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAsDhC;IAEF,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CA0BnC;IAEF,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAqBvC;IAEF;;;;;OAKG;IACH,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,qBAAqB;IAe5E;;;OAGG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAOxE;;;OAGG;IACH,SAAS,CAAC,mBAAmB,IAAI,IAAI;IAErC;;;OAGG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAE9B;;;OAGG;IACH,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAuBxE;;;;;;;;OAQG;IACH,SAAS,CAAC,WAAW,CACpB,OAAO,EAAE,yBAAyB,EAClC,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO,GACtB,IAAI;IA8BA,cAAc,IAAI,IAAI;CAG7B"}
package/dist/pactMap.js CHANGED
@@ -88,8 +88,8 @@ class PactMap extends shared_object_base_1.SharedObject {
88
88
  // We use a consensus-like approach here, so a proposal is valid if the value is unset or if there is no
89
89
  // pending change and it was made with knowledge of the most recently accepted value. We'll drop invalid
90
90
  // proposals on the ground.
91
- const proposalValid = currentValue === undefined
92
- || (currentValue.pending === undefined && currentValue.accepted.sequenceNumber <= refSeq);
91
+ const proposalValid = currentValue === undefined ||
92
+ (currentValue.pending === undefined && currentValue.accepted.sequenceNumber <= refSeq);
93
93
  if (!proposalValid) {
94
94
  return;
95
95
  }
@@ -115,7 +115,8 @@ class PactMap extends shared_object_base_1.SharedObject {
115
115
  });
116
116
  this.emit("accepted", key);
117
117
  }
118
- else if (this.runtime.clientId !== undefined && expectedSignoffs.includes(this.runtime.clientId)) {
118
+ else if (this.runtime.clientId !== undefined &&
119
+ expectedSignoffs.includes(this.runtime.clientId)) {
119
120
  // Emit an accept upon a new key entering pending state if our accept is expected.
120
121
  const acceptOp = {
121
122
  type: "accept",
@@ -238,11 +239,11 @@ class PactMap extends shared_object_base_1.SharedObject {
238
239
  // Early-exit if:
239
240
  if (
240
241
  // there's nothing to delete
241
- currentValue === undefined
242
+ currentValue === undefined ||
242
243
  // if something is pending (and so our proposal won't be valid)
243
- || currentValue.pending !== undefined
244
+ currentValue.pending !== undefined ||
244
245
  // or if the accepted value is undefined which is equivalent to already being deleted
245
- || currentValue.accepted.value === undefined) {
246
+ currentValue.accepted.value === undefined) {
246
247
  return;
247
248
  }
248
249
  this.set(key, undefined);
@@ -255,9 +256,7 @@ class PactMap extends shared_object_base_1.SharedObject {
255
256
  */
256
257
  getSignoffClients() {
257
258
  // If detached, we don't need anyone to sign off. Otherwise, we need all currently connected clients.
258
- return this.isAttached()
259
- ? [...this.runtime.getQuorum().getMembers().keys()]
260
- : [];
259
+ return this.isAttached() ? [...this.runtime.getQuorum().getMembers().keys()] : [];
261
260
  }
262
261
  /**
263
262
  * Create a summary for the PactMap
@@ -272,9 +271,9 @@ class PactMap extends shared_object_base_1.SharedObject {
272
271
  return (
273
272
  // Items have an effect if they are still pending, have a real value, or some client may try to
274
273
  // reference state before the value was accepted. Otherwise they can be dropped.
275
- pact.pending !== undefined
276
- || pact.accepted.value !== undefined
277
- || pact.accepted.sequenceNumber > this.runtime.deltaManager.minimumSequenceNumber);
274
+ pact.pending !== undefined ||
275
+ pact.accepted.value !== undefined ||
276
+ pact.accepted.sequenceNumber > this.runtime.deltaManager.minimumSequenceNumber);
278
277
  });
279
278
  return (0, shared_object_base_1.createSingleBlobSummary)(snapshotFileName, JSON.stringify(summaryEntries));
280
279
  }
@@ -313,9 +312,9 @@ class PactMap extends shared_object_base_1.SharedObject {
313
312
  // Filter out set messages that have no chance of being accepted because there's another value pending
314
313
  // or another value was accepted while we were disconnected.
315
314
  const currentValue = this.values.get(pactMapOp.key);
316
- if (currentValue !== undefined
317
- && (currentValue.pending !== undefined
318
- || pactMapOp.refSeq < ((_a = currentValue.accepted) === null || _a === void 0 ? void 0 : _a.sequenceNumber))) {
315
+ if (currentValue !== undefined &&
316
+ (currentValue.pending !== undefined ||
317
+ pactMapOp.refSeq < ((_a = currentValue.accepted) === null || _a === void 0 ? void 0 : _a.sequenceNumber))) {
319
318
  return;
320
319
  }
321
320
  // Otherwise we can resubmit
@@ -1 +1 @@
1
- {"version":3,"file":"pactMap.js","sourceRoot":"","sources":["../src/pactMap.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qDAAqD;AAErD,mCAAsC;AAEtC,+DAAsD;AACtD,+EAA8F;AAQ9F,+DAA4D;AAC5D,2EAA6G;AAC7G,qDAAkD;AA0ElD,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,MAAa,OAAqB,SAAQ,iCAA4B;IAyBlE;;;;;;OAMG;IACH,YAAmB,EAAU,EAAE,OAA+B,EAAE,UAA8B;QAC1F,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC;QAZpC,WAAM,GAAyB,IAAI,GAAG,EAAE,CAAC;QAEzC,eAAU,GAAiB,IAAI,qBAAY,EAAE,CAAC;QA4G9C,sBAAiB,GAAG,CACjC,GAAW,EACX,KAAoB,EACpB,MAAc,EACd,iBAAyB,EACrB,EAAE;YACN,MAAM,YAAY,GAAG,IAAI,CA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CAAC,mBAAmB,CAAC,CAAC;aAC5C;SACJ;IACL,CAAC;IAEM,cAAc;QACjB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;CACJ;AAlVD,0BAkVC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable unicorn/numeric-separators-style */\n\nimport { EventEmitter } from \"events\";\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelStorageService,\n IChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport { createSingleBlobSummary, IFluidSerializer, SharedObject } from \"@fluidframework/shared-object-base\";\nimport { PactMapFactory } from \"./pactMapFactory\";\nimport { IPactMap, IPactMapEvents } from \"./interfaces\";\n\n/**\n * The accepted pact information, if any.\n */\ninterface IAcceptedPact<T> {\n /**\n * The accepted value of the given type or undefined (typically in case of delete).\n */\n value: T | undefined;\n\n /**\n * The sequence number when the value was accepted, which will normally coincide with one of three possibilities:\n * - The sequence number of the \"accept\" op from the final client we expected signoff from\n * - The sequence number of the ClientLeave of the final client we expected signoff from\n * - The sequence number of the \"set\" op, if there were no expected signoffs (i.e. only the submitting client\n * was connected when the op was sequenced)\n *\n * For values set in detached state, it will be 0.\n */\n sequenceNumber: number;\n}\n\n/**\n * The pending pact information, if any.\n */\ninterface IPendingPact<T> {\n /**\n * The pending value of the given type or undefined (typically in case of delete).\n */\n value: T | undefined;\n /**\n * The list of clientIds that we expect \"accept\" ops from. Clients are also removed from this list if they\n * disconnect without accepting. When this list empties, the pending value transitions to accepted.\n */\n expectedSignoffs: string[];\n}\n\n/**\n * Internal format of the values stored in the PactMap.\n */\ntype Pact<T> =\n { accepted: IAcceptedPact<T>; pending: undefined; }\n | { accepted: undefined; pending: IPendingPact<T>; }\n | { accepted: IAcceptedPact<T>; pending: IPendingPact<T>; };\n\n/**\n * PactMap operation formats\n */\ninterface IPactMapSetOperation<T> {\n type: \"set\";\n key: string;\n value: T | undefined;\n\n /**\n * A \"set\" is only valid if it is made with knowledge of the most-recent accepted proposal - its reference\n * sequence number is greater than or equal to the sequence number when that prior value was accepted.\n *\n * However, we can't trust the built-in referenceSequenceNumber of the op because of resubmit on reconnect,\n * which will update the referenceSequenceNumber on our behalf.\n *\n * Instead we need to separately stamp the real reference sequence number on the op itself.\n */\n refSeq: number;\n}\n\ninterface IPactMapAcceptOperation {\n type: \"accept\";\n key: string;\n}\n\ntype IPactMapOperation<T> = IPactMapSetOperation<T> | IPactMapAcceptOperation;\n\nconst snapshotFileName = \"header\";\n\n/**\n * The PactMap distributed data structure provides key/value storage with a cautious conflict resolution strategy.\n * This strategy optimizes for all clients being aware of the change prior to considering the value as accepted.\n *\n * It is still experimental and under development. Please do try it out, but expect breaking changes in the future.\n *\n * @remarks\n * ### Creation\n *\n * To create a `PactMap`, call the static create method:\n *\n * ```typescript\n * const pactMap = PactMap.create(this.runtime, id);\n * ```\n *\n * ### Usage\n *\n * Setting and reading values is somewhat similar to a `SharedMap`. However, because the acceptance strategy\n * cannot be resolved until other clients have witnessed the set, the new value will only be reflected in the data\n * after the consensus is reached.\n *\n * ```typescript\n * pactMap.on(\"pending\", (key: string) => {\n * console.log(pactMap.getPending(key));\n * });\n * pactMap.on(\"accepted\", (key: string) => {\n * console.log(pactMap.get(key));\n * });\n * pactMap.set(\"myKey\", \"myValue\");\n *\n * // Reading from the pact map prior to the async operation's completion will still return the old value.\n * console.log(pactMap.get(\"myKey\"));\n * ```\n *\n * The acceptance process has two stages. When an op indicating a client's attempt to set a value is sequenced,\n * we first verify that it was set with knowledge of the most recently accepted value (consensus-like FWW). If it\n * meets this bar, then the value is \"pending\". During this time, clients may observe the pending value and act\n * upon it, but should be aware that not all other clients may have witnessed the value yet. Once all clients\n * that were connected at the time of the value being set have explicitly acknowledged the new value, the value\n * becomes \"accepted\". Once the value is accepted, it once again becomes possible to set the value, again with\n * consensus-like FWW resolution.\n *\n * Since all connected clients must explicitly accept the new value, it is important that all connected clients\n * have the PactMap loaded, including e.g. the summarizing client. Otherwise, those clients who have not loaded\n * the PactMap will not be responding to proposals and delay their acceptance (until they disconnect, which implicitly\n * removes them from consideration). The easiest way to ensure all clients load the PactMap is to instantiate it\n * as part of instantiating the IRuntime for the container (containerHasInitialized if using Aqueduct).\n *\n * ### Eventing\n *\n * `PactMap` is an `EventEmitter`, and will emit events when a new value is accepted for a key.\n *\n * ```typescript\n * pactMap.on(\"accept\", (key: string) => {\n * console.log(`New value was accepted for key: ${ key }, value: ${ pactMap.get(key) }`);\n * });\n * ```\n */\nexport class PactMap<T = unknown> extends SharedObject<IPactMapEvents> implements IPactMap<T> {\n /**\n * Create a new PactMap\n *\n * @param runtime - data store runtime the new PactMap belongs to\n * @param id - optional name of the PactMap\n * @returns newly created PactMap (but not attached yet)\n */\n public static create(runtime: IFluidDataStoreRuntime, id?: string): PactMap {\n return runtime.createChannel(id, PactMapFactory.Type) as PactMap;\n }\n\n /**\n * Get a factory for PactMap to register with the data store.\n *\n * @returns a factory that creates and loads PactMaps\n */\n public static getFactory(): IChannelFactory {\n return new PactMapFactory();\n }\n\n private readonly values: Map<string, Pact<T>> = new Map();\n\n private readonly incomingOp: EventEmitter = new EventEmitter();\n\n /**\n * Constructs a new PactMap. If the object is non-local an id and service interfaces will\n * be provided\n *\n * @param runtime - data store runtime the PactMap belongs to\n * @param id - optional name of the PactMap\n */\n public constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes) {\n super(id, runtime, attributes, \"fluid_pactMap_\");\n\n this.incomingOp.on(\"set\", this.handleIncomingSet);\n this.incomingOp.on(\"accept\", this.handleIncomingAccept);\n\n this.runtime.getQuorum().on(\"removeMember\", this.handleQuorumRemoveMember);\n }\n\n /**\n * {@inheritDoc IPactMap.get}\n */\n public get(key: string): T | undefined {\n return this.values.get(key)?.accepted?.value;\n }\n\n /**\n * {@inheritDoc IPactMap.isPending}\n */\n public isPending(key: string): boolean {\n return this.values.get(key)?.pending !== undefined;\n }\n\n /**\n * {@inheritDoc IPactMap.getPending}\n */\n public getPending(key: string): T | undefined {\n return this.values.get(key)?.pending?.value;\n }\n\n /**\n * {@inheritDoc IPactMap.set}\n */\n public set(key: string, value: T | undefined): void {\n const currentValue = this.values.get(key);\n // Early-exit if we can't submit a valid proposal (there's already a pending proposal)\n if (currentValue?.pending !== undefined) {\n return;\n }\n\n // If not attached, we basically pretend we got an ack immediately.\n if (!this.isAttached()) {\n // Queueing as a microtask to permit callers to complete their callstacks before the result of the set\n // takes effect. This more closely resembles the pattern in the attached state, where the ack will not\n // be received synchronously.\n queueMicrotask(() => {\n this.handleIncomingSet(\n key,\n value,\n 0 /* refSeq */,\n 0 /* setSequenceNumber */,\n );\n });\n return;\n }\n\n const setOp: IPactMapSetOperation<T> = {\n type: \"set\",\n key,\n value,\n refSeq: this.runtime.deltaManager.lastSequenceNumber,\n };\n\n this.submitLocalMessage(setOp);\n }\n\n /**\n * {@inheritDoc IPactMap.delete}\n */\n public delete(key: string): void {\n const currentValue = this.values.get(key);\n // Early-exit if:\n if (\n // there's nothing to delete\n currentValue === undefined\n // if something is pending (and so our proposal won't be valid)\n || currentValue.pending !== undefined\n // or if the accepted value is undefined which is equivalent to already being deleted\n || currentValue.accepted.value === undefined\n ) {\n return;\n }\n\n this.set(key, undefined);\n }\n\n /**\n * Get a point-in-time list of clients who must sign off on values coming in for them to move from \"pending\" to\n * \"accepted\" state. This list is finalized for a value at the moment it goes pending (i.e. if more clients\n * join later, they are not added to the list of signoffs).\n * @returns The list of clientIds for clients who must sign off to accept the incoming pending value\n */\n private getSignoffClients(): string[] {\n // If detached, we don't need anyone to sign off. Otherwise, we need all currently connected clients.\n return this.isAttached()\n ? [...this.runtime.getQuorum().getMembers().keys()]\n : [];\n }\n\n private readonly handleIncomingSet = (\n key: string,\n value: T | undefined,\n refSeq: number,\n setSequenceNumber: number,\n ): void => {\n const currentValue = this.values.get(key);\n // We use a consensus-like approach here, so a proposal is valid if the value is unset or if there is no\n // pending change and it was made with knowledge of the most recently accepted value. We'll drop invalid\n // proposals on the ground.\n const proposalValid =\n currentValue === undefined\n || (currentValue.pending === undefined && currentValue.accepted.sequenceNumber <= refSeq);\n if (!proposalValid) {\n return;\n }\n\n const accepted = currentValue?.accepted;\n\n // We expect signoffs from all connected clients at the time the set was sequenced (including the client who\n // sent the set).\n const expectedSignoffs = this.getSignoffClients();\n\n const newPact: Pact<T> = {\n accepted,\n pending: {\n value,\n expectedSignoffs,\n },\n };\n\n this.values.set(key, newPact);\n\n this.emit(\"pending\", key);\n\n if (expectedSignoffs.length === 0) {\n // At least the submitting client should be amongst the expectedSignoffs, but keeping this check around\n // as extra protection and in case we bring back the \"submitting client implicitly accepts\" optimization.\n this.values.set(key, {\n accepted: { value, sequenceNumber: setSequenceNumber },\n pending: undefined,\n });\n this.emit(\"accepted\", key);\n } else if (this.runtime.clientId !== undefined && expectedSignoffs.includes(this.runtime.clientId)) {\n // Emit an accept upon a new key entering pending state if our accept is expected.\n const acceptOp: IPactMapAcceptOperation = {\n type: \"accept\",\n key,\n };\n this.submitLocalMessage(acceptOp);\n }\n };\n\n private readonly handleIncomingAccept = (\n key: string,\n clientId: string,\n sequenceNumber: number,\n ): void => {\n const pending = this.values.get(key)?.pending;\n // We don't resubmit accepts on reconnect so this should only run for expected accepts.\n assert(pending !== undefined, 0x2f8 /* Unexpected accept op, nothing pending */);\n assert(\n pending.expectedSignoffs.includes(clientId),\n 0x2f9 /* Unexpected accept op, client not in expectedSignoffs */);\n\n // Remove the client from the expected signoffs\n pending.expectedSignoffs = pending.expectedSignoffs.filter(\n (expectedClientId) => expectedClientId !== clientId,\n );\n\n if (pending.expectedSignoffs.length === 0) {\n // The pending value has settled\n this.values.set(key, {\n accepted: { value: pending.value, sequenceNumber },\n pending: undefined,\n });\n this.emit(\"accepted\", key);\n }\n };\n\n private readonly handleQuorumRemoveMember = (clientId: string): void => {\n for (const [key, { pending }] of this.values) {\n if (pending !== undefined) {\n pending.expectedSignoffs = pending.expectedSignoffs.filter(\n (expectedClientId) => expectedClientId !== clientId,\n );\n\n if (pending.expectedSignoffs.length === 0) {\n // The pending value has settled\n this.values.set(key, {\n accepted: {\n value: pending.value,\n // The sequence number of the ClientLeave message.\n sequenceNumber: this.runtime.deltaManager.lastSequenceNumber,\n },\n pending: undefined,\n });\n this.emit(\"accepted\", key);\n }\n }\n }\n };\n\n /**\n * Create a summary for the PactMap\n *\n * @returns the summary of the current state of the PactMap\n * @internal\n */\n protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n const allEntries = [...this.values.entries()];\n // Filter out items that are ineffectual\n const summaryEntries = allEntries.filter(([, pact]) => {\n return (\n // Items have an effect if they are still pending, have a real value, or some client may try to\n // reference state before the value was accepted. Otherwise they can be dropped.\n pact.pending !== undefined\n || pact.accepted.value !== undefined\n || pact.accepted.sequenceNumber > this.runtime.deltaManager.minimumSequenceNumber\n );\n });\n return createSingleBlobSummary(snapshotFileName, JSON.stringify(summaryEntries));\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n * @internal\n */\n protected async loadCore(storage: IChannelStorageService): Promise<void> {\n const content = await readAndParse<[string, Pact<T>][]>(storage, snapshotFileName);\n for (const [key, value] of content) {\n this.values.set(key, value);\n }\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.initializeLocalCore}\n * @internal\n */\n protected initializeLocalCore(): void { }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.onDisconnect}\n * @internal\n */\n protected onDisconnect(): void { }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.reSubmitCore}\n * @internal\n */\n protected reSubmitCore(content: unknown, localOpMetadata: unknown): void {\n const pactMapOp = content as IPactMapOperation<T>;\n // Filter out accept messages - if we're coming back from a disconnect, our acceptance is never required\n // because we're implicitly removed from the list of expected accepts.\n if (pactMapOp.type === \"accept\") {\n return;\n }\n\n // Filter out set messages that have no chance of being accepted because there's another value pending\n // or another value was accepted while we were disconnected.\n const currentValue = this.values.get(pactMapOp.key);\n if (\n currentValue !== undefined\n && (\n currentValue.pending !== undefined\n || pactMapOp.refSeq < currentValue.accepted?.sequenceNumber\n )\n ) {\n return;\n }\n\n // Otherwise we can resubmit\n this.submitLocalMessage(pactMapOp, localOpMetadata);\n }\n\n /**\n * Process a PactMap operation\n *\n * @param message - the message to prepare\n * @param local - whether the message was sent by the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n * @internal\n */\n protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void {\n if (message.type === MessageType.Operation) {\n const op = message.contents as IPactMapOperation<T>;\n\n switch (op.type) {\n case \"set\":\n this.incomingOp.emit(\"set\", op.key, op.value, op.refSeq, message.sequenceNumber);\n break;\n\n case \"accept\":\n this.incomingOp.emit(\"accept\", op.key, message.clientId, message.sequenceNumber);\n break;\n\n default:\n throw new Error(\"Unknown operation\");\n }\n }\n }\n\n public applyStashedOp(): void {\n throw new Error(\"not implemented\");\n }\n}\n"]}
1
+ {"version":3,"file":"pactMap.js","sourceRoot":"","sources":["../src/pactMap.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qDAAqD;AAErD,mCAAsC;AAEtC,+DAAsD;AACtD,+EAA8F;AAQ9F,+DAA4D;AAC5D,2EAI4C;AAC5C,qDAAkD;AA0ElD,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,MAAa,OAAqB,SAAQ,iCAA4B;IAyBrE;;;;;;OAMG;IACH,YACC,EAAU,EACV,OAA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E,CAAC,GAAG,EACN,EAAE,CAAC,KAAK,EACR,EAAE,CAAC,MAAM,EACT,OAAO,CAAC,cAAc,CACtB,CAAC;oBACF,MAAM;gBAEP,KAAK,QAAQ;oBACZ,IAAI,CAAC,UAAU,CAAC,IAAI,CACnB,QAAQ,EACR,EAAE,CAAC,GAAG,EACN,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,cAAc,CACtB,CAAC;oBACF,MAAM;gBAEP;oBACC,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;aACtC;SACD;IACF,CAAC;IAEM,cAAc;QACpB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD;AAhWD,0BAgWC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable unicorn/numeric-separators-style */\n\nimport { EventEmitter } from \"events\";\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport {\n\tcreateSingleBlobSummary,\n\tIFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base\";\nimport { PactMapFactory } from \"./pactMapFactory\";\nimport { IPactMap, IPactMapEvents } from \"./interfaces\";\n\n/**\n * The accepted pact information, if any.\n */\ninterface IAcceptedPact<T> {\n\t/**\n\t * The accepted value of the given type or undefined (typically in case of delete).\n\t */\n\tvalue: T | undefined;\n\n\t/**\n\t * The sequence number when the value was accepted, which will normally coincide with one of three possibilities:\n\t * - The sequence number of the \"accept\" op from the final client we expected signoff from\n\t * - The sequence number of the ClientLeave of the final client we expected signoff from\n\t * - The sequence number of the \"set\" op, if there were no expected signoffs (i.e. only the submitting client\n\t * was connected when the op was sequenced)\n\t *\n\t * For values set in detached state, it will be 0.\n\t */\n\tsequenceNumber: number;\n}\n\n/**\n * The pending pact information, if any.\n */\ninterface IPendingPact<T> {\n\t/**\n\t * The pending value of the given type or undefined (typically in case of delete).\n\t */\n\tvalue: T | undefined;\n\t/**\n\t * The list of clientIds that we expect \"accept\" ops from. Clients are also removed from this list if they\n\t * disconnect without accepting. When this list empties, the pending value transitions to accepted.\n\t */\n\texpectedSignoffs: string[];\n}\n\n/**\n * Internal format of the values stored in the PactMap.\n */\ntype Pact<T> =\n\t| { accepted: IAcceptedPact<T>; pending: undefined }\n\t| { accepted: undefined; pending: IPendingPact<T> }\n\t| { accepted: IAcceptedPact<T>; pending: IPendingPact<T> };\n\n/**\n * PactMap operation formats\n */\ninterface IPactMapSetOperation<T> {\n\ttype: \"set\";\n\tkey: string;\n\tvalue: T | undefined;\n\n\t/**\n\t * A \"set\" is only valid if it is made with knowledge of the most-recent accepted proposal - its reference\n\t * sequence number is greater than or equal to the sequence number when that prior value was accepted.\n\t *\n\t * However, we can't trust the built-in referenceSequenceNumber of the op because of resubmit on reconnect,\n\t * which will update the referenceSequenceNumber on our behalf.\n\t *\n\t * Instead we need to separately stamp the real reference sequence number on the op itself.\n\t */\n\trefSeq: number;\n}\n\ninterface IPactMapAcceptOperation {\n\ttype: \"accept\";\n\tkey: string;\n}\n\ntype IPactMapOperation<T> = IPactMapSetOperation<T> | IPactMapAcceptOperation;\n\nconst snapshotFileName = \"header\";\n\n/**\n * The PactMap distributed data structure provides key/value storage with a cautious conflict resolution strategy.\n * This strategy optimizes for all clients being aware of the change prior to considering the value as accepted.\n *\n * It is still experimental and under development. Please do try it out, but expect breaking changes in the future.\n *\n * @remarks\n * ### Creation\n *\n * To create a `PactMap`, call the static create method:\n *\n * ```typescript\n * const pactMap = PactMap.create(this.runtime, id);\n * ```\n *\n * ### Usage\n *\n * Setting and reading values is somewhat similar to a `SharedMap`. However, because the acceptance strategy\n * cannot be resolved until other clients have witnessed the set, the new value will only be reflected in the data\n * after the consensus is reached.\n *\n * ```typescript\n * pactMap.on(\"pending\", (key: string) => {\n * console.log(pactMap.getPending(key));\n * });\n * pactMap.on(\"accepted\", (key: string) => {\n * console.log(pactMap.get(key));\n * });\n * pactMap.set(\"myKey\", \"myValue\");\n *\n * // Reading from the pact map prior to the async operation's completion will still return the old value.\n * console.log(pactMap.get(\"myKey\"));\n * ```\n *\n * The acceptance process has two stages. When an op indicating a client's attempt to set a value is sequenced,\n * we first verify that it was set with knowledge of the most recently accepted value (consensus-like FWW). If it\n * meets this bar, then the value is \"pending\". During this time, clients may observe the pending value and act\n * upon it, but should be aware that not all other clients may have witnessed the value yet. Once all clients\n * that were connected at the time of the value being set have explicitly acknowledged the new value, the value\n * becomes \"accepted\". Once the value is accepted, it once again becomes possible to set the value, again with\n * consensus-like FWW resolution.\n *\n * Since all connected clients must explicitly accept the new value, it is important that all connected clients\n * have the PactMap loaded, including e.g. the summarizing client. Otherwise, those clients who have not loaded\n * the PactMap will not be responding to proposals and delay their acceptance (until they disconnect, which implicitly\n * removes them from consideration). The easiest way to ensure all clients load the PactMap is to instantiate it\n * as part of instantiating the IRuntime for the container (containerHasInitialized if using Aqueduct).\n *\n * ### Eventing\n *\n * `PactMap` is an `EventEmitter`, and will emit events when a new value is accepted for a key.\n *\n * ```typescript\n * pactMap.on(\"accept\", (key: string) => {\n * console.log(`New value was accepted for key: ${ key }, value: ${ pactMap.get(key) }`);\n * });\n * ```\n */\nexport class PactMap<T = unknown> extends SharedObject<IPactMapEvents> implements IPactMap<T> {\n\t/**\n\t * Create a new PactMap\n\t *\n\t * @param runtime - data store runtime the new PactMap belongs to\n\t * @param id - optional name of the PactMap\n\t * @returns newly created PactMap (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string): PactMap {\n\t\treturn runtime.createChannel(id, PactMapFactory.Type) as PactMap;\n\t}\n\n\t/**\n\t * Get a factory for PactMap to register with the data store.\n\t *\n\t * @returns a factory that creates and loads PactMaps\n\t */\n\tpublic static getFactory(): IChannelFactory {\n\t\treturn new PactMapFactory();\n\t}\n\n\tprivate readonly values: Map<string, Pact<T>> = new Map();\n\n\tprivate readonly incomingOp: EventEmitter = new EventEmitter();\n\n\t/**\n\t * Constructs a new PactMap. If the object is non-local an id and service interfaces will\n\t * be provided\n\t *\n\t * @param runtime - data store runtime the PactMap belongs to\n\t * @param id - optional name of the PactMap\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_pactMap_\");\n\n\t\tthis.incomingOp.on(\"set\", this.handleIncomingSet);\n\t\tthis.incomingOp.on(\"accept\", this.handleIncomingAccept);\n\n\t\tthis.runtime.getQuorum().on(\"removeMember\", this.handleQuorumRemoveMember);\n\t}\n\n\t/**\n\t * {@inheritDoc IPactMap.get}\n\t */\n\tpublic get(key: string): T | undefined {\n\t\treturn this.values.get(key)?.accepted?.value;\n\t}\n\n\t/**\n\t * {@inheritDoc IPactMap.isPending}\n\t */\n\tpublic isPending(key: string): boolean {\n\t\treturn this.values.get(key)?.pending !== undefined;\n\t}\n\n\t/**\n\t * {@inheritDoc IPactMap.getPending}\n\t */\n\tpublic getPending(key: string): T | undefined {\n\t\treturn this.values.get(key)?.pending?.value;\n\t}\n\n\t/**\n\t * {@inheritDoc IPactMap.set}\n\t */\n\tpublic set(key: string, value: T | undefined): void {\n\t\tconst currentValue = this.values.get(key);\n\t\t// Early-exit if we can't submit a valid proposal (there's already a pending proposal)\n\t\tif (currentValue?.pending !== undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If not attached, we basically pretend we got an ack immediately.\n\t\tif (!this.isAttached()) {\n\t\t\t// Queueing as a microtask to permit callers to complete their callstacks before the result of the set\n\t\t\t// takes effect. This more closely resembles the pattern in the attached state, where the ack will not\n\t\t\t// be received synchronously.\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tthis.handleIncomingSet(key, value, 0 /* refSeq */, 0 /* setSequenceNumber */);\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst setOp: IPactMapSetOperation<T> = {\n\t\t\ttype: \"set\",\n\t\t\tkey,\n\t\t\tvalue,\n\t\t\trefSeq: this.runtime.deltaManager.lastSequenceNumber,\n\t\t};\n\n\t\tthis.submitLocalMessage(setOp);\n\t}\n\n\t/**\n\t * {@inheritDoc IPactMap.delete}\n\t */\n\tpublic delete(key: string): void {\n\t\tconst currentValue = this.values.get(key);\n\t\t// Early-exit if:\n\t\tif (\n\t\t\t// there's nothing to delete\n\t\t\tcurrentValue === undefined ||\n\t\t\t// if something is pending (and so our proposal won't be valid)\n\t\t\tcurrentValue.pending !== undefined ||\n\t\t\t// or if the accepted value is undefined which is equivalent to already being deleted\n\t\t\tcurrentValue.accepted.value === undefined\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.set(key, undefined);\n\t}\n\n\t/**\n\t * Get a point-in-time list of clients who must sign off on values coming in for them to move from \"pending\" to\n\t * \"accepted\" state. This list is finalized for a value at the moment it goes pending (i.e. if more clients\n\t * join later, they are not added to the list of signoffs).\n\t * @returns The list of clientIds for clients who must sign off to accept the incoming pending value\n\t */\n\tprivate getSignoffClients(): string[] {\n\t\t// If detached, we don't need anyone to sign off. Otherwise, we need all currently connected clients.\n\t\treturn this.isAttached() ? [...this.runtime.getQuorum().getMembers().keys()] : [];\n\t}\n\n\tprivate readonly handleIncomingSet = (\n\t\tkey: string,\n\t\tvalue: T | undefined,\n\t\trefSeq: number,\n\t\tsetSequenceNumber: number,\n\t): void => {\n\t\tconst currentValue = this.values.get(key);\n\t\t// We use a consensus-like approach here, so a proposal is valid if the value is unset or if there is no\n\t\t// pending change and it was made with knowledge of the most recently accepted value. We'll drop invalid\n\t\t// proposals on the ground.\n\t\tconst proposalValid =\n\t\t\tcurrentValue === undefined ||\n\t\t\t(currentValue.pending === undefined && currentValue.accepted.sequenceNumber <= refSeq);\n\t\tif (!proposalValid) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst accepted = currentValue?.accepted;\n\n\t\t// We expect signoffs from all connected clients at the time the set was sequenced (including the client who\n\t\t// sent the set).\n\t\tconst expectedSignoffs = this.getSignoffClients();\n\n\t\tconst newPact: Pact<T> = {\n\t\t\taccepted,\n\t\t\tpending: {\n\t\t\t\tvalue,\n\t\t\t\texpectedSignoffs,\n\t\t\t},\n\t\t};\n\n\t\tthis.values.set(key, newPact);\n\n\t\tthis.emit(\"pending\", key);\n\n\t\tif (expectedSignoffs.length === 0) {\n\t\t\t// At least the submitting client should be amongst the expectedSignoffs, but keeping this check around\n\t\t\t// as extra protection and in case we bring back the \"submitting client implicitly accepts\" optimization.\n\t\t\tthis.values.set(key, {\n\t\t\t\taccepted: { value, sequenceNumber: setSequenceNumber },\n\t\t\t\tpending: undefined,\n\t\t\t});\n\t\t\tthis.emit(\"accepted\", key);\n\t\t} else if (\n\t\t\tthis.runtime.clientId !== undefined &&\n\t\t\texpectedSignoffs.includes(this.runtime.clientId)\n\t\t) {\n\t\t\t// Emit an accept upon a new key entering pending state if our accept is expected.\n\t\t\tconst acceptOp: IPactMapAcceptOperation = {\n\t\t\t\ttype: \"accept\",\n\t\t\t\tkey,\n\t\t\t};\n\t\t\tthis.submitLocalMessage(acceptOp);\n\t\t}\n\t};\n\n\tprivate readonly handleIncomingAccept = (\n\t\tkey: string,\n\t\tclientId: string,\n\t\tsequenceNumber: number,\n\t): void => {\n\t\tconst pending = this.values.get(key)?.pending;\n\t\t// We don't resubmit accepts on reconnect so this should only run for expected accepts.\n\t\tassert(pending !== undefined, 0x2f8 /* Unexpected accept op, nothing pending */);\n\t\tassert(\n\t\t\tpending.expectedSignoffs.includes(clientId),\n\t\t\t0x2f9 /* Unexpected accept op, client not in expectedSignoffs */,\n\t\t);\n\n\t\t// Remove the client from the expected signoffs\n\t\tpending.expectedSignoffs = pending.expectedSignoffs.filter(\n\t\t\t(expectedClientId) => expectedClientId !== clientId,\n\t\t);\n\n\t\tif (pending.expectedSignoffs.length === 0) {\n\t\t\t// The pending value has settled\n\t\t\tthis.values.set(key, {\n\t\t\t\taccepted: { value: pending.value, sequenceNumber },\n\t\t\t\tpending: undefined,\n\t\t\t});\n\t\t\tthis.emit(\"accepted\", key);\n\t\t}\n\t};\n\n\tprivate readonly handleQuorumRemoveMember = (clientId: string): void => {\n\t\tfor (const [key, { pending }] of this.values) {\n\t\t\tif (pending !== undefined) {\n\t\t\t\tpending.expectedSignoffs = pending.expectedSignoffs.filter(\n\t\t\t\t\t(expectedClientId) => expectedClientId !== clientId,\n\t\t\t\t);\n\n\t\t\t\tif (pending.expectedSignoffs.length === 0) {\n\t\t\t\t\t// The pending value has settled\n\t\t\t\t\tthis.values.set(key, {\n\t\t\t\t\t\taccepted: {\n\t\t\t\t\t\t\tvalue: pending.value,\n\t\t\t\t\t\t\t// The sequence number of the ClientLeave message.\n\t\t\t\t\t\t\tsequenceNumber: this.runtime.deltaManager.lastSequenceNumber,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tpending: undefined,\n\t\t\t\t\t});\n\t\t\t\t\tthis.emit(\"accepted\", key);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Create a summary for the PactMap\n\t *\n\t * @returns the summary of the current state of the PactMap\n\t * @internal\n\t */\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst allEntries = [...this.values.entries()];\n\t\t// Filter out items that are ineffectual\n\t\tconst summaryEntries = allEntries.filter(([, pact]) => {\n\t\t\treturn (\n\t\t\t\t// Items have an effect if they are still pending, have a real value, or some client may try to\n\t\t\t\t// reference state before the value was accepted. Otherwise they can be dropped.\n\t\t\t\tpact.pending !== undefined ||\n\t\t\t\tpact.accepted.value !== undefined ||\n\t\t\t\tpact.accepted.sequenceNumber > this.runtime.deltaManager.minimumSequenceNumber\n\t\t\t);\n\t\t});\n\t\treturn createSingleBlobSummary(snapshotFileName, JSON.stringify(summaryEntries));\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t * @internal\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst content = await readAndParse<[string, Pact<T>][]>(storage, snapshotFileName);\n\t\tfor (const [key, value] of content) {\n\t\t\tthis.values.set(key, value);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.initializeLocalCore}\n\t * @internal\n\t */\n\tprotected initializeLocalCore(): void {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.onDisconnect}\n\t * @internal\n\t */\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.reSubmitCore}\n\t * @internal\n\t */\n\tprotected reSubmitCore(content: unknown, localOpMetadata: unknown): void {\n\t\tconst pactMapOp = content as IPactMapOperation<T>;\n\t\t// Filter out accept messages - if we're coming back from a disconnect, our acceptance is never required\n\t\t// because we're implicitly removed from the list of expected accepts.\n\t\tif (pactMapOp.type === \"accept\") {\n\t\t\treturn;\n\t\t}\n\n\t\t// Filter out set messages that have no chance of being accepted because there's another value pending\n\t\t// or another value was accepted while we were disconnected.\n\t\tconst currentValue = this.values.get(pactMapOp.key);\n\t\tif (\n\t\t\tcurrentValue !== undefined &&\n\t\t\t(currentValue.pending !== undefined ||\n\t\t\t\tpactMapOp.refSeq < currentValue.accepted?.sequenceNumber)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Otherwise we can resubmit\n\t\tthis.submitLocalMessage(pactMapOp, localOpMetadata);\n\t}\n\n\t/**\n\t * Process a PactMap operation\n\t *\n\t * @param message - the message to prepare\n\t * @param local - whether the message was sent by the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t * @internal\n\t */\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tif (message.type === MessageType.Operation) {\n\t\t\tconst op = message.contents as IPactMapOperation<T>;\n\n\t\t\tswitch (op.type) {\n\t\t\t\tcase \"set\":\n\t\t\t\t\tthis.incomingOp.emit(\n\t\t\t\t\t\t\"set\",\n\t\t\t\t\t\top.key,\n\t\t\t\t\t\top.value,\n\t\t\t\t\t\top.refSeq,\n\t\t\t\t\t\tmessage.sequenceNumber,\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"accept\":\n\t\t\t\t\tthis.incomingOp.emit(\n\t\t\t\t\t\t\"accept\",\n\t\t\t\t\t\top.key,\n\t\t\t\t\t\tmessage.clientId,\n\t\t\t\t\t\tmessage.sequenceNumber,\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic applyStashedOp(): void {\n\t\tthrow new Error(\"not implemented\");\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"pactMapFactory.d.ts","sourceRoot":"","sources":["../src/pactMapFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EAClB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGxC;;GAEG;AACH,qBAAa,cAAe,YAAW,eAAe;IAClD,gBAAuB,IAAI,gDAAgD;IAE3E,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,UAAU,IAAI,kBAAkB,CAE1C;IAED;;OAEG;IACU,IAAI,CACb,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAM/C,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,QAAQ;CAKxE"}
1
+ {"version":3,"file":"pactMapFactory.d.ts","sourceRoot":"","sources":["../src/pactMapFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGxC;;GAEG;AACH,qBAAa,cAAe,YAAW,eAAe;IACrD,gBAAuB,IAAI,gDAAgD;IAE3E,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,QAAQ,CAAC;IAMb,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,QAAQ;CAKrE"}
@@ -1 +1 @@
1
- {"version":3,"file":"pactMapFactory.js","sourceRoot":"","sources":["../src/pactMapFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,uCAAoC;AAEpC,qDAA8C;AAE9C;;GAEG;AACH,MAAa,cAAc;IASvB,IAAW,IAAI;QACX,OAAO,cAAc,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED,IAAW,UAAU;QACjB,OAAO,cAAc,CAAC,UAAU,CAAC;IACrC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CACb,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAC9B,MAAM,OAAO,GAAG,IAAI,iBAAO,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QACrD,MAAM,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACnB,CAAC;IAEM,MAAM,CAAC,QAAgC,EAAE,EAAU;QACtD,MAAM,OAAO,GAAG,IAAI,iBAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3D,OAAO,CAAC,eAAe,EAAE,CAAC;QAC1B,OAAO,OAAO,CAAC;IACnB,CAAC;;AAlCL,wCAmCC;AAlC0B,mBAAI,GAAG,4CAA4C,CAAC;AAEpD,yBAAU,GAAuB;IACpD,IAAI,EAAE,cAAc,CAAC,IAAI;IACzB,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,2BAAU;CAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelServices,\n IChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { PactMap } from \"./pactMap\";\nimport { IPactMap } from \"./interfaces\";\nimport { pkgVersion } from \"./packageVersion\";\n\n/**\n * The factory that produces the PactMap\n */\nexport class PactMapFactory implements IChannelFactory {\n public static readonly Type = \"https://graph.microsoft.com/types/pact-map\";\n\n public static readonly Attributes: IChannelAttributes = {\n type: PactMapFactory.Type,\n snapshotFormatVersion: \"0.1\",\n packageVersion: pkgVersion,\n };\n\n public get type(): string {\n return PactMapFactory.Type;\n }\n\n public get attributes(): IChannelAttributes {\n return PactMapFactory.Attributes;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n */\n public async load(\n runtime: IFluidDataStoreRuntime,\n id: string,\n services: IChannelServices,\n attributes: IChannelAttributes): Promise<IPactMap> {\n const pactMap = new PactMap(id, runtime, attributes);\n await pactMap.load(services);\n return pactMap;\n }\n\n public create(document: IFluidDataStoreRuntime, id: string): IPactMap {\n const pactMap = new PactMap(id, document, this.attributes);\n pactMap.initializeLocal();\n return pactMap;\n }\n}\n"]}
1
+ {"version":3,"file":"pactMapFactory.js","sourceRoot":"","sources":["../src/pactMapFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,uCAAoC;AAEpC,qDAA8C;AAE9C;;GAEG;AACH,MAAa,cAAc;IAS1B,IAAW,IAAI;QACd,OAAO,cAAc,CAAC,IAAI,CAAC;IAC5B,CAAC;IAED,IAAW,UAAU;QACpB,OAAO,cAAc,CAAC,UAAU,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAE9B,MAAM,OAAO,GAAG,IAAI,iBAAO,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QACrD,MAAM,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IAChB,CAAC;IAEM,MAAM,CAAC,QAAgC,EAAE,EAAU;QACzD,MAAM,OAAO,GAAG,IAAI,iBAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3D,OAAO,CAAC,eAAe,EAAE,CAAC;QAC1B,OAAO,OAAO,CAAC;IAChB,CAAC;;AAnCF,wCAoCC;AAnCuB,mBAAI,GAAG,4CAA4C,CAAC;AAEpD,yBAAU,GAAuB;IACvD,IAAI,EAAE,cAAc,CAAC,IAAI;IACzB,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,2BAAU;CAC1B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n\tIChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { PactMap } from \"./pactMap\";\nimport { IPactMap } from \"./interfaces\";\nimport { pkgVersion } from \"./packageVersion\";\n\n/**\n * The factory that produces the PactMap\n */\nexport class PactMapFactory implements IChannelFactory {\n\tpublic static readonly Type = \"https://graph.microsoft.com/types/pact-map\";\n\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: PactMapFactory.Type,\n\t\tsnapshotFormatVersion: \"0.1\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\tpublic get type(): string {\n\t\treturn PactMapFactory.Type;\n\t}\n\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn PactMapFactory.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<IPactMap> {\n\t\tconst pactMap = new PactMap(id, runtime, attributes);\n\t\tawait pactMap.load(services);\n\t\treturn pactMap;\n\t}\n\n\tpublic create(document: IFluidDataStoreRuntime, id: string): IPactMap {\n\t\tconst pactMap = new PactMap(id, document, this.attributes);\n\t\tpactMap.initializeLocal();\n\t\treturn pactMap;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAExF;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,mBAAmB;IACvD;;OAEG;IACH,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,OAAE;CACpE;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,aAAa,CAA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,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISharedObject, ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\n\n/**\n * IPactMapEvents are the events fired by an IPactMap.\n */\nexport interface IPactMapEvents extends ISharedObjectEvents {\n /**\n * Notifies when a new value goes pending or has been accepted.\n */\n (event: \"pending\" | \"accepted\", listener: (key: string) => void);\n}\n\n/**\n * An IPactMap is a key-value storage, in which setting a value is done via a proposal system. All collaborators\n * who were connected at the time of the proposal must accept the change before it is considered accepted (or, if\n * those clients disconnect they are considered to have implicitly accepted). As a result, the value goes through\n * two phases:\n * 1. \"pending\" state where the proposal has been sequenced, but there are still outstanding acceptances\n * 2. \"accepted\" state where all clients who were connected at the time the proposal was made have either accepted\n * or disconnected.\n */\nexport interface IPactMap<T = unknown> extends ISharedObject<IPactMapEvents> {\n /**\n * Gets the accepted value for the given key.\n * @param key - The key to retrieve from\n */\n get(key: string): T | undefined;\n\n /**\n * Returns whether there is a pending value for the given key. Can be used to distinguish a pending delete vs.\n * nothing pending when getPending would just return undefined.\n * @param key - The key to check\n */\n isPending(key: string): boolean;\n\n /**\n * Gets the pending value for the given key.\n * @param key - The key to retrieve from\n */\n getPending(key: string): T | undefined;\n\n /**\n * Sets the value for the given key. After setting the value, it will be in \"pending\" state until all connected\n * clients have approved the change. The accepted value remains unchanged until that time.\n * @param key - The key to set\n * @param value - The value to store\n */\n set(key: string, value: T | undefined): void;\n\n /**\n * Deletes the key/value pair at the given key. After issuing the delete, the delete is in \"pending\" state until\n * all connected clients have approved the delete. The accepted value remains unchanged until that time.\n * @param key - the key to delete\n */\n delete(key: string): void;\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISharedObject, ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\n\n/**\n * IPactMapEvents are the events fired by an IPactMap.\n */\nexport interface IPactMapEvents extends ISharedObjectEvents {\n\t/**\n\t * Notifies when a new value goes pending or has been accepted.\n\t */\n\t(event: \"pending\" | \"accepted\", listener: (key: string) => void);\n}\n\n/**\n * An IPactMap is a key-value storage, in which setting a value is done via a proposal system. All collaborators\n * who were connected at the time of the proposal must accept the change before it is considered accepted (or, if\n * those clients disconnect they are considered to have implicitly accepted). As a result, the value goes through\n * two phases:\n * 1. \"pending\" state where the proposal has been sequenced, but there are still outstanding acceptances\n * 2. \"accepted\" state where all clients who were connected at the time the proposal was made have either accepted\n * or disconnected.\n */\nexport interface IPactMap<T = unknown> extends ISharedObject<IPactMapEvents> {\n\t/**\n\t * Gets the accepted value for the given key.\n\t * @param key - The key to retrieve from\n\t */\n\tget(key: string): T | undefined;\n\n\t/**\n\t * Returns whether there is a pending value for the given key. Can be used to distinguish a pending delete vs.\n\t * nothing pending when getPending would just return undefined.\n\t * @param key - The key to check\n\t */\n\tisPending(key: string): boolean;\n\n\t/**\n\t * Gets the pending value for the given key.\n\t * @param key - The key to retrieve from\n\t */\n\tgetPending(key: string): T | undefined;\n\n\t/**\n\t * Sets the value for the given key. After setting the value, it will be in \"pending\" state until all connected\n\t * clients have approved the change. The accepted value remains unchanged until that time.\n\t * @param key - The key to set\n\t * @param value - The value to store\n\t */\n\tset(key: string, value: T | undefined): void;\n\n\t/**\n\t * Deletes the key/value pair at the given key. After issuing the delete, the delete is in \"pending\" state until\n\t * all connected clients have approved the delete. The accepted value remains unchanged until that time.\n\t * @param key - the key to delete\n\t */\n\tdelete(key: string): void;\n}\n"]}
@@ -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 = "@fluid-experimental/pact-map";
8
- export declare const pkgVersion = "2.0.0-internal.3.0.2";
8
+ export declare const pkgVersion = "2.0.0-internal.3.2.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluid-experimental/pact-map";
8
- export const pkgVersion = "2.0.0-internal.3.0.2";
8
+ export const pkgVersion = "2.0.0-internal.3.2.0";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,8BAA8B,CAAC;AACtD,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,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 = \"@fluid-experimental/pact-map\";\nexport const pkgVersion = \"2.0.0-internal.3.0.2\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,8BAA8B,CAAC;AACtD,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,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 = \"@fluid-experimental/pact-map\";\nexport const pkgVersion = \"2.0.0-internal.3.2.0\";\n"]}
@@ -1 +1 @@
1
- {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H,SAAS,CAAC,mBAAmB,IAAI,IAAI;IAErC;;;OAGG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAE9B;;;OAGG;IACH,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAuBxE;;;;;;;;OAQG;IACH,SAAS,CAAC,WAAW,CACpB,OAAO,EAAE,yBAAyB,EAClC,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO,GACtB,IAAI;IA8BA,cAAc,IAAI,IAAI;CAG7B"}
package/lib/pactMap.js CHANGED
@@ -7,7 +7,7 @@ import { EventEmitter } from "events";
7
7
  import { assert } from "@fluidframework/common-utils";
8
8
  import { MessageType } from "@fluidframework/protocol-definitions";
9
9
  import { readAndParse } from "@fluidframework/driver-utils";
10
- import { createSingleBlobSummary, SharedObject } from "@fluidframework/shared-object-base";
10
+ import { createSingleBlobSummary, SharedObject, } from "@fluidframework/shared-object-base";
11
11
  import { PactMapFactory } from "./pactMapFactory";
12
12
  const snapshotFileName = "header";
13
13
  /**
@@ -85,8 +85,8 @@ export class PactMap extends SharedObject {
85
85
  // We use a consensus-like approach here, so a proposal is valid if the value is unset or if there is no
86
86
  // pending change and it was made with knowledge of the most recently accepted value. We'll drop invalid
87
87
  // proposals on the ground.
88
- const proposalValid = currentValue === undefined
89
- || (currentValue.pending === undefined && currentValue.accepted.sequenceNumber <= refSeq);
88
+ const proposalValid = currentValue === undefined ||
89
+ (currentValue.pending === undefined && currentValue.accepted.sequenceNumber <= refSeq);
90
90
  if (!proposalValid) {
91
91
  return;
92
92
  }
@@ -112,7 +112,8 @@ export class PactMap extends SharedObject {
112
112
  });
113
113
  this.emit("accepted", key);
114
114
  }
115
- else if (this.runtime.clientId !== undefined && expectedSignoffs.includes(this.runtime.clientId)) {
115
+ else if (this.runtime.clientId !== undefined &&
116
+ expectedSignoffs.includes(this.runtime.clientId)) {
116
117
  // Emit an accept upon a new key entering pending state if our accept is expected.
117
118
  const acceptOp = {
118
119
  type: "accept",
@@ -235,11 +236,11 @@ export class PactMap extends SharedObject {
235
236
  // Early-exit if:
236
237
  if (
237
238
  // there's nothing to delete
238
- currentValue === undefined
239
+ currentValue === undefined ||
239
240
  // if something is pending (and so our proposal won't be valid)
240
- || currentValue.pending !== undefined
241
+ currentValue.pending !== undefined ||
241
242
  // or if the accepted value is undefined which is equivalent to already being deleted
242
- || currentValue.accepted.value === undefined) {
243
+ currentValue.accepted.value === undefined) {
243
244
  return;
244
245
  }
245
246
  this.set(key, undefined);
@@ -252,9 +253,7 @@ export class PactMap extends SharedObject {
252
253
  */
253
254
  getSignoffClients() {
254
255
  // If detached, we don't need anyone to sign off. Otherwise, we need all currently connected clients.
255
- return this.isAttached()
256
- ? [...this.runtime.getQuorum().getMembers().keys()]
257
- : [];
256
+ return this.isAttached() ? [...this.runtime.getQuorum().getMembers().keys()] : [];
258
257
  }
259
258
  /**
260
259
  * Create a summary for the PactMap
@@ -269,9 +268,9 @@ export class PactMap extends SharedObject {
269
268
  return (
270
269
  // Items have an effect if they are still pending, have a real value, or some client may try to
271
270
  // reference state before the value was accepted. Otherwise they can be dropped.
272
- pact.pending !== undefined
273
- || pact.accepted.value !== undefined
274
- || pact.accepted.sequenceNumber > this.runtime.deltaManager.minimumSequenceNumber);
271
+ pact.pending !== undefined ||
272
+ pact.accepted.value !== undefined ||
273
+ pact.accepted.sequenceNumber > this.runtime.deltaManager.minimumSequenceNumber);
275
274
  });
276
275
  return createSingleBlobSummary(snapshotFileName, JSON.stringify(summaryEntries));
277
276
  }
@@ -310,9 +309,9 @@ export class PactMap extends SharedObject {
310
309
  // Filter out set messages that have no chance of being accepted because there's another value pending
311
310
  // or another value was accepted while we were disconnected.
312
311
  const currentValue = this.values.get(pactMapOp.key);
313
- if (currentValue !== undefined
314
- && (currentValue.pending !== undefined
315
- || pactMapOp.refSeq < ((_a = currentValue.accepted) === null || _a === void 0 ? void 0 : _a.sequenceNumber))) {
312
+ if (currentValue !== undefined &&
313
+ (currentValue.pending !== undefined ||
314
+ pactMapOp.refSeq < ((_a = currentValue.accepted) === null || _a === void 0 ? void 0 : _a.sequenceNumber))) {
316
315
  return;
317
316
  }
318
317
  // Otherwise we can resubmit