@fluid-experimental/pact-map 2.0.0-internal.2.4.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 +26 -0
- package/.mocharc.js +12 -0
- package/LICENSE +21 -0
- package/README.md +55 -0
- package/api-extractor.json +4 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces.d.ts +55 -0
- package/dist/interfaces.d.ts.map +1 -0
- package/dist/interfaces.js +7 -0
- package/dist/interfaces.js.map +1 -0
- package/dist/packageVersion.d.ts +9 -0
- package/dist/packageVersion.d.ts.map +1 -0
- package/dist/packageVersion.js +12 -0
- package/dist/packageVersion.js.map +1 -0
- package/dist/pactMap.d.ts +162 -0
- package/dist/pactMap.d.ts.map +1 -0
- package/dist/pactMap.js +353 -0
- package/dist/pactMap.js.map +1 -0
- package/dist/pactMapFactory.d.ts +21 -0
- package/dist/pactMapFactory.d.ts.map +1 -0
- package/dist/pactMapFactory.js +41 -0
- package/dist/pactMapFactory.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -0
- package/lib/interfaces.d.ts +55 -0
- package/lib/interfaces.d.ts.map +1 -0
- package/lib/interfaces.js +6 -0
- package/lib/interfaces.js.map +1 -0
- package/lib/packageVersion.d.ts +9 -0
- package/lib/packageVersion.d.ts.map +1 -0
- package/lib/packageVersion.js +9 -0
- package/lib/packageVersion.js.map +1 -0
- package/lib/pactMap.d.ts +162 -0
- package/lib/pactMap.d.ts.map +1 -0
- package/lib/pactMap.js +349 -0
- package/lib/pactMap.js.map +1 -0
- package/lib/pactMapFactory.d.ts +21 -0
- package/lib/pactMapFactory.d.ts.map +1 -0
- package/lib/pactMapFactory.js +37 -0
- package/lib/pactMapFactory.js.map +1 -0
- package/package.json +98 -0
- package/prettier.config.cjs +8 -0
- package/src/index.ts +7 -0
- package/src/interfaces.ts +61 -0
- package/src/packageVersion.ts +9 -0
- package/src/pactMap.ts +493 -0
- package/src/pactMapFactory.ts +54 -0
- package/tsconfig.esnext.json +7 -0
- package/tsconfig.json +14 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
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
|
+
],
|
|
26
|
+
};
|
package/.mocharc.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const getFluidTestMochaConfig = require('@fluidframework/mocha-test-setup/mocharc-common');
|
|
9
|
+
|
|
10
|
+
const packageDir = __dirname;
|
|
11
|
+
const config = getFluidTestMochaConfig(packageDir);
|
|
12
|
+
module.exports = config;
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# @fluid-experimental/pact-map
|
|
2
|
+
|
|
3
|
+
<!-- AUTO-GENERATED-CONTENT:START (README_SIMPLE:scripts=FALSE) -->
|
|
4
|
+
|
|
5
|
+
<!-- prettier-ignore-start -->
|
|
6
|
+
|
|
7
|
+
<!-- This section is automatically generated. To update it, make the appropriate changes to docs/md-magic.config.js or the embedded content, then run 'npm run build:md-magic' in the docs folder. -->
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
To get started, install the package by running the following command:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm i @fluid-experimental/pact-map
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## API Documentation
|
|
18
|
+
|
|
19
|
+
API documentation for **@fluid-experimental/pact-map** is available at <https://fluidframework.com/docs/apis/pact-map>.
|
|
20
|
+
|
|
21
|
+
## Contribution Guidelines
|
|
22
|
+
|
|
23
|
+
There are many ways to [contribute](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md) to Fluid.
|
|
24
|
+
|
|
25
|
+
- Participate in Q&A in our [GitHub Discussions](https://github.com/microsoft/FluidFramework/discussions).
|
|
26
|
+
- [Submit bugs](https://github.com/microsoft/FluidFramework/issues) and help us verify fixes as they are checked in.
|
|
27
|
+
- Review the [source code changes](https://github.com/microsoft/FluidFramework/pulls).
|
|
28
|
+
- [Contribute bug fixes](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md).
|
|
29
|
+
|
|
30
|
+
Detailed instructions for working in the repo can be found in the [Wiki](https://github.com/microsoft/FluidFramework/wiki).
|
|
31
|
+
|
|
32
|
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
|
33
|
+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
|
34
|
+
|
|
35
|
+
This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
|
|
36
|
+
Use of these trademarks or logos must follow Microsoft’s [Trademark & Brand Guidelines](https://www.microsoft.com/trademarks).
|
|
37
|
+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
|
38
|
+
|
|
39
|
+
## Help
|
|
40
|
+
|
|
41
|
+
Not finding what you're looking for in this README?
|
|
42
|
+
Check out our [GitHub Wiki](https://github.com/microsoft/FluidFramework/wiki) or [fluidframework.com](https://fluidframework.com/docs/).
|
|
43
|
+
|
|
44
|
+
Still not finding what you're looking for? Please [file an issue](https://github.com/microsoft/FluidFramework/wiki/Submitting-Bugs-and-Feature-Requests).
|
|
45
|
+
Thank you!
|
|
46
|
+
|
|
47
|
+
## Trademark
|
|
48
|
+
|
|
49
|
+
This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
|
|
50
|
+
Use of these trademarks or logos must follow Microsoft's [Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
|
|
51
|
+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
|
52
|
+
|
|
53
|
+
<!-- prettier-ignore-end -->
|
|
54
|
+
|
|
55
|
+
<!-- AUTO-GENERATED-CONTENT:END -->
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.PactMap = void 0;
|
|
8
|
+
var pactMap_1 = require("./pactMap");
|
|
9
|
+
Object.defineProperty(exports, "PactMap", { enumerable: true, get: function () { return pactMap_1.PactMap; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,qCAAoC;AAA3B,kGAAA,OAAO,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { IPactMap, IPactMapEvents } from \"./interfaces\";\nexport { PactMap } from \"./pactMap\";\n"]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
|
|
6
|
+
/**
|
|
7
|
+
* IPactMapEvents are the events fired by an IPactMap.
|
|
8
|
+
*/
|
|
9
|
+
export interface IPactMapEvents extends ISharedObjectEvents {
|
|
10
|
+
/**
|
|
11
|
+
* Notifies when a new value goes pending or has been accepted.
|
|
12
|
+
*/
|
|
13
|
+
(event: "pending" | "accepted", listener: (key: string) => void): any;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* An IPactMap is a key-value storage, in which setting a value is done via a proposal system. All collaborators
|
|
17
|
+
* who were connected at the time of the proposal must accept the change before it is considered accepted (or, if
|
|
18
|
+
* those clients disconnect they are considered to have implicitly accepted). As a result, the value goes through
|
|
19
|
+
* two phases:
|
|
20
|
+
* 1. "pending" state where the proposal has been sequenced, but there are still outstanding acceptances
|
|
21
|
+
* 2. "accepted" state where all clients who were connected at the time the proposal was made have either accepted
|
|
22
|
+
* or disconnected.
|
|
23
|
+
*/
|
|
24
|
+
export interface IPactMap<T = unknown> extends ISharedObject<IPactMapEvents> {
|
|
25
|
+
/**
|
|
26
|
+
* Gets the accepted value for the given key.
|
|
27
|
+
* @param key - The key to retrieve from
|
|
28
|
+
*/
|
|
29
|
+
get(key: string): T | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Returns whether there is a pending value for the given key. Can be used to distinguish a pending delete vs.
|
|
32
|
+
* nothing pending when getPending would just return undefined.
|
|
33
|
+
* @param key - The key to check
|
|
34
|
+
*/
|
|
35
|
+
isPending(key: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Gets the pending value for the given key.
|
|
38
|
+
* @param key - The key to retrieve from
|
|
39
|
+
*/
|
|
40
|
+
getPending(key: string): T | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Sets the value for the given key. After setting the value, it will be in "pending" state until all connected
|
|
43
|
+
* clients have approved the change. The accepted value remains unchanged until that time.
|
|
44
|
+
* @param key - The key to set
|
|
45
|
+
* @param value - The value to store
|
|
46
|
+
*/
|
|
47
|
+
set(key: string, value: T | undefined): void;
|
|
48
|
+
/**
|
|
49
|
+
* Deletes the key/value pair at the given key. After issuing the delete, the delete is in "pending" state until
|
|
50
|
+
* all connected clients have approved the delete. The accepted value remains unchanged until that time.
|
|
51
|
+
* @param key - the key to delete
|
|
52
|
+
*/
|
|
53
|
+
delete(key: string): void;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
|
+
*/
|
|
7
|
+
export declare const pkgName = "@fluid-experimental/pact-map";
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.2.4.0";
|
|
9
|
+
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AACtD,eAAO,MAAM,UAAU,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*
|
|
6
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
|
+
exports.pkgName = "@fluid-experimental/pact-map";
|
|
11
|
+
exports.pkgVersion = "2.0.0-internal.2.4.0";
|
|
12
|
+
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -0,0 +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.2.4.0\";\n"]}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
6
|
+
import { IChannelAttributes, IFluidDataStoreRuntime, IChannelStorageService, IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
7
|
+
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
8
|
+
import { IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
|
|
9
|
+
import { IPactMap, IPactMapEvents } from "./interfaces";
|
|
10
|
+
/**
|
|
11
|
+
* The PactMap distributed data structure provides key/value storage with a cautious conflict resolution strategy.
|
|
12
|
+
* This strategy optimizes for all clients being aware of the change prior to considering the value as accepted.
|
|
13
|
+
*
|
|
14
|
+
* It is still experimental and under development. Please do try it out, but expect breaking changes in the future.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* ### Creation
|
|
18
|
+
*
|
|
19
|
+
* To create a `PactMap`, call the static create method:
|
|
20
|
+
*
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const pactMap = PactMap.create(this.runtime, id);
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* ### Usage
|
|
26
|
+
*
|
|
27
|
+
* Setting and reading values is somewhat similar to a `SharedMap`. However, because the acceptance strategy
|
|
28
|
+
* cannot be resolved until other clients have witnessed the set, the new value will only be reflected in the data
|
|
29
|
+
* after the consensus is reached.
|
|
30
|
+
*
|
|
31
|
+
* ```typescript
|
|
32
|
+
* pactMap.on("pending", (key: string) => {
|
|
33
|
+
* console.log(pactMap.getPending(key));
|
|
34
|
+
* });
|
|
35
|
+
* pactMap.on("accepted", (key: string) => {
|
|
36
|
+
* console.log(pactMap.get(key));
|
|
37
|
+
* });
|
|
38
|
+
* pactMap.set("myKey", "myValue");
|
|
39
|
+
*
|
|
40
|
+
* // Reading from the pact map prior to the async operation's completion will still return the old value.
|
|
41
|
+
* console.log(pactMap.get("myKey"));
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* The acceptance process has two stages. When an op indicating a client's attempt to set a value is sequenced,
|
|
45
|
+
* we first verify that it was set with knowledge of the most recently accepted value (consensus-like FWW). If it
|
|
46
|
+
* meets this bar, then the value is "pending". During this time, clients may observe the pending value and act
|
|
47
|
+
* upon it, but should be aware that not all other clients may have witnessed the value yet. Once all clients
|
|
48
|
+
* that were connected at the time of the value being set have explicitly acknowledged the new value, the value
|
|
49
|
+
* becomes "accepted". Once the value is accepted, it once again becomes possible to set the value, again with
|
|
50
|
+
* consensus-like FWW resolution.
|
|
51
|
+
*
|
|
52
|
+
* Since all connected clients must explicitly accept the new value, it is important that all connected clients
|
|
53
|
+
* have the PactMap loaded, including e.g. the summarizing client. Otherwise, those clients who have not loaded
|
|
54
|
+
* the PactMap will not be responding to proposals and delay their acceptance (until they disconnect, which implicitly
|
|
55
|
+
* removes them from consideration). The easiest way to ensure all clients load the PactMap is to instantiate it
|
|
56
|
+
* as part of instantiating the IRuntime for the container (containerHasInitialized if using Aqueduct).
|
|
57
|
+
*
|
|
58
|
+
* ### Eventing
|
|
59
|
+
*
|
|
60
|
+
* `PactMap` is an `EventEmitter`, and will emit events when a new value is accepted for a key.
|
|
61
|
+
*
|
|
62
|
+
* ```typescript
|
|
63
|
+
* pactMap.on("accept", (key: string) => {
|
|
64
|
+
* console.log(`New value was accepted for key: ${ key }, value: ${ pactMap.get(key) }`);
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare class PactMap<T = unknown> extends SharedObject<IPactMapEvents> implements IPactMap<T> {
|
|
69
|
+
/**
|
|
70
|
+
* Create a new PactMap
|
|
71
|
+
*
|
|
72
|
+
* @param runtime - data store runtime the new PactMap belongs to
|
|
73
|
+
* @param id - optional name of the PactMap
|
|
74
|
+
* @returns newly created PactMap (but not attached yet)
|
|
75
|
+
*/
|
|
76
|
+
static create(runtime: IFluidDataStoreRuntime, id?: string): PactMap;
|
|
77
|
+
/**
|
|
78
|
+
* Get a factory for PactMap to register with the data store.
|
|
79
|
+
*
|
|
80
|
+
* @returns a factory that creates and loads PactMaps
|
|
81
|
+
*/
|
|
82
|
+
static getFactory(): IChannelFactory;
|
|
83
|
+
private readonly values;
|
|
84
|
+
private readonly incomingOp;
|
|
85
|
+
/**
|
|
86
|
+
* Constructs a new PactMap. If the object is non-local an id and service interfaces will
|
|
87
|
+
* be provided
|
|
88
|
+
*
|
|
89
|
+
* @param runtime - data store runtime the PactMap belongs to
|
|
90
|
+
* @param id - optional name of the PactMap
|
|
91
|
+
*/
|
|
92
|
+
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
93
|
+
/**
|
|
94
|
+
* {@inheritDoc IPactMap.get}
|
|
95
|
+
*/
|
|
96
|
+
get(key: string): T | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* {@inheritDoc IPactMap.isPending}
|
|
99
|
+
*/
|
|
100
|
+
isPending(key: string): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* {@inheritDoc IPactMap.getPending}
|
|
103
|
+
*/
|
|
104
|
+
getPending(key: string): T | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* {@inheritDoc IPactMap.set}
|
|
107
|
+
*/
|
|
108
|
+
set(key: string, value: T | undefined): void;
|
|
109
|
+
/**
|
|
110
|
+
* {@inheritDoc IPactMap.delete}
|
|
111
|
+
*/
|
|
112
|
+
delete(key: string): void;
|
|
113
|
+
/**
|
|
114
|
+
* Get a point-in-time list of clients who must sign off on values coming in for them to move from "pending" to
|
|
115
|
+
* "accepted" state. This list is finalized for a value at the moment it goes pending (i.e. if more clients
|
|
116
|
+
* join later, they are not added to the list of signoffs).
|
|
117
|
+
* @returns The list of clientIds for clients who must sign off to accept the incoming pending value
|
|
118
|
+
*/
|
|
119
|
+
private getSignoffClients;
|
|
120
|
+
private readonly handleIncomingSet;
|
|
121
|
+
private readonly handleIncomingAccept;
|
|
122
|
+
private readonly handleQuorumRemoveMember;
|
|
123
|
+
/**
|
|
124
|
+
* Create a summary for the PactMap
|
|
125
|
+
*
|
|
126
|
+
* @returns the summary of the current state of the PactMap
|
|
127
|
+
* @internal
|
|
128
|
+
*/
|
|
129
|
+
protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
|
|
130
|
+
/**
|
|
131
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
|
|
132
|
+
* @internal
|
|
133
|
+
*/
|
|
134
|
+
protected loadCore(storage: IChannelStorageService): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.initializeLocalCore}
|
|
137
|
+
* @internal
|
|
138
|
+
*/
|
|
139
|
+
protected initializeLocalCore(): void;
|
|
140
|
+
/**
|
|
141
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.onDisconnect}
|
|
142
|
+
* @internal
|
|
143
|
+
*/
|
|
144
|
+
protected onDisconnect(): void;
|
|
145
|
+
/**
|
|
146
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.reSubmitCore}
|
|
147
|
+
* @internal
|
|
148
|
+
*/
|
|
149
|
+
protected reSubmitCore(content: unknown, localOpMetadata: unknown): void;
|
|
150
|
+
/**
|
|
151
|
+
* Process a PactMap operation
|
|
152
|
+
*
|
|
153
|
+
* @param message - the message to prepare
|
|
154
|
+
* @param local - whether the message was sent by the local client
|
|
155
|
+
* @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
|
|
156
|
+
* For messages from a remote client, this will be undefined.
|
|
157
|
+
* @internal
|
|
158
|
+
*/
|
|
159
|
+
protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
|
160
|
+
applyStashedOp(): void;
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=pactMap.d.ts.map
|
|
@@ -0,0 +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,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO;IAI3E;;;;OAIG;WACW,UAAU,IAAI,eAAe;IAI3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmC;IAE1D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoC;IAE/D;;;;;;OAMG;gBACgB,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,kBAAkB;IAS9F;;OAEG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAItC;;OAEG;IACI,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAItC;;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;IAiCnD;;OAEG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAiBhC;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAmDhC;IAEF,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAyBnC;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;IAyBxE;;;;;;;;OAQG;IACH,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAmBlG,cAAc,IAAI,IAAI;CAGhC"}
|