From 31fee9c6c5f0bfb5efe6eee3cb3c020c00c5b57c Mon Sep 17 00:00:00 2001 From: Rishhi Balakrishnan <107130183+RishhiB@users.noreply.github.com> Date: Fri, 31 Jan 2025 16:00:04 +0000 Subject: [PATCH 1/6] Enable no-unchecked-record-access to routerlicious driver --- packages/drivers/routerlicious-driver/.eslintrc.cjs | 2 +- .../drivers/routerlicious-driver/src/createNewUtils.ts | 5 +---- .../drivers/routerlicious-driver/src/documentService.ts | 6 +++--- .../routerlicious-driver/src/documentServiceFactory.ts | 8 ++++---- .../routerlicious-driver/src/r11sSnapshotParser.ts | 2 +- .../routerlicious-driver/src/summaryTreeUploadManager.ts | 5 ++--- 6 files changed, 12 insertions(+), 16 deletions(-) diff --git a/packages/drivers/routerlicious-driver/.eslintrc.cjs b/packages/drivers/routerlicious-driver/.eslintrc.cjs index 1f213a985b45..9512602efd60 100644 --- a/packages/drivers/routerlicious-driver/.eslintrc.cjs +++ b/packages/drivers/routerlicious-driver/.eslintrc.cjs @@ -15,6 +15,6 @@ module.exports = { "@typescript-eslint/no-non-null-assertion": "off", "@typescript-eslint/strict-boolean-expressions": "off", "no-case-declarations": "off", - "@fluid-internal/fluid/no-unchecked-record-access": "warn", + "@fluid-internal/fluid/no-unchecked-record-access": "error", }, }; diff --git a/packages/drivers/routerlicious-driver/src/createNewUtils.ts b/packages/drivers/routerlicious-driver/src/createNewUtils.ts index 37675d3dca95..3de896017101 100644 --- a/packages/drivers/routerlicious-driver/src/createNewUtils.ts +++ b/packages/drivers/routerlicious-driver/src/createNewUtils.ts @@ -12,10 +12,7 @@ import { ISummaryTree, SummaryType } from "@fluidframework/driver-definitions"; * @returns Modified summary tree where the blob contents could be utf8 string only. */ export function convertSummaryToCreateNewSummary(summary: ISummaryTree): ISummaryTree { - const keys = Object.keys(summary.tree); - for (const key of keys) { - const summaryObject = summary.tree[key]; - + for (const [key, summaryObject] of Object.entries(summary.tree)) { switch (summaryObject.type) { case SummaryType.Tree: { summary.tree[key] = convertSummaryToCreateNewSummary(summaryObject); diff --git a/packages/drivers/routerlicious-driver/src/documentService.ts b/packages/drivers/routerlicious-driver/src/documentService.ts index 71642c821f85..75e1b7e9ba61 100644 --- a/packages/drivers/routerlicious-driver/src/documentService.ts +++ b/packages/drivers/routerlicious-driver/src/documentService.ts @@ -302,9 +302,9 @@ export class DocumentService } const fluidResolvedUrl = response.resolvedUrl; this._resolvedUrl = fluidResolvedUrl; - this.storageUrl = fluidResolvedUrl.endpoints.storageUrl; - this.ordererUrl = fluidResolvedUrl.endpoints.ordererUrl; - this.deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl; + this.storageUrl = fluidResolvedUrl?.endpoints?.storageUrl; + this.ordererUrl = fluidResolvedUrl?.endpoints?.ordererUrl; + this.deltaStorageUrl = fluidResolvedUrl?.endpoints?.deltaStorageUrl; this.deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl ?? this.ordererUrl; return true; } diff --git a/packages/drivers/routerlicious-driver/src/documentServiceFactory.ts b/packages/drivers/routerlicious-driver/src/documentServiceFactory.ts index 0fb133dc4833..58e89d0632d5 100644 --- a/packages/drivers/routerlicious-driver/src/documentServiceFactory.ts +++ b/packages/drivers/routerlicious-driver/src/documentServiceFactory.ts @@ -213,7 +213,7 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact } parsedUrl.pathname = replaceDocumentIdInPath(parsedUrl.pathname, documentId); - const deltaStorageUrl = resolvedUrl.endpoints.deltaStorageUrl; + const deltaStorageUrl: string | undefined = resolvedUrl.endpoints.deltaStorageUrl; if (!deltaStorageUrl) { throw new Error( `All endpoints urls must be provided. [deltaStorageUrl:${deltaStorageUrl}]`, @@ -303,9 +303,9 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact }, ); - const storageUrl = fluidResolvedUrl.endpoints.storageUrl; - const ordererUrl = fluidResolvedUrl.endpoints.ordererUrl; - const deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl; + const storageUrl = fluidResolvedUrl?.endpoints?.storageUrl; + const ordererUrl = fluidResolvedUrl?.endpoints?.ordererUrl; + const deltaStorageUrl = fluidResolvedUrl?.endpoints?.deltaStorageUrl; const deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl || ordererUrl; // backward compatibility if (!ordererUrl || !deltaStorageUrl) { throw new Error( diff --git a/packages/drivers/routerlicious-driver/src/r11sSnapshotParser.ts b/packages/drivers/routerlicious-driver/src/r11sSnapshotParser.ts index 417cc89656aa..d3b23bdadec2 100644 --- a/packages/drivers/routerlicious-driver/src/r11sSnapshotParser.ts +++ b/packages/drivers/routerlicious-driver/src/r11sSnapshotParser.ts @@ -36,7 +36,7 @@ function buildHierarchy( const entryPathBase = entryPath.slice(lastIndex + 1); // The flat output is breadth-first so we can assume we see tree nodes prior to their contents - const node = lookup[entryPathDir]; + const node: ISnapshotTree | undefined = lookup[entryPathDir]; // Add in either the blob or tree if (entry.type === "tree") { diff --git a/packages/drivers/routerlicious-driver/src/summaryTreeUploadManager.ts b/packages/drivers/routerlicious-driver/src/summaryTreeUploadManager.ts index 78faa9a5b9f2..1a9c49151e42 100644 --- a/packages/drivers/routerlicious-driver/src/summaryTreeUploadManager.ts +++ b/packages/drivers/routerlicious-driver/src/summaryTreeUploadManager.ts @@ -41,8 +41,7 @@ export class SummaryTreeUploadManager implements ISummaryUploadManager { previousFullSnapshot: ISnapshotTreeEx | undefined, ): Promise { const entries = await Promise.all( - Object.keys(summaryTree.tree).map(async (key) => { - const entry = summaryTree.tree[key]; + Object.entries(summaryTree.tree).map(async ([key, entry]) => { const pathHandle = await this.writeSummaryTreeObject(entry, previousFullSnapshot); const treeEntry: IGitCreateTreeEntry = { mode: getGitMode(entry), @@ -128,7 +127,7 @@ export class SummaryTreeUploadManager implements ISummaryUploadManager { if (path.length === 1) { switch (handleType) { case SummaryType.Blob: { - const tryId = previousSnapshot.blobs[key]; + const tryId: string | undefined = previousSnapshot.blobs[key]; assert( !!tryId, 0x0b4 /* "Parent summary does not have blob handle for specified path." */, From 5ed8641efe799235d695a4bb6f06488d37be1264 Mon Sep 17 00:00:00 2001 From: Rishhi Balakrishnan <107130183+RishhiB@users.noreply.github.com> Date: Fri, 31 Jan 2025 16:02:29 +0000 Subject: [PATCH 2/6] deleted no-unchecked-record-access in eslintrc --- packages/drivers/routerlicious-driver/.eslintrc.cjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/drivers/routerlicious-driver/.eslintrc.cjs b/packages/drivers/routerlicious-driver/.eslintrc.cjs index 9512602efd60..16eba2a7b2ba 100644 --- a/packages/drivers/routerlicious-driver/.eslintrc.cjs +++ b/packages/drivers/routerlicious-driver/.eslintrc.cjs @@ -14,7 +14,6 @@ module.exports = { rules: { "@typescript-eslint/no-non-null-assertion": "off", "@typescript-eslint/strict-boolean-expressions": "off", - "no-case-declarations": "off", - "@fluid-internal/fluid/no-unchecked-record-access": "error", + "no-case-declarations": "off" }, }; From a3071c89487db655e2227c023730787ee3c8241b Mon Sep 17 00:00:00 2001 From: Rishhi Balakrishnan <107130183+RishhiB@users.noreply.github.com> Date: Fri, 31 Jan 2025 16:46:59 +0000 Subject: [PATCH 3/6] add comma --- packages/drivers/routerlicious-driver/.eslintrc.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/drivers/routerlicious-driver/.eslintrc.cjs b/packages/drivers/routerlicious-driver/.eslintrc.cjs index 16eba2a7b2ba..80de27c908d2 100644 --- a/packages/drivers/routerlicious-driver/.eslintrc.cjs +++ b/packages/drivers/routerlicious-driver/.eslintrc.cjs @@ -14,6 +14,6 @@ module.exports = { rules: { "@typescript-eslint/no-non-null-assertion": "off", "@typescript-eslint/strict-boolean-expressions": "off", - "no-case-declarations": "off" + "no-case-declarations": "off", }, }; From 3314d3599cf033cfaa9f7bd69e0d5db77129035e Mon Sep 17 00:00:00 2001 From: Rishhi Balakrishnan <107130183+RishhiB@users.noreply.github.com> Date: Fri, 31 Jan 2025 18:08:32 +0000 Subject: [PATCH 4/6] allow error --- .../routerlicious-driver/src/documentServiceFactory.ts | 8 ++++---- .../routerlicious-driver/src/r11sSnapshotParser.ts | 2 +- .../routerlicious-driver/src/summaryTreeUploadManager.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/drivers/routerlicious-driver/src/documentServiceFactory.ts b/packages/drivers/routerlicious-driver/src/documentServiceFactory.ts index 58e89d0632d5..0fb133dc4833 100644 --- a/packages/drivers/routerlicious-driver/src/documentServiceFactory.ts +++ b/packages/drivers/routerlicious-driver/src/documentServiceFactory.ts @@ -213,7 +213,7 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact } parsedUrl.pathname = replaceDocumentIdInPath(parsedUrl.pathname, documentId); - const deltaStorageUrl: string | undefined = resolvedUrl.endpoints.deltaStorageUrl; + const deltaStorageUrl = resolvedUrl.endpoints.deltaStorageUrl; if (!deltaStorageUrl) { throw new Error( `All endpoints urls must be provided. [deltaStorageUrl:${deltaStorageUrl}]`, @@ -303,9 +303,9 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact }, ); - const storageUrl = fluidResolvedUrl?.endpoints?.storageUrl; - const ordererUrl = fluidResolvedUrl?.endpoints?.ordererUrl; - const deltaStorageUrl = fluidResolvedUrl?.endpoints?.deltaStorageUrl; + const storageUrl = fluidResolvedUrl.endpoints.storageUrl; + const ordererUrl = fluidResolvedUrl.endpoints.ordererUrl; + const deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl; const deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl || ordererUrl; // backward compatibility if (!ordererUrl || !deltaStorageUrl) { throw new Error( diff --git a/packages/drivers/routerlicious-driver/src/r11sSnapshotParser.ts b/packages/drivers/routerlicious-driver/src/r11sSnapshotParser.ts index d3b23bdadec2..417cc89656aa 100644 --- a/packages/drivers/routerlicious-driver/src/r11sSnapshotParser.ts +++ b/packages/drivers/routerlicious-driver/src/r11sSnapshotParser.ts @@ -36,7 +36,7 @@ function buildHierarchy( const entryPathBase = entryPath.slice(lastIndex + 1); // The flat output is breadth-first so we can assume we see tree nodes prior to their contents - const node: ISnapshotTree | undefined = lookup[entryPathDir]; + const node = lookup[entryPathDir]; // Add in either the blob or tree if (entry.type === "tree") { diff --git a/packages/drivers/routerlicious-driver/src/summaryTreeUploadManager.ts b/packages/drivers/routerlicious-driver/src/summaryTreeUploadManager.ts index 1a9c49151e42..c77f38ccf650 100644 --- a/packages/drivers/routerlicious-driver/src/summaryTreeUploadManager.ts +++ b/packages/drivers/routerlicious-driver/src/summaryTreeUploadManager.ts @@ -127,7 +127,7 @@ export class SummaryTreeUploadManager implements ISummaryUploadManager { if (path.length === 1) { switch (handleType) { case SummaryType.Blob: { - const tryId: string | undefined = previousSnapshot.blobs[key]; + const tryId = previousSnapshot.blobs[key]; assert( !!tryId, 0x0b4 /* "Parent summary does not have blob handle for specified path." */, From 2fbd07ed4a3ce4dff11ceafe309ce649351cfd7e Mon Sep 17 00:00:00 2001 From: Rishhi Balakrishnan <107130183+RishhiB@users.noreply.github.com> Date: Mon, 3 Feb 2025 17:45:02 +0000 Subject: [PATCH 5/6] undo optional chaining --- .../drivers/routerlicious-driver/src/documentService.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/drivers/routerlicious-driver/src/documentService.ts b/packages/drivers/routerlicious-driver/src/documentService.ts index 75e1b7e9ba61..71642c821f85 100644 --- a/packages/drivers/routerlicious-driver/src/documentService.ts +++ b/packages/drivers/routerlicious-driver/src/documentService.ts @@ -302,9 +302,9 @@ export class DocumentService } const fluidResolvedUrl = response.resolvedUrl; this._resolvedUrl = fluidResolvedUrl; - this.storageUrl = fluidResolvedUrl?.endpoints?.storageUrl; - this.ordererUrl = fluidResolvedUrl?.endpoints?.ordererUrl; - this.deltaStorageUrl = fluidResolvedUrl?.endpoints?.deltaStorageUrl; + this.storageUrl = fluidResolvedUrl.endpoints.storageUrl; + this.ordererUrl = fluidResolvedUrl.endpoints.ordererUrl; + this.deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl; this.deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl ?? this.ordererUrl; return true; } From 8f38751f5f2701ab66a3dfd5a50595e31ca42057 Mon Sep 17 00:00:00 2001 From: Rishhi Balakrishnan <107130183+RishhiB@users.noreply.github.com> Date: Mon, 3 Feb 2025 17:46:42 +0000 Subject: [PATCH 6/6] undo lint changes --- packages/drivers/routerlicious-driver/.eslintrc.cjs | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/drivers/routerlicious-driver/.eslintrc.cjs b/packages/drivers/routerlicious-driver/.eslintrc.cjs index 80de27c908d2..1f213a985b45 100644 --- a/packages/drivers/routerlicious-driver/.eslintrc.cjs +++ b/packages/drivers/routerlicious-driver/.eslintrc.cjs @@ -15,5 +15,6 @@ module.exports = { "@typescript-eslint/no-non-null-assertion": "off", "@typescript-eslint/strict-boolean-expressions": "off", "no-case-declarations": "off", + "@fluid-internal/fluid/no-unchecked-record-access": "warn", }, };