Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement(routerlicious-driver): change Object.keys to Object.entries #23710

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/drivers/routerlicious-driver/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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": "warn",
"no-case-declarations": "off"
},
};
5 changes: 1 addition & 4 deletions packages/drivers/routerlicious-driver/src/createNewUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions packages/drivers/routerlicious-driver/src/documentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}]`,
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ export class SummaryTreeUploadManager implements ISummaryUploadManager {
previousFullSnapshot: ISnapshotTreeEx | undefined,
): Promise<string> {
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),
Expand Down Expand Up @@ -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." */,
Expand Down
Loading