@fluid-experimental/last-edited 2.0.0-dev.4.4.0.162574 → 2.0.0-dev.5.3.2.178189

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @fluid-experimental/last-edited
2
2
 
3
+ ## 2.0.0-internal.5.3.0
4
+
5
+ Dependency updates only.
6
+
7
+ ## 2.0.0-internal.5.2.0
8
+
9
+ Dependency updates only.
10
+
11
+ ## 2.0.0-internal.5.1.0
12
+
13
+ Dependency updates only.
14
+
15
+ ## 2.0.0-internal.5.0.0
16
+
17
+ Dependency updates only.
18
+
19
+ ## 2.0.0-internal.4.4.0
20
+
21
+ Dependency updates only.
22
+
3
23
  ## 2.0.0-internal.4.1.0
4
24
 
5
25
  Dependency updates only.
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAkB,MAAM,sCAAsC,CAAC;AAEjG,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAoB,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAkCzE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kCAAkC,CACjD,iBAAiB,EAAE,uBAAuB,EAC1C,OAAO,EAAE,iBAAiB,EAC1B,sBAAsB,GAAE,CACvB,OAAO,EAAE,yBAAyB,KAC9B,OAAqC,GACxC,IAAI,CAkBN"}
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAkB,MAAM,sCAAsC,CAAC;AAEjG,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAoB,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAoCzE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kCAAkC,CACjD,iBAAiB,EAAE,uBAAuB,EAC1C,OAAO,EAAE,iBAAiB,EAC1B,sBAAsB,GAAE,CACvB,OAAO,EAAE,yBAAyB,KAC9B,OAAqC,GACxC,IAAI,CAkBN"}
package/dist/setup.js CHANGED
@@ -21,6 +21,8 @@ const shouldDiscardMessageDefault = (message) => message.type !== container_runt
21
21
  * client who sent the message doesn't exist in the quorum.
22
22
  */
23
23
  function getLastEditDetailsFromMessage(message, quorum) {
24
+ // TODO: Verify whether this should be able to handle server-generated ops (with null clientId)
25
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
24
26
  const sequencedClient = quorum.getMember(message.clientId);
25
27
  const user = sequencedClient === null || sequencedClient === void 0 ? void 0 : sequencedClient.client.user;
26
28
  if (user !== undefined) {
package/dist/setup.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,yEAAyE;AAIzE;;;;;;GAMG;AACH,MAAM,2BAA2B,GAAG,CAAC,OAAkC,EAAW,EAAE,CACnF,OAAO,CAAC,IAAI,KAAK,wCAAoB,CAAC,MAAM;IAC5C,OAAO,CAAC,IAAI,KAAK,wCAAoB,CAAC,gBAAgB;IACtD,OAAO,CAAC,IAAI,KAAK,wCAAoB,CAAC,KAAK,CAAC;AAE7C;;;GAGG;AACH,SAAS,6BAA6B,CACrC,OAAkC,EAClC,MAAsB;IAEtB,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3D,MAAM,IAAI,GAAG,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,MAAM,CAAC,IAAI,CAAC;IAC1C,IAAI,IAAI,KAAK,SAAS,EAAE;QACvB,MAAM,eAAe,GAAqB;YACzC,IAAI;YACJ,SAAS,EAAE,OAAO,CAAC,SAAS;SAC5B,CAAC;QACF,OAAO,eAAe,CAAC;KACvB;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,kCAAkC,CACjD,iBAA0C,EAC1C,OAA0B,EAC1B,yBAEe,2BAA2B;IAE1C,+EAA+E;IAC/E,+CAA+C;IAC/C,8GAA8G;IAC9G,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,OAAkC,EAAE,cAAwB,EAAE,EAAE;QACjF,6EAA6E;QAC7E,IAAI,cAAc,KAAK,KAAK,IAAI,sBAAsB,CAAC,OAAO,CAAC,EAAE;YAChE,OAAO;SACP;QAED,6EAA6E;QAC7E,MAAM,eAAe,GAAG,6BAA6B,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;QACpF,IAAI,eAAe,KAAK,SAAS,EAAE;YAClC,OAAO;SACP;QAED,iBAAiB,CAAC,qBAAqB,CAAC,eAAe,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACJ,CAAC;AAxBD,gFAwBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISequencedDocumentMessage, IQuorumClients } from \"@fluidframework/protocol-definitions\";\nimport { ContainerMessageType } from \"@fluidframework/container-runtime\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { ILastEditDetails, IFluidLastEditedTracker } from \"./interfaces\";\n\n/**\n * Default implementation of {@link setupLastEditedTrackerForContainer}'s `shouldDiscardMessageFn` parameter,\n * which tells that all messages other than {@link @fluidframework/container-runtime#ContainerMessageType.Alias},\n * {@link @fluidframework/container-runtime#ContainerMessageType.Attach}, and\n * {@link @fluidframework/container-runtime#ContainerMessageType.FluidDataStoreOp} type messages should be\n * discarded.\n */\nconst shouldDiscardMessageDefault = (message: ISequencedDocumentMessage): boolean =>\n\tmessage.type !== ContainerMessageType.Attach &&\n\tmessage.type !== ContainerMessageType.FluidDataStoreOp &&\n\tmessage.type !== ContainerMessageType.Alias;\n\n/**\n * Extracts the user information and timestamp from a message. Returns undefined if the user information for the\n * client who sent the message doesn't exist in the quorum.\n */\nfunction getLastEditDetailsFromMessage(\n\tmessage: ISequencedDocumentMessage,\n\tquorum: IQuorumClients,\n): ILastEditDetails | undefined {\n\tconst sequencedClient = quorum.getMember(message.clientId);\n\tconst user = sequencedClient?.client.user;\n\tif (user !== undefined) {\n\t\tconst lastEditDetails: ILastEditDetails = {\n\t\t\tuser,\n\t\t\ttimestamp: message.timestamp,\n\t\t};\n\t\treturn lastEditDetails;\n\t}\n\treturn undefined;\n}\n\n/**\n * Helper function to set up a data object that provides IFluidLastEditedTracker to track last edited in a Container.\n *\n * It does the following:\n *\n * - Registers an \"op\" listener on the runtime. On each message, it calls the shouldDiscardMessageFn to check\n * if the message should be discarded. It also discards all scheduler message. If a message is not discarded,\n * it passes the last edited information from the message to the last edited tracker.\n *\n * - The last edited information from the last message received before the lastEditedTracker is\n * loaded is stored and passed to the tracker once it loads.\n * @param lastEditedTracker - The last edited tracker.\n * @param runtime - The container runtime whose messages are to be tracked.\n * @param shouldDiscardMessageFn - Function that tells if a message should not be considered in computing last edited.\n */\nexport function setupLastEditedTrackerForContainer(\n\tlastEditedTracker: IFluidLastEditedTracker,\n\truntime: IContainerRuntime,\n\tshouldDiscardMessageFn: (\n\t\tmessage: ISequencedDocumentMessage,\n\t) => boolean = shouldDiscardMessageDefault,\n): void {\n\t// Register an op listener on the runtime. If the lastEditedTracker has loaded,\n\t// it passes the last edited information to its\n\t// last edited tracker. If the lastEditedTracker hasn't loaded, store the last edited information temporarily.\n\truntime.on(\"op\", (message: ISequencedDocumentMessage, runtimeMessage?: boolean) => {\n\t\t// If this message should be discarded as per shouldDiscardMessageFn, return.\n\t\tif (runtimeMessage === false || shouldDiscardMessageFn(message)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Get the last edited details from the message. If it doesn't exist, return.\n\t\tconst lastEditDetails = getLastEditDetailsFromMessage(message, runtime.getQuorum());\n\t\tif (lastEditDetails === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tlastEditedTracker.updateLastEditDetails(lastEditDetails);\n\t});\n}\n"]}
1
+ {"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,yEAAyE;AAIzE;;;;;;GAMG;AACH,MAAM,2BAA2B,GAAG,CAAC,OAAkC,EAAW,EAAE,CACnF,OAAO,CAAC,IAAI,KAAK,wCAAoB,CAAC,MAAM;IAC5C,OAAO,CAAC,IAAI,KAAK,wCAAoB,CAAC,gBAAgB;IACtD,OAAO,CAAC,IAAI,KAAK,wCAAoB,CAAC,KAAK,CAAC;AAE7C;;;GAGG;AACH,SAAS,6BAA6B,CACrC,OAAkC,EAClC,MAAsB;IAEtB,+FAA+F;IAC/F,4EAA4E;IAC5E,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,QAAkB,CAAC,CAAC;IACrE,MAAM,IAAI,GAAG,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,MAAM,CAAC,IAAI,CAAC;IAC1C,IAAI,IAAI,KAAK,SAAS,EAAE;QACvB,MAAM,eAAe,GAAqB;YACzC,IAAI;YACJ,SAAS,EAAE,OAAO,CAAC,SAAS;SAC5B,CAAC;QACF,OAAO,eAAe,CAAC;KACvB;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,kCAAkC,CACjD,iBAA0C,EAC1C,OAA0B,EAC1B,yBAEe,2BAA2B;IAE1C,+EAA+E;IAC/E,+CAA+C;IAC/C,8GAA8G;IAC9G,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,OAAkC,EAAE,cAAwB,EAAE,EAAE;QACjF,6EAA6E;QAC7E,IAAI,cAAc,KAAK,KAAK,IAAI,sBAAsB,CAAC,OAAO,CAAC,EAAE;YAChE,OAAO;SACP;QAED,6EAA6E;QAC7E,MAAM,eAAe,GAAG,6BAA6B,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;QACpF,IAAI,eAAe,KAAK,SAAS,EAAE;YAClC,OAAO;SACP;QAED,iBAAiB,CAAC,qBAAqB,CAAC,eAAe,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACJ,CAAC;AAxBD,gFAwBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISequencedDocumentMessage, IQuorumClients } from \"@fluidframework/protocol-definitions\";\nimport { ContainerMessageType } from \"@fluidframework/container-runtime\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { ILastEditDetails, IFluidLastEditedTracker } from \"./interfaces\";\n\n/**\n * Default implementation of {@link setupLastEditedTrackerForContainer}'s `shouldDiscardMessageFn` parameter,\n * which tells that all messages other than {@link @fluidframework/container-runtime#ContainerMessageType.Alias},\n * {@link @fluidframework/container-runtime#ContainerMessageType.Attach}, and\n * {@link @fluidframework/container-runtime#ContainerMessageType.FluidDataStoreOp} type messages should be\n * discarded.\n */\nconst shouldDiscardMessageDefault = (message: ISequencedDocumentMessage): boolean =>\n\tmessage.type !== ContainerMessageType.Attach &&\n\tmessage.type !== ContainerMessageType.FluidDataStoreOp &&\n\tmessage.type !== ContainerMessageType.Alias;\n\n/**\n * Extracts the user information and timestamp from a message. Returns undefined if the user information for the\n * client who sent the message doesn't exist in the quorum.\n */\nfunction getLastEditDetailsFromMessage(\n\tmessage: ISequencedDocumentMessage,\n\tquorum: IQuorumClients,\n): ILastEditDetails | undefined {\n\t// TODO: Verify whether this should be able to handle server-generated ops (with null clientId)\n\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n\tconst sequencedClient = quorum.getMember(message.clientId as string);\n\tconst user = sequencedClient?.client.user;\n\tif (user !== undefined) {\n\t\tconst lastEditDetails: ILastEditDetails = {\n\t\t\tuser,\n\t\t\ttimestamp: message.timestamp,\n\t\t};\n\t\treturn lastEditDetails;\n\t}\n\treturn undefined;\n}\n\n/**\n * Helper function to set up a data object that provides IFluidLastEditedTracker to track last edited in a Container.\n *\n * It does the following:\n *\n * - Registers an \"op\" listener on the runtime. On each message, it calls the shouldDiscardMessageFn to check\n * if the message should be discarded. It also discards all scheduler message. If a message is not discarded,\n * it passes the last edited information from the message to the last edited tracker.\n *\n * - The last edited information from the last message received before the lastEditedTracker is\n * loaded is stored and passed to the tracker once it loads.\n * @param lastEditedTracker - The last edited tracker.\n * @param runtime - The container runtime whose messages are to be tracked.\n * @param shouldDiscardMessageFn - Function that tells if a message should not be considered in computing last edited.\n */\nexport function setupLastEditedTrackerForContainer(\n\tlastEditedTracker: IFluidLastEditedTracker,\n\truntime: IContainerRuntime,\n\tshouldDiscardMessageFn: (\n\t\tmessage: ISequencedDocumentMessage,\n\t) => boolean = shouldDiscardMessageDefault,\n): void {\n\t// Register an op listener on the runtime. If the lastEditedTracker has loaded,\n\t// it passes the last edited information to its\n\t// last edited tracker. If the lastEditedTracker hasn't loaded, store the last edited information temporarily.\n\truntime.on(\"op\", (message: ISequencedDocumentMessage, runtimeMessage?: boolean) => {\n\t\t// If this message should be discarded as per shouldDiscardMessageFn, return.\n\t\tif (runtimeMessage === false || shouldDiscardMessageFn(message)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Get the last edited details from the message. If it doesn't exist, return.\n\t\tconst lastEditDetails = getLastEditDetailsFromMessage(message, runtime.getQuorum());\n\t\tif (lastEditDetails === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tlastEditedTracker.updateLastEditDetails(lastEditDetails);\n\t});\n}\n"]}
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.34.9"
9
+ }
10
+ ]
11
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAkB,MAAM,sCAAsC,CAAC;AAEjG,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAoB,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAkCzE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kCAAkC,CACjD,iBAAiB,EAAE,uBAAuB,EAC1C,OAAO,EAAE,iBAAiB,EAC1B,sBAAsB,GAAE,CACvB,OAAO,EAAE,yBAAyB,KAC9B,OAAqC,GACxC,IAAI,CAkBN"}
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAkB,MAAM,sCAAsC,CAAC;AAEjG,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAoB,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAoCzE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kCAAkC,CACjD,iBAAiB,EAAE,uBAAuB,EAC1C,OAAO,EAAE,iBAAiB,EAC1B,sBAAsB,GAAE,CACvB,OAAO,EAAE,yBAAyB,KAC9B,OAAqC,GACxC,IAAI,CAkBN"}
package/lib/setup.js CHANGED
@@ -18,6 +18,8 @@ const shouldDiscardMessageDefault = (message) => message.type !== ContainerMessa
18
18
  * client who sent the message doesn't exist in the quorum.
19
19
  */
20
20
  function getLastEditDetailsFromMessage(message, quorum) {
21
+ // TODO: Verify whether this should be able to handle server-generated ops (with null clientId)
22
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
21
23
  const sequencedClient = quorum.getMember(message.clientId);
22
24
  const user = sequencedClient === null || sequencedClient === void 0 ? void 0 : sequencedClient.client.user;
23
25
  if (user !== undefined) {
package/lib/setup.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAIzE;;;;;;GAMG;AACH,MAAM,2BAA2B,GAAG,CAAC,OAAkC,EAAW,EAAE,CACnF,OAAO,CAAC,IAAI,KAAK,oBAAoB,CAAC,MAAM;IAC5C,OAAO,CAAC,IAAI,KAAK,oBAAoB,CAAC,gBAAgB;IACtD,OAAO,CAAC,IAAI,KAAK,oBAAoB,CAAC,KAAK,CAAC;AAE7C;;;GAGG;AACH,SAAS,6BAA6B,CACrC,OAAkC,EAClC,MAAsB;IAEtB,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3D,MAAM,IAAI,GAAG,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,MAAM,CAAC,IAAI,CAAC;IAC1C,IAAI,IAAI,KAAK,SAAS,EAAE;QACvB,MAAM,eAAe,GAAqB;YACzC,IAAI;YACJ,SAAS,EAAE,OAAO,CAAC,SAAS;SAC5B,CAAC;QACF,OAAO,eAAe,CAAC;KACvB;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,kCAAkC,CACjD,iBAA0C,EAC1C,OAA0B,EAC1B,yBAEe,2BAA2B;IAE1C,+EAA+E;IAC/E,+CAA+C;IAC/C,8GAA8G;IAC9G,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,OAAkC,EAAE,cAAwB,EAAE,EAAE;QACjF,6EAA6E;QAC7E,IAAI,cAAc,KAAK,KAAK,IAAI,sBAAsB,CAAC,OAAO,CAAC,EAAE;YAChE,OAAO;SACP;QAED,6EAA6E;QAC7E,MAAM,eAAe,GAAG,6BAA6B,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;QACpF,IAAI,eAAe,KAAK,SAAS,EAAE;YAClC,OAAO;SACP;QAED,iBAAiB,CAAC,qBAAqB,CAAC,eAAe,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISequencedDocumentMessage, IQuorumClients } from \"@fluidframework/protocol-definitions\";\nimport { ContainerMessageType } from \"@fluidframework/container-runtime\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { ILastEditDetails, IFluidLastEditedTracker } from \"./interfaces\";\n\n/**\n * Default implementation of {@link setupLastEditedTrackerForContainer}'s `shouldDiscardMessageFn` parameter,\n * which tells that all messages other than {@link @fluidframework/container-runtime#ContainerMessageType.Alias},\n * {@link @fluidframework/container-runtime#ContainerMessageType.Attach}, and\n * {@link @fluidframework/container-runtime#ContainerMessageType.FluidDataStoreOp} type messages should be\n * discarded.\n */\nconst shouldDiscardMessageDefault = (message: ISequencedDocumentMessage): boolean =>\n\tmessage.type !== ContainerMessageType.Attach &&\n\tmessage.type !== ContainerMessageType.FluidDataStoreOp &&\n\tmessage.type !== ContainerMessageType.Alias;\n\n/**\n * Extracts the user information and timestamp from a message. Returns undefined if the user information for the\n * client who sent the message doesn't exist in the quorum.\n */\nfunction getLastEditDetailsFromMessage(\n\tmessage: ISequencedDocumentMessage,\n\tquorum: IQuorumClients,\n): ILastEditDetails | undefined {\n\tconst sequencedClient = quorum.getMember(message.clientId);\n\tconst user = sequencedClient?.client.user;\n\tif (user !== undefined) {\n\t\tconst lastEditDetails: ILastEditDetails = {\n\t\t\tuser,\n\t\t\ttimestamp: message.timestamp,\n\t\t};\n\t\treturn lastEditDetails;\n\t}\n\treturn undefined;\n}\n\n/**\n * Helper function to set up a data object that provides IFluidLastEditedTracker to track last edited in a Container.\n *\n * It does the following:\n *\n * - Registers an \"op\" listener on the runtime. On each message, it calls the shouldDiscardMessageFn to check\n * if the message should be discarded. It also discards all scheduler message. If a message is not discarded,\n * it passes the last edited information from the message to the last edited tracker.\n *\n * - The last edited information from the last message received before the lastEditedTracker is\n * loaded is stored and passed to the tracker once it loads.\n * @param lastEditedTracker - The last edited tracker.\n * @param runtime - The container runtime whose messages are to be tracked.\n * @param shouldDiscardMessageFn - Function that tells if a message should not be considered in computing last edited.\n */\nexport function setupLastEditedTrackerForContainer(\n\tlastEditedTracker: IFluidLastEditedTracker,\n\truntime: IContainerRuntime,\n\tshouldDiscardMessageFn: (\n\t\tmessage: ISequencedDocumentMessage,\n\t) => boolean = shouldDiscardMessageDefault,\n): void {\n\t// Register an op listener on the runtime. If the lastEditedTracker has loaded,\n\t// it passes the last edited information to its\n\t// last edited tracker. If the lastEditedTracker hasn't loaded, store the last edited information temporarily.\n\truntime.on(\"op\", (message: ISequencedDocumentMessage, runtimeMessage?: boolean) => {\n\t\t// If this message should be discarded as per shouldDiscardMessageFn, return.\n\t\tif (runtimeMessage === false || shouldDiscardMessageFn(message)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Get the last edited details from the message. If it doesn't exist, return.\n\t\tconst lastEditDetails = getLastEditDetailsFromMessage(message, runtime.getQuorum());\n\t\tif (lastEditDetails === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tlastEditedTracker.updateLastEditDetails(lastEditDetails);\n\t});\n}\n"]}
1
+ {"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAIzE;;;;;;GAMG;AACH,MAAM,2BAA2B,GAAG,CAAC,OAAkC,EAAW,EAAE,CACnF,OAAO,CAAC,IAAI,KAAK,oBAAoB,CAAC,MAAM;IAC5C,OAAO,CAAC,IAAI,KAAK,oBAAoB,CAAC,gBAAgB;IACtD,OAAO,CAAC,IAAI,KAAK,oBAAoB,CAAC,KAAK,CAAC;AAE7C;;;GAGG;AACH,SAAS,6BAA6B,CACrC,OAAkC,EAClC,MAAsB;IAEtB,+FAA+F;IAC/F,4EAA4E;IAC5E,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,QAAkB,CAAC,CAAC;IACrE,MAAM,IAAI,GAAG,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,MAAM,CAAC,IAAI,CAAC;IAC1C,IAAI,IAAI,KAAK,SAAS,EAAE;QACvB,MAAM,eAAe,GAAqB;YACzC,IAAI;YACJ,SAAS,EAAE,OAAO,CAAC,SAAS;SAC5B,CAAC;QACF,OAAO,eAAe,CAAC;KACvB;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,kCAAkC,CACjD,iBAA0C,EAC1C,OAA0B,EAC1B,yBAEe,2BAA2B;IAE1C,+EAA+E;IAC/E,+CAA+C;IAC/C,8GAA8G;IAC9G,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,OAAkC,EAAE,cAAwB,EAAE,EAAE;QACjF,6EAA6E;QAC7E,IAAI,cAAc,KAAK,KAAK,IAAI,sBAAsB,CAAC,OAAO,CAAC,EAAE;YAChE,OAAO;SACP;QAED,6EAA6E;QAC7E,MAAM,eAAe,GAAG,6BAA6B,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;QACpF,IAAI,eAAe,KAAK,SAAS,EAAE;YAClC,OAAO;SACP;QAED,iBAAiB,CAAC,qBAAqB,CAAC,eAAe,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISequencedDocumentMessage, IQuorumClients } from \"@fluidframework/protocol-definitions\";\nimport { ContainerMessageType } from \"@fluidframework/container-runtime\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { ILastEditDetails, IFluidLastEditedTracker } from \"./interfaces\";\n\n/**\n * Default implementation of {@link setupLastEditedTrackerForContainer}'s `shouldDiscardMessageFn` parameter,\n * which tells that all messages other than {@link @fluidframework/container-runtime#ContainerMessageType.Alias},\n * {@link @fluidframework/container-runtime#ContainerMessageType.Attach}, and\n * {@link @fluidframework/container-runtime#ContainerMessageType.FluidDataStoreOp} type messages should be\n * discarded.\n */\nconst shouldDiscardMessageDefault = (message: ISequencedDocumentMessage): boolean =>\n\tmessage.type !== ContainerMessageType.Attach &&\n\tmessage.type !== ContainerMessageType.FluidDataStoreOp &&\n\tmessage.type !== ContainerMessageType.Alias;\n\n/**\n * Extracts the user information and timestamp from a message. Returns undefined if the user information for the\n * client who sent the message doesn't exist in the quorum.\n */\nfunction getLastEditDetailsFromMessage(\n\tmessage: ISequencedDocumentMessage,\n\tquorum: IQuorumClients,\n): ILastEditDetails | undefined {\n\t// TODO: Verify whether this should be able to handle server-generated ops (with null clientId)\n\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n\tconst sequencedClient = quorum.getMember(message.clientId as string);\n\tconst user = sequencedClient?.client.user;\n\tif (user !== undefined) {\n\t\tconst lastEditDetails: ILastEditDetails = {\n\t\t\tuser,\n\t\t\ttimestamp: message.timestamp,\n\t\t};\n\t\treturn lastEditDetails;\n\t}\n\treturn undefined;\n}\n\n/**\n * Helper function to set up a data object that provides IFluidLastEditedTracker to track last edited in a Container.\n *\n * It does the following:\n *\n * - Registers an \"op\" listener on the runtime. On each message, it calls the shouldDiscardMessageFn to check\n * if the message should be discarded. It also discards all scheduler message. If a message is not discarded,\n * it passes the last edited information from the message to the last edited tracker.\n *\n * - The last edited information from the last message received before the lastEditedTracker is\n * loaded is stored and passed to the tracker once it loads.\n * @param lastEditedTracker - The last edited tracker.\n * @param runtime - The container runtime whose messages are to be tracked.\n * @param shouldDiscardMessageFn - Function that tells if a message should not be considered in computing last edited.\n */\nexport function setupLastEditedTrackerForContainer(\n\tlastEditedTracker: IFluidLastEditedTracker,\n\truntime: IContainerRuntime,\n\tshouldDiscardMessageFn: (\n\t\tmessage: ISequencedDocumentMessage,\n\t) => boolean = shouldDiscardMessageDefault,\n): void {\n\t// Register an op listener on the runtime. If the lastEditedTracker has loaded,\n\t// it passes the last edited information to its\n\t// last edited tracker. If the lastEditedTracker hasn't loaded, store the last edited information temporarily.\n\truntime.on(\"op\", (message: ISequencedDocumentMessage, runtimeMessage?: boolean) => {\n\t\t// If this message should be discarded as per shouldDiscardMessageFn, return.\n\t\tif (runtimeMessage === false || shouldDiscardMessageFn(message)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Get the last edited details from the message. If it doesn't exist, return.\n\t\tconst lastEditDetails = getLastEditDetailsFromMessage(message, runtime.getQuorum());\n\t\tif (lastEditDetails === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tlastEditedTracker.updateLastEditDetails(lastEditDetails);\n\t});\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-experimental/last-edited",
3
- "version": "2.0.0-dev.4.4.0.162574",
3
+ "version": "2.0.0-dev.5.3.2.178189",
4
4
  "description": "Tracks the last edited information in the Container.",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -35,19 +35,21 @@
35
35
  "temp-directory": "nyc/.nyc_output"
36
36
  },
37
37
  "dependencies": {
38
- "@fluidframework/aqueduct": "2.0.0-dev.4.4.0.162574",
38
+ "@fluidframework/aqueduct": "2.0.0-dev.5.3.2.178189",
39
39
  "@fluidframework/common-definitions": "^0.20.1",
40
- "@fluidframework/container-runtime": "2.0.0-dev.4.4.0.162574",
41
- "@fluidframework/container-runtime-definitions": "2.0.0-dev.4.4.0.162574",
42
- "@fluidframework/core-interfaces": "2.0.0-dev.4.4.0.162574",
40
+ "@fluidframework/container-runtime": "2.0.0-dev.5.3.2.178189",
41
+ "@fluidframework/container-runtime-definitions": "2.0.0-dev.5.3.2.178189",
42
+ "@fluidframework/core-interfaces": "2.0.0-dev.5.3.2.178189",
43
43
  "@fluidframework/protocol-definitions": "^1.1.0",
44
- "@fluidframework/runtime-utils": "2.0.0-dev.4.4.0.162574",
45
- "@fluidframework/shared-summary-block": "2.0.0-dev.4.4.0.162574"
44
+ "@fluidframework/runtime-utils": "2.0.0-dev.5.3.2.178189",
45
+ "@fluidframework/shared-summary-block": "2.0.0-dev.5.3.2.178189"
46
46
  },
47
47
  "devDependencies": {
48
- "@fluid-tools/build-cli": "^0.17.0",
49
- "@fluidframework/build-common": "^1.1.0",
48
+ "@fluid-tools/build-cli": "^0.21.0",
49
+ "@fluidframework/build-common": "^1.2.0",
50
+ "@fluidframework/build-tools": "^0.21.0",
50
51
  "@fluidframework/eslint-config-fluid": "^2.0.0",
52
+ "@fluidframework/mocha-test-setup": "2.0.0-dev.5.3.2.178189",
51
53
  "@microsoft/api-extractor": "^7.34.4",
52
54
  "@types/mocha": "^9.1.1",
53
55
  "@types/node": "^14.18.38",
@@ -65,13 +67,11 @@
65
67
  "broken": {}
66
68
  },
67
69
  "scripts": {
68
- "build": "concurrently npm:build:compile npm:lint && npm run build:docs",
69
- "build:compile": "concurrently npm:tsc npm:build:esnext",
70
+ "build": "fluid-build . --task build",
71
+ "build:compile": "fluid-build . --task compile",
70
72
  "build:compile:min": "npm run build:compile",
71
73
  "build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
72
74
  "build:esnext": "tsc --project ./tsconfig.esnext.json",
73
- "build:full": "npm run build",
74
- "build:full:compile": "npm run build:compile",
75
75
  "ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
76
76
  "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
77
77
  "eslint": "eslint --format stylish src",
package/src/setup.ts CHANGED
@@ -28,7 +28,9 @@ function getLastEditDetailsFromMessage(
28
28
  message: ISequencedDocumentMessage,
29
29
  quorum: IQuorumClients,
30
30
  ): ILastEditDetails | undefined {
31
- const sequencedClient = quorum.getMember(message.clientId);
31
+ // TODO: Verify whether this should be able to handle server-generated ops (with null clientId)
32
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
33
+ const sequencedClient = quorum.getMember(message.clientId as string);
32
34
  const user = sequencedClient?.client.user;
33
35
  if (user !== undefined) {
34
36
  const lastEditDetails: ILastEditDetails = {