@fluidframework/ordered-collection 2.0.0-rc.1.0.6 → 2.0.0-rc.2.0.1

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 (100) hide show
  1. package/{.eslintrc.js → .eslintrc.cjs} +4 -1
  2. package/{.mocharc.js → .mocharc.cjs} +1 -1
  3. package/CHANGELOG.md +4 -0
  4. package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
  5. package/api-extractor.json +1 -1
  6. package/api-report/ordered-collection.api.md +15 -1
  7. package/dist/consensusOrderedCollection.d.ts +1 -1
  8. package/dist/consensusOrderedCollection.d.ts.map +1 -1
  9. package/dist/consensusOrderedCollection.js +11 -5
  10. package/dist/consensusOrderedCollection.js.map +1 -1
  11. package/dist/consensusOrderedCollectionFactory.d.ts +3 -1
  12. package/dist/consensusOrderedCollectionFactory.d.ts.map +1 -1
  13. package/dist/consensusOrderedCollectionFactory.js +7 -5
  14. package/dist/consensusOrderedCollectionFactory.js.map +1 -1
  15. package/dist/consensusQueue.d.ts +1 -1
  16. package/dist/consensusQueue.d.ts.map +1 -1
  17. package/dist/consensusQueue.js +7 -7
  18. package/dist/consensusQueue.js.map +1 -1
  19. package/dist/index.d.ts +5 -4
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +12 -10
  22. package/dist/index.js.map +1 -1
  23. package/dist/ordered-collection-alpha.d.ts +2 -0
  24. package/dist/ordered-collection-beta.d.ts +4 -0
  25. package/dist/ordered-collection-public.d.ts +4 -0
  26. package/dist/ordered-collection-untrimmed.d.ts +17 -0
  27. package/dist/package.json +3 -0
  28. package/dist/packageVersion.d.ts +1 -1
  29. package/dist/packageVersion.js +1 -1
  30. package/dist/packageVersion.js.map +1 -1
  31. package/dist/testUtils.d.ts +1 -1
  32. package/dist/testUtils.d.ts.map +1 -1
  33. package/dist/testUtils.js +3 -3
  34. package/dist/testUtils.js.map +1 -1
  35. package/dist/tsdoc-metadata.json +1 -1
  36. package/lib/{consensusOrderedCollection.d.mts → consensusOrderedCollection.d.ts} +2 -2
  37. package/lib/consensusOrderedCollection.d.ts.map +1 -0
  38. package/lib/{consensusOrderedCollection.mjs → consensusOrderedCollection.js} +10 -4
  39. package/lib/consensusOrderedCollection.js.map +1 -0
  40. package/lib/{consensusOrderedCollectionFactory.d.mts → consensusOrderedCollectionFactory.d.ts} +4 -2
  41. package/lib/consensusOrderedCollectionFactory.d.ts.map +1 -0
  42. package/lib/{consensusOrderedCollectionFactory.mjs → consensusOrderedCollectionFactory.js} +5 -3
  43. package/lib/consensusOrderedCollectionFactory.js.map +1 -0
  44. package/lib/{consensusQueue.d.mts → consensusQueue.d.ts} +2 -2
  45. package/lib/consensusQueue.d.ts.map +1 -0
  46. package/lib/{consensusQueue.mjs → consensusQueue.js} +4 -4
  47. package/lib/consensusQueue.js.map +1 -0
  48. package/lib/{index.d.mts → index.d.ts} +6 -5
  49. package/lib/index.d.ts.map +1 -0
  50. package/lib/{index.mjs → index.js} +6 -5
  51. package/lib/index.js.map +1 -0
  52. package/lib/{interfaces.d.mts → interfaces.d.ts} +1 -1
  53. package/lib/interfaces.d.ts.map +1 -0
  54. package/lib/{interfaces.mjs → interfaces.js} +1 -1
  55. package/lib/interfaces.js.map +1 -0
  56. package/lib/{ordered-collection-alpha.d.mts → ordered-collection-alpha.d.ts} +2 -0
  57. package/lib/{ordered-collection-beta.d.mts → ordered-collection-beta.d.ts} +4 -0
  58. package/lib/{ordered-collection-public.d.mts → ordered-collection-public.d.ts} +4 -0
  59. package/lib/{ordered-collection-untrimmed.d.mts → ordered-collection-untrimmed.d.ts} +17 -0
  60. package/lib/{packageVersion.d.mts → packageVersion.d.ts} +2 -2
  61. package/lib/packageVersion.d.ts.map +1 -0
  62. package/lib/{packageVersion.mjs → packageVersion.js} +2 -2
  63. package/lib/packageVersion.js.map +1 -0
  64. package/lib/{snapshotableArray.d.mts → snapshotableArray.d.ts} +1 -1
  65. package/lib/snapshotableArray.d.ts.map +1 -0
  66. package/lib/{snapshotableArray.mjs → snapshotableArray.js} +1 -1
  67. package/lib/snapshotableArray.js.map +1 -0
  68. package/lib/test/consensusOrderedCollection.spec.js +314 -0
  69. package/lib/test/consensusOrderedCollection.spec.js.map +1 -0
  70. package/lib/test/types/validateOrderedCollectionPrevious.generated.js +24 -0
  71. package/lib/test/types/validateOrderedCollectionPrevious.generated.js.map +1 -0
  72. package/lib/{testUtils.d.mts → testUtils.d.ts} +2 -2
  73. package/lib/testUtils.d.ts.map +1 -0
  74. package/lib/{testUtils.mjs → testUtils.js} +2 -2
  75. package/lib/testUtils.js.map +1 -0
  76. package/package.json +42 -47
  77. package/src/consensusOrderedCollection.ts +16 -10
  78. package/src/consensusOrderedCollectionFactory.ts +5 -3
  79. package/src/consensusQueue.ts +4 -4
  80. package/src/index.ts +5 -4
  81. package/src/packageVersion.ts +1 -1
  82. package/src/testUtils.ts +1 -1
  83. package/tsconfig.cjs.json +7 -0
  84. package/tsconfig.json +2 -5
  85. package/lib/consensusOrderedCollection.d.mts.map +0 -1
  86. package/lib/consensusOrderedCollection.mjs.map +0 -1
  87. package/lib/consensusOrderedCollectionFactory.d.mts.map +0 -1
  88. package/lib/consensusOrderedCollectionFactory.mjs.map +0 -1
  89. package/lib/consensusQueue.d.mts.map +0 -1
  90. package/lib/consensusQueue.mjs.map +0 -1
  91. package/lib/index.d.mts.map +0 -1
  92. package/lib/index.mjs.map +0 -1
  93. package/lib/interfaces.d.mts.map +0 -1
  94. package/lib/interfaces.mjs.map +0 -1
  95. package/lib/packageVersion.d.mts.map +0 -1
  96. package/lib/packageVersion.mjs.map +0 -1
  97. package/lib/snapshotableArray.d.mts.map +0 -1
  98. package/lib/snapshotableArray.mjs.map +0 -1
  99. package/lib/testUtils.d.mts.map +0 -1
  100. package/lib/testUtils.mjs.map +0 -1
@@ -4,7 +4,10 @@
4
4
  */
5
5
 
6
6
  module.exports = {
7
- extends: [require.resolve("@fluidframework/eslint-config-fluid/minimal"), "prettier"],
7
+ extends: [
8
+ require.resolve("@fluidframework/eslint-config-fluid/minimal-deprecated"),
9
+ "prettier",
10
+ ],
8
11
  parserOptions: {
9
12
  project: ["./tsconfig.json", "./src/test/tsconfig.json"],
10
13
  },
@@ -5,7 +5,7 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const getFluidTestMochaConfig = require("@fluidframework/mocha-test-setup/mocharc-common");
8
+ const getFluidTestMochaConfig = require("@fluid-internal/mocha-test-setup/mocharc-common");
9
9
 
10
10
  const packageDir = __dirname;
11
11
  const config = getFluidTestMochaConfig(packageDir);
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @fluidframework/ordered-collection
2
2
 
3
+ ## 2.0.0-rc.2.0.0
4
+
5
+ Dependency updates only.
6
+
3
7
  ## 2.0.0-rc.1.0.0
4
8
 
5
9
  ### Minor Changes
@@ -1,4 +1,8 @@
1
1
  {
2
2
  "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
- "extends": "../../../common/build/build-common/api-extractor-base-esm.json"
3
+ "extends": "../../../common/build/build-common/api-extractor-base.cjs.primary.json",
4
+ // CJS is actually secondary; so, no report.
5
+ "apiReport": {
6
+ "enabled": false
7
+ }
4
8
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
- "extends": "../../../common/build/build-common/api-extractor-base.json"
3
+ "extends": "../../../common/build/build-common/api-extractor-base.esm.primary.json"
4
4
  }
@@ -35,7 +35,6 @@ export class ConsensusOrderedCollection<T = any> extends SharedObject<IConsensus
35
35
  protected completeCore(acquireId: string): void;
36
36
  // (undocumented)
37
37
  protected isActive(): boolean;
38
- // (undocumented)
39
38
  protected loadCore(storage: IChannelStorageService): Promise<void>;
40
39
  // (undocumented)
41
40
  protected onDisconnect(): void;
@@ -57,6 +56,21 @@ export class ConsensusQueue<T = any> extends ConsensusOrderedCollection<T> {
57
56
  static getFactory(): IChannelFactory;
58
57
  }
59
58
 
59
+ // @internal
60
+ export class ConsensusQueueFactory implements IConsensusOrderedCollectionFactory {
61
+ // (undocumented)
62
+ static readonly Attributes: IChannelAttributes;
63
+ // (undocumented)
64
+ get attributes(): IChannelAttributes;
65
+ // (undocumented)
66
+ create(document: IFluidDataStoreRuntime, id: string): IConsensusOrderedCollection;
67
+ load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<IConsensusOrderedCollection>;
68
+ // (undocumented)
69
+ static Type: string;
70
+ // (undocumented)
71
+ get type(): string;
72
+ }
73
+
60
74
  // @alpha (undocumented)
61
75
  export enum ConsensusResult {
62
76
  // (undocumented)
@@ -6,7 +6,7 @@ import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions"
6
6
  import { IChannelAttributes, IFluidDataStoreRuntime, IChannelStorageService } from "@fluidframework/datastore-definitions";
7
7
  import { IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
8
8
  import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
9
- import { ConsensusCallback, IConsensusOrderedCollection, IOrderedCollection, IConsensusOrderedCollectionEvents } from "./interfaces";
9
+ import { ConsensusCallback, IConsensusOrderedCollection, IOrderedCollection, IConsensusOrderedCollectionEvents } from "./interfaces.js";
10
10
  /**
11
11
  * Implementation of a consensus collection shared object
12
12
  *
@@ -1 +1 @@
1
- {"version":3,"file":"consensusOrderedCollection.d.ts","sourceRoot":"","sources":["../src/consensusOrderedCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAG5E,OAAO,EACN,i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AAc,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAW1E,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,qBAAqB;IAa5E,SAAS,CAAC,QAAQ;cAIF,QAAQ,CAAC,SAAS,EAAE,MAAM;IAe1C,SAAS,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM;IASxC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM;IAiBnC,SAAS,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM;IAUvC;;OAEG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBxE,SAAS,CAAC,YAAY;IAQtB,SAAS,CAAC,WAAW,CACpB,OAAO,EAAE,yBAAyB,EAClC,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO;YAqCX,MAAM;IAepB,OAAO,CAAC,OAAO;IAKf,OAAO,CAAC,WAAW;YAmBL,eAAe;IAY7B,OAAO,CAAC,YAAY;IAepB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,gBAAgB;IAKxB,SAAS,CAAC,cAAc,IAAI,IAAI;CAGhC"}
@@ -11,7 +11,7 @@ const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
11
11
  const shared_object_base_1 = require("@fluidframework/shared-object-base");
12
12
  const runtime_utils_1 = require("@fluidframework/runtime-utils");
13
13
  const uuid_1 = require("uuid");
14
- const interfaces_1 = require("./interfaces");
14
+ const interfaces_js_1 = require("./interfaces.js");
15
15
  const snapshotFileNameData = "header";
16
16
  const snapshotFileNameTracking = "jobTracking";
17
17
  const idForLocalUnattachedClient = undefined;
@@ -61,6 +61,7 @@ class ConsensusOrderedCollection extends shared_object_base_1.SharedObject {
61
61
  await this.submit({
62
62
  opName: "add",
63
63
  value: valueSer,
64
+ deserializedValue: value,
64
65
  });
65
66
  }
66
67
  /**
@@ -74,10 +75,10 @@ class ConsensusOrderedCollection extends shared_object_base_1.SharedObject {
74
75
  }
75
76
  const res = await callback(result.value);
76
77
  switch (res) {
77
- case interfaces_1.ConsensusResult.Complete:
78
+ case interfaces_js_1.ConsensusResult.Complete:
78
79
  await this.complete(result.acquireId);
79
80
  break;
80
- case interfaces_1.ConsensusResult.Release:
81
+ case interfaces_js_1.ConsensusResult.Release:
81
82
  this.release(result.acquireId);
82
83
  this.emit("localRelease", result.value, true /* intentional */);
83
84
  break;
@@ -145,7 +146,7 @@ class ConsensusOrderedCollection extends shared_object_base_1.SharedObject {
145
146
  opName: "release",
146
147
  acquireId,
147
148
  }).catch((error) => {
148
- this.runtime.logger.sendErrorEvent({ eventName: "ConsensusQueue_release" }, error);
149
+ this.logger.sendErrorEvent({ eventName: "ConsensusQueue_release" }, error);
149
150
  });
150
151
  }
151
152
  }
@@ -186,7 +187,12 @@ class ConsensusOrderedCollection extends shared_object_base_1.SharedObject {
186
187
  let value;
187
188
  switch (op.opName) {
188
189
  case "add":
189
- this.addCore(this.deserializeValue(op.value, this.serializer));
190
+ if (op.deserializedValue !== undefined) {
191
+ this.addCore(op.deserializedValue);
192
+ }
193
+ else {
194
+ this.addCore(this.deserializeValue(op.value, this.serializer));
195
+ }
190
196
  break;
191
197
  case "acquire":
192
198
  value = this.acquireCore(op.acquireId, message.clientId ?? undefined);
@@ -1 +1 @@
1
- {"version":3,"file":"consensusOrderedCollection.js","sourceRoot":"","sources":["../src/consensusOrderedCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAC9D,2DAAqE;AACrE,+EAA8F;AAM9F,2EAAoF;AAEpF,iEAAmE;AACnE,+BAAkC;AAClC,6CAMsB;AAEtB,MAAM,oBAAoB,GAAG,QAAQ,CAAC;AACtC,MAAM,wBAAwB,GAAG,aAAa,CAAC;AAwD/C,MAAM,0BAA0B,GAAG,SAAS,CAAC;AAE7C;;;;;;;;;GASG;AACH,MAAa,0BACZ,SAAQ,iCAAkD;IAQ1D;;;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CAAC;IACpC,CAAC;CACD;AAjTD,gEAiTC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions\";\nimport { IFluidSerializer, SharedObject } from \"@fluidframework/shared-object-base\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n\tConsensusCallback,\n\tConsensusResult,\n\tIConsensusOrderedCollection,\n\tIOrderedCollection,\n\tIConsensusOrderedCollectionEvents,\n} from \"./interfaces\";\n\nconst snapshotFileNameData = \"header\";\nconst snapshotFileNameTracking = \"jobTracking\";\n\ninterface IConsensusOrderedCollectionValue<T> {\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\treadonly acquireId: string;\n\n\t// The actual value\n\treadonly value: T;\n}\n\n/**\n * An operation for consensus ordered collection\n */\ninterface IConsensusOrderedCollectionAddOperation {\n\topName: \"add\";\n\t// serialized value\n\tvalue: string;\n}\n\ninterface IConsensusOrderedCollectionAcquireOperation {\n\topName: \"acquire\";\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\tacquireId: string;\n}\n\ninterface IConsensusOrderedCollectionCompleteOperation {\n\topName: \"complete\";\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\tacquireId: string;\n}\n\ninterface IConsensusOrderedCollectionReleaseOperation {\n\topName: \"release\";\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\tacquireId: string;\n}\n\ntype IConsensusOrderedCollectionOperation =\n\t| IConsensusOrderedCollectionAddOperation\n\t| IConsensusOrderedCollectionAcquireOperation\n\t| IConsensusOrderedCollectionCompleteOperation\n\t| IConsensusOrderedCollectionReleaseOperation;\n\n/** The type of the resolve function to call after the local operation is ack'd */\ntype PendingResolve<T> = (value: IConsensusOrderedCollectionValue<T> | undefined) => void;\n\n/**\n * For job tracking, we need to keep track of which client \"owns\" a given value.\n * Key is the acquireId from when it was acquired\n * Value is the acquired value, and the id of the client who acquired it, or undefined for unattached client\n */\ntype JobTrackingInfo<T> = Map<string, { value: T; clientId: string | undefined }>;\nconst idForLocalUnattachedClient = undefined;\n\n/**\n * Implementation of a consensus collection shared object\n *\n * Implements the shared object's communication, and the semantics around the\n * release/complete mechanism following acquire.\n *\n * Generally not used directly. A derived type will pass in a backing data type\n * IOrderedCollection that will define the deterministic add/acquire order and snapshot ability.\n * @alpha\n */\nexport class ConsensusOrderedCollection<T = any>\n\textends SharedObject<IConsensusOrderedCollectionEvents<T>>\n\timplements IConsensusOrderedCollection<T>\n{\n\t/**\n\t * The set of values that have been acquired but not yet completed or released\n\t */\n\tprivate jobTracking: JobTrackingInfo<T> = new Map();\n\n\t/**\n\t * Constructs a new consensus collection. If the object is non-local an id and service interfaces will\n\t * be provided\n\t */\n\tprotected constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\tprivate readonly data: IOrderedCollection<T>,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_consensusOrderedCollection_\");\n\n\t\t// We can't simply call this.removeClient(this.runtime.clientId) in on runtime disconnected,\n\t\t// because other clients may disconnect concurrently.\n\t\t// Disconnect order matters because it defines the order items go back to the queue.\n\t\t// So we put items back to queue only when we process our own removeMember event.\n\t\truntime.getQuorum().on(\"removeMember\", (clientId: string) => {\n\t\t\tassert(!!clientId, 0x067 /* \"Missing clientId for removal!\" */);\n\t\t\tthis.removeClient(clientId);\n\t\t});\n\t}\n\n\t/**\n\t * Add a value to the consensus collection.\n\t */\n\tpublic async add(value: T): Promise<void> {\n\t\tconst valueSer = this.serializeValue(value, this.serializer);\n\n\t\tif (!this.isAttached()) {\n\t\t\t// For the case where this is not attached yet, explicitly JSON\n\t\t\t// clone the value to match the behavior of going thru the wire.\n\t\t\tconst addValue = this.deserializeValue(valueSer, this.serializer) as T;\n\t\t\tthis.addCore(addValue);\n\t\t\treturn;\n\t\t}\n\n\t\tawait this.submit<IConsensusOrderedCollectionAddOperation>({\n\t\t\topName: \"add\",\n\t\t\tvalue: valueSer,\n\t\t});\n\t}\n\n\t/**\n\t * Remove a value from the consensus collection. If the collection is empty, returns false.\n\t * Otherwise calls callback with the value\n\t */\n\tpublic async acquire(callback: ConsensusCallback<T>): Promise<boolean> {\n\t\tconst result = await this.acquireInternal();\n\t\tif (result === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst res = await callback(result.value);\n\n\t\tswitch (res) {\n\t\t\tcase ConsensusResult.Complete:\n\t\t\t\tawait this.complete(result.acquireId);\n\t\t\t\tbreak;\n\t\t\tcase ConsensusResult.Release:\n\t\t\t\tthis.release(result.acquireId);\n\t\t\t\tthis.emit(\"localRelease\", result.value, true /* intentional */);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tunreachableCase(res);\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Wait for a value to be available and acquire it from the consensus collection\n\t */\n\tpublic async waitAndAcquire(callback: ConsensusCallback<T>): Promise<void> {\n\t\tdo {\n\t\t\tif (this.data.size() === 0) {\n\t\t\t\t// Wait for new entry before trying to acquire again\n\t\t\t\tawait this.newAckBasedPromise<T>((resolve) => {\n\t\t\t\t\tthis.once(\"add\", resolve);\n\t\t\t\t});\n\t\t\t}\n\t\t} while (!(await this.acquire(callback)));\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\t// If we are transitioning from unattached to attached mode,\n\t\t// then we are losing all checked out work!\n\t\tthis.removeClient(idForLocalUnattachedClient);\n\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tlet blobContent = this.serializeValue(this.data.asArray(), serializer);\n\t\tbuilder.addBlob(snapshotFileNameData, blobContent);\n\t\tblobContent = this.serializeValue(Array.from(this.jobTracking.entries()), serializer);\n\t\tbuilder.addBlob(snapshotFileNameTracking, blobContent);\n\t\treturn builder.getSummaryTree();\n\t}\n\n\tprotected isActive() {\n\t\treturn this.runtime.connected && this.runtime.deltaManager.active;\n\t}\n\n\tprotected async complete(acquireId: string) {\n\t\tif (!this.isAttached()) {\n\t\t\tthis.completeCore(acquireId);\n\t\t\treturn;\n\t\t}\n\n\t\t// if not active, this item already was released to queue (as observed by other clients)\n\t\tif (this.isActive()) {\n\t\t\tawait this.submit<IConsensusOrderedCollectionCompleteOperation>({\n\t\t\t\topName: \"complete\",\n\t\t\t\tacquireId,\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected completeCore(acquireId: string) {\n\t\t// Note: item may be no longer in jobTracking and returned back to queue!\n\t\tconst rec = this.jobTracking.get(acquireId);\n\t\tif (rec !== undefined) {\n\t\t\tthis.jobTracking.delete(acquireId);\n\t\t\tthis.emit(\"complete\", rec.value);\n\t\t}\n\t}\n\n\tprotected release(acquireId: string) {\n\t\tif (!this.isAttached()) {\n\t\t\tthis.releaseCore(acquireId);\n\t\t\treturn;\n\t\t}\n\n\t\t// if not active, this item already was released to queue (as observed by other clients)\n\t\tif (this.isActive()) {\n\t\t\tthis.submit<IConsensusOrderedCollectionReleaseOperation>({\n\t\t\t\topName: \"release\",\n\t\t\t\tacquireId,\n\t\t\t}).catch((error) => {\n\t\t\t\tthis.runtime.logger.sendErrorEvent({ eventName: \"ConsensusQueue_release\" }, error);\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected releaseCore(acquireId: string) {\n\t\t// Note: item may be no longer in jobTracking and returned back to queue!\n\t\tconst rec = this.jobTracking.get(acquireId);\n\t\tif (rec !== undefined) {\n\t\t\tthis.jobTracking.delete(acquireId);\n\t\t\tthis.data.add(rec.value);\n\t\t\tthis.emit(\"add\", rec.value, false /* newlyAdded */);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tassert(\n\t\t\tthis.jobTracking.size === 0,\n\t\t\t0x068 /* \"On consensusOrderedCollection load, job tracking size > 0\" */,\n\t\t);\n\t\tconst blob = await storage.readBlob(snapshotFileNameTracking);\n\t\tconst rawContentTracking = bufferToString(blob, \"utf8\");\n\t\tconst content = this.deserializeValue(rawContentTracking, this.serializer);\n\t\tthis.jobTracking = new Map(content) as JobTrackingInfo<T>;\n\n\t\tassert(\n\t\t\tthis.data.size() === 0,\n\t\t\t0x069 /* \"On consensusOrderedCollection load, data size > 0\" */,\n\t\t);\n\t\tconst blob2 = await storage.readBlob(snapshotFileNameData);\n\t\tconst rawContentData = bufferToString(blob2, \"utf8\");\n\t\tconst content2 = this.deserializeValue(rawContentData, this.serializer) as T[];\n\t\tthis.data.loadFrom(content2);\n\t}\n\n\tprotected onDisconnect() {\n\t\tfor (const [, { value, clientId }] of this.jobTracking) {\n\t\t\tif (clientId === this.runtime.clientId) {\n\t\t\t\tthis.emit(\"localRelease\", value, false /* intentional */);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t) {\n\t\tif (message.type === MessageType.Operation) {\n\t\t\tconst op = message.contents as IConsensusOrderedCollectionOperation;\n\t\t\tlet value: IConsensusOrderedCollectionValue<T> | undefined;\n\t\t\tswitch (op.opName) {\n\t\t\t\tcase \"add\":\n\t\t\t\t\tthis.addCore(this.deserializeValue(op.value, this.serializer) as T);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"acquire\":\n\t\t\t\t\tvalue = this.acquireCore(op.acquireId, message.clientId ?? undefined);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"complete\":\n\t\t\t\t\tthis.completeCore(op.acquireId);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"release\":\n\t\t\t\t\tthis.releaseCore(op.acquireId);\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(op);\n\t\t\t}\n\t\t\tif (local) {\n\t\t\t\t// Resolve the pending promise for this operation now that we have received an ack for it.\n\t\t\t\tconst resolve = localOpMetadata as PendingResolve<T>;\n\t\t\t\tresolve(value);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async submit<TMessage extends IConsensusOrderedCollectionOperation>(\n\t\tmessage: TMessage,\n\t): Promise<IConsensusOrderedCollectionValue<T> | undefined> {\n\t\tassert(this.isAttached(), 0x06a /* \"Trying to submit message while detached!\" */);\n\n\t\treturn this.newAckBasedPromise<IConsensusOrderedCollectionValue<T> | undefined>(\n\t\t\t(resolve) => {\n\t\t\t\t// Send the resolve function as the localOpMetadata. This will be provided back to us when the\n\t\t\t\t// op is ack'd.\n\t\t\t\tthis.submitLocalMessage(message, resolve);\n\t\t\t\t// If we fail due to runtime being disposed, it's better to return undefined then unhandled exception.\n\t\t\t},\n\t\t).catch((error) => undefined);\n\t}\n\n\tprivate addCore(value: T) {\n\t\tthis.data.add(value);\n\t\tthis.emit(\"add\", value, true /* newlyAdded */);\n\t}\n\n\tprivate acquireCore(\n\t\tacquireId: string,\n\t\tclientId?: string,\n\t): IConsensusOrderedCollectionValue<T> | undefined {\n\t\tif (this.data.size() === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst value = this.data.remove();\n\n\t\tconst value2: IConsensusOrderedCollectionValue<T> = {\n\t\t\tacquireId,\n\t\t\tvalue,\n\t\t};\n\t\tthis.jobTracking.set(value2.acquireId, { value, clientId });\n\n\t\tthis.emit(\"acquire\", value, clientId);\n\t\treturn value2;\n\t}\n\n\tprivate async acquireInternal(): Promise<IConsensusOrderedCollectionValue<T> | undefined> {\n\t\tif (!this.isAttached()) {\n\t\t\t// can be undefined if queue is empty\n\t\t\treturn this.acquireCore(uuid(), idForLocalUnattachedClient);\n\t\t}\n\n\t\treturn this.submit<IConsensusOrderedCollectionAcquireOperation>({\n\t\t\topName: \"acquire\",\n\t\t\tacquireId: uuid(),\n\t\t});\n\t}\n\n\tprivate removeClient(clientIdToRemove?: string) {\n\t\tconst added: T[] = [];\n\t\tfor (const [acquireId, { value, clientId }] of this.jobTracking) {\n\t\t\tif (clientId === clientIdToRemove) {\n\t\t\t\tthis.jobTracking.delete(acquireId);\n\t\t\t\tthis.data.add(value);\n\t\t\t\tadded.push(value);\n\t\t\t}\n\t\t}\n\n\t\t// Raise all events only after all state changes are completed,\n\t\t// to guarantee same ordering of operations if collection is manipulated from events.\n\t\tadded.map((value) => this.emit(\"add\", value, false /* newlyAdded */));\n\t}\n\n\tprivate serializeValue(value, serializer: IFluidSerializer) {\n\t\treturn serializer.stringify(value, this.handle);\n\t}\n\n\tprivate deserializeValue(content: string, serializer: IFluidSerializer) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn serializer.parse(content);\n\t}\n\n\tprotected applyStashedOp() {\n\t\tthrow new Error(\"not implemented\");\n\t}\n}\n"]}
1
+ {"version":3,"file":"consensusOrderedCollection.js","sourceRoot":"","sources":["../src/consensusOrderedCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAC9D,2DAAqE;AACrE,+EAA8F;AAM9F,2EAAoF;AAEpF,iEAAmE;AACnE,+BAAkC;AAClC,mDAMyB;AAEzB,MAAM,oBAAoB,GAAG,QAAQ,CAAC;AACtC,MAAM,wBAAwB,GAAG,aAAa,CAAC;AAyD/C,MAAM,0BAA0B,GAAG,SAAS,CAAC;AAE7C;;;;;;;;;GASG;AACH,MAAa,0BACZ,SAAQ,iCAAkD;IAQ1D;;;OAGG;IACH,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B,EACb,IAA2B;QAE5C,KAAK,CAAC,EAAE,EAAE,OA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;IAES,cAAc;QACvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD;AAtTD,gEAsTC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions\";\nimport { IFluidSerializer, SharedObject } from \"@fluidframework/shared-object-base\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n\tConsensusCallback,\n\tConsensusResult,\n\tIConsensusOrderedCollection,\n\tIOrderedCollection,\n\tIConsensusOrderedCollectionEvents,\n} from \"./interfaces.js\";\n\nconst snapshotFileNameData = \"header\";\nconst snapshotFileNameTracking = \"jobTracking\";\n\ninterface IConsensusOrderedCollectionValue<T> {\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\treadonly acquireId: string;\n\n\t// The actual value\n\treadonly value: T;\n}\n\n/**\n * An operation for consensus ordered collection\n */\ninterface IConsensusOrderedCollectionAddOperation<T> {\n\topName: \"add\";\n\t// serialized value\n\tvalue: string;\n\tdeserializedValue?: T;\n}\n\ninterface IConsensusOrderedCollectionAcquireOperation {\n\topName: \"acquire\";\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\tacquireId: string;\n}\n\ninterface IConsensusOrderedCollectionCompleteOperation {\n\topName: \"complete\";\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\tacquireId: string;\n}\n\ninterface IConsensusOrderedCollectionReleaseOperation {\n\topName: \"release\";\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\tacquireId: string;\n}\n\ntype IConsensusOrderedCollectionOperation<T> =\n\t| IConsensusOrderedCollectionAddOperation<T>\n\t| IConsensusOrderedCollectionAcquireOperation\n\t| IConsensusOrderedCollectionCompleteOperation\n\t| IConsensusOrderedCollectionReleaseOperation;\n\n/** The type of the resolve function to call after the local operation is ack'd */\ntype PendingResolve<T> = (value: IConsensusOrderedCollectionValue<T> | undefined) => void;\n\n/**\n * For job tracking, we need to keep track of which client \"owns\" a given value.\n * Key is the acquireId from when it was acquired\n * Value is the acquired value, and the id of the client who acquired it, or undefined for unattached client\n */\ntype JobTrackingInfo<T> = Map<string, { value: T; clientId: string | undefined }>;\nconst idForLocalUnattachedClient = undefined;\n\n/**\n * Implementation of a consensus collection shared object\n *\n * Implements the shared object's communication, and the semantics around the\n * release/complete mechanism following acquire.\n *\n * Generally not used directly. A derived type will pass in a backing data type\n * IOrderedCollection that will define the deterministic add/acquire order and snapshot ability.\n * @alpha\n */\nexport class ConsensusOrderedCollection<T = any>\n\textends SharedObject<IConsensusOrderedCollectionEvents<T>>\n\timplements IConsensusOrderedCollection<T>\n{\n\t/**\n\t * The set of values that have been acquired but not yet completed or released\n\t */\n\tprivate jobTracking: JobTrackingInfo<T> = new Map();\n\n\t/**\n\t * Constructs a new consensus collection. If the object is non-local an id and service interfaces will\n\t * be provided\n\t */\n\tprotected constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\tprivate readonly data: IOrderedCollection<T>,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_consensusOrderedCollection_\");\n\n\t\t// We can't simply call this.removeClient(this.runtime.clientId) in on runtime disconnected,\n\t\t// because other clients may disconnect concurrently.\n\t\t// Disconnect order matters because it defines the order items go back to the queue.\n\t\t// So we put items back to queue only when we process our own removeMember event.\n\t\truntime.getQuorum().on(\"removeMember\", (clientId: string) => {\n\t\t\tassert(!!clientId, 0x067 /* \"Missing clientId for removal!\" */);\n\t\t\tthis.removeClient(clientId);\n\t\t});\n\t}\n\n\t/**\n\t * Add a value to the consensus collection.\n\t */\n\tpublic async add(value: T): Promise<void> {\n\t\tconst valueSer = this.serializeValue(value, this.serializer);\n\n\t\tif (!this.isAttached()) {\n\t\t\t// For the case where this is not attached yet, explicitly JSON\n\t\t\t// clone the value to match the behavior of going thru the wire.\n\t\t\tconst addValue = this.deserializeValue(valueSer, this.serializer) as T;\n\t\t\tthis.addCore(addValue);\n\t\t\treturn;\n\t\t}\n\n\t\tawait this.submit<IConsensusOrderedCollectionAddOperation<T>>({\n\t\t\topName: \"add\",\n\t\t\tvalue: valueSer,\n\t\t\tdeserializedValue: value,\n\t\t});\n\t}\n\n\t/**\n\t * Remove a value from the consensus collection. If the collection is empty, returns false.\n\t * Otherwise calls callback with the value\n\t */\n\tpublic async acquire(callback: ConsensusCallback<T>): Promise<boolean> {\n\t\tconst result = await this.acquireInternal();\n\t\tif (result === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst res = await callback(result.value);\n\n\t\tswitch (res) {\n\t\t\tcase ConsensusResult.Complete:\n\t\t\t\tawait this.complete(result.acquireId);\n\t\t\t\tbreak;\n\t\t\tcase ConsensusResult.Release:\n\t\t\t\tthis.release(result.acquireId);\n\t\t\t\tthis.emit(\"localRelease\", result.value, true /* intentional */);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tunreachableCase(res);\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Wait for a value to be available and acquire it from the consensus collection\n\t */\n\tpublic async waitAndAcquire(callback: ConsensusCallback<T>): Promise<void> {\n\t\tdo {\n\t\t\tif (this.data.size() === 0) {\n\t\t\t\t// Wait for new entry before trying to acquire again\n\t\t\t\tawait this.newAckBasedPromise<T>((resolve) => {\n\t\t\t\t\tthis.once(\"add\", resolve);\n\t\t\t\t});\n\t\t\t}\n\t\t} while (!(await this.acquire(callback)));\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\t// If we are transitioning from unattached to attached mode,\n\t\t// then we are losing all checked out work!\n\t\tthis.removeClient(idForLocalUnattachedClient);\n\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tlet blobContent = this.serializeValue(this.data.asArray(), serializer);\n\t\tbuilder.addBlob(snapshotFileNameData, blobContent);\n\t\tblobContent = this.serializeValue(Array.from(this.jobTracking.entries()), serializer);\n\t\tbuilder.addBlob(snapshotFileNameTracking, blobContent);\n\t\treturn builder.getSummaryTree();\n\t}\n\n\tprotected isActive() {\n\t\treturn this.runtime.connected && this.runtime.deltaManager.active;\n\t}\n\n\tprotected async complete(acquireId: string) {\n\t\tif (!this.isAttached()) {\n\t\t\tthis.completeCore(acquireId);\n\t\t\treturn;\n\t\t}\n\n\t\t// if not active, this item already was released to queue (as observed by other clients)\n\t\tif (this.isActive()) {\n\t\t\tawait this.submit<IConsensusOrderedCollectionCompleteOperation>({\n\t\t\t\topName: \"complete\",\n\t\t\t\tacquireId,\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected completeCore(acquireId: string) {\n\t\t// Note: item may be no longer in jobTracking and returned back to queue!\n\t\tconst rec = this.jobTracking.get(acquireId);\n\t\tif (rec !== undefined) {\n\t\t\tthis.jobTracking.delete(acquireId);\n\t\t\tthis.emit(\"complete\", rec.value);\n\t\t}\n\t}\n\n\tprotected release(acquireId: string) {\n\t\tif (!this.isAttached()) {\n\t\t\tthis.releaseCore(acquireId);\n\t\t\treturn;\n\t\t}\n\n\t\t// if not active, this item already was released to queue (as observed by other clients)\n\t\tif (this.isActive()) {\n\t\t\tthis.submit<IConsensusOrderedCollectionReleaseOperation>({\n\t\t\t\topName: \"release\",\n\t\t\t\tacquireId,\n\t\t\t}).catch((error) => {\n\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"ConsensusQueue_release\" }, error);\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected releaseCore(acquireId: string) {\n\t\t// Note: item may be no longer in jobTracking and returned back to queue!\n\t\tconst rec = this.jobTracking.get(acquireId);\n\t\tif (rec !== undefined) {\n\t\t\tthis.jobTracking.delete(acquireId);\n\t\t\tthis.data.add(rec.value);\n\t\t\tthis.emit(\"add\", rec.value, false /* newlyAdded */);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tassert(\n\t\t\tthis.jobTracking.size === 0,\n\t\t\t0x068 /* \"On consensusOrderedCollection load, job tracking size > 0\" */,\n\t\t);\n\t\tconst blob = await storage.readBlob(snapshotFileNameTracking);\n\t\tconst rawContentTracking = bufferToString(blob, \"utf8\");\n\t\tconst content = this.deserializeValue(rawContentTracking, this.serializer);\n\t\tthis.jobTracking = new Map(content) as JobTrackingInfo<T>;\n\n\t\tassert(\n\t\t\tthis.data.size() === 0,\n\t\t\t0x069 /* \"On consensusOrderedCollection load, data size > 0\" */,\n\t\t);\n\t\tconst blob2 = await storage.readBlob(snapshotFileNameData);\n\t\tconst rawContentData = bufferToString(blob2, \"utf8\");\n\t\tconst content2 = this.deserializeValue(rawContentData, this.serializer) as T[];\n\t\tthis.data.loadFrom(content2);\n\t}\n\n\tprotected onDisconnect() {\n\t\tfor (const [, { value, clientId }] of this.jobTracking) {\n\t\t\tif (clientId === this.runtime.clientId) {\n\t\t\t\tthis.emit(\"localRelease\", value, false /* intentional */);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t) {\n\t\tif (message.type === MessageType.Operation) {\n\t\t\tconst op = message.contents as IConsensusOrderedCollectionOperation<T>;\n\t\t\tlet value: IConsensusOrderedCollectionValue<T> | undefined;\n\t\t\tswitch (op.opName) {\n\t\t\t\tcase \"add\":\n\t\t\t\t\tif (op.deserializedValue !== undefined) {\n\t\t\t\t\t\tthis.addCore(op.deserializedValue);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.addCore(this.deserializeValue(op.value, this.serializer) as T);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"acquire\":\n\t\t\t\t\tvalue = this.acquireCore(op.acquireId, message.clientId ?? undefined);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"complete\":\n\t\t\t\t\tthis.completeCore(op.acquireId);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"release\":\n\t\t\t\t\tthis.releaseCore(op.acquireId);\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(op);\n\t\t\t}\n\t\t\tif (local) {\n\t\t\t\t// Resolve the pending promise for this operation now that we have received an ack for it.\n\t\t\t\tconst resolve = localOpMetadata as PendingResolve<T>;\n\t\t\t\tresolve(value);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async submit<TMessage extends IConsensusOrderedCollectionOperation<T>>(\n\t\tmessage: TMessage,\n\t): Promise<IConsensusOrderedCollectionValue<T> | undefined> {\n\t\tassert(this.isAttached(), 0x06a /* \"Trying to submit message while detached!\" */);\n\n\t\treturn this.newAckBasedPromise<IConsensusOrderedCollectionValue<T> | undefined>(\n\t\t\t(resolve) => {\n\t\t\t\t// Send the resolve function as the localOpMetadata. This will be provided back to us when the\n\t\t\t\t// op is ack'd.\n\t\t\t\tthis.submitLocalMessage(message, resolve);\n\t\t\t\t// If we fail due to runtime being disposed, it's better to return undefined then unhandled exception.\n\t\t\t},\n\t\t).catch((error) => undefined);\n\t}\n\n\tprivate addCore(value: T) {\n\t\tthis.data.add(value);\n\t\tthis.emit(\"add\", value, true /* newlyAdded */);\n\t}\n\n\tprivate acquireCore(\n\t\tacquireId: string,\n\t\tclientId?: string,\n\t): IConsensusOrderedCollectionValue<T> | undefined {\n\t\tif (this.data.size() === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst value = this.data.remove();\n\n\t\tconst value2: IConsensusOrderedCollectionValue<T> = {\n\t\t\tacquireId,\n\t\t\tvalue,\n\t\t};\n\t\tthis.jobTracking.set(value2.acquireId, { value, clientId });\n\n\t\tthis.emit(\"acquire\", value, clientId);\n\t\treturn value2;\n\t}\n\n\tprivate async acquireInternal(): Promise<IConsensusOrderedCollectionValue<T> | undefined> {\n\t\tif (!this.isAttached()) {\n\t\t\t// can be undefined if queue is empty\n\t\t\treturn this.acquireCore(uuid(), idForLocalUnattachedClient);\n\t\t}\n\n\t\treturn this.submit<IConsensusOrderedCollectionAcquireOperation>({\n\t\t\topName: \"acquire\",\n\t\t\tacquireId: uuid(),\n\t\t});\n\t}\n\n\tprivate removeClient(clientIdToRemove?: string) {\n\t\tconst added: T[] = [];\n\t\tfor (const [acquireId, { value, clientId }] of this.jobTracking) {\n\t\t\tif (clientId === clientIdToRemove) {\n\t\t\t\tthis.jobTracking.delete(acquireId);\n\t\t\t\tthis.data.add(value);\n\t\t\t\tadded.push(value);\n\t\t\t}\n\t\t}\n\n\t\t// Raise all events only after all state changes are completed,\n\t\t// to guarantee same ordering of operations if collection is manipulated from events.\n\t\tadded.map((value) => this.emit(\"add\", value, false /* newlyAdded */));\n\t}\n\n\tprivate serializeValue(value, serializer: IFluidSerializer) {\n\t\treturn serializer.stringify(value, this.handle);\n\t}\n\n\tprivate deserializeValue(content: string, serializer: IFluidSerializer) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn serializer.parse(content);\n\t}\n\n\tprotected applyStashedOp(): void {\n\t\tthrow new Error(\"not implemented\");\n\t}\n}\n"]}
@@ -3,9 +3,11 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { IChannelAttributes, IFluidDataStoreRuntime, IChannelServices } from "@fluidframework/datastore-definitions";
6
- import { IConsensusOrderedCollection, IConsensusOrderedCollectionFactory } from "./interfaces";
6
+ import { IConsensusOrderedCollection, IConsensusOrderedCollectionFactory } from "./interfaces.js";
7
7
  /**
8
8
  * The factory that defines the consensus queue
9
+ *
10
+ * @internal
9
11
  */
10
12
  export declare class ConsensusQueueFactory implements IConsensusOrderedCollectionFactory {
11
13
  static Type: string;
@@ -1 +1 @@
1
- {"version":3,"file":"consensusOrderedCollectionFactory.d.ts","sourceRoot":"","sources":["../src/consensusOrderedCollectionFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,2BAA2B,EAAE,kCAAkC,EAAE,MAAM,cAAc,CAAC;AAG/F;;GAEG;AACH,qBAAa,qBAAsB,YAAW,kCAAkC;IAC/E,OAAc,IAAI,SAAuD;IAEzE,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF,IAAW,IAAI,WAEd;IAED,IAAW,UAAU,uBAEpB;IAED;;OAEG;IACU,IAAI,CAChB,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAC5B,OAAO,CAAC,2BAA2B,CAAC;IAMhC,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,2BAA2B;CAKxF"}
1
+ {"version":3,"file":"consensusOrderedCollectionFactory.d.ts","sourceRoot":"","sources":["../src/consensusOrderedCollectionFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,2BAA2B,EAAE,kCAAkC,EAAE,MAAM,iBAAiB,CAAC;AAGlG;;;;GAIG;AACH,qBAAa,qBAAsB,YAAW,kCAAkC;IAC/E,OAAc,IAAI,SAAuD;IAEzE,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF,IAAW,IAAI,WAEd;IAED,IAAW,UAAU,uBAEpB;IAED;;OAEG;IACU,IAAI,CAChB,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAC5B,OAAO,CAAC,2BAA2B,CAAC;IAMhC,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,2BAA2B;CAKxF"}
@@ -5,10 +5,12 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.ConsensusQueueFactory = void 0;
8
- const consensusQueue_1 = require("./consensusQueue");
9
- const packageVersion_1 = require("./packageVersion");
8
+ const consensusQueue_js_1 = require("./consensusQueue.js");
9
+ const packageVersion_js_1 = require("./packageVersion.js");
10
10
  /**
11
11
  * The factory that defines the consensus queue
12
+ *
13
+ * @internal
12
14
  */
13
15
  class ConsensusQueueFactory {
14
16
  get type() {
@@ -21,12 +23,12 @@ class ConsensusQueueFactory {
21
23
  * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
22
24
  */
23
25
  async load(runtime, id, services, attributes) {
24
- const collection = new consensusQueue_1.ConsensusQueue(id, runtime, attributes);
26
+ const collection = new consensusQueue_js_1.ConsensusQueue(id, runtime, attributes);
25
27
  await collection.load(services);
26
28
  return collection;
27
29
  }
28
30
  create(document, id) {
29
- const collection = new consensusQueue_1.ConsensusQueue(id, document, this.attributes);
31
+ const collection = new consensusQueue_js_1.ConsensusQueue(id, document, this.attributes);
30
32
  collection.initializeLocal();
31
33
  return collection;
32
34
  }
@@ -36,6 +38,6 @@ ConsensusQueueFactory.Type = "https://graph.microsoft.com/types/consensus-queue"
36
38
  ConsensusQueueFactory.Attributes = {
37
39
  type: ConsensusQueueFactory.Type,
38
40
  snapshotFormatVersion: "0.1",
39
- packageVersion: packageVersion_1.pkgVersion,
41
+ packageVersion: packageVersion_js_1.pkgVersion,
40
42
  };
41
43
  //# sourceMappingURL=consensusOrderedCollectionFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"consensusOrderedCollectionFactory.js","sourceRoot":"","sources":["../src/consensusOrderedCollectionFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,qDAAkD;AAElD,qDAA8C;AAE9C;;GAEG;AACH,MAAa,qBAAqB;IASjC,IAAW,IAAI;QACd,OAAO,qBAAqB,CAAC,IAAI,CAAC;IACnC,CAAC;IAED,IAAW,UAAU;QACpB,OAAO,qBAAqB,CAAC,UAAU,CAAC;IACzC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAE9B,MAAM,UAAU,GAAG,IAAI,+BAAc,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAC/D,MAAM,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChC,OAAO,UAAU,CAAC;IACnB,CAAC;IAEM,MAAM,CAAC,QAAgC,EAAE,EAAU;QACzD,MAAM,UAAU,GAAG,IAAI,+BAAc,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACrE,UAAU,CAAC,eAAe,EAAE,CAAC;QAC7B,OAAO,UAAU,CAAC;IACnB,CAAC;;AAnCF,sDAoCC;AAnCc,0BAAI,GAAG,mDAAmD,CAAC;AAElD,gCAAU,GAAuB;IACvD,IAAI,EAAE,qBAAqB,CAAC,IAAI;IAChC,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} from \"@fluidframework/datastore-definitions\";\nimport { ConsensusQueue } from \"./consensusQueue\";\nimport { IConsensusOrderedCollection, IConsensusOrderedCollectionFactory } from \"./interfaces\";\nimport { pkgVersion } from \"./packageVersion\";\n\n/**\n * The factory that defines the consensus queue\n */\nexport class ConsensusQueueFactory implements IConsensusOrderedCollectionFactory {\n\tpublic static Type = \"https://graph.microsoft.com/types/consensus-queue\";\n\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: ConsensusQueueFactory.Type,\n\t\tsnapshotFormatVersion: \"0.1\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\tpublic get type() {\n\t\treturn ConsensusQueueFactory.Type;\n\t}\n\n\tpublic get attributes() {\n\t\treturn ConsensusQueueFactory.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<IConsensusOrderedCollection> {\n\t\tconst collection = new ConsensusQueue(id, runtime, attributes);\n\t\tawait collection.load(services);\n\t\treturn collection;\n\t}\n\n\tpublic create(document: IFluidDataStoreRuntime, id: string): IConsensusOrderedCollection {\n\t\tconst collection = new ConsensusQueue(id, document, this.attributes);\n\t\tcollection.initializeLocal();\n\t\treturn collection;\n\t}\n}\n"]}
1
+ {"version":3,"file":"consensusOrderedCollectionFactory.js","sourceRoot":"","sources":["../src/consensusOrderedCollectionFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,2DAAqD;AAErD,2DAAiD;AAEjD;;;;GAIG;AACH,MAAa,qBAAqB;IASjC,IAAW,IAAI;QACd,OAAO,qBAAqB,CAAC,IAAI,CAAC;IACnC,CAAC;IAED,IAAW,UAAU;QACpB,OAAO,qBAAqB,CAAC,UAAU,CAAC;IACzC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAE9B,MAAM,UAAU,GAAG,IAAI,kCAAc,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAC/D,MAAM,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChC,OAAO,UAAU,CAAC;IACnB,CAAC;IAEM,MAAM,CAAC,QAAgC,EAAE,EAAU;QACzD,MAAM,UAAU,GAAG,IAAI,kCAAc,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACrE,UAAU,CAAC,eAAe,EAAE,CAAC;QAC7B,OAAO,UAAU,CAAC;IACnB,CAAC;;AAnCF,sDAoCC;AAnCc,0BAAI,GAAG,mDAAmD,CAAC;AAElD,gCAAU,GAAuB;IACvD,IAAI,EAAE,qBAAqB,CAAC,IAAI;IAChC,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,8BAAU;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} from \"@fluidframework/datastore-definitions\";\nimport { ConsensusQueue } from \"./consensusQueue.js\";\nimport { IConsensusOrderedCollection, IConsensusOrderedCollectionFactory } from \"./interfaces.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * The factory that defines the consensus queue\n *\n * @internal\n */\nexport class ConsensusQueueFactory implements IConsensusOrderedCollectionFactory {\n\tpublic static Type = \"https://graph.microsoft.com/types/consensus-queue\";\n\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: ConsensusQueueFactory.Type,\n\t\tsnapshotFormatVersion: \"0.1\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\tpublic get type() {\n\t\treturn ConsensusQueueFactory.Type;\n\t}\n\n\tpublic get attributes() {\n\t\treturn ConsensusQueueFactory.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<IConsensusOrderedCollection> {\n\t\tconst collection = new ConsensusQueue(id, runtime, attributes);\n\t\tawait collection.load(services);\n\t\treturn collection;\n\t}\n\n\tpublic create(document: IFluidDataStoreRuntime, id: string): IConsensusOrderedCollection {\n\t\tconst collection = new ConsensusQueue(id, document, this.attributes);\n\t\tcollection.initializeLocal();\n\t\treturn collection;\n\t}\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { IFluidDataStoreRuntime, IChannelAttributes, IChannelFactory } from "@fluidframework/datastore-definitions";
6
- import { ConsensusOrderedCollection } from "./consensusOrderedCollection";
6
+ import { ConsensusOrderedCollection } from "./consensusOrderedCollection.js";
7
7
  /**
8
8
  * Implementation of a consensus stack
9
9
  *
@@ -1 +1 @@
1
- {"version":3,"file":"consensusQueue.d.ts","sourceRoot":"","sources":["../src/consensusQueue.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EACf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAqB1E;;;;;GAKG;AACH,qBAAa,cAAc,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,0BAA0B,CAAC,CAAC,CAAC;IACzE;;;;;;OAMG;WACW,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,MAAM;IAI1E;;;;OAIG;WACW,UAAU,IAAI,eAAe;IAI3C;;;OAGG;gBAEF,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,sBAAsB,EAC/B,UAAU,EAAE,kBAAkB;CAI/B"}
1
+ {"version":3,"file":"consensusQueue.d.ts","sourceRoot":"","sources":["../src/consensusQueue.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EACf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAqB7E;;;;;GAKG;AACH,qBAAa,cAAc,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,0BAA0B,CAAC,CAAC,CAAC;IACzE;;;;;;OAMG;WACW,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,MAAM;IAI1E;;;;OAIG;WACW,UAAU,IAAI,eAAe;IAI3C;;;OAGG;gBAEF,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,sBAAsB,EAC/B,UAAU,EAAE,kBAAkB;CAI/B"}
@@ -5,13 +5,13 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.ConsensusQueue = void 0;
8
- const consensusOrderedCollection_1 = require("./consensusOrderedCollection");
9
- const consensusOrderedCollectionFactory_1 = require("./consensusOrderedCollectionFactory");
10
- const snapshotableArray_1 = require("./snapshotableArray");
8
+ const consensusOrderedCollection_js_1 = require("./consensusOrderedCollection.js");
9
+ const consensusOrderedCollectionFactory_js_1 = require("./consensusOrderedCollectionFactory.js");
10
+ const snapshotableArray_js_1 = require("./snapshotableArray.js");
11
11
  /**
12
12
  * An JS array based queue implementation that is the backing data structure for ConsensusQueue
13
13
  */
14
- class SnapshotableQueue extends snapshotableArray_1.SnapshotableArray {
14
+ class SnapshotableQueue extends snapshotableArray_js_1.SnapshotableArray {
15
15
  add(value) {
16
16
  this.data.push(value);
17
17
  }
@@ -28,7 +28,7 @@ class SnapshotableQueue extends snapshotableArray_1.SnapshotableArray {
28
28
  * An derived type of ConsensusOrderedCollection with a queue as the backing data and order.
29
29
  * @alpha
30
30
  */
31
- class ConsensusQueue extends consensusOrderedCollection_1.ConsensusOrderedCollection {
31
+ class ConsensusQueue extends consensusOrderedCollection_js_1.ConsensusOrderedCollection {
32
32
  /**
33
33
  * Create a new consensus queue
34
34
  *
@@ -37,7 +37,7 @@ class ConsensusQueue extends consensusOrderedCollection_1.ConsensusOrderedCollec
37
37
  * @returns newly create consensus queue (but not attached yet)
38
38
  */
39
39
  static create(runtime, id) {
40
- return runtime.createChannel(id, consensusOrderedCollectionFactory_1.ConsensusQueueFactory.Type);
40
+ return runtime.createChannel(id, consensusOrderedCollectionFactory_js_1.ConsensusQueueFactory.Type);
41
41
  }
42
42
  /**
43
43
  * Get a factory for ConsensusQueue to register with the data store.
@@ -45,7 +45,7 @@ class ConsensusQueue extends consensusOrderedCollection_1.ConsensusOrderedCollec
45
45
  * @returns a factory that creates and load ConsensusQueue
46
46
  */
47
47
  static getFactory() {
48
- return new consensusOrderedCollectionFactory_1.ConsensusQueueFactory();
48
+ return new consensusOrderedCollectionFactory_js_1.ConsensusQueueFactory();
49
49
  }
50
50
  /**
51
51
  * Constructs a new consensus queue. If the object is non-local an id and service interfaces will
@@ -1 +1 @@
1
- {"version":3,"file":"consensusQueue.js","sourceRoot":"","sources":["../src/consensusQueue.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,6EAA0E;AAC1E,2FAA4E;AAE5E,2DAAwD;AAExD;;GAEG;AACH,MAAM,iBAAqB,SAAQ,qCAAoB;IAC/C,GAAG,CAAC,KAAQ;QAClB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAEM,MAAM;QACZ,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;SAC9C;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAO,CAAC;IAC/B,CAAC;CACD;AAED;;;;;GAKG;AACH,MAAa,cAAwB,SAAQ,uDAA6B;IACzE;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAAU,OAA+B,EAAE,EAAW;QACzE,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,yDAAqB,CAAC,IAAI,CAAsB,CAAC;IACnF,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU;QACvB,OAAO,IAAI,yDAAqB,EAAE,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B;QAE9B,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,iBAAiB,EAAK,CAAC,CAAC;IAC5D,CAAC;CACD;AAhCD,wCAgCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIFluidDataStoreRuntime,\n\tIChannelAttributes,\n\tIChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { ConsensusOrderedCollection } from \"./consensusOrderedCollection\";\nimport { ConsensusQueueFactory } from \"./consensusOrderedCollectionFactory\";\nimport { IOrderedCollection } from \"./interfaces\";\nimport { SnapshotableArray } from \"./snapshotableArray\";\n\n/**\n * An JS array based queue implementation that is the backing data structure for ConsensusQueue\n */\nclass SnapshotableQueue<T> extends SnapshotableArray<T> implements IOrderedCollection<T> {\n\tpublic add(value: T) {\n\t\tthis.data.push(value);\n\t}\n\n\tpublic remove(): T {\n\t\tif (this.size() === 0) {\n\t\t\tthrow new Error(\"SnapshotableQueue is empty\");\n\t\t}\n\t\treturn this.data.shift() as T;\n\t}\n}\n\n/**\n * Implementation of a consensus stack\n *\n * An derived type of ConsensusOrderedCollection with a queue as the backing data and order.\n * @alpha\n */\nexport class ConsensusQueue<T = any> extends ConsensusOrderedCollection<T> {\n\t/**\n\t * Create a new consensus queue\n\t *\n\t * @param runtime - data store runtime the new consensus queue belongs to\n\t * @param id - optional name of theconsensus queue\n\t * @returns newly create consensus queue (but not attached yet)\n\t */\n\tpublic static create<T = any>(runtime: IFluidDataStoreRuntime, id?: string) {\n\t\treturn runtime.createChannel(id, ConsensusQueueFactory.Type) as ConsensusQueue<T>;\n\t}\n\n\t/**\n\t * Get a factory for ConsensusQueue to register with the data store.\n\t *\n\t * @returns a factory that creates and load ConsensusQueue\n\t */\n\tpublic static getFactory(): IChannelFactory {\n\t\treturn new ConsensusQueueFactory();\n\t}\n\n\t/**\n\t * Constructs a new consensus queue. If the object is non-local an id and service interfaces will\n\t * be provided\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, new SnapshotableQueue<T>());\n\t}\n}\n"]}
1
+ {"version":3,"file":"consensusQueue.js","sourceRoot":"","sources":["../src/consensusQueue.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,mFAA6E;AAC7E,iGAA+E;AAE/E,iEAA2D;AAE3D;;GAEG;AACH,MAAM,iBAAqB,SAAQ,wCAAoB;IAC/C,GAAG,CAAC,KAAQ;QAClB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAEM,MAAM;QACZ,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;SAC9C;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAO,CAAC;IAC/B,CAAC;CACD;AAED;;;;;GAKG;AACH,MAAa,cAAwB,SAAQ,0DAA6B;IACzE;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAAU,OAA+B,EAAE,EAAW;QACzE,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,4DAAqB,CAAC,IAAI,CAAsB,CAAC;IACnF,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU;QACvB,OAAO,IAAI,4DAAqB,EAAE,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B;QAE9B,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,iBAAiB,EAAK,CAAC,CAAC;IAC5D,CAAC;CACD;AAhCD,wCAgCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIFluidDataStoreRuntime,\n\tIChannelAttributes,\n\tIChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { ConsensusOrderedCollection } from \"./consensusOrderedCollection.js\";\nimport { ConsensusQueueFactory } from \"./consensusOrderedCollectionFactory.js\";\nimport { IOrderedCollection } from \"./interfaces.js\";\nimport { SnapshotableArray } from \"./snapshotableArray.js\";\n\n/**\n * An JS array based queue implementation that is the backing data structure for ConsensusQueue\n */\nclass SnapshotableQueue<T> extends SnapshotableArray<T> implements IOrderedCollection<T> {\n\tpublic add(value: T) {\n\t\tthis.data.push(value);\n\t}\n\n\tpublic remove(): T {\n\t\tif (this.size() === 0) {\n\t\t\tthrow new Error(\"SnapshotableQueue is empty\");\n\t\t}\n\t\treturn this.data.shift() as T;\n\t}\n}\n\n/**\n * Implementation of a consensus stack\n *\n * An derived type of ConsensusOrderedCollection with a queue as the backing data and order.\n * @alpha\n */\nexport class ConsensusQueue<T = any> extends ConsensusOrderedCollection<T> {\n\t/**\n\t * Create a new consensus queue\n\t *\n\t * @param runtime - data store runtime the new consensus queue belongs to\n\t * @param id - optional name of theconsensus queue\n\t * @returns newly create consensus queue (but not attached yet)\n\t */\n\tpublic static create<T = any>(runtime: IFluidDataStoreRuntime, id?: string) {\n\t\treturn runtime.createChannel(id, ConsensusQueueFactory.Type) as ConsensusQueue<T>;\n\t}\n\n\t/**\n\t * Get a factory for ConsensusQueue to register with the data store.\n\t *\n\t * @returns a factory that creates and load ConsensusQueue\n\t */\n\tpublic static getFactory(): IChannelFactory {\n\t\treturn new ConsensusQueueFactory();\n\t}\n\n\t/**\n\t * Constructs a new consensus queue. If the object is non-local an id and service interfaces will\n\t * be provided\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, new SnapshotableQueue<T>());\n\t}\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -2,8 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { ConsensusCallback, ConsensusResult, IConsensusOrderedCollection, IConsensusOrderedCollectionEvents, IConsensusOrderedCollectionFactory, IOrderedCollection, ISnapshotable, } from "./interfaces";
6
- export { ConsensusOrderedCollection } from "./consensusOrderedCollection";
7
- export { ConsensusQueue } from "./consensusQueue";
8
- export { acquireAndComplete, waitAcquireAndComplete } from "./testUtils";
5
+ export { ConsensusCallback, ConsensusResult, IConsensusOrderedCollection, IConsensusOrderedCollectionEvents, IConsensusOrderedCollectionFactory, IOrderedCollection, ISnapshotable, } from "./interfaces.js";
6
+ export { ConsensusQueueFactory } from "./consensusOrderedCollectionFactory.js";
7
+ export { ConsensusOrderedCollection } from "./consensusOrderedCollection.js";
8
+ export { ConsensusQueue } from "./consensusQueue.js";
9
+ export { acquireAndComplete, waitAcquireAndComplete } from "./testUtils.js";
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,iBAAiB,EACjB,eAAe,EACf,2BAA2B,EAC3B,iCAAiC,EACjC,kCAAkC,EAClC,kBAAkB,EAClB,aAAa,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,iBAAiB,EACjB,eAAe,EACf,2BAA2B,EAC3B,iCAAiC,EACjC,kCAAkC,EAClC,kBAAkB,EAClB,aAAa,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -4,14 +4,16 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.waitAcquireAndComplete = exports.acquireAndComplete = exports.ConsensusQueue = exports.ConsensusOrderedCollection = exports.ConsensusResult = void 0;
8
- var interfaces_1 = require("./interfaces");
9
- Object.defineProperty(exports, "ConsensusResult", { enumerable: true, get: function () { return interfaces_1.ConsensusResult; } });
10
- var consensusOrderedCollection_1 = require("./consensusOrderedCollection");
11
- Object.defineProperty(exports, "ConsensusOrderedCollection", { enumerable: true, get: function () { return consensusOrderedCollection_1.ConsensusOrderedCollection; } });
12
- var consensusQueue_1 = require("./consensusQueue");
13
- Object.defineProperty(exports, "ConsensusQueue", { enumerable: true, get: function () { return consensusQueue_1.ConsensusQueue; } });
14
- var testUtils_1 = require("./testUtils");
15
- Object.defineProperty(exports, "acquireAndComplete", { enumerable: true, get: function () { return testUtils_1.acquireAndComplete; } });
16
- Object.defineProperty(exports, "waitAcquireAndComplete", { enumerable: true, get: function () { return testUtils_1.waitAcquireAndComplete; } });
7
+ exports.waitAcquireAndComplete = exports.acquireAndComplete = exports.ConsensusQueue = exports.ConsensusOrderedCollection = exports.ConsensusQueueFactory = exports.ConsensusResult = void 0;
8
+ var interfaces_js_1 = require("./interfaces.js");
9
+ Object.defineProperty(exports, "ConsensusResult", { enumerable: true, get: function () { return interfaces_js_1.ConsensusResult; } });
10
+ var consensusOrderedCollectionFactory_js_1 = require("./consensusOrderedCollectionFactory.js");
11
+ Object.defineProperty(exports, "ConsensusQueueFactory", { enumerable: true, get: function () { return consensusOrderedCollectionFactory_js_1.ConsensusQueueFactory; } });
12
+ var consensusOrderedCollection_js_1 = require("./consensusOrderedCollection.js");
13
+ Object.defineProperty(exports, "ConsensusOrderedCollection", { enumerable: true, get: function () { return consensusOrderedCollection_js_1.ConsensusOrderedCollection; } });
14
+ var consensusQueue_js_1 = require("./consensusQueue.js");
15
+ Object.defineProperty(exports, "ConsensusQueue", { enumerable: true, get: function () { return consensusQueue_js_1.ConsensusQueue; } });
16
+ var testUtils_js_1 = require("./testUtils.js");
17
+ Object.defineProperty(exports, "acquireAndComplete", { enumerable: true, get: function () { return testUtils_js_1.acquireAndComplete; } });
18
+ Object.defineProperty(exports, "waitAcquireAndComplete", { enumerable: true, get: function () { return testUtils_js_1.waitAcquireAndComplete; } });
17
19
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2CAQsB;AANrB,6GAAA,eAAe,OAAA;AAOhB,2EAA0E;AAAjE,wIAAA,0BAA0B,OAAA;AACnC,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,yCAAyE;AAAhE,+GAAA,kBAAkB,OAAA;AAAE,mHAAA,sBAAsB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tConsensusCallback,\n\tConsensusResult,\n\tIConsensusOrderedCollection,\n\tIConsensusOrderedCollectionEvents,\n\tIConsensusOrderedCollectionFactory,\n\tIOrderedCollection,\n\tISnapshotable,\n} from \"./interfaces\";\nexport { ConsensusOrderedCollection } from \"./consensusOrderedCollection\";\nexport { ConsensusQueue } from \"./consensusQueue\";\nexport { acquireAndComplete, waitAcquireAndComplete } from \"./testUtils\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iDAQyB;AANxB,gHAAA,eAAe,OAAA;AAOhB,+FAA+E;AAAtE,6IAAA,qBAAqB,OAAA;AAC9B,iFAA6E;AAApE,2IAAA,0BAA0B,OAAA;AACnC,yDAAqD;AAA5C,mHAAA,cAAc,OAAA;AACvB,+CAA4E;AAAnE,kHAAA,kBAAkB,OAAA;AAAE,sHAAA,sBAAsB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tConsensusCallback,\n\tConsensusResult,\n\tIConsensusOrderedCollection,\n\tIConsensusOrderedCollectionEvents,\n\tIConsensusOrderedCollectionFactory,\n\tIOrderedCollection,\n\tISnapshotable,\n} from \"./interfaces.js\";\nexport { ConsensusQueueFactory } from \"./consensusOrderedCollectionFactory.js\";\nexport { ConsensusOrderedCollection } from \"./consensusOrderedCollection.js\";\nexport { ConsensusQueue } from \"./consensusQueue.js\";\nexport { acquireAndComplete, waitAcquireAndComplete } from \"./testUtils.js\";\n"]}
@@ -103,6 +103,8 @@ export declare class ConsensusQueue<T = any> extends ConsensusOrderedCollection<
103
103
  constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
104
104
  }
105
105
 
106
+ /* Excluded from this release type: ConsensusQueueFactory */
107
+
106
108
  /**
107
109
  * @alpha
108
110
  */
@@ -18,6 +18,8 @@ import { SharedObject } from '@fluidframework/shared-object-base';
18
18
 
19
19
  /* Excluded from this release type: ConsensusQueue */
20
20
 
21
+ /* Excluded from this release type: ConsensusQueueFactory */
22
+
21
23
  /* Excluded from this release type: ConsensusResult */
22
24
 
23
25
  /* Excluded from this release type: IConsensusOrderedCollection */
@@ -30,6 +32,8 @@ import { SharedObject } from '@fluidframework/shared-object-base';
30
32
 
31
33
  /* Excluded from this release type: ISnapshotable */
32
34
 
35
+ /* Excluded from this release type: SharedObject */
36
+
33
37
  /* Excluded from this release type: waitAcquireAndComplete */
34
38
 
35
39
  export { }
@@ -18,6 +18,8 @@ import { SharedObject } from '@fluidframework/shared-object-base';
18
18
 
19
19
  /* Excluded from this release type: ConsensusQueue */
20
20
 
21
+ /* Excluded from this release type: ConsensusQueueFactory */
22
+
21
23
  /* Excluded from this release type: ConsensusResult */
22
24
 
23
25
  /* Excluded from this release type: IConsensusOrderedCollection */
@@ -30,6 +32,8 @@ import { SharedObject } from '@fluidframework/shared-object-base';
30
32
 
31
33
  /* Excluded from this release type: ISnapshotable */
32
34
 
35
+ /* Excluded from this release type: SharedObject */
36
+
33
37
  /* Excluded from this release type: waitAcquireAndComplete */
34
38
 
35
39
  export { }
@@ -108,6 +108,23 @@ export declare class ConsensusQueue<T = any> extends ConsensusOrderedCollection<
108
108
  constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
109
109
  }
110
110
 
111
+ /**
112
+ * The factory that defines the consensus queue
113
+ *
114
+ * @internal
115
+ */
116
+ export declare class ConsensusQueueFactory implements IConsensusOrderedCollectionFactory {
117
+ static Type: string;
118
+ static readonly Attributes: IChannelAttributes;
119
+ get type(): string;
120
+ get attributes(): IChannelAttributes;
121
+ /**
122
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
123
+ */
124
+ load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<IConsensusOrderedCollection>;
125
+ create(document: IFluidDataStoreRuntime, id: string): IConsensusOrderedCollection;
126
+ }
127
+
111
128
  /**
112
129
  * @alpha
113
130
  */
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -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/ordered-collection";
8
- export declare const pkgVersion = "2.0.0-rc.1.0.6";
8
+ export declare const pkgVersion = "2.0.0-rc.2.0.1";
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 = "@fluidframework/ordered-collection";
11
- exports.pkgVersion = "2.0.0-rc.1.0.6";
11
+ exports.pkgVersion = "2.0.0-rc.2.0.1";
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,oCAAoC,CAAC;AAC/C,QAAA,UAAU,GAAG,gBAAgB,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/ordered-collection\";\nexport const pkgVersion = \"2.0.0-rc.1.0.6\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,oCAAoC,CAAC;AAC/C,QAAA,UAAU,GAAG,gBAAgB,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/ordered-collection\";\nexport const pkgVersion = \"2.0.0-rc.2.0.1\";\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { IConsensusOrderedCollection } from "./interfaces";
5
+ import { IConsensusOrderedCollection } from "./interfaces.js";
6
6
  /**
7
7
  * Helper method to acquire and complete an item
8
8
  * Should be used in test code only
@@ -1 +1 @@
1
- {"version":3,"file":"testUtils.d.ts","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAmB,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAE5E;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EACzC,UAAU,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACxC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAOxB;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,EAC7C,UAAU,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACxC,OAAO,CAAC,CAAC,CAAC,CAOZ"}
1
+ {"version":3,"file":"testUtils.d.ts","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAmB,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAE/E;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EACzC,UAAU,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACxC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAOxB;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,EAC7C,UAAU,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACxC,OAAO,CAAC,CAAC,CAAC,CAOZ"}