@fluid-tools/fetch-tool 2.115.0 → 2.116.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @fluid-tools/fetch-tool
2
2
 
3
+ ## 2.116.0
4
+
5
+ Dependency updates only.
6
+
3
7
  ## 2.115.0
4
8
 
5
9
  Dependency updates only.
package/README.md CHANGED
@@ -163,7 +163,7 @@ There are many ways to [contribute](https://github.com/microsoft/FluidFramework/
163
163
  - Review the [source code changes](https://github.com/microsoft/FluidFramework/pulls).
164
164
  - [Contribute bug fixes](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md).
165
165
 
166
- Detailed instructions for working in the repo can be found in the [Wiki](https://github.com/microsoft/FluidFramework/wiki).
166
+ Detailed instructions for working in the repo can be found in the [Wiki](https://github.com/microsoft/FluidFramework/blob/main/docs/content/Home.md).
167
167
 
168
168
  This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
169
169
  For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
@@ -174,9 +174,11 @@ Use of Microsoft trademarks or logos in modified versions of this project must n
174
174
 
175
175
  ## Help
176
176
 
177
- Not finding what you're looking for in this README? Check out [fluidframework.com](https://fluidframework.com/docs/).
177
+ Not finding what you're looking for in this README?
178
+ Check out [fluidframework.com](https://fluidframework.com/docs/).
178
179
 
179
- Still not finding what you're looking for? Please [file an issue](https://github.com/microsoft/FluidFramework/wiki/Submitting-Bugs-and-Feature-Requests).
180
+ Still not finding what you're looking for?
181
+ Please [file an issue](https://github.com/microsoft/FluidFramework/blob/main/docs/content/Contributing/Submitting-Bugs-and-Feature-Requests.md).
180
182
 
181
183
  Thank you!
182
184
 
@@ -1 +1 @@
1
- {"version":3,"file":"fluidFetchMessages.d.ts","sourceRoot":"","sources":["../src/fluidFetchMessages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EACN,KAAK,gBAAgB,EAIrB,MAAM,6CAA6C,CAAC;AAgRrD,wBAAsB,kBAAkB,CACvC,eAAe,CAAC,EAAE,gBAAgB,EAClC,OAAO,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAiCf"}
1
+ {"version":3,"file":"fluidFetchMessages.d.ts","sourceRoot":"","sources":["../src/fluidFetchMessages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EACN,KAAK,gBAAgB,EAIrB,MAAM,6CAA6C,CAAC;AAgRrD,wBAAsB,kBAAkB,CACvC,eAAe,CAAC,EAAE,gBAAgB,EAClC,OAAO,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAgCf"}
@@ -233,9 +233,8 @@ async function fluidFetchMessages(documentService, saveDir) {
233
233
  return (0, fluidAnalyzeMessages_js_1.printMessageStats)(generator, fluidFetchArgs_js_1.dumpMessageStats, fluidFetchArgs_js_1.dumpMessages, fluidFetchArgs_js_1.messageTypeFilter);
234
234
  }
235
235
  else {
236
- let item;
237
- // eslint-disable-next-line no-empty -- TODO: Investigate / document what is going on here.
238
- for await (item of generator) {
236
+ for await (const _item of generator) {
237
+ // Iteration drains the generator so its side effects complete.
239
238
  }
240
239
  }
241
240
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fluidFetchMessages.js","sourceRoot":"","sources":["../src/fluidFetchMessages.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,4CAAoB;AAEpB,kEAA6D;AAE7D,0EAKqD;AAErD,uEAA8D;AAC9D,2DAO6B;AAE7B,SAAS,iBAAiB,CAAC,KAAa;IACvC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,uBAAuB;AACpE,CAAC;AAED,IAAI,mBAAmB,GAA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,EAClC,OAAgB;IAEhB,MAAM,YAAY,GAAG,oCAAgB,IAAI,gCAAY,CAAC;IACtD,IAAI,CAAC,YAAY,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,eAAe,KAAK,SAAS,CAAC,EAAE,CAAC;QAC/E,OAAO;IACR,CAAC;IAED,MAAM,KAAK,GACV,OAAO,KAAK,SAAS;QACpB,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,YAAE;aACD,WAAW,CAAC,OAAO,CAAC;aACpB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YAChB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBAClC,OAAO,KAAK,CAAC;YACd,CAAC;YACD,OAAO,IAAI,CAAC;QACb,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAExC,IAAI,SAAS,GAAG,wBAAwB,CAAC,eAAe,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAE1E,IAAI,OAAO,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,IAAI,eAAe,EAAE,CAAC;QACrE,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,YAAY,EAAE,CAAC;QAClB,OAAO,IAAA,2CAAiB,EAAC,SAAS,EAAE,oCAAgB,EAAE,gCAAY,EAAE,qCAAiB,CAAC,CAAC;IACxF,CAAC;SAAM,CAAC;QACP,IAAI,IAAI,CAAC;QACT,2FAA2F;QAC3F,IAAI,KAAK,EAAE,IAAI,IAAI,SAAS,EAAE,CAAC;QAC/B,CAAC;IACF,CAAC;AACF,CAAC;AApCD,gDAoCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport fs from \"fs\";\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\nimport {\n\ttype IDocumentService,\n\tMessageType,\n\tScopeType,\n\ttype ISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\n\nimport { printMessageStats } from \"./fluidAnalyzeMessages.js\";\nimport {\n\tconnectToWebSocket,\n\tdumpMessageStats,\n\tdumpMessages,\n\tmessageTypeFilter,\n\toverWrite,\n\tparamActualFormatting,\n} from \"./fluidFetchArgs.js\";\n\nfunction filenameFromIndex(index: number): string {\n\treturn index === 0 ? \"\" : index.toString(); // support old tools...\n}\n\nlet firstAvailableDelta = 1;\nasync function* loadAllSequencedMessages(\n\tdocumentService?: IDocumentService,\n\tdir?: string,\n\tfiles?: string[],\n): AsyncGenerator<ISequencedDocumentMessage[]> {\n\tlet lastSeq = 0;\n\t// flag for mismatch between last sequence number read and new one to be read\n\tlet seqNumMismatch = false;\n\n\t// If we have local save, read ops from there first\n\tif (files !== undefined) {\n\t\tfor (let i = 0; i < files.length; i++) {\n\t\t\tconst file = filenameFromIndex(i);\n\t\t\ttry {\n\t\t\t\tconsole.log(`reading messages${file}.json`);\n\t\t\t\tconst fileContent = fs.readFileSync(`${dir}/messages${file}.json`, {\n\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t});\n\t\t\t\tconst messages: ISequencedDocumentMessage[] = JSON.parse(fileContent);\n\t\t\t\t// check if there is mismatch\n\t\t\t\tseqNumMismatch = messages[0].sequenceNumber !== lastSeq + 1;\n\t\t\t\tassert(\n\t\t\t\t\t!seqNumMismatch,\n\t\t\t\t\t0x1b9 /* \"Unexpected value for sequence number of first message in file\" */,\n\t\t\t\t);\n\t\t\t\tlastSeq = messages[messages.length - 1].sequenceNumber;\n\t\t\t\tyield messages;\n\t\t\t} catch (e) {\n\t\t\t\tif (seqNumMismatch) {\n\t\t\t\t\tif (overWrite) {\n\t\t\t\t\t\t// with overWrite option on, we will delete all exisintg message.json files\n\t\t\t\t\t\tfor (let index = 0; index < files.length; index++) {\n\t\t\t\t\t\t\tconst name = filenameFromIndex(index);\n\t\t\t\t\t\t\tfs.unlinkSync(`${dir}/messages${name}.json`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t// prompt user to back up and delete existing files\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\"There are deleted ops in the document being requested,\" +\n\t\t\t\t\t\t\t\" please back up the existing messages.json file and delete it from its directory.\" +\n\t\t\t\t\t\t\t\" Then try fetch tool again.\",\n\t\t\t\t\t);\n\t\t\t\t\tconsole.error(e);\n\t\t\t\t\treturn;\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(`Error reading / parsing messages from ${files}`);\n\t\t\t\t\tconsole.error(e);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (lastSeq !== 0) {\n\t\t\tconsole.log(`Read ${lastSeq} ops from local cache`);\n\t\t}\n\t}\n\n\tif (!documentService) {\n\t\treturn;\n\t}\n\n\tconst deltaStorage = await documentService.connectToDeltaStorage();\n\n\tlet timeStart = Date.now();\n\tlet requests = 0;\n\tlet opsStorage = 0;\n\n\tconsole.log(\"fetching cached messages\");\n\t// reading only 1 op to test if there is mismatch\n\tconst teststream = deltaStorage.fetchMessages(lastSeq + 1, lastSeq + 2);\n\n\ttry {\n\t\tawait teststream.read();\n\t} catch (error: any) {\n\t\tconst statusCode = error.getTelemetryProperties().statusCode;\n\t\tconst innerMostErrorCode = error.getTelemetryProperties().innerMostErrorCode;\n\t\tif (statusCode !== 410 || innerMostErrorCode !== \"fluidDeltaDataNotAvailable\") {\n\t\t\tthrow error;\n\t\t}\n\n\t\t// This indicates we tried to fetch ops from storage that have been deleted (because they are past some retention policy).\n\t\t// In that case, the error message should indicate the first sequence number that is available.\n\t\t// We make a best-effort attempt for the original query (fetch all ops) by starting from that sequence number.\n\t\tconst props = error.getTelemetryProperties();\n\t\tconst { responseMessage } = props;\n\t\tconst [_, seq] =\n\t\t\ttypeof responseMessage === \"string\"\n\t\t\t\t? (/GenesisSequenceNumber '(\\d+)'/.exec(responseMessage) ?? [])\n\t\t\t\t: [];\n\t\tif (seq !== undefined) {\n\t\t\tlastSeq = parseInt(seq, 10);\n\t\t\tfirstAvailableDelta = lastSeq + 1;\n\t\t\tconsole.log(\n\t\t\t\t`Not all ops are available (older ops may have been deleted from storage). Starting from sequenceNumber: ${firstAvailableDelta}.`,\n\t\t\t);\n\t\t} else {\n\t\t\tconsole.log(props);\n\t\t\tthrow new Error(\n\t\t\t\t`Unexpected structure for 410 error: ${error.message}. Further error properties were logged above. This indicates a problem with fetch-tool.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tconsole.log(\"fetching remaining messages from delta storage\");\n\n\t// continue reading rest of the ops\n\tconst stream = deltaStorage.fetchMessages(\n\t\tlastSeq + 1, // inclusive left\n\t\tundefined, // to\n\t);\n\n\twhile (true) {\n\t\tconst result = await stream.read();\n\t\tif (result.done) {\n\t\t\tbreak;\n\t\t}\n\t\trequests++;\n\t\tconst messages = result.value;\n\n\t\t// Empty buckets should never be returned\n\t\tassert(messages.length !== 0, 0x1ba /* \"should not return empty buckets\" */);\n\t\t// console.log(`Loaded ops at ${messages[0].sequenceNumber}`);\n\n\t\t// This parsing of message contents happens in delta manager. But when we analyze messages\n\t\t// for message stats, we skip that path. So parsing of json contents needs to happen here.\n\t\tfor (const message of messages) {\n\t\t\tif (\n\t\t\t\ttypeof message.contents === \"string\" &&\n\t\t\t\tmessage.contents !== \"\" &&\n\t\t\t\tmessage.type !== MessageType.ClientLeave\n\t\t\t) {\n\t\t\t\tmessage.contents = JSON.parse(message.contents);\n\t\t\t}\n\t\t}\n\n\t\topsStorage += messages.length;\n\t\tlastSeq = messages[messages.length - 1].sequenceNumber;\n\t\tyield messages;\n\t}\n\n\tconsole.log(\n\t\t`\\n${Math.floor(\n\t\t\t(Date.now() - timeStart) / 1000,\n\t\t)} seconds to retrieve ${opsStorage} ops in ${requests} requests`,\n\t);\n\n\tif (connectToWebSocket) {\n\t\tlet logMsg = \"\";\n\t\tconst client: IClient = {\n\t\t\tmode: \"write\",\n\t\t\tpermission: [],\n\t\t\tscopes: [ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite],\n\t\t\tdetails: {\n\t\t\t\tcapabilities: { interactive: true },\n\t\t\t},\n\t\t\tuser: { id: \"blah\" },\n\t\t};\n\t\tconsole.log(\"Retrieving messages from web socket\");\n\t\ttimeStart = Date.now();\n\t\tconst deltaStream = await documentService.connectToDeltaStream(client);\n\t\tconst initialMessages = deltaStream.initialMessages;\n\t\tdeltaStream.dispose();\n\t\tconsole.log(\n\t\t\t`${Math.floor((Date.now() - timeStart) / 1000)} seconds to connect to web socket`,\n\t\t);\n\n\t\tif (initialMessages !== undefined) {\n\t\t\tconst lastSequenceNumber = lastSeq;\n\t\t\tconst filtered = initialMessages.filter((a) => a.sequenceNumber > lastSequenceNumber);\n\t\t\tconst sorted = filtered.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n\t\t\tlastSeq = sorted[sorted.length - 1].sequenceNumber;\n\t\t\tlogMsg = ` (${opsStorage} delta storage, ${\n\t\t\t\tinitialMessages.length\n\t\t\t} initial ws messages, ${initialMessages.length - sorted.length} dup)`;\n\t\t\tyield sorted;\n\t\t}\n\t\tconsole.log(`${lastSeq} total messages${logMsg}`);\n\t}\n}\n\nasync function* saveOps(\n\tgen: AsyncGenerator<ISequencedDocumentMessage[]>,\n\tdir: string,\n\tfiles: string[],\n): AsyncGenerator<ISequencedDocumentMessage[]> {\n\t// Split into 100K ops\n\tconst chunk = 100 * 1000;\n\n\tlet sequencedMessages: ISequencedDocumentMessage[] = [];\n\n\t// Figure out first file we want to write to\n\tlet index = 0;\n\tlet curr: number = 1;\n\tif (files.length !== 0) {\n\t\tindex = files.length - 1;\n\t\tconst name = filenameFromIndex(index);\n\t\tconst fileContent = fs.readFileSync(`${dir}/messages${name}.json`, { encoding: \"utf-8\" });\n\t\tconst messages: ISequencedDocumentMessage[] = JSON.parse(fileContent);\n\t\tcurr = messages[0].sequenceNumber;\n\t}\n\n\twhile (true) {\n\t\tconst result: IteratorResult<ISequencedDocumentMessage[]> = await gen.next();\n\t\tif (files.length === 0) {\n\t\t\tcurr = firstAvailableDelta;\n\t\t}\n\t\tif (result.done !== true) {\n\t\t\tlet messages = result.value;\n\t\t\tyield messages;\n\t\t\tif (messages[messages.length - 1].sequenceNumber < curr) {\n\t\t\t\t// Nothing interesting.\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (messages[0].sequenceNumber < curr) {\n\t\t\t\tmessages = messages.filter((msg) => msg.sequenceNumber >= curr);\n\t\t\t}\n\t\t\tsequencedMessages = sequencedMessages.concat(messages);\n\t\t\tassert(\n\t\t\t\tsequencedMessages[0].sequenceNumber === curr,\n\t\t\t\t0x1bb /* \"Unexpected sequence number on first of messages to save\" */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\tsequencedMessages[sequencedMessages.length - 1].sequenceNumber ===\n\t\t\t\t\tcurr + sequencedMessages.length - 1,\n\t\t\t\t0x1bc /* \"Unexpected sequence number on last of messages to save\" */,\n\t\t\t);\n\t\t}\n\n\t\t// Time to write it out?\n\t\twhile (\n\t\t\tsequencedMessages.length >= chunk ||\n\t\t\t(result.done === true && sequencedMessages.length !== 0)\n\t\t) {\n\t\t\tconst name = filenameFromIndex(index);\n\t\t\tconst write = sequencedMessages.splice(0, chunk);\n\t\t\tconsole.log(`writing messages${name}.json`);\n\t\t\tfs.writeFileSync(\n\t\t\t\t`${dir}/messages${name}.json`,\n\t\t\t\tJSON.stringify(write, undefined, paramActualFormatting ? 0 : 2),\n\t\t\t);\n\t\t\t// increment curr by chunk\n\t\t\tcurr += chunk;\n\t\t\tassert(\n\t\t\t\tsequencedMessages.length === 0 || sequencedMessages[0].sequenceNumber === curr,\n\t\t\t\t0x1bd /* \"Stopped writing at unexpected sequence number\" */,\n\t\t\t);\n\t\t\tindex++;\n\t\t}\n\n\t\tif (result.done === true) {\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nexport async function fluidFetchMessages(\n\tdocumentService?: IDocumentService,\n\tsaveDir?: string,\n): Promise<void> {\n\tconst messageStats = dumpMessageStats || dumpMessages;\n\tif (!messageStats && (saveDir === undefined || documentService === undefined)) {\n\t\treturn;\n\t}\n\n\tconst files =\n\t\tsaveDir === undefined\n\t\t\t? undefined\n\t\t\t: fs\n\t\t\t\t\t.readdirSync(saveDir)\n\t\t\t\t\t.filter((file) => {\n\t\t\t\t\t\tif (!file.startsWith(\"messages\")) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t})\n\t\t\t\t\t.sort((a, b) => a.localeCompare(b));\n\n\tlet generator = loadAllSequencedMessages(documentService, saveDir, files);\n\n\tif (saveDir !== undefined && files !== undefined && documentService) {\n\t\tgenerator = saveOps(generator, saveDir, files);\n\t}\n\n\tif (messageStats) {\n\t\treturn printMessageStats(generator, dumpMessageStats, dumpMessages, messageTypeFilter);\n\t} else {\n\t\tlet item;\n\t\t// eslint-disable-next-line no-empty -- TODO: Investigate / document what is going on here.\n\t\tfor await (item of generator) {\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"fluidFetchMessages.js","sourceRoot":"","sources":["../src/fluidFetchMessages.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,4CAAoB;AAEpB,kEAA6D;AAE7D,0EAKqD;AAErD,uEAA8D;AAC9D,2DAO6B;AAE7B,SAAS,iBAAiB,CAAC,KAAa;IACvC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,uBAAuB;AACpE,CAAC;AAED,IAAI,mBAAmB,GAAG,CAAC,CAAC;AAC5B,KAAK,SAAS,CAAC,CAAC,wBAAwB,CACvC,eAAkC,EAClC,GAAY,EACZ,KAAgB;IAEhB,I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C,OAAO,KAAK,SAAS,IAAI,eAAe,KAAK,SAAS,CAAC,EAAE,CAAC;QAC/E,OAAO;IACR,CAAC;IAED,MAAM,KAAK,GACV,OAAO,KAAK,SAAS;QACpB,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,YAAE;aACD,WAAW,CAAC,OAAO,CAAC;aACpB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YAChB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBAClC,OAAO,KAAK,CAAC;YACd,CAAC;YACD,OAAO,IAAI,CAAC;QACb,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAExC,IAAI,SAAS,GAAG,wBAAwB,CAAC,eAAe,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAE1E,IAAI,OAAO,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,IAAI,eAAe,EAAE,CAAC;QACrE,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,YAAY,EAAE,CAAC;QAClB,OAAO,IAAA,2CAAiB,EAAC,SAAS,EAAE,oCAAgB,EAAE,gCAAY,EAAE,qCAAiB,CAAC,CAAC;IACxF,CAAC;SAAM,CAAC;QACP,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,SAAS,EAAE,CAAC;YACrC,+DAA+D;QAChE,CAAC;IACF,CAAC;AACF,CAAC;AAnCD,gDAmCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport fs from \"fs\";\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\nimport {\n\ttype IDocumentService,\n\tMessageType,\n\tScopeType,\n\ttype ISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\n\nimport { printMessageStats } from \"./fluidAnalyzeMessages.js\";\nimport {\n\tconnectToWebSocket,\n\tdumpMessageStats,\n\tdumpMessages,\n\tmessageTypeFilter,\n\toverWrite,\n\tparamActualFormatting,\n} from \"./fluidFetchArgs.js\";\n\nfunction filenameFromIndex(index: number): string {\n\treturn index === 0 ? \"\" : index.toString(); // support old tools...\n}\n\nlet firstAvailableDelta = 1;\nasync function* loadAllSequencedMessages(\n\tdocumentService?: IDocumentService,\n\tdir?: string,\n\tfiles?: string[],\n): AsyncGenerator<ISequencedDocumentMessage[]> {\n\tlet lastSeq = 0;\n\t// flag for mismatch between last sequence number read and new one to be read\n\tlet seqNumMismatch = false;\n\n\t// If we have local save, read ops from there first\n\tif (files !== undefined) {\n\t\tfor (let i = 0; i < files.length; i++) {\n\t\t\tconst file = filenameFromIndex(i);\n\t\t\ttry {\n\t\t\t\tconsole.log(`reading messages${file}.json`);\n\t\t\t\tconst fileContent = fs.readFileSync(`${dir}/messages${file}.json`, {\n\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t});\n\t\t\t\tconst messages: ISequencedDocumentMessage[] = JSON.parse(fileContent);\n\t\t\t\t// check if there is mismatch\n\t\t\t\tseqNumMismatch = messages[0].sequenceNumber !== lastSeq + 1;\n\t\t\t\tassert(\n\t\t\t\t\t!seqNumMismatch,\n\t\t\t\t\t0x1b9 /* \"Unexpected value for sequence number of first message in file\" */,\n\t\t\t\t);\n\t\t\t\tlastSeq = messages[messages.length - 1].sequenceNumber;\n\t\t\t\tyield messages;\n\t\t\t} catch (e) {\n\t\t\t\tif (seqNumMismatch) {\n\t\t\t\t\tif (overWrite) {\n\t\t\t\t\t\t// with overWrite option on, we will delete all exisintg message.json files\n\t\t\t\t\t\tfor (let index = 0; index < files.length; index++) {\n\t\t\t\t\t\t\tconst name = filenameFromIndex(index);\n\t\t\t\t\t\t\tfs.unlinkSync(`${dir}/messages${name}.json`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t// prompt user to back up and delete existing files\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\"There are deleted ops in the document being requested,\" +\n\t\t\t\t\t\t\t\" please back up the existing messages.json file and delete it from its directory.\" +\n\t\t\t\t\t\t\t\" Then try fetch tool again.\",\n\t\t\t\t\t);\n\t\t\t\t\tconsole.error(e);\n\t\t\t\t\treturn;\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(`Error reading / parsing messages from ${files}`);\n\t\t\t\t\tconsole.error(e);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (lastSeq !== 0) {\n\t\t\tconsole.log(`Read ${lastSeq} ops from local cache`);\n\t\t}\n\t}\n\n\tif (!documentService) {\n\t\treturn;\n\t}\n\n\tconst deltaStorage = await documentService.connectToDeltaStorage();\n\n\tlet timeStart = Date.now();\n\tlet requests = 0;\n\tlet opsStorage = 0;\n\n\tconsole.log(\"fetching cached messages\");\n\t// reading only 1 op to test if there is mismatch\n\tconst teststream = deltaStorage.fetchMessages(lastSeq + 1, lastSeq + 2);\n\n\ttry {\n\t\tawait teststream.read();\n\t} catch (error: any) {\n\t\tconst statusCode = error.getTelemetryProperties().statusCode;\n\t\tconst innerMostErrorCode = error.getTelemetryProperties().innerMostErrorCode;\n\t\tif (statusCode !== 410 || innerMostErrorCode !== \"fluidDeltaDataNotAvailable\") {\n\t\t\tthrow error;\n\t\t}\n\n\t\t// This indicates we tried to fetch ops from storage that have been deleted (because they are past some retention policy).\n\t\t// In that case, the error message should indicate the first sequence number that is available.\n\t\t// We make a best-effort attempt for the original query (fetch all ops) by starting from that sequence number.\n\t\tconst props = error.getTelemetryProperties();\n\t\tconst { responseMessage } = props;\n\t\tconst [_, seq] =\n\t\t\ttypeof responseMessage === \"string\"\n\t\t\t\t? (/GenesisSequenceNumber '(\\d+)'/.exec(responseMessage) ?? [])\n\t\t\t\t: [];\n\t\tif (seq !== undefined) {\n\t\t\tlastSeq = parseInt(seq, 10);\n\t\t\tfirstAvailableDelta = lastSeq + 1;\n\t\t\tconsole.log(\n\t\t\t\t`Not all ops are available (older ops may have been deleted from storage). Starting from sequenceNumber: ${firstAvailableDelta}.`,\n\t\t\t);\n\t\t} else {\n\t\t\tconsole.log(props);\n\t\t\tthrow new Error(\n\t\t\t\t`Unexpected structure for 410 error: ${error.message}. Further error properties were logged above. This indicates a problem with fetch-tool.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tconsole.log(\"fetching remaining messages from delta storage\");\n\n\t// continue reading rest of the ops\n\tconst stream = deltaStorage.fetchMessages(\n\t\tlastSeq + 1, // inclusive left\n\t\tundefined, // to\n\t);\n\n\twhile (true) {\n\t\tconst result = await stream.read();\n\t\tif (result.done) {\n\t\t\tbreak;\n\t\t}\n\t\trequests++;\n\t\tconst messages = result.value;\n\n\t\t// Empty buckets should never be returned\n\t\tassert(messages.length !== 0, 0x1ba /* \"should not return empty buckets\" */);\n\t\t// console.log(`Loaded ops at ${messages[0].sequenceNumber}`);\n\n\t\t// This parsing of message contents happens in delta manager. But when we analyze messages\n\t\t// for message stats, we skip that path. So parsing of json contents needs to happen here.\n\t\tfor (const message of messages) {\n\t\t\tif (\n\t\t\t\ttypeof message.contents === \"string\" &&\n\t\t\t\tmessage.contents !== \"\" &&\n\t\t\t\tmessage.type !== MessageType.ClientLeave\n\t\t\t) {\n\t\t\t\tmessage.contents = JSON.parse(message.contents);\n\t\t\t}\n\t\t}\n\n\t\topsStorage += messages.length;\n\t\tlastSeq = messages[messages.length - 1].sequenceNumber;\n\t\tyield messages;\n\t}\n\n\tconsole.log(\n\t\t`\\n${Math.floor(\n\t\t\t(Date.now() - timeStart) / 1000,\n\t\t)} seconds to retrieve ${opsStorage} ops in ${requests} requests`,\n\t);\n\n\tif (connectToWebSocket) {\n\t\tlet logMsg = \"\";\n\t\tconst client: IClient = {\n\t\t\tmode: \"write\",\n\t\t\tpermission: [],\n\t\t\tscopes: [ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite],\n\t\t\tdetails: {\n\t\t\t\tcapabilities: { interactive: true },\n\t\t\t},\n\t\t\tuser: { id: \"blah\" },\n\t\t};\n\t\tconsole.log(\"Retrieving messages from web socket\");\n\t\ttimeStart = Date.now();\n\t\tconst deltaStream = await documentService.connectToDeltaStream(client);\n\t\tconst initialMessages = deltaStream.initialMessages;\n\t\tdeltaStream.dispose();\n\t\tconsole.log(\n\t\t\t`${Math.floor((Date.now() - timeStart) / 1000)} seconds to connect to web socket`,\n\t\t);\n\n\t\tif (initialMessages !== undefined) {\n\t\t\tconst lastSequenceNumber = lastSeq;\n\t\t\tconst filtered = initialMessages.filter((a) => a.sequenceNumber > lastSequenceNumber);\n\t\t\tconst sorted = filtered.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n\t\t\tlastSeq = sorted[sorted.length - 1].sequenceNumber;\n\t\t\tlogMsg = ` (${opsStorage} delta storage, ${\n\t\t\t\tinitialMessages.length\n\t\t\t} initial ws messages, ${initialMessages.length - sorted.length} dup)`;\n\t\t\tyield sorted;\n\t\t}\n\t\tconsole.log(`${lastSeq} total messages${logMsg}`);\n\t}\n}\n\nasync function* saveOps(\n\tgen: AsyncGenerator<ISequencedDocumentMessage[]>,\n\tdir: string,\n\tfiles: string[],\n): AsyncGenerator<ISequencedDocumentMessage[]> {\n\t// Split into 100K ops\n\tconst chunk = 100 * 1000;\n\n\tlet sequencedMessages: ISequencedDocumentMessage[] = [];\n\n\t// Figure out first file we want to write to\n\tlet index = 0;\n\tlet curr: number = 1;\n\tif (files.length !== 0) {\n\t\tindex = files.length - 1;\n\t\tconst name = filenameFromIndex(index);\n\t\tconst fileContent = fs.readFileSync(`${dir}/messages${name}.json`, { encoding: \"utf-8\" });\n\t\tconst messages: ISequencedDocumentMessage[] = JSON.parse(fileContent);\n\t\tcurr = messages[0].sequenceNumber;\n\t}\n\n\twhile (true) {\n\t\tconst result: IteratorResult<ISequencedDocumentMessage[]> = await gen.next();\n\t\tif (files.length === 0) {\n\t\t\tcurr = firstAvailableDelta;\n\t\t}\n\t\tif (result.done !== true) {\n\t\t\tlet messages = result.value;\n\t\t\tyield messages;\n\t\t\tif (messages[messages.length - 1].sequenceNumber < curr) {\n\t\t\t\t// Nothing interesting.\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (messages[0].sequenceNumber < curr) {\n\t\t\t\tmessages = messages.filter((msg) => msg.sequenceNumber >= curr);\n\t\t\t}\n\t\t\tsequencedMessages = sequencedMessages.concat(messages);\n\t\t\tassert(\n\t\t\t\tsequencedMessages[0].sequenceNumber === curr,\n\t\t\t\t0x1bb /* \"Unexpected sequence number on first of messages to save\" */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\tsequencedMessages[sequencedMessages.length - 1].sequenceNumber ===\n\t\t\t\t\tcurr + sequencedMessages.length - 1,\n\t\t\t\t0x1bc /* \"Unexpected sequence number on last of messages to save\" */,\n\t\t\t);\n\t\t}\n\n\t\t// Time to write it out?\n\t\twhile (\n\t\t\tsequencedMessages.length >= chunk ||\n\t\t\t(result.done === true && sequencedMessages.length !== 0)\n\t\t) {\n\t\t\tconst name = filenameFromIndex(index);\n\t\t\tconst write = sequencedMessages.splice(0, chunk);\n\t\t\tconsole.log(`writing messages${name}.json`);\n\t\t\tfs.writeFileSync(\n\t\t\t\t`${dir}/messages${name}.json`,\n\t\t\t\tJSON.stringify(write, undefined, paramActualFormatting ? 0 : 2),\n\t\t\t);\n\t\t\t// increment curr by chunk\n\t\t\tcurr += chunk;\n\t\t\tassert(\n\t\t\t\tsequencedMessages.length === 0 || sequencedMessages[0].sequenceNumber === curr,\n\t\t\t\t0x1bd /* \"Stopped writing at unexpected sequence number\" */,\n\t\t\t);\n\t\t\tindex++;\n\t\t}\n\n\t\tif (result.done === true) {\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nexport async function fluidFetchMessages(\n\tdocumentService?: IDocumentService,\n\tsaveDir?: string,\n): Promise<void> {\n\tconst messageStats = dumpMessageStats || dumpMessages;\n\tif (!messageStats && (saveDir === undefined || documentService === undefined)) {\n\t\treturn;\n\t}\n\n\tconst files =\n\t\tsaveDir === undefined\n\t\t\t? undefined\n\t\t\t: fs\n\t\t\t\t\t.readdirSync(saveDir)\n\t\t\t\t\t.filter((file) => {\n\t\t\t\t\t\tif (!file.startsWith(\"messages\")) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t})\n\t\t\t\t\t.sort((a, b) => a.localeCompare(b));\n\n\tlet generator = loadAllSequencedMessages(documentService, saveDir, files);\n\n\tif (saveDir !== undefined && files !== undefined && documentService) {\n\t\tgenerator = saveOps(generator, saveDir, files);\n\t}\n\n\tif (messageStats) {\n\t\treturn printMessageStats(generator, dumpMessageStats, dumpMessages, messageTypeFilter);\n\t} else {\n\t\tfor await (const _item of generator) {\n\t\t\t// Iteration drains the generator so its side effects complete.\n\t\t}\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"fluidFetchMessages.d.ts","sourceRoot":"","sources":["../src/fluidFetchMessages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EACN,KAAK,gBAAgB,EAIrB,MAAM,6CAA6C,CAAC;AAgRrD,wBAAsB,kBAAkB,CACvC,eAAe,CAAC,EAAE,gBAAgB,EAClC,OAAO,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAiCf"}
1
+ {"version":3,"file":"fluidFetchMessages.d.ts","sourceRoot":"","sources":["../src/fluidFetchMessages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EACN,KAAK,gBAAgB,EAIrB,MAAM,6CAA6C,CAAC;AAgRrD,wBAAsB,kBAAkB,CACvC,eAAe,CAAC,EAAE,gBAAgB,EAClC,OAAO,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAgCf"}
@@ -227,9 +227,8 @@ export async function fluidFetchMessages(documentService, saveDir) {
227
227
  return printMessageStats(generator, dumpMessageStats, dumpMessages, messageTypeFilter);
228
228
  }
229
229
  else {
230
- let item;
231
- // eslint-disable-next-line no-empty -- TODO: Investigate / document what is going on here.
232
- for await (item of generator) {
230
+ for await (const _item of generator) {
231
+ // Iteration drains the generator so its side effects complete.
233
232
  }
234
233
  }
235
234
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fluidFetchMessages.js","sourceRoot":"","sources":["../src/fluidFetchMessages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAEN,WAAW,EACX,SAAS,GAET,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EACN,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,qBAAqB,GACrB,MAAM,qBAAqB,CAAC;AAE7B,SAAS,iBAAiB,CAAC,KAAa;IACvC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,uBAAuB;AACpE,CAAC;AAED,IAAI,mBAAmB,GAAG,CAAC,CAAC;AAC5B,KAAK,SAAS,CAAC,CAAC,wBAAwB,CACvC,eAAkC,EAClC,GAAY,EACZ,KAAgB;IAEhB,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,6EAA6E;IAC7E,IAAI,cAAc,GAAG,KAAK,CAAC;IAE3B,mDAAmD;IACnD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,MAAM,IAAI,GAAG,iBAAiB,CAAC,CAAC,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OAAO,KAAK,CAAC;YACd,CAAC;YACD,OAAO,IAAI,CAAC;QACb,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAExC,IAAI,SAAS,GAAG,wBAAwB,CAAC,eAAe,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAE1E,IAAI,OAAO,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,IAAI,eAAe,EAAE,CAAC;QACrE,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,YAAY,EAAE,CAAC;QAClB,OAAO,iBAAiB,CAAC,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAC;IACxF,CAAC;SAAM,CAAC;QACP,IAAI,IAAI,CAAC;QACT,2FAA2F;QAC3F,IAAI,KAAK,EAAE,IAAI,IAAI,SAAS,EAAE,CAAC;QAC/B,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport fs from \"fs\";\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\nimport {\n\ttype IDocumentService,\n\tMessageType,\n\tScopeType,\n\ttype ISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\n\nimport { printMessageStats } from \"./fluidAnalyzeMessages.js\";\nimport {\n\tconnectToWebSocket,\n\tdumpMessageStats,\n\tdumpMessages,\n\tmessageTypeFilter,\n\toverWrite,\n\tparamActualFormatting,\n} from \"./fluidFetchArgs.js\";\n\nfunction filenameFromIndex(index: number): string {\n\treturn index === 0 ? \"\" : index.toString(); // support old tools...\n}\n\nlet firstAvailableDelta = 1;\nasync function* loadAllSequencedMessages(\n\tdocumentService?: IDocumentService,\n\tdir?: string,\n\tfiles?: string[],\n): AsyncGenerator<ISequencedDocumentMessage[]> {\n\tlet lastSeq = 0;\n\t// flag for mismatch between last sequence number read and new one to be read\n\tlet seqNumMismatch = false;\n\n\t// If we have local save, read ops from there first\n\tif (files !== undefined) {\n\t\tfor (let i = 0; i < files.length; i++) {\n\t\t\tconst file = filenameFromIndex(i);\n\t\t\ttry {\n\t\t\t\tconsole.log(`reading messages${file}.json`);\n\t\t\t\tconst fileContent = fs.readFileSync(`${dir}/messages${file}.json`, {\n\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t});\n\t\t\t\tconst messages: ISequencedDocumentMessage[] = JSON.parse(fileContent);\n\t\t\t\t// check if there is mismatch\n\t\t\t\tseqNumMismatch = messages[0].sequenceNumber !== lastSeq + 1;\n\t\t\t\tassert(\n\t\t\t\t\t!seqNumMismatch,\n\t\t\t\t\t0x1b9 /* \"Unexpected value for sequence number of first message in file\" */,\n\t\t\t\t);\n\t\t\t\tlastSeq = messages[messages.length - 1].sequenceNumber;\n\t\t\t\tyield messages;\n\t\t\t} catch (e) {\n\t\t\t\tif (seqNumMismatch) {\n\t\t\t\t\tif (overWrite) {\n\t\t\t\t\t\t// with overWrite option on, we will delete all exisintg message.json files\n\t\t\t\t\t\tfor (let index = 0; index < files.length; index++) {\n\t\t\t\t\t\t\tconst name = filenameFromIndex(index);\n\t\t\t\t\t\t\tfs.unlinkSync(`${dir}/messages${name}.json`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t// prompt user to back up and delete existing files\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\"There are deleted ops in the document being requested,\" +\n\t\t\t\t\t\t\t\" please back up the existing messages.json file and delete it from its directory.\" +\n\t\t\t\t\t\t\t\" Then try fetch tool again.\",\n\t\t\t\t\t);\n\t\t\t\t\tconsole.error(e);\n\t\t\t\t\treturn;\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(`Error reading / parsing messages from ${files}`);\n\t\t\t\t\tconsole.error(e);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (lastSeq !== 0) {\n\t\t\tconsole.log(`Read ${lastSeq} ops from local cache`);\n\t\t}\n\t}\n\n\tif (!documentService) {\n\t\treturn;\n\t}\n\n\tconst deltaStorage = await documentService.connectToDeltaStorage();\n\n\tlet timeStart = Date.now();\n\tlet requests = 0;\n\tlet opsStorage = 0;\n\n\tconsole.log(\"fetching cached messages\");\n\t// reading only 1 op to test if there is mismatch\n\tconst teststream = deltaStorage.fetchMessages(lastSeq + 1, lastSeq + 2);\n\n\ttry {\n\t\tawait teststream.read();\n\t} catch (error: any) {\n\t\tconst statusCode = error.getTelemetryProperties().statusCode;\n\t\tconst innerMostErrorCode = error.getTelemetryProperties().innerMostErrorCode;\n\t\tif (statusCode !== 410 || innerMostErrorCode !== \"fluidDeltaDataNotAvailable\") {\n\t\t\tthrow error;\n\t\t}\n\n\t\t// This indicates we tried to fetch ops from storage that have been deleted (because they are past some retention policy).\n\t\t// In that case, the error message should indicate the first sequence number that is available.\n\t\t// We make a best-effort attempt for the original query (fetch all ops) by starting from that sequence number.\n\t\tconst props = error.getTelemetryProperties();\n\t\tconst { responseMessage } = props;\n\t\tconst [_, seq] =\n\t\t\ttypeof responseMessage === \"string\"\n\t\t\t\t? (/GenesisSequenceNumber '(\\d+)'/.exec(responseMessage) ?? [])\n\t\t\t\t: [];\n\t\tif (seq !== undefined) {\n\t\t\tlastSeq = parseInt(seq, 10);\n\t\t\tfirstAvailableDelta = lastSeq + 1;\n\t\t\tconsole.log(\n\t\t\t\t`Not all ops are available (older ops may have been deleted from storage). Starting from sequenceNumber: ${firstAvailableDelta}.`,\n\t\t\t);\n\t\t} else {\n\t\t\tconsole.log(props);\n\t\t\tthrow new Error(\n\t\t\t\t`Unexpected structure for 410 error: ${error.message}. Further error properties were logged above. This indicates a problem with fetch-tool.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tconsole.log(\"fetching remaining messages from delta storage\");\n\n\t// continue reading rest of the ops\n\tconst stream = deltaStorage.fetchMessages(\n\t\tlastSeq + 1, // inclusive left\n\t\tundefined, // to\n\t);\n\n\twhile (true) {\n\t\tconst result = await stream.read();\n\t\tif (result.done) {\n\t\t\tbreak;\n\t\t}\n\t\trequests++;\n\t\tconst messages = result.value;\n\n\t\t// Empty buckets should never be returned\n\t\tassert(messages.length !== 0, 0x1ba /* \"should not return empty buckets\" */);\n\t\t// console.log(`Loaded ops at ${messages[0].sequenceNumber}`);\n\n\t\t// This parsing of message contents happens in delta manager. But when we analyze messages\n\t\t// for message stats, we skip that path. So parsing of json contents needs to happen here.\n\t\tfor (const message of messages) {\n\t\t\tif (\n\t\t\t\ttypeof message.contents === \"string\" &&\n\t\t\t\tmessage.contents !== \"\" &&\n\t\t\t\tmessage.type !== MessageType.ClientLeave\n\t\t\t) {\n\t\t\t\tmessage.contents = JSON.parse(message.contents);\n\t\t\t}\n\t\t}\n\n\t\topsStorage += messages.length;\n\t\tlastSeq = messages[messages.length - 1].sequenceNumber;\n\t\tyield messages;\n\t}\n\n\tconsole.log(\n\t\t`\\n${Math.floor(\n\t\t\t(Date.now() - timeStart) / 1000,\n\t\t)} seconds to retrieve ${opsStorage} ops in ${requests} requests`,\n\t);\n\n\tif (connectToWebSocket) {\n\t\tlet logMsg = \"\";\n\t\tconst client: IClient = {\n\t\t\tmode: \"write\",\n\t\t\tpermission: [],\n\t\t\tscopes: [ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite],\n\t\t\tdetails: {\n\t\t\t\tcapabilities: { interactive: true },\n\t\t\t},\n\t\t\tuser: { id: \"blah\" },\n\t\t};\n\t\tconsole.log(\"Retrieving messages from web socket\");\n\t\ttimeStart = Date.now();\n\t\tconst deltaStream = await documentService.connectToDeltaStream(client);\n\t\tconst initialMessages = deltaStream.initialMessages;\n\t\tdeltaStream.dispose();\n\t\tconsole.log(\n\t\t\t`${Math.floor((Date.now() - timeStart) / 1000)} seconds to connect to web socket`,\n\t\t);\n\n\t\tif (initialMessages !== undefined) {\n\t\t\tconst lastSequenceNumber = lastSeq;\n\t\t\tconst filtered = initialMessages.filter((a) => a.sequenceNumber > lastSequenceNumber);\n\t\t\tconst sorted = filtered.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n\t\t\tlastSeq = sorted[sorted.length - 1].sequenceNumber;\n\t\t\tlogMsg = ` (${opsStorage} delta storage, ${\n\t\t\t\tinitialMessages.length\n\t\t\t} initial ws messages, ${initialMessages.length - sorted.length} dup)`;\n\t\t\tyield sorted;\n\t\t}\n\t\tconsole.log(`${lastSeq} total messages${logMsg}`);\n\t}\n}\n\nasync function* saveOps(\n\tgen: AsyncGenerator<ISequencedDocumentMessage[]>,\n\tdir: string,\n\tfiles: string[],\n): AsyncGenerator<ISequencedDocumentMessage[]> {\n\t// Split into 100K ops\n\tconst chunk = 100 * 1000;\n\n\tlet sequencedMessages: ISequencedDocumentMessage[] = [];\n\n\t// Figure out first file we want to write to\n\tlet index = 0;\n\tlet curr: number = 1;\n\tif (files.length !== 0) {\n\t\tindex = files.length - 1;\n\t\tconst name = filenameFromIndex(index);\n\t\tconst fileContent = fs.readFileSync(`${dir}/messages${name}.json`, { encoding: \"utf-8\" });\n\t\tconst messages: ISequencedDocumentMessage[] = JSON.parse(fileContent);\n\t\tcurr = messages[0].sequenceNumber;\n\t}\n\n\twhile (true) {\n\t\tconst result: IteratorResult<ISequencedDocumentMessage[]> = await gen.next();\n\t\tif (files.length === 0) {\n\t\t\tcurr = firstAvailableDelta;\n\t\t}\n\t\tif (result.done !== true) {\n\t\t\tlet messages = result.value;\n\t\t\tyield messages;\n\t\t\tif (messages[messages.length - 1].sequenceNumber < curr) {\n\t\t\t\t// Nothing interesting.\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (messages[0].sequenceNumber < curr) {\n\t\t\t\tmessages = messages.filter((msg) => msg.sequenceNumber >= curr);\n\t\t\t}\n\t\t\tsequencedMessages = sequencedMessages.concat(messages);\n\t\t\tassert(\n\t\t\t\tsequencedMessages[0].sequenceNumber === curr,\n\t\t\t\t0x1bb /* \"Unexpected sequence number on first of messages to save\" */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\tsequencedMessages[sequencedMessages.length - 1].sequenceNumber ===\n\t\t\t\t\tcurr + sequencedMessages.length - 1,\n\t\t\t\t0x1bc /* \"Unexpected sequence number on last of messages to save\" */,\n\t\t\t);\n\t\t}\n\n\t\t// Time to write it out?\n\t\twhile (\n\t\t\tsequencedMessages.length >= chunk ||\n\t\t\t(result.done === true && sequencedMessages.length !== 0)\n\t\t) {\n\t\t\tconst name = filenameFromIndex(index);\n\t\t\tconst write = sequencedMessages.splice(0, chunk);\n\t\t\tconsole.log(`writing messages${name}.json`);\n\t\t\tfs.writeFileSync(\n\t\t\t\t`${dir}/messages${name}.json`,\n\t\t\t\tJSON.stringify(write, undefined, paramActualFormatting ? 0 : 2),\n\t\t\t);\n\t\t\t// increment curr by chunk\n\t\t\tcurr += chunk;\n\t\t\tassert(\n\t\t\t\tsequencedMessages.length === 0 || sequencedMessages[0].sequenceNumber === curr,\n\t\t\t\t0x1bd /* \"Stopped writing at unexpected sequence number\" */,\n\t\t\t);\n\t\t\tindex++;\n\t\t}\n\n\t\tif (result.done === true) {\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nexport async function fluidFetchMessages(\n\tdocumentService?: IDocumentService,\n\tsaveDir?: string,\n): Promise<void> {\n\tconst messageStats = dumpMessageStats || dumpMessages;\n\tif (!messageStats && (saveDir === undefined || documentService === undefined)) {\n\t\treturn;\n\t}\n\n\tconst files =\n\t\tsaveDir === undefined\n\t\t\t? undefined\n\t\t\t: fs\n\t\t\t\t\t.readdirSync(saveDir)\n\t\t\t\t\t.filter((file) => {\n\t\t\t\t\t\tif (!file.startsWith(\"messages\")) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t})\n\t\t\t\t\t.sort((a, b) => a.localeCompare(b));\n\n\tlet generator = loadAllSequencedMessages(documentService, saveDir, files);\n\n\tif (saveDir !== undefined && files !== undefined && documentService) {\n\t\tgenerator = saveOps(generator, saveDir, files);\n\t}\n\n\tif (messageStats) {\n\t\treturn printMessageStats(generator, dumpMessageStats, dumpMessages, messageTypeFilter);\n\t} else {\n\t\tlet item;\n\t\t// eslint-disable-next-line no-empty -- TODO: Investigate / document what is going on here.\n\t\tfor await (item of generator) {\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"fluidFetchMessages.js","sourceRoot":"","sources":["../src/fluidFetchMessages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAEN,WAAW,EACX,SAAS,GAET,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EACN,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,qBAAqB,GACrB,MAAM,qBAAqB,CAAC;AAE7B,SAAS,iBAAiB,CAAC,KAAa;IACvC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,uBAAuB;AACpE,CAAC;AAED,IAAI,mBAAmB,GAAG,CAAC,CAAC;AAC5B,KAAK,SAAS,CAAC,CAAC,wBAAwB,CACvC,eAAkC,EAClC,GAAY,EACZ,KAAgB;IAEhB,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,6EAA6E;IAC7E,IAAI,cAAc,GAAG,KAAK,CAAC;IAE3B,mDAAmD;IACnD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CA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AAE,EAAE;YAChB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBAClC,OAAO,KAAK,CAAC;YACd,CAAC;YACD,OAAO,IAAI,CAAC;QACb,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAExC,IAAI,SAAS,GAAG,wBAAwB,CAAC,eAAe,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAE1E,IAAI,OAAO,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,IAAI,eAAe,EAAE,CAAC;QACrE,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,YAAY,EAAE,CAAC;QAClB,OAAO,iBAAiB,CAAC,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAC;IACxF,CAAC;SAAM,CAAC;QACP,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,SAAS,EAAE,CAAC;YACrC,+DAA+D;QAChE,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport fs from \"fs\";\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\nimport {\n\ttype IDocumentService,\n\tMessageType,\n\tScopeType,\n\ttype ISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\n\nimport { printMessageStats } from \"./fluidAnalyzeMessages.js\";\nimport {\n\tconnectToWebSocket,\n\tdumpMessageStats,\n\tdumpMessages,\n\tmessageTypeFilter,\n\toverWrite,\n\tparamActualFormatting,\n} from \"./fluidFetchArgs.js\";\n\nfunction filenameFromIndex(index: number): string {\n\treturn index === 0 ? \"\" : index.toString(); // support old tools...\n}\n\nlet firstAvailableDelta = 1;\nasync function* loadAllSequencedMessages(\n\tdocumentService?: IDocumentService,\n\tdir?: string,\n\tfiles?: string[],\n): AsyncGenerator<ISequencedDocumentMessage[]> {\n\tlet lastSeq = 0;\n\t// flag for mismatch between last sequence number read and new one to be read\n\tlet seqNumMismatch = false;\n\n\t// If we have local save, read ops from there first\n\tif (files !== undefined) {\n\t\tfor (let i = 0; i < files.length; i++) {\n\t\t\tconst file = filenameFromIndex(i);\n\t\t\ttry {\n\t\t\t\tconsole.log(`reading messages${file}.json`);\n\t\t\t\tconst fileContent = fs.readFileSync(`${dir}/messages${file}.json`, {\n\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t});\n\t\t\t\tconst messages: ISequencedDocumentMessage[] = JSON.parse(fileContent);\n\t\t\t\t// check if there is mismatch\n\t\t\t\tseqNumMismatch = messages[0].sequenceNumber !== lastSeq + 1;\n\t\t\t\tassert(\n\t\t\t\t\t!seqNumMismatch,\n\t\t\t\t\t0x1b9 /* \"Unexpected value for sequence number of first message in file\" */,\n\t\t\t\t);\n\t\t\t\tlastSeq = messages[messages.length - 1].sequenceNumber;\n\t\t\t\tyield messages;\n\t\t\t} catch (e) {\n\t\t\t\tif (seqNumMismatch) {\n\t\t\t\t\tif (overWrite) {\n\t\t\t\t\t\t// with overWrite option on, we will delete all exisintg message.json files\n\t\t\t\t\t\tfor (let index = 0; index < files.length; index++) {\n\t\t\t\t\t\t\tconst name = filenameFromIndex(index);\n\t\t\t\t\t\t\tfs.unlinkSync(`${dir}/messages${name}.json`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t// prompt user to back up and delete existing files\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\"There are deleted ops in the document being requested,\" +\n\t\t\t\t\t\t\t\" please back up the existing messages.json file and delete it from its directory.\" +\n\t\t\t\t\t\t\t\" Then try fetch tool again.\",\n\t\t\t\t\t);\n\t\t\t\t\tconsole.error(e);\n\t\t\t\t\treturn;\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(`Error reading / parsing messages from ${files}`);\n\t\t\t\t\tconsole.error(e);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (lastSeq !== 0) {\n\t\t\tconsole.log(`Read ${lastSeq} ops from local cache`);\n\t\t}\n\t}\n\n\tif (!documentService) {\n\t\treturn;\n\t}\n\n\tconst deltaStorage = await documentService.connectToDeltaStorage();\n\n\tlet timeStart = Date.now();\n\tlet requests = 0;\n\tlet opsStorage = 0;\n\n\tconsole.log(\"fetching cached messages\");\n\t// reading only 1 op to test if there is mismatch\n\tconst teststream = deltaStorage.fetchMessages(lastSeq + 1, lastSeq + 2);\n\n\ttry {\n\t\tawait teststream.read();\n\t} catch (error: any) {\n\t\tconst statusCode = error.getTelemetryProperties().statusCode;\n\t\tconst innerMostErrorCode = error.getTelemetryProperties().innerMostErrorCode;\n\t\tif (statusCode !== 410 || innerMostErrorCode !== \"fluidDeltaDataNotAvailable\") {\n\t\t\tthrow error;\n\t\t}\n\n\t\t// This indicates we tried to fetch ops from storage that have been deleted (because they are past some retention policy).\n\t\t// In that case, the error message should indicate the first sequence number that is available.\n\t\t// We make a best-effort attempt for the original query (fetch all ops) by starting from that sequence number.\n\t\tconst props = error.getTelemetryProperties();\n\t\tconst { responseMessage } = props;\n\t\tconst [_, seq] =\n\t\t\ttypeof responseMessage === \"string\"\n\t\t\t\t? (/GenesisSequenceNumber '(\\d+)'/.exec(responseMessage) ?? [])\n\t\t\t\t: [];\n\t\tif (seq !== undefined) {\n\t\t\tlastSeq = parseInt(seq, 10);\n\t\t\tfirstAvailableDelta = lastSeq + 1;\n\t\t\tconsole.log(\n\t\t\t\t`Not all ops are available (older ops may have been deleted from storage). Starting from sequenceNumber: ${firstAvailableDelta}.`,\n\t\t\t);\n\t\t} else {\n\t\t\tconsole.log(props);\n\t\t\tthrow new Error(\n\t\t\t\t`Unexpected structure for 410 error: ${error.message}. Further error properties were logged above. This indicates a problem with fetch-tool.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tconsole.log(\"fetching remaining messages from delta storage\");\n\n\t// continue reading rest of the ops\n\tconst stream = deltaStorage.fetchMessages(\n\t\tlastSeq + 1, // inclusive left\n\t\tundefined, // to\n\t);\n\n\twhile (true) {\n\t\tconst result = await stream.read();\n\t\tif (result.done) {\n\t\t\tbreak;\n\t\t}\n\t\trequests++;\n\t\tconst messages = result.value;\n\n\t\t// Empty buckets should never be returned\n\t\tassert(messages.length !== 0, 0x1ba /* \"should not return empty buckets\" */);\n\t\t// console.log(`Loaded ops at ${messages[0].sequenceNumber}`);\n\n\t\t// This parsing of message contents happens in delta manager. But when we analyze messages\n\t\t// for message stats, we skip that path. So parsing of json contents needs to happen here.\n\t\tfor (const message of messages) {\n\t\t\tif (\n\t\t\t\ttypeof message.contents === \"string\" &&\n\t\t\t\tmessage.contents !== \"\" &&\n\t\t\t\tmessage.type !== MessageType.ClientLeave\n\t\t\t) {\n\t\t\t\tmessage.contents = JSON.parse(message.contents);\n\t\t\t}\n\t\t}\n\n\t\topsStorage += messages.length;\n\t\tlastSeq = messages[messages.length - 1].sequenceNumber;\n\t\tyield messages;\n\t}\n\n\tconsole.log(\n\t\t`\\n${Math.floor(\n\t\t\t(Date.now() - timeStart) / 1000,\n\t\t)} seconds to retrieve ${opsStorage} ops in ${requests} requests`,\n\t);\n\n\tif (connectToWebSocket) {\n\t\tlet logMsg = \"\";\n\t\tconst client: IClient = {\n\t\t\tmode: \"write\",\n\t\t\tpermission: [],\n\t\t\tscopes: [ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite],\n\t\t\tdetails: {\n\t\t\t\tcapabilities: { interactive: true },\n\t\t\t},\n\t\t\tuser: { id: \"blah\" },\n\t\t};\n\t\tconsole.log(\"Retrieving messages from web socket\");\n\t\ttimeStart = Date.now();\n\t\tconst deltaStream = await documentService.connectToDeltaStream(client);\n\t\tconst initialMessages = deltaStream.initialMessages;\n\t\tdeltaStream.dispose();\n\t\tconsole.log(\n\t\t\t`${Math.floor((Date.now() - timeStart) / 1000)} seconds to connect to web socket`,\n\t\t);\n\n\t\tif (initialMessages !== undefined) {\n\t\t\tconst lastSequenceNumber = lastSeq;\n\t\t\tconst filtered = initialMessages.filter((a) => a.sequenceNumber > lastSequenceNumber);\n\t\t\tconst sorted = filtered.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n\t\t\tlastSeq = sorted[sorted.length - 1].sequenceNumber;\n\t\t\tlogMsg = ` (${opsStorage} delta storage, ${\n\t\t\t\tinitialMessages.length\n\t\t\t} initial ws messages, ${initialMessages.length - sorted.length} dup)`;\n\t\t\tyield sorted;\n\t\t}\n\t\tconsole.log(`${lastSeq} total messages${logMsg}`);\n\t}\n}\n\nasync function* saveOps(\n\tgen: AsyncGenerator<ISequencedDocumentMessage[]>,\n\tdir: string,\n\tfiles: string[],\n): AsyncGenerator<ISequencedDocumentMessage[]> {\n\t// Split into 100K ops\n\tconst chunk = 100 * 1000;\n\n\tlet sequencedMessages: ISequencedDocumentMessage[] = [];\n\n\t// Figure out first file we want to write to\n\tlet index = 0;\n\tlet curr: number = 1;\n\tif (files.length !== 0) {\n\t\tindex = files.length - 1;\n\t\tconst name = filenameFromIndex(index);\n\t\tconst fileContent = fs.readFileSync(`${dir}/messages${name}.json`, { encoding: \"utf-8\" });\n\t\tconst messages: ISequencedDocumentMessage[] = JSON.parse(fileContent);\n\t\tcurr = messages[0].sequenceNumber;\n\t}\n\n\twhile (true) {\n\t\tconst result: IteratorResult<ISequencedDocumentMessage[]> = await gen.next();\n\t\tif (files.length === 0) {\n\t\t\tcurr = firstAvailableDelta;\n\t\t}\n\t\tif (result.done !== true) {\n\t\t\tlet messages = result.value;\n\t\t\tyield messages;\n\t\t\tif (messages[messages.length - 1].sequenceNumber < curr) {\n\t\t\t\t// Nothing interesting.\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (messages[0].sequenceNumber < curr) {\n\t\t\t\tmessages = messages.filter((msg) => msg.sequenceNumber >= curr);\n\t\t\t}\n\t\t\tsequencedMessages = sequencedMessages.concat(messages);\n\t\t\tassert(\n\t\t\t\tsequencedMessages[0].sequenceNumber === curr,\n\t\t\t\t0x1bb /* \"Unexpected sequence number on first of messages to save\" */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\tsequencedMessages[sequencedMessages.length - 1].sequenceNumber ===\n\t\t\t\t\tcurr + sequencedMessages.length - 1,\n\t\t\t\t0x1bc /* \"Unexpected sequence number on last of messages to save\" */,\n\t\t\t);\n\t\t}\n\n\t\t// Time to write it out?\n\t\twhile (\n\t\t\tsequencedMessages.length >= chunk ||\n\t\t\t(result.done === true && sequencedMessages.length !== 0)\n\t\t) {\n\t\t\tconst name = filenameFromIndex(index);\n\t\t\tconst write = sequencedMessages.splice(0, chunk);\n\t\t\tconsole.log(`writing messages${name}.json`);\n\t\t\tfs.writeFileSync(\n\t\t\t\t`${dir}/messages${name}.json`,\n\t\t\t\tJSON.stringify(write, undefined, paramActualFormatting ? 0 : 2),\n\t\t\t);\n\t\t\t// increment curr by chunk\n\t\t\tcurr += chunk;\n\t\t\tassert(\n\t\t\t\tsequencedMessages.length === 0 || sequencedMessages[0].sequenceNumber === curr,\n\t\t\t\t0x1bd /* \"Stopped writing at unexpected sequence number\" */,\n\t\t\t);\n\t\t\tindex++;\n\t\t}\n\n\t\tif (result.done === true) {\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nexport async function fluidFetchMessages(\n\tdocumentService?: IDocumentService,\n\tsaveDir?: string,\n): Promise<void> {\n\tconst messageStats = dumpMessageStats || dumpMessages;\n\tif (!messageStats && (saveDir === undefined || documentService === undefined)) {\n\t\treturn;\n\t}\n\n\tconst files =\n\t\tsaveDir === undefined\n\t\t\t? undefined\n\t\t\t: fs\n\t\t\t\t\t.readdirSync(saveDir)\n\t\t\t\t\t.filter((file) => {\n\t\t\t\t\t\tif (!file.startsWith(\"messages\")) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t})\n\t\t\t\t\t.sort((a, b) => a.localeCompare(b));\n\n\tlet generator = loadAllSequencedMessages(documentService, saveDir, files);\n\n\tif (saveDir !== undefined && files !== undefined && documentService) {\n\t\tgenerator = saveOps(generator, saveDir, files);\n\t}\n\n\tif (messageStats) {\n\t\treturn printMessageStats(generator, dumpMessageStats, dumpMessages, messageTypeFilter);\n\t} else {\n\t\tfor await (const _item of generator) {\n\t\t\t// Iteration drains the generator so its side effects complete.\n\t\t}\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-tools/fetch-tool",
3
- "version": "2.115.0",
3
+ "version": "2.116.0",
4
4
  "description": "Console tool to fetch Fluid data from relay service",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -17,27 +17,27 @@
17
17
  "dependencies": {
18
18
  "@azure/identity": "^4.13.0",
19
19
  "@azure/identity-cache-persistence": "^1.1.0",
20
- "@fluid-internal/client-utils": "~2.115.0",
21
- "@fluidframework/container-runtime": "~2.115.0",
22
- "@fluidframework/core-interfaces": "~2.115.0",
23
- "@fluidframework/core-utils": "~2.115.0",
24
- "@fluidframework/datastore": "~2.115.0",
25
- "@fluidframework/driver-definitions": "~2.115.0",
26
- "@fluidframework/odsp-doclib-utils": "~2.115.0",
27
- "@fluidframework/odsp-driver": "~2.115.0",
28
- "@fluidframework/odsp-driver-definitions": "~2.115.0",
29
- "@fluidframework/odsp-urlresolver": "~2.115.0",
30
- "@fluidframework/routerlicious-driver": "~2.115.0",
31
- "@fluidframework/routerlicious-urlresolver": "~2.115.0",
32
- "@fluidframework/runtime-definitions": "~2.115.0",
33
- "@fluidframework/tool-utils": "~2.115.0"
20
+ "@fluid-internal/client-utils": "~2.116.0",
21
+ "@fluidframework/container-runtime": "~2.116.0",
22
+ "@fluidframework/core-interfaces": "~2.116.0",
23
+ "@fluidframework/core-utils": "~2.116.0",
24
+ "@fluidframework/datastore": "~2.116.0",
25
+ "@fluidframework/driver-definitions": "~2.116.0",
26
+ "@fluidframework/odsp-doclib-utils": "~2.116.0",
27
+ "@fluidframework/odsp-driver": "~2.116.0",
28
+ "@fluidframework/odsp-driver-definitions": "~2.116.0",
29
+ "@fluidframework/odsp-urlresolver": "~2.116.0",
30
+ "@fluidframework/routerlicious-driver": "~2.116.0",
31
+ "@fluidframework/routerlicious-urlresolver": "~2.116.0",
32
+ "@fluidframework/runtime-definitions": "~2.116.0",
33
+ "@fluidframework/tool-utils": "~2.116.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@biomejs/biome": "~2.4.5",
37
- "@fluid-tools/build-cli": "^0.65.0",
37
+ "@fluid-tools/build-cli": "^0.67.0",
38
38
  "@fluidframework/build-common": "^2.0.3",
39
- "@fluidframework/build-tools": "^0.65.0",
40
- "@fluidframework/eslint-config-fluid": "^13.0.0",
39
+ "@fluidframework/build-tools": "^0.67.0",
40
+ "@fluidframework/eslint-config-fluid": "^14.0.0",
41
41
  "@types/node": "~22.19.17",
42
42
  "copyfiles": "^2.4.1",
43
43
  "eslint": "~9.39.1",
@@ -315,9 +315,8 @@ export async function fluidFetchMessages(
315
315
  if (messageStats) {
316
316
  return printMessageStats(generator, dumpMessageStats, dumpMessages, messageTypeFilter);
317
317
  } else {
318
- let item;
319
- // eslint-disable-next-line no-empty -- TODO: Investigate / document what is going on here.
320
- for await (item of generator) {
318
+ for await (const _item of generator) {
319
+ // Iteration drains the generator so its side effects complete.
321
320
  }
322
321
  }
323
322
  }