@fluidframework/ordered-collection 2.0.0-internal.8.0.1 → 2.0.0-rc.1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +0 -6
  3. package/api-extractor-esm.json +4 -0
  4. package/api-extractor-lint.json +1 -10
  5. package/api-extractor.json +1 -9
  6. package/api-report/ordered-collection.api.md +8 -8
  7. package/dist/consensusOrderedCollection.d.ts +1 -1
  8. package/dist/{consensusOrderedCollection.cjs → consensusOrderedCollection.js} +3 -3
  9. package/dist/consensusOrderedCollection.js.map +1 -0
  10. package/dist/{consensusOrderedCollectionFactory.cjs → consensusOrderedCollectionFactory.js} +3 -3
  11. package/dist/consensusOrderedCollectionFactory.js.map +1 -0
  12. package/dist/consensusQueue.d.ts +1 -1
  13. package/dist/{consensusQueue.cjs → consensusQueue.js} +5 -5
  14. package/dist/consensusQueue.js.map +1 -0
  15. package/dist/{index.cjs → index.js} +5 -5
  16. package/dist/index.js.map +1 -0
  17. package/dist/interfaces.d.ts +6 -6
  18. package/dist/{interfaces.cjs → interfaces.js} +2 -2
  19. package/dist/interfaces.js.map +1 -0
  20. package/dist/ordered-collection-alpha.d.ts +199 -8
  21. package/dist/ordered-collection-beta.d.ts +0 -20
  22. package/dist/ordered-collection-public.d.ts +0 -20
  23. package/dist/ordered-collection-untrimmed.d.ts +8 -8
  24. package/dist/packageVersion.d.ts +1 -1
  25. package/dist/packageVersion.d.ts.map +1 -1
  26. package/dist/{packageVersion.cjs → packageVersion.js} +2 -2
  27. package/dist/packageVersion.js.map +1 -0
  28. package/dist/{snapshotableArray.cjs → snapshotableArray.js} +1 -1
  29. package/dist/snapshotableArray.js.map +1 -0
  30. package/dist/{testUtils.cjs → testUtils.js} +2 -2
  31. package/dist/testUtils.js.map +1 -0
  32. package/lib/{consensusOrderedCollection.d.ts → consensusOrderedCollection.d.mts} +2 -2
  33. package/lib/consensusOrderedCollection.d.mts.map +1 -0
  34. package/lib/consensusOrderedCollection.mjs +1 -1
  35. package/lib/consensusOrderedCollection.mjs.map +1 -1
  36. package/lib/{consensusOrderedCollectionFactory.d.ts → consensusOrderedCollectionFactory.d.mts} +1 -1
  37. package/lib/consensusOrderedCollectionFactory.d.mts.map +1 -0
  38. package/lib/{consensusQueue.d.ts → consensusQueue.d.mts} +2 -2
  39. package/lib/consensusQueue.d.mts.map +1 -0
  40. package/lib/consensusQueue.mjs +1 -1
  41. package/lib/consensusQueue.mjs.map +1 -1
  42. package/lib/{index.d.ts → index.d.mts} +1 -1
  43. package/lib/index.d.mts.map +1 -0
  44. package/lib/{interfaces.d.ts → interfaces.d.mts} +7 -7
  45. package/lib/interfaces.d.mts.map +1 -0
  46. package/lib/interfaces.mjs +1 -1
  47. package/lib/interfaces.mjs.map +1 -1
  48. package/lib/ordered-collection-alpha.d.mts +226 -0
  49. package/lib/{ordered-collection-beta.d.ts → ordered-collection-public.d.mts} +0 -20
  50. package/lib/{ordered-collection-untrimmed.d.ts → ordered-collection-untrimmed.d.mts} +8 -8
  51. package/lib/{packageVersion.d.ts → packageVersion.d.mts} +2 -2
  52. package/lib/packageVersion.d.mts.map +1 -0
  53. package/lib/packageVersion.mjs +1 -1
  54. package/lib/packageVersion.mjs.map +1 -1
  55. package/lib/{snapshotableArray.d.ts → snapshotableArray.d.mts} +1 -1
  56. package/lib/snapshotableArray.d.mts.map +1 -0
  57. package/lib/{testUtils.d.ts → testUtils.d.mts} +1 -1
  58. package/lib/testUtils.d.mts.map +1 -0
  59. package/package.json +79 -26
  60. package/src/consensusOrderedCollection.ts +1 -1
  61. package/src/consensusQueue.ts +1 -1
  62. package/src/interfaces.ts +6 -6
  63. package/src/packageVersion.ts +1 -1
  64. package/dist/consensusOrderedCollection.cjs.map +0 -1
  65. package/dist/consensusOrderedCollectionFactory.cjs.map +0 -1
  66. package/dist/consensusQueue.cjs.map +0 -1
  67. package/dist/index.cjs.map +0 -1
  68. package/dist/interfaces.cjs.map +0 -1
  69. package/dist/packageVersion.cjs.map +0 -1
  70. package/dist/snapshotableArray.cjs.map +0 -1
  71. package/dist/testUtils.cjs.map +0 -1
  72. package/lib/consensusOrderedCollection.d.ts.map +0 -1
  73. package/lib/consensusOrderedCollectionFactory.d.ts.map +0 -1
  74. package/lib/consensusQueue.d.ts.map +0 -1
  75. package/lib/index.d.ts.map +0 -1
  76. package/lib/interfaces.d.ts.map +0 -1
  77. package/lib/ordered-collection-public.d.ts +0 -55
  78. package/lib/packageVersion.d.ts.map +0 -1
  79. package/lib/snapshotableArray.d.ts.map +0 -1
  80. package/lib/testUtils.d.ts.map +0 -1
  81. package/tsc-multi.test.json +0 -4
  82. /package/lib/{ordered-collection-alpha.d.ts → ordered-collection-beta.d.mts} +0 -0
@@ -5,7 +5,7 @@
5
5
  import { IFluidDataStoreRuntime, IChannelServices, IChannelAttributes, IChannelFactory } from "@fluidframework/datastore-definitions";
6
6
  import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
7
7
  /**
8
- * @internal
8
+ * @alpha
9
9
  */
10
10
  export declare enum ConsensusResult {
11
11
  Release = 0,
@@ -14,7 +14,7 @@ export declare enum ConsensusResult {
14
14
  /**
15
15
  * Callback provided to acquire() and waitAndAcquire() methods.
16
16
  * @returns ConsensusResult indicating whether item was completed, or releases back to the queue.
17
- * @internal
17
+ * @alpha
18
18
  */
19
19
  export type ConsensusCallback<T> = (value: T) => Promise<ConsensusResult>;
20
20
  /**
@@ -30,7 +30,7 @@ export interface IConsensusOrderedCollectionFactory extends IChannelFactory {
30
30
  }
31
31
  /**
32
32
  * Events notifying about addition, acquisition, release and completion of items
33
- * @internal
33
+ * @alpha
34
34
  */
35
35
  export interface IConsensusOrderedCollectionEvents<T> extends ISharedObjectEvents {
36
36
  /**
@@ -80,7 +80,7 @@ export interface IConsensusOrderedCollectionEvents<T> extends ISharedObjectEvent
80
80
  * All objects added to the collection will be cloned (via JSON).
81
81
  * They will not be references to the original input object. Thus changed to
82
82
  * the input object will not reflect the object in the collection.
83
- * @internal
83
+ * @alpha
84
84
  */
85
85
  export interface IConsensusOrderedCollection<T = any> extends ISharedObject<IConsensusOrderedCollectionEvents<T>> {
86
86
  /**
@@ -104,7 +104,7 @@ export interface IConsensusOrderedCollection<T = any> extends ISharedObject<ICon
104
104
  *
105
105
  * TODO: move this to be use in other place
106
106
  * TODO: currently input and output is not symmetrical, can they become symmetrical?
107
- * @internal
107
+ * @alpha
108
108
  */
109
109
  export interface ISnapshotable<T> {
110
110
  asArray(): T[];
@@ -116,7 +116,7 @@ export interface ISnapshotable<T> {
116
116
  * Collection of objects that has deterministic add and remove ordering.
117
117
  * Object implementing this interface can be used as the data backing
118
118
  * for the ConsensusOrderedCollection
119
- * @internal
119
+ * @alpha
120
120
  */
121
121
  export interface IOrderedCollection<T = any> extends ISnapshotable<T> {
122
122
  /**
@@ -132,4 +132,4 @@ export interface IOrderedCollection<T = any> extends ISnapshotable<T> {
132
132
  */
133
133
  size(): number;
134
134
  }
135
- //# sourceMappingURL=interfaces.d.ts.map
135
+ //# sourceMappingURL=interfaces.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.mts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EACN,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,MAAM,uCAAuC;OACvC,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oCAAoC;AAEvF;;GAEG;AACH,oBAAY,eAAe;IAC1B,OAAO,IAAA;IACP,QAAQ,IAAA;CACR;AAED;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;AAE1E;;;;;;GAMG;AACH,MAAM,WAAW,kCAAmC,SAAQ,eAAe;IAC1E,IAAI,CACH,QAAQ,EAAE,sBAAsB,EAChC,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAC5B,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAExC,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,2BAA2B,CAAC;CAClF;AAED;;;GAGG;AACH,MAAM,WAAW,iCAAiC,CAAC,CAAC,CAAE,SAAQ,mBAAmB;IAChF;;;;OAIG;IACH,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAAC;IACxE;;;OAGG;IACH,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAAC;IAE1E;;OAEG;IACH,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC;IAExD;;;;;;OAMG;IACH,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,WAAW,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAAC;CAClF;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,2BAA2B,CAAC,CAAC,GAAG,GAAG,CACnD,SAAQ,aAAa,CAAC,iCAAiC,CAAC,CAAC,CAAC,CAAC;IAC3D;;OAEG;IACH,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7B;;;;OAIG;IACH,OAAO,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE1D;;;OAGG;IACH,cAAc,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC;IAC/B,OAAO,IAAI,CAAC,EAAE,CAAC;IAEf,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;IACpE;;OAEG;IACH,GAAG,CAAC,KAAK,EAAE,CAAC,OAAE;IAEd;;OAEG;IACH,MAAM,IAAI,CAAC,CAAC;IAEZ;;OAEG;IACH,IAAI,IAAI,MAAM,CAAC;CACf"}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  /**
6
- * @internal
6
+ * @alpha
7
7
  */
8
8
  export var ConsensusResult;
9
9
  (function (ConsensusResult) {
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.mjs","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH;;GAEG;AACH,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IAC1B,2DAAO,CAAA;IACP,6DAAQ,CAAA;AACT,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B","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 * @internal\n */\nexport enum ConsensusResult {\n\tRelease,\n\tComplete,\n}\n\n/**\n * Callback provided to acquire() and waitAndAcquire() methods.\n * @returns ConsensusResult indicating whether item was completed, or releases back to the queue.\n * @internal\n */\nexport type ConsensusCallback<T> = (value: T) => Promise<ConsensusResult>;\n\n/**\n * Consensus Ordered Collection channel factory interface\n *\n * Extends the base IChannelFactory to return a more definite type of IConsensusOrderedCollection\n * Use for the runtime to create and load distributed data structure by type name of each channel\n * @internal\n */\nexport interface IConsensusOrderedCollectionFactory extends IChannelFactory {\n\tload(\n\t\tdocument: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes,\n\t): Promise<IConsensusOrderedCollection>;\n\n\tcreate(document: IFluidDataStoreRuntime, id: string): IConsensusOrderedCollection;\n}\n\n/**\n * Events notifying about addition, acquisition, release and completion of items\n * @internal\n */\nexport interface IConsensusOrderedCollectionEvents<T> extends ISharedObjectEvents {\n\t/**\n\t * Event fires when new item is added to the queue or\n\t * an item previously acquired is returned back to a queue (including client loosing connection)\n\t * @param newlyAdded - indicates if it's newly added item of previously acquired item\n\t */\n\t(event: \"add\", listener: (value: T, newlyAdded: boolean) => void): this;\n\t/**\n\t * Event fires when a client acquired an item\n\t * Fires both for locally acquired items, as well as items acquired by remote clients\n\t */\n\t(event: \"acquire\", listener: (value: T, clientId?: string) => void): this;\n\n\t/**\n\t * \"Complete event fires when a client completes an item.\n\t */\n\t(event: \"complete\", listener: (value: T) => void): this;\n\n\t/**\n\t * Event fires when locally acquired item is being released back to the queue.\n\t * Please note that release process is asynchronous, so it takes a while for it to happen\n\t * (\"add\" event will be fired as result of it)\n\t * @param intentional - indicates whether release was intentional (result of returning\n\t * ConsensusResult.Release from callback) or it happened as result of lost connection.\n\t */\n\t(event: \"localRelease\", listener: (value: T, intentional: boolean) => void): this;\n}\n\n/**\n * Consensus Ordered Collection interface\n *\n * An consensus ordered collection is a distributed data structure, which\n * holds a collection of JSON-able or handles, and has a\n * deterministic add/remove order.\n *\n * @remarks\n * The order the server receive the add/remove operation determines the\n * order those operation are applied to the collection. Different clients\n * issuing `add` or `acquire` operations at the same time will be sequenced.\n * The order dictates which `add` is done first, thus determining the order\n * in which it appears in the collection. It also determines which client\n * will get the first removed item, etc. All operations are asynchronous.\n * A function `waitAndAcquire` is provided to wait for and remove an entry in the collection.\n *\n * As a client acquires an item, it processes it and then returns a value (via callback)\n * indicating whether it has completed processing the item, or whether the item should be\n * released back to the collection for another client to process.\n *\n * All objects added to the collection will be cloned (via JSON).\n * They will not be references to the original input object. Thus changed to\n * the input object will not reflect the object in the collection.\n * @internal\n */\nexport interface IConsensusOrderedCollection<T = any>\n\textends ISharedObject<IConsensusOrderedCollectionEvents<T>> {\n\t/**\n\t * Adds a value to the collection\n\t */\n\tadd(value: T): Promise<void>;\n\n\t/**\n\t * Retrieves a value from the collection.\n\t * @returns Returns true (and calls callback with acquired value) if collection was not empty.\n\t * Otherwise returns false.\n\t */\n\tacquire(callback: ConsensusCallback<T>): Promise<boolean>;\n\n\t/**\n\t * Wait for a value to be available and remove it from the consensus collection\n\t * Calls callback with retrieved value.\n\t */\n\twaitAndAcquire(callback: ConsensusCallback<T>): Promise<void>;\n}\n\n/**\n * Interface for object that can be snapshoted\n *\n * TODO: move this to be use in other place\n * TODO: currently input and output is not symmetrical, can they become symmetrical?\n * @internal\n */\nexport interface ISnapshotable<T> {\n\tasArray(): T[];\n\n\tloadFrom(values: T[]): void;\n}\n\n/**\n * Ordered Collection interface\n *\n * Collection of objects that has deterministic add and remove ordering.\n * Object implementing this interface can be used as the data backing\n * for the ConsensusOrderedCollection\n * @internal\n */\nexport interface IOrderedCollection<T = any> extends ISnapshotable<T> {\n\t/**\n\t * Adds a value to the collection\n\t */\n\tadd(value: T);\n\n\t/**\n\t * Retrieves a value from the collection.\n\t */\n\tremove(): T;\n\n\t/**\n\t * Return the size of the collection\n\t */\n\tsize(): number;\n}\n"]}
1
+ {"version":3,"file":"interfaces.mjs","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH;;GAEG;AACH,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IAC1B,2DAAO,CAAA;IACP,6DAAQ,CAAA;AACT,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B","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 * @alpha\n */\nexport enum ConsensusResult {\n\tRelease,\n\tComplete,\n}\n\n/**\n * Callback provided to acquire() and waitAndAcquire() methods.\n * @returns ConsensusResult indicating whether item was completed, or releases back to the queue.\n * @alpha\n */\nexport type ConsensusCallback<T> = (value: T) => Promise<ConsensusResult>;\n\n/**\n * Consensus Ordered Collection channel factory interface\n *\n * Extends the base IChannelFactory to return a more definite type of IConsensusOrderedCollection\n * Use for the runtime to create and load distributed data structure by type name of each channel\n * @internal\n */\nexport interface IConsensusOrderedCollectionFactory extends IChannelFactory {\n\tload(\n\t\tdocument: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes,\n\t): Promise<IConsensusOrderedCollection>;\n\n\tcreate(document: IFluidDataStoreRuntime, id: string): IConsensusOrderedCollection;\n}\n\n/**\n * Events notifying about addition, acquisition, release and completion of items\n * @alpha\n */\nexport interface IConsensusOrderedCollectionEvents<T> extends ISharedObjectEvents {\n\t/**\n\t * Event fires when new item is added to the queue or\n\t * an item previously acquired is returned back to a queue (including client loosing connection)\n\t * @param newlyAdded - indicates if it's newly added item of previously acquired item\n\t */\n\t(event: \"add\", listener: (value: T, newlyAdded: boolean) => void): this;\n\t/**\n\t * Event fires when a client acquired an item\n\t * Fires both for locally acquired items, as well as items acquired by remote clients\n\t */\n\t(event: \"acquire\", listener: (value: T, clientId?: string) => void): this;\n\n\t/**\n\t * \"Complete event fires when a client completes an item.\n\t */\n\t(event: \"complete\", listener: (value: T) => void): this;\n\n\t/**\n\t * Event fires when locally acquired item is being released back to the queue.\n\t * Please note that release process is asynchronous, so it takes a while for it to happen\n\t * (\"add\" event will be fired as result of it)\n\t * @param intentional - indicates whether release was intentional (result of returning\n\t * ConsensusResult.Release from callback) or it happened as result of lost connection.\n\t */\n\t(event: \"localRelease\", listener: (value: T, intentional: boolean) => void): this;\n}\n\n/**\n * Consensus Ordered Collection interface\n *\n * An consensus ordered collection is a distributed data structure, which\n * holds a collection of JSON-able or handles, and has a\n * deterministic add/remove order.\n *\n * @remarks\n * The order the server receive the add/remove operation determines the\n * order those operation are applied to the collection. Different clients\n * issuing `add` or `acquire` operations at the same time will be sequenced.\n * The order dictates which `add` is done first, thus determining the order\n * in which it appears in the collection. It also determines which client\n * will get the first removed item, etc. All operations are asynchronous.\n * A function `waitAndAcquire` is provided to wait for and remove an entry in the collection.\n *\n * As a client acquires an item, it processes it and then returns a value (via callback)\n * indicating whether it has completed processing the item, or whether the item should be\n * released back to the collection for another client to process.\n *\n * All objects added to the collection will be cloned (via JSON).\n * They will not be references to the original input object. Thus changed to\n * the input object will not reflect the object in the collection.\n * @alpha\n */\nexport interface IConsensusOrderedCollection<T = any>\n\textends ISharedObject<IConsensusOrderedCollectionEvents<T>> {\n\t/**\n\t * Adds a value to the collection\n\t */\n\tadd(value: T): Promise<void>;\n\n\t/**\n\t * Retrieves a value from the collection.\n\t * @returns Returns true (and calls callback with acquired value) if collection was not empty.\n\t * Otherwise returns false.\n\t */\n\tacquire(callback: ConsensusCallback<T>): Promise<boolean>;\n\n\t/**\n\t * Wait for a value to be available and remove it from the consensus collection\n\t * Calls callback with retrieved value.\n\t */\n\twaitAndAcquire(callback: ConsensusCallback<T>): Promise<void>;\n}\n\n/**\n * Interface for object that can be snapshoted\n *\n * TODO: move this to be use in other place\n * TODO: currently input and output is not symmetrical, can they become symmetrical?\n * @alpha\n */\nexport interface ISnapshotable<T> {\n\tasArray(): T[];\n\n\tloadFrom(values: T[]): void;\n}\n\n/**\n * Ordered Collection interface\n *\n * Collection of objects that has deterministic add and remove ordering.\n * Object implementing this interface can be used as the data backing\n * for the ConsensusOrderedCollection\n * @alpha\n */\nexport interface IOrderedCollection<T = any> extends ISnapshotable<T> {\n\t/**\n\t * Adds a value to the collection\n\t */\n\tadd(value: T);\n\n\t/**\n\t * Retrieves a value from the collection.\n\t */\n\tremove(): T;\n\n\t/**\n\t * Return the size of the collection\n\t */\n\tsize(): number;\n}\n"]}
@@ -0,0 +1,226 @@
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: acquireAndComplete */
14
+
15
+ /**
16
+ * Callback provided to acquire() and waitAndAcquire() methods.
17
+ * @returns ConsensusResult indicating whether item was completed, or releases back to the queue.
18
+ * @alpha
19
+ */
20
+ export declare type ConsensusCallback<T> = (value: T) => Promise<ConsensusResult>;
21
+
22
+ /**
23
+ * Implementation of a consensus collection shared object
24
+ *
25
+ * Implements the shared object's communication, and the semantics around the
26
+ * release/complete mechanism following acquire.
27
+ *
28
+ * Generally not used directly. A derived type will pass in a backing data type
29
+ * IOrderedCollection that will define the deterministic add/acquire order and snapshot ability.
30
+ * @alpha
31
+ */
32
+ export declare class ConsensusOrderedCollection<T = any> extends SharedObject<IConsensusOrderedCollectionEvents<T>> implements IConsensusOrderedCollection<T> {
33
+ private readonly data;
34
+ /**
35
+ * The set of values that have been acquired but not yet completed or released
36
+ */
37
+ private jobTracking;
38
+ /**
39
+ * Constructs a new consensus collection. If the object is non-local an id and service interfaces will
40
+ * be provided
41
+ */
42
+ protected constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes, data: IOrderedCollection<T>);
43
+ /**
44
+ * Add a value to the consensus collection.
45
+ */
46
+ add(value: T): Promise<void>;
47
+ /**
48
+ * Remove a value from the consensus collection. If the collection is empty, returns false.
49
+ * Otherwise calls callback with the value
50
+ */
51
+ acquire(callback: ConsensusCallback<T>): Promise<boolean>;
52
+ /**
53
+ * Wait for a value to be available and acquire it from the consensus collection
54
+ */
55
+ waitAndAcquire(callback: ConsensusCallback<T>): Promise<void>;
56
+ protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
57
+ protected isActive(): boolean;
58
+ protected complete(acquireId: string): Promise<void>;
59
+ protected completeCore(acquireId: string): void;
60
+ protected release(acquireId: string): void;
61
+ protected releaseCore(acquireId: string): void;
62
+ /**
63
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
64
+ */
65
+ protected loadCore(storage: IChannelStorageService): Promise<void>;
66
+ protected onDisconnect(): void;
67
+ protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
68
+ private submit;
69
+ private addCore;
70
+ private acquireCore;
71
+ private acquireInternal;
72
+ private removeClient;
73
+ private serializeValue;
74
+ private deserializeValue;
75
+ protected applyStashedOp(): void;
76
+ }
77
+
78
+ /**
79
+ * Implementation of a consensus stack
80
+ *
81
+ * An derived type of ConsensusOrderedCollection with a queue as the backing data and order.
82
+ * @alpha
83
+ */
84
+ export declare class ConsensusQueue<T = any> extends ConsensusOrderedCollection<T> {
85
+ /**
86
+ * Create a new consensus queue
87
+ *
88
+ * @param runtime - data store runtime the new consensus queue belongs to
89
+ * @param id - optional name of theconsensus queue
90
+ * @returns newly create consensus queue (but not attached yet)
91
+ */
92
+ static create<T = any>(runtime: IFluidDataStoreRuntime, id?: string): ConsensusQueue<T>;
93
+ /**
94
+ * Get a factory for ConsensusQueue to register with the data store.
95
+ *
96
+ * @returns a factory that creates and load ConsensusQueue
97
+ */
98
+ static getFactory(): IChannelFactory;
99
+ /**
100
+ * Constructs a new consensus queue. If the object is non-local an id and service interfaces will
101
+ * be provided
102
+ */
103
+ constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
104
+ }
105
+
106
+ /**
107
+ * @alpha
108
+ */
109
+ export declare enum ConsensusResult {
110
+ Release = 0,
111
+ Complete = 1
112
+ }
113
+
114
+ /**
115
+ * Consensus Ordered Collection interface
116
+ *
117
+ * An consensus ordered collection is a distributed data structure, which
118
+ * holds a collection of JSON-able or handles, and has a
119
+ * deterministic add/remove order.
120
+ *
121
+ * @remarks
122
+ * The order the server receive the add/remove operation determines the
123
+ * order those operation are applied to the collection. Different clients
124
+ * issuing `add` or `acquire` operations at the same time will be sequenced.
125
+ * The order dictates which `add` is done first, thus determining the order
126
+ * in which it appears in the collection. It also determines which client
127
+ * will get the first removed item, etc. All operations are asynchronous.
128
+ * A function `waitAndAcquire` is provided to wait for and remove an entry in the collection.
129
+ *
130
+ * As a client acquires an item, it processes it and then returns a value (via callback)
131
+ * indicating whether it has completed processing the item, or whether the item should be
132
+ * released back to the collection for another client to process.
133
+ *
134
+ * All objects added to the collection will be cloned (via JSON).
135
+ * They will not be references to the original input object. Thus changed to
136
+ * the input object will not reflect the object in the collection.
137
+ * @alpha
138
+ */
139
+ export declare interface IConsensusOrderedCollection<T = any> extends ISharedObject<IConsensusOrderedCollectionEvents<T>> {
140
+ /**
141
+ * Adds a value to the collection
142
+ */
143
+ add(value: T): Promise<void>;
144
+ /**
145
+ * Retrieves a value from the collection.
146
+ * @returns Returns true (and calls callback with acquired value) if collection was not empty.
147
+ * Otherwise returns false.
148
+ */
149
+ acquire(callback: ConsensusCallback<T>): Promise<boolean>;
150
+ /**
151
+ * Wait for a value to be available and remove it from the consensus collection
152
+ * Calls callback with retrieved value.
153
+ */
154
+ waitAndAcquire(callback: ConsensusCallback<T>): Promise<void>;
155
+ }
156
+
157
+ /**
158
+ * Events notifying about addition, acquisition, release and completion of items
159
+ * @alpha
160
+ */
161
+ export declare interface IConsensusOrderedCollectionEvents<T> extends ISharedObjectEvents {
162
+ /**
163
+ * Event fires when new item is added to the queue or
164
+ * an item previously acquired is returned back to a queue (including client loosing connection)
165
+ * @param newlyAdded - indicates if it's newly added item of previously acquired item
166
+ */
167
+ (event: "add", listener: (value: T, newlyAdded: boolean) => void): this;
168
+ /**
169
+ * Event fires when a client acquired an item
170
+ * Fires both for locally acquired items, as well as items acquired by remote clients
171
+ */
172
+ (event: "acquire", listener: (value: T, clientId?: string) => void): this;
173
+ /**
174
+ * "Complete event fires when a client completes an item.
175
+ */
176
+ (event: "complete", listener: (value: T) => void): this;
177
+ /**
178
+ * Event fires when locally acquired item is being released back to the queue.
179
+ * Please note that release process is asynchronous, so it takes a while for it to happen
180
+ * ("add" event will be fired as result of it)
181
+ * @param intentional - indicates whether release was intentional (result of returning
182
+ * ConsensusResult.Release from callback) or it happened as result of lost connection.
183
+ */
184
+ (event: "localRelease", listener: (value: T, intentional: boolean) => void): this;
185
+ }
186
+
187
+ /* Excluded from this release type: IConsensusOrderedCollectionFactory */
188
+
189
+ /**
190
+ * Ordered Collection interface
191
+ *
192
+ * Collection of objects that has deterministic add and remove ordering.
193
+ * Object implementing this interface can be used as the data backing
194
+ * for the ConsensusOrderedCollection
195
+ * @alpha
196
+ */
197
+ export declare interface IOrderedCollection<T = any> extends ISnapshotable<T> {
198
+ /**
199
+ * Adds a value to the collection
200
+ */
201
+ add(value: T): any;
202
+ /**
203
+ * Retrieves a value from the collection.
204
+ */
205
+ remove(): T;
206
+ /**
207
+ * Return the size of the collection
208
+ */
209
+ size(): number;
210
+ }
211
+
212
+ /**
213
+ * Interface for object that can be snapshoted
214
+ *
215
+ * TODO: move this to be use in other place
216
+ * TODO: currently input and output is not symmetrical, can they become symmetrical?
217
+ * @alpha
218
+ */
219
+ export declare interface ISnapshotable<T> {
220
+ asArray(): T[];
221
+ loadFrom(values: T[]): void;
222
+ }
223
+
224
+ /* Excluded from this release type: waitAcquireAndComplete */
225
+
226
+ export { }
@@ -20,36 +20,16 @@ import { SharedObject } from '@fluidframework/shared-object-base';
20
20
 
21
21
  /* Excluded from this release type: ConsensusResult */
22
22
 
23
- /* Excluded from this release type: IChannelAttributes */
24
-
25
- /* Excluded from this release type: IChannelFactory */
26
-
27
- /* Excluded from this release type: IChannelServices */
28
-
29
- /* Excluded from this release type: IChannelStorageService */
30
-
31
23
  /* Excluded from this release type: IConsensusOrderedCollection */
32
24
 
33
25
  /* Excluded from this release type: IConsensusOrderedCollectionEvents */
34
26
 
35
27
  /* Excluded from this release type: IConsensusOrderedCollectionFactory */
36
28
 
37
- /* Excluded from this release type: IFluidDataStoreRuntime */
38
-
39
- /* Excluded from this release type: IFluidSerializer */
40
-
41
29
  /* Excluded from this release type: IOrderedCollection */
42
30
 
43
- /* Excluded from this release type: ISharedObject */
44
-
45
- /* Excluded from this release type: ISharedObjectEvents */
46
-
47
31
  /* Excluded from this release type: ISnapshotable */
48
32
 
49
- /* Excluded from this release type: ISummaryTreeWithStats */
50
-
51
- /* Excluded from this release type: SharedObject */
52
-
53
33
  /* Excluded from this release type: waitAcquireAndComplete */
54
34
 
55
35
  export { }
@@ -20,7 +20,7 @@ export declare function acquireAndComplete<T>(collection: IConsensusOrderedColle
20
20
  /**
21
21
  * Callback provided to acquire() and waitAndAcquire() methods.
22
22
  * @returns ConsensusResult indicating whether item was completed, or releases back to the queue.
23
- * @internal
23
+ * @alpha
24
24
  */
25
25
  export declare type ConsensusCallback<T> = (value: T) => Promise<ConsensusResult>;
26
26
 
@@ -32,7 +32,7 @@ export declare type ConsensusCallback<T> = (value: T) => Promise<ConsensusResult
32
32
  *
33
33
  * Generally not used directly. A derived type will pass in a backing data type
34
34
  * IOrderedCollection that will define the deterministic add/acquire order and snapshot ability.
35
- * @internal
35
+ * @alpha
36
36
  */
37
37
  export declare class ConsensusOrderedCollection<T = any> extends SharedObject<IConsensusOrderedCollectionEvents<T>> implements IConsensusOrderedCollection<T> {
38
38
  private readonly data;
@@ -84,7 +84,7 @@ export declare class ConsensusOrderedCollection<T = any> extends SharedObject<IC
84
84
  * Implementation of a consensus stack
85
85
  *
86
86
  * An derived type of ConsensusOrderedCollection with a queue as the backing data and order.
87
- * @internal
87
+ * @alpha
88
88
  */
89
89
  export declare class ConsensusQueue<T = any> extends ConsensusOrderedCollection<T> {
90
90
  /**
@@ -109,7 +109,7 @@ export declare class ConsensusQueue<T = any> extends ConsensusOrderedCollection<
109
109
  }
110
110
 
111
111
  /**
112
- * @internal
112
+ * @alpha
113
113
  */
114
114
  export declare enum ConsensusResult {
115
115
  Release = 0,
@@ -139,7 +139,7 @@ export declare enum ConsensusResult {
139
139
  * All objects added to the collection will be cloned (via JSON).
140
140
  * They will not be references to the original input object. Thus changed to
141
141
  * the input object will not reflect the object in the collection.
142
- * @internal
142
+ * @alpha
143
143
  */
144
144
  export declare interface IConsensusOrderedCollection<T = any> extends ISharedObject<IConsensusOrderedCollectionEvents<T>> {
145
145
  /**
@@ -161,7 +161,7 @@ export declare interface IConsensusOrderedCollection<T = any> extends ISharedObj
161
161
 
162
162
  /**
163
163
  * Events notifying about addition, acquisition, release and completion of items
164
- * @internal
164
+ * @alpha
165
165
  */
166
166
  export declare interface IConsensusOrderedCollectionEvents<T> extends ISharedObjectEvents {
167
167
  /**
@@ -207,7 +207,7 @@ export declare interface IConsensusOrderedCollectionFactory extends IChannelFact
207
207
  * Collection of objects that has deterministic add and remove ordering.
208
208
  * Object implementing this interface can be used as the data backing
209
209
  * for the ConsensusOrderedCollection
210
- * @internal
210
+ * @alpha
211
211
  */
212
212
  export declare interface IOrderedCollection<T = any> extends ISnapshotable<T> {
213
213
  /**
@@ -229,7 +229,7 @@ export declare interface IOrderedCollection<T = any> extends ISnapshotable<T> {
229
229
  *
230
230
  * TODO: move this to be use in other place
231
231
  * TODO: currently input and output is not symmetrical, can they become symmetrical?
232
- * @internal
232
+ * @alpha
233
233
  */
234
234
  export declare interface ISnapshotable<T> {
235
235
  asArray(): T[];
@@ -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-internal.8.0.1";
9
- //# sourceMappingURL=packageVersion.d.ts.map
8
+ export declare const pkgVersion = "2.0.0-rc.1.0.0";
9
+ //# sourceMappingURL=packageVersion.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packageVersion.d.mts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,uCAAuC,CAAC;AAC5D,eAAO,MAAM,UAAU,mBAAmB,CAAC"}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/ordered-collection";
8
- export const pkgVersion = "2.0.0-internal.8.0.1";
8
+ export const pkgVersion = "2.0.0-rc.1.0.0";
9
9
  //# sourceMappingURL=packageVersion.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.mjs","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,oCAAoC,CAAC;AAC5D,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/ordered-collection\";\nexport const pkgVersion = \"2.0.0-internal.8.0.1\";\n"]}
1
+ {"version":3,"file":"packageVersion.mjs","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,oCAAoC,CAAC;AAC5D,MAAM,CAAC,MAAM,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.0\";\n"]}
@@ -8,4 +8,4 @@ export declare class SnapshotableArray<T> extends Array {
8
8
  loadFrom(from: T[]): Promise<void>;
9
9
  size(): number;
10
10
  }
11
- //# sourceMappingURL=snapshotableArray.d.ts.map
11
+ //# sourceMappingURL=snapshotableArray.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshotableArray.d.mts","sourceRoot":"","sources":["../src/snapshotableArray.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,qBAAa,iBAAiB,CAAC,CAAC,CAAE,SAAQ,KAAK;IAC9C,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,CAAM;IAElB,OAAO;IAID,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAKxC,IAAI,IAAI,MAAM;CAGrB"}
@@ -15,4 +15,4 @@ export declare function acquireAndComplete<T>(collection: IConsensusOrderedColle
15
15
  * @internal
16
16
  */
17
17
  export declare function waitAcquireAndComplete<T>(collection: IConsensusOrderedCollection<T>): Promise<T>;
18
- //# sourceMappingURL=testUtils.d.ts.map
18
+ //# sourceMappingURL=testUtils.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testUtils.d.mts","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAmB,2BAA2B,EAAE;AAEvD;;;;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"}