@fluid-tools/fetch-tool 2.74.0 → 2.81.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 +8 -0
- package/dist/fluidAnalyzeMessages.d.ts +2 -2
- package/dist/fluidAnalyzeMessages.d.ts.map +1 -1
- package/dist/fluidAnalyzeMessages.js +2 -2
- package/dist/fluidAnalyzeMessages.js.map +1 -1
- package/dist/fluidFetch.js +3 -1
- package/dist/fluidFetch.js.map +1 -1
- package/dist/fluidFetchArgs.d.ts.map +1 -1
- package/dist/fluidFetchArgs.js.map +1 -1
- package/dist/fluidFetchInit.d.ts +2 -1
- package/dist/fluidFetchInit.d.ts.map +1 -1
- package/dist/fluidFetchInit.js +1 -1
- package/dist/fluidFetchInit.js.map +1 -1
- package/dist/fluidFetchMessages.d.ts.map +1 -1
- package/dist/fluidFetchMessages.js +2 -2
- package/dist/fluidFetchMessages.js.map +1 -1
- package/dist/fluidFetchSharePoint.d.ts.map +1 -1
- package/dist/fluidFetchSharePoint.js.map +1 -1
- package/dist/fluidFetchSnapshot.d.ts.map +1 -1
- package/dist/fluidFetchSnapshot.js +4 -1
- package/dist/fluidFetchSnapshot.js.map +1 -1
- package/eslint.config.mts +4 -4
- package/lib/fluidAnalyzeMessages.d.ts +2 -2
- package/lib/fluidAnalyzeMessages.d.ts.map +1 -1
- package/lib/fluidAnalyzeMessages.js +2 -2
- package/lib/fluidAnalyzeMessages.js.map +1 -1
- package/lib/fluidFetch.js +3 -1
- package/lib/fluidFetch.js.map +1 -1
- package/lib/fluidFetchArgs.d.ts.map +1 -1
- package/lib/fluidFetchArgs.js.map +1 -1
- package/lib/fluidFetchInit.d.ts +2 -1
- package/lib/fluidFetchInit.d.ts.map +1 -1
- package/lib/fluidFetchInit.js +1 -1
- package/lib/fluidFetchInit.js.map +1 -1
- package/lib/fluidFetchMessages.d.ts.map +1 -1
- package/lib/fluidFetchMessages.js +2 -2
- package/lib/fluidFetchMessages.js.map +1 -1
- package/lib/fluidFetchSharePoint.d.ts.map +1 -1
- package/lib/fluidFetchSharePoint.js.map +1 -1
- package/lib/fluidFetchSnapshot.d.ts.map +1 -1
- package/lib/fluidFetchSnapshot.js +4 -1
- package/lib/fluidFetchSnapshot.js.map +1 -1
- package/package.json +21 -21
- package/src/fluidAnalyzeMessages.ts +14 -13
- package/src/fluidFetch.ts +10 -5
- package/src/fluidFetchArgs.ts +6 -6
- package/src/fluidFetchInit.ts +12 -7
- package/src/fluidFetchMessages.ts +5 -4
- package/src/fluidFetchSharePoint.ts +8 -4
- package/src/fluidFetchSnapshot.ts +21 -8
- package/.eslintrc.cjs +0 -27
|
@@ -23,7 +23,7 @@ import type { IAttachMessage, IEnvelope } from "@fluidframework/runtime-definiti
|
|
|
23
23
|
const noClientName = "No Client";
|
|
24
24
|
const objectTypePrefix = "https://graph.microsoft.com/types/";
|
|
25
25
|
|
|
26
|
-
function incr(map: Map<string, [number, number]>, key: string, size: number, count = 1) {
|
|
26
|
+
function incr(map: Map<string, [number, number]>, key: string, size: number, count = 1): void {
|
|
27
27
|
const value = map.get(key);
|
|
28
28
|
if (value === undefined) {
|
|
29
29
|
map.set(key, [count, size]);
|
|
@@ -50,7 +50,7 @@ interface IMessageAnalyzer {
|
|
|
50
50
|
* Helper class to track session statistics
|
|
51
51
|
*/
|
|
52
52
|
class ActiveSession {
|
|
53
|
-
public static create(email: string, message: ISequencedDocumentMessage) {
|
|
53
|
+
public static create(email: string, message: ISequencedDocumentMessage): ActiveSession {
|
|
54
54
|
return new ActiveSession(email, message);
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -61,7 +61,7 @@ class ActiveSession {
|
|
|
61
61
|
private readonly startMessage: ISequencedDocumentMessage,
|
|
62
62
|
) {}
|
|
63
63
|
|
|
64
|
-
public reportOp(timestamp: number) {
|
|
64
|
+
public reportOp(timestamp: number): void {
|
|
65
65
|
this.opCount++;
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -90,7 +90,7 @@ function dumpStats(
|
|
|
90
90
|
removeTotals?: boolean;
|
|
91
91
|
reverseSort?: boolean;
|
|
92
92
|
},
|
|
93
|
-
) {
|
|
93
|
+
): void {
|
|
94
94
|
const fieldSizes = [10, 14];
|
|
95
95
|
const nameLength = 72;
|
|
96
96
|
const fieldsLength = fieldSizes[0] + fieldSizes[1] + 1;
|
|
@@ -174,7 +174,7 @@ function dumpStats(
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
const getObjectId = (dataStoreId: string, id: string) => `[${dataStoreId}]/${id}`;
|
|
177
|
+
const getObjectId = (dataStoreId: string, id: string): string => `[${dataStoreId}]/${id}`;
|
|
178
178
|
|
|
179
179
|
/**
|
|
180
180
|
* Analyzer for sessions
|
|
@@ -477,11 +477,11 @@ class MessageDumper implements IMessageAnalyzer {
|
|
|
477
477
|
}
|
|
478
478
|
|
|
479
479
|
export async function printMessageStats(
|
|
480
|
-
generator
|
|
480
|
+
generator: AsyncGenerator<ISequencedDocumentMessage[]>,
|
|
481
481
|
dumpMessageStats: boolean,
|
|
482
482
|
dumpMessages: boolean,
|
|
483
483
|
messageTypeFilter: Set<string> = new Set<string>(),
|
|
484
|
-
) {
|
|
484
|
+
): Promise<void> {
|
|
485
485
|
let lastMessage: ISequencedDocumentMessage | undefined;
|
|
486
486
|
|
|
487
487
|
const analyzers: IMessageAnalyzer[] = [
|
|
@@ -498,7 +498,7 @@ export async function printMessageStats(
|
|
|
498
498
|
}
|
|
499
499
|
|
|
500
500
|
for await (const messages of generator) {
|
|
501
|
-
for (const message of messages
|
|
501
|
+
for (const message of messages) {
|
|
502
502
|
const msgSize = JSON.stringify(message).length;
|
|
503
503
|
lastMessage = message;
|
|
504
504
|
|
|
@@ -531,7 +531,7 @@ function processOp(
|
|
|
531
531
|
dataTypeStats: Map<string, [number, number]>,
|
|
532
532
|
messageTypeStats: Map<string, [number, number]>,
|
|
533
533
|
chunkMap: Map<string, { chunks: string[]; totalSize: number }>,
|
|
534
|
-
) {
|
|
534
|
+
): void {
|
|
535
535
|
let type = runtimeMessage.type;
|
|
536
536
|
let recorded = false;
|
|
537
537
|
let totalMsgSize = msgSize;
|
|
@@ -675,7 +675,7 @@ function processOp(
|
|
|
675
675
|
function processDataStoreAttachOp(
|
|
676
676
|
attachMessage: IAttachMessage | string,
|
|
677
677
|
dataType: Map<string, string>,
|
|
678
|
-
) {
|
|
678
|
+
): void {
|
|
679
679
|
// dataType.set(getObjectId(attachMessage.id), attachMessage.type);
|
|
680
680
|
|
|
681
681
|
// That's data store, and it brings a bunch of data structures.
|
|
@@ -703,7 +703,7 @@ function reportOpenSessions(
|
|
|
703
703
|
sessionsInProgress: Map<string, ActiveSession>,
|
|
704
704
|
sessions: Map<string, [number, number]>,
|
|
705
705
|
users: Map<string, [number, number]>,
|
|
706
|
-
) {
|
|
706
|
+
): void {
|
|
707
707
|
const activeSessions = new Map<string, [number, number]>();
|
|
708
708
|
|
|
709
709
|
for (const [clientId, ses] of sessionsInProgress) {
|
|
@@ -739,10 +739,11 @@ function reportOpenSessions(
|
|
|
739
739
|
function calcChannelStats(
|
|
740
740
|
dataType: Map<string, string>,
|
|
741
741
|
objectStats: Map<string, [number, number]>,
|
|
742
|
-
) {
|
|
742
|
+
): Map<string, [number, number]> {
|
|
743
743
|
const channelStats = new Map<string, [number, number]>();
|
|
744
744
|
for (const [objectId, type] of dataType) {
|
|
745
745
|
let value = objectStats.get(objectId);
|
|
746
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy
|
|
746
747
|
if (value === undefined) {
|
|
747
748
|
value = [0, 0];
|
|
748
749
|
}
|
|
@@ -761,7 +762,7 @@ function processQuorumMessages(
|
|
|
761
762
|
sessionsInProgress: Map<string, ActiveSession>,
|
|
762
763
|
sessions: Map<string, [number, number]>,
|
|
763
764
|
users: Map<string, [number, number]>,
|
|
764
|
-
) {
|
|
765
|
+
): ActiveSession | undefined {
|
|
765
766
|
let session: ActiveSession | undefined;
|
|
766
767
|
const dataString = (message as any).data;
|
|
767
768
|
if (message.type === "join") {
|
package/src/fluidFetch.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { fluidFetchMessages } from "./fluidFetchMessages.js";
|
|
|
17
17
|
import { getSharepointFiles, getSingleSharePointFile } from "./fluidFetchSharePoint.js";
|
|
18
18
|
import { fluidFetchSnapshot } from "./fluidFetchSnapshot.js";
|
|
19
19
|
|
|
20
|
-
async function fluidFetchOneFile(urlStr: string, name?: string) {
|
|
20
|
+
async function fluidFetchOneFile(urlStr: string, name?: string): Promise<void> {
|
|
21
21
|
const documentService = await fluidFetchInit(urlStr);
|
|
22
22
|
const saveDir =
|
|
23
23
|
paramSaveDir !== undefined
|
|
@@ -41,7 +41,10 @@ async function fluidFetchOneFile(urlStr: string, name?: string) {
|
|
|
41
41
|
await fluidFetchMessages(documentService, saveDir);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
async function tryFluidFetchOneSharePointFile(
|
|
44
|
+
async function tryFluidFetchOneSharePointFile(
|
|
45
|
+
server: string,
|
|
46
|
+
driveItem: IOdspDriveItem,
|
|
47
|
+
): Promise<void> {
|
|
45
48
|
const { path, name, driveId, itemId } = driveItem;
|
|
46
49
|
console.log(`File: ${path}/${name}`);
|
|
47
50
|
await fluidFetchOneFile(
|
|
@@ -61,7 +64,7 @@ function getSharePointSpecificDriveItem(
|
|
|
61
64
|
}
|
|
62
65
|
}
|
|
63
66
|
|
|
64
|
-
function getSharepointServerRelativePathFromURL(url: URL) {
|
|
67
|
+
function getSharepointServerRelativePathFromURL(url: URL): string | undefined {
|
|
65
68
|
if (url.pathname.startsWith("/_api/v2.1/drives/")) {
|
|
66
69
|
return undefined;
|
|
67
70
|
}
|
|
@@ -83,7 +86,7 @@ function getSharepointServerRelativePathFromURL(url: URL) {
|
|
|
83
86
|
return decodeURI(sitePath);
|
|
84
87
|
}
|
|
85
88
|
|
|
86
|
-
async function fluidFetchMain() {
|
|
89
|
+
async function fluidFetchMain(): Promise<void> {
|
|
87
90
|
if (paramURL === undefined) {
|
|
88
91
|
return;
|
|
89
92
|
}
|
|
@@ -128,7 +131,9 @@ fluidFetchMain()
|
|
|
128
131
|
if (key !== "message" && key !== "stack") {
|
|
129
132
|
extraMsg += `\n${key}: ${JSON.stringify(error[key], undefined, 2)}`;
|
|
130
133
|
}
|
|
131
|
-
} catch (_) {
|
|
134
|
+
} catch (_) {
|
|
135
|
+
// TODO: document why we are ignoring the error here
|
|
136
|
+
}
|
|
132
137
|
}
|
|
133
138
|
console.error(`ERROR: ${error.stack}${extraMsg}`);
|
|
134
139
|
} else if (typeof error === "object") {
|
package/src/fluidFetchArgs.ts
CHANGED
|
@@ -47,7 +47,7 @@ const optionsArray = [
|
|
|
47
47
|
["--loginHint", "login hint for the user with document access."],
|
|
48
48
|
];
|
|
49
49
|
|
|
50
|
-
function printUsage() {
|
|
50
|
+
function printUsage(): void {
|
|
51
51
|
console.log("Usage: fluid-fetch [options] URL");
|
|
52
52
|
console.log("URL: <ODSP URL>|<Routerlicious URL>");
|
|
53
53
|
console.log("Options:");
|
|
@@ -66,7 +66,7 @@ export function setArguments(values: {
|
|
|
66
66
|
dumpSnapshotStats?: boolean;
|
|
67
67
|
dumpSnapshotTrees?: boolean;
|
|
68
68
|
overWrite?: boolean;
|
|
69
|
-
}) {
|
|
69
|
+
}): void {
|
|
70
70
|
paramSaveDir = values.saveDir;
|
|
71
71
|
paramURL = values.paramURL;
|
|
72
72
|
dumpMessages = values.dumpMessages ?? dumpMessages;
|
|
@@ -76,7 +76,7 @@ export function setArguments(values: {
|
|
|
76
76
|
overWrite = values.overWrite ?? overWrite;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
export function parseArguments() {
|
|
79
|
+
export function parseArguments(): void {
|
|
80
80
|
for (let i = 2; i < process.argv.length; i++) {
|
|
81
81
|
const arg = process.argv[i];
|
|
82
82
|
switch (arg) {
|
|
@@ -157,7 +157,7 @@ export function parseArguments() {
|
|
|
157
157
|
checkArgs();
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
function parseStrArg(i: number, name: string) {
|
|
160
|
+
function parseStrArg(i: number, name: string): string {
|
|
161
161
|
if (i + 1 >= process.argv.length) {
|
|
162
162
|
console.error(`ERROR: Missing ${name}`);
|
|
163
163
|
printUsage();
|
|
@@ -165,7 +165,7 @@ function parseStrArg(i: number, name: string) {
|
|
|
165
165
|
}
|
|
166
166
|
return process.argv[i + 1];
|
|
167
167
|
}
|
|
168
|
-
function parseIntArg(i: number, name: string, allowZero: boolean) {
|
|
168
|
+
function parseIntArg(i: number, name: string, allowZero: boolean): number {
|
|
169
169
|
if (i + 1 >= process.argv.length) {
|
|
170
170
|
console.error(`ERROR: Missing ${name}`);
|
|
171
171
|
printUsage();
|
|
@@ -181,7 +181,7 @@ function parseIntArg(i: number, name: string, allowZero: boolean) {
|
|
|
181
181
|
return paramNumber;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
function checkArgs() {
|
|
184
|
+
function checkArgs(): void {
|
|
185
185
|
if (paramSnapshotVersionIndex !== undefined) {
|
|
186
186
|
paramNumSnapshotVersions = Math.max(
|
|
187
187
|
paramSnapshotVersionIndex + 1,
|
package/src/fluidFetchInit.ts
CHANGED
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { IRequest } from "@fluidframework/core-interfaces";
|
|
7
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
IDocumentService,
|
|
9
|
+
IResolvedUrl,
|
|
10
|
+
} from "@fluidframework/driver-definitions/internal";
|
|
8
11
|
import type {
|
|
9
12
|
IPublicClientConfig,
|
|
10
13
|
IOdspAuthRequestInfo,
|
|
@@ -31,7 +34,7 @@ async function initializeODSPCore(
|
|
|
31
34
|
odspResolvedUrl: IOdspResolvedUrl,
|
|
32
35
|
server: string,
|
|
33
36
|
clientConfig: IPublicClientConfig,
|
|
34
|
-
) {
|
|
37
|
+
): Promise<IDocumentService | undefined> {
|
|
35
38
|
const { driveId, itemId } = odspResolvedUrl;
|
|
36
39
|
|
|
37
40
|
connectionInfo = {
|
|
@@ -52,7 +55,9 @@ async function initializeODSPCore(
|
|
|
52
55
|
item: ${itemId}
|
|
53
56
|
docId: ${docId}`);
|
|
54
57
|
|
|
55
|
-
const getStorageTokenStub = async (
|
|
58
|
+
const getStorageTokenStub = async (
|
|
59
|
+
options: OdspResourceTokenFetchOptions,
|
|
60
|
+
): Promise<string> => {
|
|
56
61
|
return resolveWrapper(
|
|
57
62
|
async (authRequestInfo: IOdspAuthRequestInfo) => {
|
|
58
63
|
if (
|
|
@@ -68,7 +73,7 @@ async function initializeODSPCore(
|
|
|
68
73
|
);
|
|
69
74
|
};
|
|
70
75
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
71
|
-
const getWebsocketTokenStub = (_options: OdspResourceTokenFetchOptions) =>
|
|
76
|
+
const getWebsocketTokenStub = (_options: OdspResourceTokenFetchOptions): Promise<string> =>
|
|
72
77
|
Promise.resolve("");
|
|
73
78
|
const odspDocumentServiceFactory = new odsp.OdspDocumentServiceFactory(
|
|
74
79
|
getStorageTokenStub,
|
|
@@ -86,7 +91,7 @@ async function initializeR11s(
|
|
|
86
91
|
server: string,
|
|
87
92
|
pathname: string,
|
|
88
93
|
r11sResolvedUrl: IResolvedUrl,
|
|
89
|
-
) {
|
|
94
|
+
): Promise<IDocumentService | undefined> {
|
|
90
95
|
const path = pathname.split("/");
|
|
91
96
|
let tenantId: string;
|
|
92
97
|
let documentId: string;
|
|
@@ -108,7 +113,7 @@ async function initializeR11s(
|
|
|
108
113
|
};
|
|
109
114
|
|
|
110
115
|
if (localDataOnly) {
|
|
111
|
-
return;
|
|
116
|
+
return undefined;
|
|
112
117
|
}
|
|
113
118
|
|
|
114
119
|
console.log(`Connecting to r11s: tenantId=${tenantId} id:${documentId}`);
|
|
@@ -159,7 +164,7 @@ async function resolveUrl(url: string): Promise<IResolvedInfo | undefined> {
|
|
|
159
164
|
return undefined;
|
|
160
165
|
}
|
|
161
166
|
|
|
162
|
-
export async function fluidFetchInit(urlStr: string) {
|
|
167
|
+
export async function fluidFetchInit(urlStr: string): Promise<IDocumentService | undefined> {
|
|
163
168
|
const resolvedInfo = await resolveUrl(urlStr);
|
|
164
169
|
if (resolvedInfo === undefined) {
|
|
165
170
|
throw new Error(`Unknown URL ${urlStr}`);
|
|
@@ -33,7 +33,7 @@ async function* loadAllSequencedMessages(
|
|
|
33
33
|
documentService?: IDocumentService,
|
|
34
34
|
dir?: string,
|
|
35
35
|
files?: string[],
|
|
36
|
-
) {
|
|
36
|
+
): AsyncGenerator<ISequencedDocumentMessage[]> {
|
|
37
37
|
let lastSeq = 0;
|
|
38
38
|
// flag for mismatch between last sequence number read and new one to be read
|
|
39
39
|
let seqNumMismatch = false;
|
|
@@ -210,10 +210,10 @@ async function* loadAllSequencedMessages(
|
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
async function* saveOps(
|
|
213
|
-
gen
|
|
213
|
+
gen: AsyncGenerator<ISequencedDocumentMessage[]>,
|
|
214
214
|
dir: string,
|
|
215
215
|
files: string[],
|
|
216
|
-
) {
|
|
216
|
+
): AsyncGenerator<ISequencedDocumentMessage[]> {
|
|
217
217
|
// Split into 100K ops
|
|
218
218
|
const chunk = 100 * 1000;
|
|
219
219
|
|
|
@@ -287,7 +287,7 @@ async function* saveOps(
|
|
|
287
287
|
export async function fluidFetchMessages(
|
|
288
288
|
documentService?: IDocumentService,
|
|
289
289
|
saveDir?: string,
|
|
290
|
-
) {
|
|
290
|
+
): Promise<void> {
|
|
291
291
|
const messageStats = dumpMessageStats || dumpMessages;
|
|
292
292
|
if (!messageStats && (saveDir === undefined || documentService === undefined)) {
|
|
293
293
|
return;
|
|
@@ -316,6 +316,7 @@ export async function fluidFetchMessages(
|
|
|
316
316
|
return printMessageStats(generator, dumpMessageStats, dumpMessages, messageTypeFilter);
|
|
317
317
|
} else {
|
|
318
318
|
let item;
|
|
319
|
+
// eslint-disable-next-line no-empty -- TODO: Investigate / document what is going on here.
|
|
319
320
|
for await (item of generator) {
|
|
320
321
|
}
|
|
321
322
|
}
|
|
@@ -113,7 +113,7 @@ async function resolveDriveItemByServerRelativePath(
|
|
|
113
113
|
server: string,
|
|
114
114
|
serverRelativePath: string,
|
|
115
115
|
clientConfig: IPublicClientConfig,
|
|
116
|
-
) {
|
|
116
|
+
): Promise<IOdspDriveItem> {
|
|
117
117
|
return resolveWrapper<IOdspDriveItem>(
|
|
118
118
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
119
119
|
(authRequestInfo) =>
|
|
@@ -127,7 +127,7 @@ async function resolveChildrenByDriveItem(
|
|
|
127
127
|
server: string,
|
|
128
128
|
folderDriveItem: IOdspDriveItem,
|
|
129
129
|
clientConfig: IPublicClientConfig,
|
|
130
|
-
) {
|
|
130
|
+
): Promise<IOdspDriveItem[]> {
|
|
131
131
|
return resolveWrapper<IOdspDriveItem[]>(
|
|
132
132
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
133
133
|
(authRequestInfo) => getChildrenByDriveItem(folderDriveItem, server, authRequestInfo),
|
|
@@ -140,7 +140,7 @@ export async function getSharepointFiles(
|
|
|
140
140
|
server: string,
|
|
141
141
|
serverRelativePath: string,
|
|
142
142
|
recurse: boolean,
|
|
143
|
-
) {
|
|
143
|
+
): Promise<IOdspDriveItem[]> {
|
|
144
144
|
const fileInfo = await resolveDriveItemByServerRelativePath(
|
|
145
145
|
server,
|
|
146
146
|
serverRelativePath,
|
|
@@ -177,7 +177,11 @@ export async function getSharepointFiles(
|
|
|
177
177
|
return files;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
export async function getSingleSharePointFile(
|
|
180
|
+
export async function getSingleSharePointFile(
|
|
181
|
+
server: string,
|
|
182
|
+
drive: string,
|
|
183
|
+
item: string,
|
|
184
|
+
): Promise<IOdspDriveItem> {
|
|
181
185
|
return resolveWrapper<IOdspDriveItem>(
|
|
182
186
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
183
187
|
(authRequestInfo) => getDriveItemFromDriveAndItem(server, drive, item, authRequestInfo),
|
|
@@ -66,7 +66,7 @@ function fetchBlobs(
|
|
|
66
66
|
tree: ISnapshotTree,
|
|
67
67
|
storage: IDocumentStorageService,
|
|
68
68
|
blobIdMap: Map<string, number>,
|
|
69
|
-
) {
|
|
69
|
+
): IFetchedBlob[] {
|
|
70
70
|
const result: IFetchedBlob[] = [];
|
|
71
71
|
for (const [item, blobId] of Object.entries(tree.blobs)) {
|
|
72
72
|
const treePath = `${prefix}${item}`;
|
|
@@ -150,12 +150,15 @@ async function fetchBlobsFromSnapshotTree(
|
|
|
150
150
|
return result;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
function getDumpFetchedData(fetchedData: IFetchedData[]) {
|
|
153
|
+
function getDumpFetchedData(fetchedData: IFetchedData[]): IFetchedData[] {
|
|
154
154
|
const sorted = fetchedData.sort((a, b) => a.treePath.localeCompare(b.treePath));
|
|
155
155
|
return sorted.filter((item) => !isFetchedTree(item) || !item.patched);
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
async function dumpSnapshotTreeVerbose(
|
|
158
|
+
async function dumpSnapshotTreeVerbose(
|
|
159
|
+
name: string,
|
|
160
|
+
fetchedData: IFetchedData[],
|
|
161
|
+
): Promise<void> {
|
|
159
162
|
let size = 0;
|
|
160
163
|
const sorted = getDumpFetchedData(fetchedData);
|
|
161
164
|
|
|
@@ -214,7 +217,11 @@ async function dumpSnapshotTree(
|
|
|
214
217
|
return { blobCountNew, blobCount: sorted.length, size, sizeNew };
|
|
215
218
|
}
|
|
216
219
|
|
|
217
|
-
async function saveSnapshot(
|
|
220
|
+
async function saveSnapshot(
|
|
221
|
+
name: string,
|
|
222
|
+
fetchedData: IFetchedData[],
|
|
223
|
+
saveDir: string,
|
|
224
|
+
): Promise<void> {
|
|
218
225
|
const outDir = `${saveDir}/${name}/`;
|
|
219
226
|
const mkdir = util.promisify(fs.mkdir);
|
|
220
227
|
|
|
@@ -238,7 +245,9 @@ async function saveSnapshot(name: string, fetchedData: IFetchedData[], saveDir:
|
|
|
238
245
|
if (!paramActualFormatting) {
|
|
239
246
|
decoded = JSON.stringify(JSON.parse(decoded), undefined, 2);
|
|
240
247
|
}
|
|
241
|
-
} catch (e) {
|
|
248
|
+
} catch (e) {
|
|
249
|
+
// TODO: document why we are ignoring the error here
|
|
250
|
+
}
|
|
242
251
|
fs.writeFileSync(`${outDir}/decoded/${item.filename}.json`, decoded);
|
|
243
252
|
} else {
|
|
244
253
|
// Write out same data for tree decoded or not, except for formatting
|
|
@@ -255,7 +264,10 @@ async function saveSnapshot(name: string, fetchedData: IFetchedData[], saveDir:
|
|
|
255
264
|
);
|
|
256
265
|
}
|
|
257
266
|
|
|
258
|
-
async function fetchBlobsFromVersion(
|
|
267
|
+
async function fetchBlobsFromVersion(
|
|
268
|
+
storage: IDocumentStorageService,
|
|
269
|
+
version: IVersion,
|
|
270
|
+
): Promise<IFetchedData[]> {
|
|
259
271
|
const tree = await reportErrors(
|
|
260
272
|
`getSnapshotTree ${version.id}`,
|
|
261
273
|
storage.getSnapshotTree(version),
|
|
@@ -266,7 +278,7 @@ async function fetchBlobsFromVersion(storage: IDocumentStorageService, version:
|
|
|
266
278
|
return fetchBlobsFromSnapshotTree(storage, tree);
|
|
267
279
|
}
|
|
268
280
|
|
|
269
|
-
async function reportErrors<T>(message: string, res: Promise<T>) {
|
|
281
|
+
async function reportErrors<T>(message: string, res: Promise<T>): Promise<T> {
|
|
270
282
|
try {
|
|
271
283
|
return await res;
|
|
272
284
|
} catch (error) {
|
|
@@ -278,7 +290,7 @@ async function reportErrors<T>(message: string, res: Promise<T>) {
|
|
|
278
290
|
export async function fluidFetchSnapshot(
|
|
279
291
|
documentService?: IDocumentService,
|
|
280
292
|
saveDir?: string,
|
|
281
|
-
) {
|
|
293
|
+
): Promise<void> {
|
|
282
294
|
if (
|
|
283
295
|
!dumpSnapshotStats &&
|
|
284
296
|
!dumpSnapshotTrees &&
|
|
@@ -373,6 +385,7 @@ export async function fluidFetchSnapshot(
|
|
|
373
385
|
if (version === undefined) {
|
|
374
386
|
console.log("No snapshot tree");
|
|
375
387
|
} else {
|
|
388
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions, @typescript-eslint/prefer-nullish-coalescing -- intentional behavior
|
|
376
389
|
if (blobsToDump === undefined) {
|
|
377
390
|
blobsToDump = await fetchBlobsFromVersion(storage, version);
|
|
378
391
|
}
|
package/.eslintrc.cjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
extends: [
|
|
8
|
-
require.resolve("@fluidframework/eslint-config-fluid/minimal-deprecated"),
|
|
9
|
-
"prettier",
|
|
10
|
-
],
|
|
11
|
-
rules: {
|
|
12
|
-
// This library is used in the browser, so we don't want dependencies on most node libraries.
|
|
13
|
-
"import-x/no-nodejs-modules": ["error", { allow: ["child_process", "fs", "util"] }],
|
|
14
|
-
|
|
15
|
-
// #region TODO: remove these once this config has been updated to use our "recommended" base instead of our deprecated minimal one.
|
|
16
|
-
"@typescript-eslint/consistent-type-exports": [
|
|
17
|
-
"error",
|
|
18
|
-
{ fixMixedExportsWithInlineTypeSpecifier: true },
|
|
19
|
-
],
|
|
20
|
-
"@typescript-eslint/consistent-type-imports": [
|
|
21
|
-
"error",
|
|
22
|
-
{ fixStyle: "inline-type-imports" },
|
|
23
|
-
],
|
|
24
|
-
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
25
|
-
// #endregion
|
|
26
|
-
},
|
|
27
|
-
};
|