@fluidframework/register-collection 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.225277

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.
Files changed (85) hide show
  1. package/.eslintrc.js +5 -7
  2. package/.mocharc.js +12 -0
  3. package/CHANGELOG.md +117 -0
  4. package/README.md +29 -8
  5. package/api-extractor-esm.json +4 -0
  6. package/api-extractor-lint.json +4 -0
  7. package/api-extractor.json +2 -2
  8. package/api-report/register-collection.api.md +90 -0
  9. package/dist/{consensusRegisterCollection.js → consensusRegisterCollection.cjs} +31 -29
  10. package/dist/consensusRegisterCollection.cjs.map +1 -0
  11. package/dist/consensusRegisterCollection.d.ts +2 -1
  12. package/dist/consensusRegisterCollection.d.ts.map +1 -1
  13. package/dist/{consensusRegisterCollectionFactory.js → consensusRegisterCollectionFactory.cjs} +5 -4
  14. package/dist/consensusRegisterCollectionFactory.cjs.map +1 -0
  15. package/dist/consensusRegisterCollectionFactory.d.ts +2 -1
  16. package/dist/consensusRegisterCollectionFactory.d.ts.map +1 -1
  17. package/dist/index.cjs +14 -0
  18. package/dist/index.cjs.map +1 -0
  19. package/dist/index.d.ts +3 -3
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/{interfaces.js → interfaces.cjs} +3 -2
  22. package/dist/interfaces.cjs.map +1 -0
  23. package/dist/interfaces.d.ts +9 -5
  24. package/dist/interfaces.d.ts.map +1 -1
  25. package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
  26. package/dist/packageVersion.cjs.map +1 -0
  27. package/dist/packageVersion.d.ts +1 -1
  28. package/dist/packageVersion.d.ts.map +1 -1
  29. package/dist/register-collection-alpha.d.ts +163 -0
  30. package/dist/register-collection-beta.d.ts +25 -0
  31. package/dist/register-collection-public.d.ts +25 -0
  32. package/dist/register-collection-untrimmed.d.ts +163 -0
  33. package/dist/tsdoc-metadata.json +11 -0
  34. package/lib/{consensusRegisterCollection.d.ts → consensusRegisterCollection.d.mts} +5 -4
  35. package/lib/consensusRegisterCollection.d.mts.map +1 -0
  36. package/lib/{consensusRegisterCollection.js → consensusRegisterCollection.mjs} +27 -25
  37. package/lib/consensusRegisterCollection.mjs.map +1 -0
  38. package/lib/{consensusRegisterCollectionFactory.d.ts → consensusRegisterCollectionFactory.d.mts} +4 -3
  39. package/lib/consensusRegisterCollectionFactory.d.mts.map +1 -0
  40. package/lib/{consensusRegisterCollectionFactory.js → consensusRegisterCollectionFactory.mjs} +5 -4
  41. package/lib/consensusRegisterCollectionFactory.mjs.map +1 -0
  42. package/lib/index.d.mts +8 -0
  43. package/lib/index.d.mts.map +1 -0
  44. package/lib/index.mjs +8 -0
  45. package/lib/index.mjs.map +1 -0
  46. package/lib/{interfaces.d.ts → interfaces.d.mts} +10 -6
  47. package/lib/interfaces.d.mts.map +1 -0
  48. package/lib/{interfaces.js → interfaces.mjs} +2 -1
  49. package/lib/interfaces.mjs.map +1 -0
  50. package/lib/{packageVersion.d.ts → packageVersion.d.mts} +2 -2
  51. package/lib/packageVersion.d.mts.map +1 -0
  52. package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
  53. package/lib/packageVersion.mjs.map +1 -0
  54. package/lib/register-collection-alpha.d.mts +163 -0
  55. package/lib/register-collection-beta.d.mts +25 -0
  56. package/lib/register-collection-public.d.mts +25 -0
  57. package/lib/register-collection-untrimmed.d.mts +163 -0
  58. package/package.json +135 -62
  59. package/prettier.config.cjs +8 -0
  60. package/src/consensusRegisterCollection.ts +307 -284
  61. package/src/consensusRegisterCollectionFactory.ts +39 -33
  62. package/src/index.ts +8 -3
  63. package/src/interfaces.ts +52 -43
  64. package/src/packageVersion.ts +1 -1
  65. package/tsc-multi.test.json +4 -0
  66. package/tsconfig.json +11 -13
  67. package/dist/consensusRegisterCollection.js.map +0 -1
  68. package/dist/consensusRegisterCollectionFactory.js.map +0 -1
  69. package/dist/index.js +0 -20
  70. package/dist/index.js.map +0 -1
  71. package/dist/interfaces.js.map +0 -1
  72. package/dist/packageVersion.js.map +0 -1
  73. package/lib/consensusRegisterCollection.d.ts.map +0 -1
  74. package/lib/consensusRegisterCollection.js.map +0 -1
  75. package/lib/consensusRegisterCollectionFactory.d.ts.map +0 -1
  76. package/lib/consensusRegisterCollectionFactory.js.map +0 -1
  77. package/lib/index.d.ts +0 -8
  78. package/lib/index.d.ts.map +0 -1
  79. package/lib/index.js +0 -8
  80. package/lib/index.js.map +0 -1
  81. package/lib/interfaces.d.ts.map +0 -1
  82. package/lib/interfaces.js.map +0 -1
  83. package/lib/packageVersion.d.ts.map +0 -1
  84. package/lib/packageVersion.js.map +0 -1
  85. package/tsconfig.esnext.json +0 -7
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.ReadPolicy = void 0;
8
8
  /**
9
9
  * Read policies used when reading the map value.
10
+ * @alpha
10
11
  */
11
12
  var ReadPolicy;
12
13
  (function (ReadPolicy) {
@@ -14,5 +15,5 @@ var ReadPolicy;
14
15
  ReadPolicy[ReadPolicy["Atomic"] = 0] = "Atomic";
15
16
  // Last writer wins. Simply returns the last written value.
16
17
  ReadPolicy[ReadPolicy["LWW"] = 1] = "LWW";
17
- })(ReadPolicy = exports.ReadPolicy || (exports.ReadPolicy = {}));
18
- //# sourceMappingURL=interfaces.js.map
18
+ })(ReadPolicy || (exports.ReadPolicy = ReadPolicy = {}));
19
+ //# sourceMappingURL=interfaces.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.cjs","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAsFH;;;GAGG;AACH,IAAY,UAMX;AAND,WAAY,UAAU;IACrB,mFAAmF;IACnF,+CAAM,CAAA;IAEN,2DAA2D;IAC3D,yCAAG,CAAA;AACJ,CAAC,EANW,UAAU,0BAAV,UAAU,QAMrB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n\tIChannelAttributes,\n\tIChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISharedObject, ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\n\n/**\n * Consensus Register Collection channel factory interface\n *\n * Extends the base IChannelFactory to return a more definite type of IConsensusRegisterCollection\n * Use for the runtime to create and load distributed data structure by type name of each channel.\n * @alpha\n */\nexport interface IConsensusRegisterCollectionFactory extends IChannelFactory {\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t */\n\tload(\n\t\tdocument: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes,\n\t): Promise<IConsensusRegisterCollection>;\n\n\tcreate(document: IFluidDataStoreRuntime, id: string): IConsensusRegisterCollection;\n}\n\n/**\n * Events emitted by {@link IConsensusRegisterCollection}.\n * @alpha\n */\nexport interface IConsensusRegisterCollectionEvents extends ISharedObjectEvents {\n\t(\n\t\tevent: \"atomicChanged\" | \"versionChanged\",\n\t\tlistener: (key: string, value: any, local: boolean) => void,\n\t);\n}\n\n/**\n * A distributed data structure that holds a set of registers with update\n * versions. On concurrent updates, a register internally stores all possible versions of a value by using reference\n * sequence number of the incoming update.\n *\n * Using all the stored versions, we can then distinguish amongst different read policies. Below are the policies\n * we support:\n *\n * Atomic: Atomicity requires a linearizable register. A linearizable register behaves as if there is only a single\n * copy of the data, and that every operation appears to take effect atomically at one point in time. This definition\n * implies that operations are executed in an well-defined order. On a concurrent update, we perform a compare-and-set\n * operation, where we compare a register sequence number with the incoming reference sequence number.\n * The earliest operation overwriting prior sequence numbers wins since every client reaches to an agreement on\n * the value. So we can safely return the first value.\n *\n * LWW: The last write to a key always wins.\n * @alpha\n */\nexport interface IConsensusRegisterCollection<T = any>\n\textends ISharedObject<IConsensusRegisterCollectionEvents> {\n\t/**\n\t * Attempts to write a register with a value. Returns a promise to indicate the roundtrip completion.\n\t * For a non existent register, it will attempt to create a new register with the specified value.\n\t *\n\t * @returns Promise<true> if write was non-concurrent\n\t */\n\twrite(key: string, value: T): Promise<boolean>;\n\n\t/**\n\t * Retrieves the agreed upon value for the register based on policy. Returns undefined if not present.\n\t */\n\tread(key: string, policy?: ReadPolicy): T | undefined;\n\n\t/**\n\t * Retrives all concurrent versions. Undefined if not present.\n\t */\n\treadVersions(key: string): T[] | undefined;\n\n\t/**\n\t * Returns the keys.\n\t */\n\tkeys(): string[];\n}\n\n/**\n * Read policies used when reading the map value.\n * @alpha\n */\nexport enum ReadPolicy {\n\t// On a concurrent update, returns the first agreed upon value amongst all clients.\n\tAtomic,\n\n\t// Last writer wins. Simply returns the last written value.\n\tLWW,\n}\n"]}
@@ -8,7 +8,8 @@ import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-objec
8
8
  * Consensus Register Collection channel factory interface
9
9
  *
10
10
  * Extends the base IChannelFactory to return a more definite type of IConsensusRegisterCollection
11
- * Use for the runtime to create and load distributed data structure by type name of each channel
11
+ * Use for the runtime to create and load distributed data structure by type name of each channel.
12
+ * @alpha
12
13
  */
13
14
  export interface IConsensusRegisterCollectionFactory extends IChannelFactory {
14
15
  /**
@@ -17,13 +18,15 @@ export interface IConsensusRegisterCollectionFactory extends IChannelFactory {
17
18
  load(document: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<IConsensusRegisterCollection>;
18
19
  create(document: IFluidDataStoreRuntime, id: string): IConsensusRegisterCollection;
19
20
  }
21
+ /**
22
+ * Events emitted by {@link IConsensusRegisterCollection}.
23
+ * @alpha
24
+ */
20
25
  export interface IConsensusRegisterCollectionEvents extends ISharedObjectEvents {
21
26
  (event: "atomicChanged" | "versionChanged", listener: (key: string, value: any, local: boolean) => void): any;
22
27
  }
23
28
  /**
24
- * Consensus Register Collection.
25
- *
26
- * A consensus register collection is a distributed data structure, which holds a set of registers with update
29
+ * A distributed data structure that holds a set of registers with update
27
30
  * versions. On concurrent updates, a register internally stores all possible versions of a value by using reference
28
31
  * sequence number of the incoming update.
29
32
  *
@@ -38,7 +41,7 @@ export interface IConsensusRegisterCollectionEvents extends ISharedObjectEvents
38
41
  * the value. So we can safely return the first value.
39
42
  *
40
43
  * LWW: The last write to a key always wins.
41
- *
44
+ * @alpha
42
45
  */
43
46
  export interface IConsensusRegisterCollection<T = any> extends ISharedObject<IConsensusRegisterCollectionEvents> {
44
47
  /**
@@ -63,6 +66,7 @@ export interface IConsensusRegisterCollection<T = any> extends ISharedObject<ICo
63
66
  }
64
67
  /**
65
68
  * Read policies used when reading the map value.
69
+ * @alpha
66
70
  */
67
71
  export declare enum ReadPolicy {
68
72
  Atomic = 0,
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EAClB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAExF;;;;;GAKG;AACH,MAAM,WAAW,mCAAoC,SAAQ,eAAe;IACxE;;OAEG;IACH,IAAI,CACA,QAAQ,EAAE,sBAAsB,EAChC,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAE3E,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,4BAA4B,CAAC;CACtF;AAED,MAAM,WAAW,kCAAmC,SAAQ,mBAAmB;IAC3E,CAAC,KAAK,EAAE,eAAe,GAAG,gBAAgB,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,OAAE;CAC5G;AAED;;;;;;;;;;;;;;;;;;;GAmBG;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AE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,OAC1D;CACF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,4BAA4B,CAAC,CAAC,GAAG,GAAG,CACpD,SAAQ,aAAa,CAAC,kCAAkC,CAAC;IACzD;;;;;OAKG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE/C;;OAEG;IACH,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,CAAC,GAAG,SAAS,CAAC;IAEtD;;OAEG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,EAAE,GAAG,SAAS,CAAC;IAE3C;;OAEG;IACH,IAAI,IAAI,MAAM,EAAE,CAAC;CACjB;AAED;;;GAGG;AACH,oBAAY,UAAU;IAErB,MAAM,IAAA;IAGN,GAAG,IAAA;CACH"}
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/register-collection";
11
- exports.pkgVersion = "1.4.0-121020";
12
- //# sourceMappingURL=packageVersion.js.map
11
+ exports.pkgVersion = "2.0.0-dev-rc.1.0.0.225277";
12
+ //# sourceMappingURL=packageVersion.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packageVersion.cjs","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,qCAAqC,CAAC;AAChD,QAAA,UAAU,GAAG,2BAA2B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/register-collection\";\nexport const pkgVersion = \"2.0.0-dev-rc.1.0.0.225277\";\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 = "@fluidframework/register-collection";
8
- export declare const pkgVersion = "1.4.0-121020";
8
+ export declare const pkgVersion = "2.0.0-dev-rc.1.0.0.225277";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,wCAAwC,CAAC;AAC7D,eAAO,MAAM,UAAU,iBAAiB,CAAC"}
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,wCAAwC,CAAC;AAC7D,eAAO,MAAM,UAAU,8BAA8B,CAAC"}
@@ -0,0 +1,163 @@
1
+ import { IChannelAttributes } from '@fluidframework/datastore-definitions';
2
+ import { IChannelFactory } from '@fluidframework/datastore-definitions';
3
+ import { IChannelServices } from '@fluidframework/datastore-definitions';
4
+ import { IChannelStorageService } from '@fluidframework/datastore-definitions';
5
+ import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
6
+ import { IFluidSerializer } from '@fluidframework/shared-object-base';
7
+ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
8
+ import { ISharedObject } from '@fluidframework/shared-object-base';
9
+ import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
10
+ import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
11
+ import { SharedObject } from '@fluidframework/shared-object-base';
12
+
13
+ /**
14
+ * {@inheritDoc IConsensusRegisterCollection}
15
+ * @alpha
16
+ */
17
+ export declare class ConsensusRegisterCollection<T> extends SharedObject<IConsensusRegisterCollectionEvents> implements IConsensusRegisterCollection<T> {
18
+ /**
19
+ * Create a new consensus register collection
20
+ *
21
+ * @param runtime - data store runtime the new consensus register collection belongs to
22
+ * @param id - optional name of the consensus register collection
23
+ * @returns newly create consensus register collection (but not attached yet)
24
+ */
25
+ static create<T>(runtime: IFluidDataStoreRuntime, id?: string): ConsensusRegisterCollection<T>;
26
+ /**
27
+ * Get a factory for ConsensusRegisterCollection to register with the data store.
28
+ *
29
+ * @returns a factory that creates and load ConsensusRegisterCollection
30
+ */
31
+ static getFactory(): ConsensusRegisterCollectionFactory;
32
+ private readonly data;
33
+ /**
34
+ * Constructs a new consensus register collection. If the object is non-local an id and service interfaces will
35
+ * be provided
36
+ */
37
+ constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
38
+ /**
39
+ * Creates a new register or writes a new value.
40
+ * Returns a promise that will resolve when the write is acked.
41
+ *
42
+ * @returns Promise<true> if write was non-concurrent
43
+ */
44
+ write(key: string, value: T): Promise<boolean>;
45
+ /**
46
+ * Returns the most recent local value of a register.
47
+ * @param key - The key to read
48
+ * @param readPolicy - The ReadPolicy to apply. Defaults to Atomic.
49
+ */
50
+ read(key: string, readPolicy?: ReadPolicy): T | undefined;
51
+ readVersions(key: string): T[] | undefined;
52
+ keys(): string[];
53
+ protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
54
+ /**
55
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
56
+ */
57
+ protected loadCore(storage: IChannelStorageService): Promise<void>;
58
+ protected onDisconnect(): void;
59
+ protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
60
+ private readAtomic;
61
+ /**
62
+ * Process an inbound write op
63
+ * @param key - Key that was written to
64
+ * @param value - Incoming value
65
+ * @param refSeq - RefSeq at the time of write on the remote client
66
+ * @param sequenceNumber - Sequence Number of this write op
67
+ * @param local - Did this write originate on this client
68
+ */
69
+ private processInboundWrite;
70
+ private stringify;
71
+ private parse;
72
+ protected applyStashedOp(): () => void;
73
+ }
74
+
75
+ /**
76
+ * The factory that defines the consensus queue.
77
+ * @alpha
78
+ */
79
+ export declare class ConsensusRegisterCollectionFactory implements IConsensusRegisterCollectionFactory {
80
+ static Type: string;
81
+ static readonly Attributes: IChannelAttributes;
82
+ get type(): string;
83
+ get attributes(): IChannelAttributes;
84
+ /**
85
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
86
+ */
87
+ load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<IConsensusRegisterCollection>;
88
+ create(document: IFluidDataStoreRuntime, id: string): IConsensusRegisterCollection;
89
+ }
90
+
91
+ /**
92
+ * A distributed data structure that holds a set of registers with update
93
+ * versions. On concurrent updates, a register internally stores all possible versions of a value by using reference
94
+ * sequence number of the incoming update.
95
+ *
96
+ * Using all the stored versions, we can then distinguish amongst different read policies. Below are the policies
97
+ * we support:
98
+ *
99
+ * Atomic: Atomicity requires a linearizable register. A linearizable register behaves as if there is only a single
100
+ * copy of the data, and that every operation appears to take effect atomically at one point in time. This definition
101
+ * implies that operations are executed in an well-defined order. On a concurrent update, we perform a compare-and-set
102
+ * operation, where we compare a register sequence number with the incoming reference sequence number.
103
+ * The earliest operation overwriting prior sequence numbers wins since every client reaches to an agreement on
104
+ * the value. So we can safely return the first value.
105
+ *
106
+ * LWW: The last write to a key always wins.
107
+ * @alpha
108
+ */
109
+ export declare interface IConsensusRegisterCollection<T = any> extends ISharedObject<IConsensusRegisterCollectionEvents> {
110
+ /**
111
+ * Attempts to write a register with a value. Returns a promise to indicate the roundtrip completion.
112
+ * For a non existent register, it will attempt to create a new register with the specified value.
113
+ *
114
+ * @returns Promise<true> if write was non-concurrent
115
+ */
116
+ write(key: string, value: T): Promise<boolean>;
117
+ /**
118
+ * Retrieves the agreed upon value for the register based on policy. Returns undefined if not present.
119
+ */
120
+ read(key: string, policy?: ReadPolicy): T | undefined;
121
+ /**
122
+ * Retrives all concurrent versions. Undefined if not present.
123
+ */
124
+ readVersions(key: string): T[] | undefined;
125
+ /**
126
+ * Returns the keys.
127
+ */
128
+ keys(): string[];
129
+ }
130
+
131
+ /**
132
+ * Events emitted by {@link IConsensusRegisterCollection}.
133
+ * @alpha
134
+ */
135
+ export declare interface IConsensusRegisterCollectionEvents extends ISharedObjectEvents {
136
+ (event: "atomicChanged" | "versionChanged", listener: (key: string, value: any, local: boolean) => void): any;
137
+ }
138
+
139
+ /**
140
+ * Consensus Register Collection channel factory interface
141
+ *
142
+ * Extends the base IChannelFactory to return a more definite type of IConsensusRegisterCollection
143
+ * Use for the runtime to create and load distributed data structure by type name of each channel.
144
+ * @alpha
145
+ */
146
+ export declare interface IConsensusRegisterCollectionFactory extends IChannelFactory {
147
+ /**
148
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
149
+ */
150
+ load(document: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<IConsensusRegisterCollection>;
151
+ create(document: IFluidDataStoreRuntime, id: string): IConsensusRegisterCollection;
152
+ }
153
+
154
+ /**
155
+ * Read policies used when reading the map value.
156
+ * @alpha
157
+ */
158
+ export declare enum ReadPolicy {
159
+ Atomic = 0,
160
+ LWW = 1
161
+ }
162
+
163
+ export { }
@@ -0,0 +1,25 @@
1
+ import { IChannelAttributes } from '@fluidframework/datastore-definitions';
2
+ import { IChannelFactory } from '@fluidframework/datastore-definitions';
3
+ import { IChannelServices } from '@fluidframework/datastore-definitions';
4
+ import { IChannelStorageService } from '@fluidframework/datastore-definitions';
5
+ import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
6
+ import { IFluidSerializer } from '@fluidframework/shared-object-base';
7
+ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
8
+ import { ISharedObject } from '@fluidframework/shared-object-base';
9
+ import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
10
+ import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
11
+ import { SharedObject } from '@fluidframework/shared-object-base';
12
+
13
+ /* Excluded from this release type: ConsensusRegisterCollection */
14
+
15
+ /* Excluded from this release type: ConsensusRegisterCollectionFactory */
16
+
17
+ /* Excluded from this release type: IConsensusRegisterCollection */
18
+
19
+ /* Excluded from this release type: IConsensusRegisterCollectionEvents */
20
+
21
+ /* Excluded from this release type: IConsensusRegisterCollectionFactory */
22
+
23
+ /* Excluded from this release type: ReadPolicy */
24
+
25
+ export { }
@@ -0,0 +1,25 @@
1
+ import { IChannelAttributes } from '@fluidframework/datastore-definitions';
2
+ import { IChannelFactory } from '@fluidframework/datastore-definitions';
3
+ import { IChannelServices } from '@fluidframework/datastore-definitions';
4
+ import { IChannelStorageService } from '@fluidframework/datastore-definitions';
5
+ import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
6
+ import { IFluidSerializer } from '@fluidframework/shared-object-base';
7
+ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
8
+ import { ISharedObject } from '@fluidframework/shared-object-base';
9
+ import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
10
+ import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
11
+ import { SharedObject } from '@fluidframework/shared-object-base';
12
+
13
+ /* Excluded from this release type: ConsensusRegisterCollection */
14
+
15
+ /* Excluded from this release type: ConsensusRegisterCollectionFactory */
16
+
17
+ /* Excluded from this release type: IConsensusRegisterCollection */
18
+
19
+ /* Excluded from this release type: IConsensusRegisterCollectionEvents */
20
+
21
+ /* Excluded from this release type: IConsensusRegisterCollectionFactory */
22
+
23
+ /* Excluded from this release type: ReadPolicy */
24
+
25
+ export { }
@@ -0,0 +1,163 @@
1
+ import { IChannelAttributes } from '@fluidframework/datastore-definitions';
2
+ import { IChannelFactory } from '@fluidframework/datastore-definitions';
3
+ import { IChannelServices } from '@fluidframework/datastore-definitions';
4
+ import { IChannelStorageService } from '@fluidframework/datastore-definitions';
5
+ import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
6
+ import { IFluidSerializer } from '@fluidframework/shared-object-base';
7
+ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
8
+ import { ISharedObject } from '@fluidframework/shared-object-base';
9
+ import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
10
+ import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
11
+ import { SharedObject } from '@fluidframework/shared-object-base';
12
+
13
+ /**
14
+ * {@inheritDoc IConsensusRegisterCollection}
15
+ * @alpha
16
+ */
17
+ export declare class ConsensusRegisterCollection<T> extends SharedObject<IConsensusRegisterCollectionEvents> implements IConsensusRegisterCollection<T> {
18
+ /**
19
+ * Create a new consensus register collection
20
+ *
21
+ * @param runtime - data store runtime the new consensus register collection belongs to
22
+ * @param id - optional name of the consensus register collection
23
+ * @returns newly create consensus register collection (but not attached yet)
24
+ */
25
+ static create<T>(runtime: IFluidDataStoreRuntime, id?: string): ConsensusRegisterCollection<T>;
26
+ /**
27
+ * Get a factory for ConsensusRegisterCollection to register with the data store.
28
+ *
29
+ * @returns a factory that creates and load ConsensusRegisterCollection
30
+ */
31
+ static getFactory(): ConsensusRegisterCollectionFactory;
32
+ private readonly data;
33
+ /**
34
+ * Constructs a new consensus register collection. If the object is non-local an id and service interfaces will
35
+ * be provided
36
+ */
37
+ constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
38
+ /**
39
+ * Creates a new register or writes a new value.
40
+ * Returns a promise that will resolve when the write is acked.
41
+ *
42
+ * @returns Promise<true> if write was non-concurrent
43
+ */
44
+ write(key: string, value: T): Promise<boolean>;
45
+ /**
46
+ * Returns the most recent local value of a register.
47
+ * @param key - The key to read
48
+ * @param readPolicy - The ReadPolicy to apply. Defaults to Atomic.
49
+ */
50
+ read(key: string, readPolicy?: ReadPolicy): T | undefined;
51
+ readVersions(key: string): T[] | undefined;
52
+ keys(): string[];
53
+ protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
54
+ /**
55
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
56
+ */
57
+ protected loadCore(storage: IChannelStorageService): Promise<void>;
58
+ protected onDisconnect(): void;
59
+ protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
60
+ private readAtomic;
61
+ /**
62
+ * Process an inbound write op
63
+ * @param key - Key that was written to
64
+ * @param value - Incoming value
65
+ * @param refSeq - RefSeq at the time of write on the remote client
66
+ * @param sequenceNumber - Sequence Number of this write op
67
+ * @param local - Did this write originate on this client
68
+ */
69
+ private processInboundWrite;
70
+ private stringify;
71
+ private parse;
72
+ protected applyStashedOp(): () => void;
73
+ }
74
+
75
+ /**
76
+ * The factory that defines the consensus queue.
77
+ * @alpha
78
+ */
79
+ export declare class ConsensusRegisterCollectionFactory implements IConsensusRegisterCollectionFactory {
80
+ static Type: string;
81
+ static readonly Attributes: IChannelAttributes;
82
+ get type(): string;
83
+ get attributes(): IChannelAttributes;
84
+ /**
85
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
86
+ */
87
+ load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<IConsensusRegisterCollection>;
88
+ create(document: IFluidDataStoreRuntime, id: string): IConsensusRegisterCollection;
89
+ }
90
+
91
+ /**
92
+ * A distributed data structure that holds a set of registers with update
93
+ * versions. On concurrent updates, a register internally stores all possible versions of a value by using reference
94
+ * sequence number of the incoming update.
95
+ *
96
+ * Using all the stored versions, we can then distinguish amongst different read policies. Below are the policies
97
+ * we support:
98
+ *
99
+ * Atomic: Atomicity requires a linearizable register. A linearizable register behaves as if there is only a single
100
+ * copy of the data, and that every operation appears to take effect atomically at one point in time. This definition
101
+ * implies that operations are executed in an well-defined order. On a concurrent update, we perform a compare-and-set
102
+ * operation, where we compare a register sequence number with the incoming reference sequence number.
103
+ * The earliest operation overwriting prior sequence numbers wins since every client reaches to an agreement on
104
+ * the value. So we can safely return the first value.
105
+ *
106
+ * LWW: The last write to a key always wins.
107
+ * @alpha
108
+ */
109
+ export declare interface IConsensusRegisterCollection<T = any> extends ISharedObject<IConsensusRegisterCollectionEvents> {
110
+ /**
111
+ * Attempts to write a register with a value. Returns a promise to indicate the roundtrip completion.
112
+ * For a non existent register, it will attempt to create a new register with the specified value.
113
+ *
114
+ * @returns Promise<true> if write was non-concurrent
115
+ */
116
+ write(key: string, value: T): Promise<boolean>;
117
+ /**
118
+ * Retrieves the agreed upon value for the register based on policy. Returns undefined if not present.
119
+ */
120
+ read(key: string, policy?: ReadPolicy): T | undefined;
121
+ /**
122
+ * Retrives all concurrent versions. Undefined if not present.
123
+ */
124
+ readVersions(key: string): T[] | undefined;
125
+ /**
126
+ * Returns the keys.
127
+ */
128
+ keys(): string[];
129
+ }
130
+
131
+ /**
132
+ * Events emitted by {@link IConsensusRegisterCollection}.
133
+ * @alpha
134
+ */
135
+ export declare interface IConsensusRegisterCollectionEvents extends ISharedObjectEvents {
136
+ (event: "atomicChanged" | "versionChanged", listener: (key: string, value: any, local: boolean) => void): any;
137
+ }
138
+
139
+ /**
140
+ * Consensus Register Collection channel factory interface
141
+ *
142
+ * Extends the base IChannelFactory to return a more definite type of IConsensusRegisterCollection
143
+ * Use for the runtime to create and load distributed data structure by type name of each channel.
144
+ * @alpha
145
+ */
146
+ export declare interface IConsensusRegisterCollectionFactory extends IChannelFactory {
147
+ /**
148
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
149
+ */
150
+ load(document: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<IConsensusRegisterCollection>;
151
+ create(document: IFluidDataStoreRuntime, id: string): IConsensusRegisterCollection;
152
+ }
153
+
154
+ /**
155
+ * Read policies used when reading the map value.
156
+ * @alpha
157
+ */
158
+ export declare enum ReadPolicy {
159
+ Atomic = 0,
160
+ LWW = 1
161
+ }
162
+
163
+ export { }
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.38.3"
9
+ }
10
+ ]
11
+ }
@@ -6,10 +6,11 @@ import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions"
6
6
  import { IChannelAttributes, IFluidDataStoreRuntime, IChannelStorageService } from "@fluidframework/datastore-definitions";
7
7
  import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
8
8
  import { IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
9
- import { ConsensusRegisterCollectionFactory } from "./consensusRegisterCollectionFactory";
10
- import { IConsensusRegisterCollection, ReadPolicy, IConsensusRegisterCollectionEvents } from "./interfaces";
9
+ import { ConsensusRegisterCollectionFactory } from "./consensusRegisterCollectionFactory.mjs";
10
+ import { IConsensusRegisterCollection, ReadPolicy, IConsensusRegisterCollectionEvents } from "./interfaces.mjs";
11
11
  /**
12
- * Implementation of a consensus register collection
12
+ * {@inheritDoc IConsensusRegisterCollection}
13
+ * @alpha
13
14
  */
14
15
  export declare class ConsensusRegisterCollection<T> extends SharedObject<IConsensusRegisterCollectionEvents> implements IConsensusRegisterCollection<T> {
15
16
  /**
@@ -68,4 +69,4 @@ export declare class ConsensusRegisterCollection<T> extends SharedObject<IConsen
68
69
  private parse;
69
70
  protected applyStashedOp(): () => void;
70
71
  }
71
- //# sourceMappingURL=consensusRegisterCollection.d.ts.map
72
+ //# sourceMappingURL=consensusRegisterCollection.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consensusRegisterCollection.d.mts","sourceRoot":"","sources":["../src/consensusRegisterCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAII,EAAE,yBAAyB,EAAe,MAAM,sCAAsC;OACtF,EACN,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,uCAAuC;OACvC,EAAE,qBAAqB,EAAE,MAAM,qCAAqC;OACpE,EAEN,gBAAgB,EAChB,YAAY,EACZ,M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