diff --git a/brainstorm/src/app_load.tsx b/brainstorm/src/app_load.tsx index 52a513bb5..db22dc72c 100644 --- a/brainstorm/src/app_load.tsx +++ b/brainstorm/src/app_load.tsx @@ -1,17 +1,17 @@ +import type { AzureClient } from "@fluidframework/azure-client"; import type { ITelemetryBaseLogger } from "@fluidframework/core-interfaces"; -import { AzureClient } from "@fluidframework/azure-client"; -import { OdspClient } from "@fluidframework/odsp-client/beta"; -import React from "react"; +import type { OdspClient } from "@fluidframework/odsp-client/beta"; +import type { IFluidContainer } from "fluid-framework"; import { DndProvider } from "react-dnd"; import { HTML5Backend } from "react-dnd-html5-backend"; import { createRoot } from "react-dom/client"; + +import { loadFluidData } from "./infra/fluid.js"; import { ReactApp } from "./react/ux.js"; import { Items, appTreeConfiguration } from "./schema/app_schema.js"; +import { containerSchema } from "./schema/container_schema.js"; import { sessionTreeConfiguration } from "./schema/session_schema.js"; import { createUndoRedoStacks } from "./utils/undo.js"; -import { containerSchema } from "./schema/container_schema.js"; -import { loadFluidData } from "./infra/fluid.js"; -import { IFluidContainer } from "fluid-framework"; export async function loadApp( client: AzureClient | OdspClient, @@ -39,7 +39,7 @@ export async function loadApp( // create the root element for React const app = document.createElement("div"); app.id = "app"; - document.body.appendChild(app); + document.body.append(app); const root = createRoot(app); // Create undo/redo stacks for the app diff --git a/brainstorm/src/index.tsx b/brainstorm/src/index.tsx index 024ff2f0c..7529298df 100644 --- a/brainstorm/src/index.tsx +++ b/brainstorm/src/index.tsx @@ -3,21 +3,23 @@ * Licensed under the MIT License. */ -import { speStart } from "./start/spe_start.js"; import { anonymousAzureStart } from "./start/azure_start.js"; +import { speStart } from "./start/spe_start.js"; async function start() { const client = process.env.FLUID_CLIENT; switch (client) { - case "spe": + case "spe": { // Start the app in SPE mode await speStart(); break; - default: + } + default: { // Start the app in Azure mode await anonymousAzureStart(); break; + } } } diff --git a/brainstorm/src/infra/azure/azureClientProps.ts b/brainstorm/src/infra/azure/azureClientProps.ts index 0f351d45b..588337ae4 100644 --- a/brainstorm/src/infra/azure/azureClientProps.ts +++ b/brainstorm/src/infra/azure/azureClientProps.ts @@ -9,8 +9,8 @@ import type { AzureLocalConnectionConfig, ITelemetryBaseLogger, } from "@fluidframework/azure-client"; -import { InsecureTokenProvider } from "./azureTokenProvider.js"; -import { AzureFunctionTokenProvider, azureUser, user } from "./azureTokenProvider.js"; + +import { InsecureTokenProvider, AzureFunctionTokenProvider, azureUser, user } from "./azureTokenProvider.js"; const client = process.env.FLUID_CLIENT; const local = client === undefined || client === "local"; @@ -20,12 +20,12 @@ if (local) { const remoteConnectionConfig: AzureRemoteConnectionConfig = { type: "remote", - tenantId: process.env.AZURE_TENANT_ID!, + tenantId: process.env.AZURE_TENANT_ID ?? "", tokenProvider: new AzureFunctionTokenProvider( - process.env.AZURE_FUNCTION_TOKEN_PROVIDER_URL!, + process.env.AZURE_FUNCTION_TOKEN_PROVIDER_URL ?? "", azureUser, ), - endpoint: process.env.AZURE_ORDERER!, + endpoint: process.env.AZURE_ORDERER ?? "", }; const localConnectionConfig: AzureLocalConnectionConfig = { @@ -34,9 +34,9 @@ const localConnectionConfig: AzureLocalConnectionConfig = { endpoint: "http://localhost:7070", }; -const connectionConfig: AzureRemoteConnectionConfig | AzureLocalConnectionConfig = !local - ? remoteConnectionConfig - : localConnectionConfig; +const connectionConfig: AzureRemoteConnectionConfig | AzureLocalConnectionConfig = local + ? localConnectionConfig + : remoteConnectionConfig; export function getClientProps(logger?: ITelemetryBaseLogger): AzureClientProps { return { diff --git a/brainstorm/src/infra/azure/azureTokenProvider.ts b/brainstorm/src/infra/azure/azureTokenProvider.ts index 35a4b2186..a74c4db2a 100644 --- a/brainstorm/src/infra/azure/azureTokenProvider.ts +++ b/brainstorm/src/infra/azure/azureTokenProvider.ts @@ -3,12 +3,12 @@ * Licensed under the MIT License. */ -import { AzureMember, ITokenProvider, ITokenResponse, IUser } from "@fluidframework/azure-client"; +import type { AzureMember, ITokenProvider, ITokenResponse, IUser } from "@fluidframework/azure-client"; import { ScopeType } from "@fluidframework/protocol-definitions"; import axios from "axios"; import { KJUR as jsrsasign } from "jsrsasign"; -import { v4 as uuid } from "uuid"; import { uniqueNamesGenerator, names } from "unique-names-generator"; +import { v4 as uuid } from "uuid"; /** * Insecure user definition. @@ -154,7 +154,7 @@ export function generateToken( lifetime: number = 60 * 60, ver = "1.0", ): string { - let userClaim = user ? user : generateUser(); + let userClaim = user ?? generateUser(); if (userClaim.id === "" || userClaim.id === undefined) { userClaim = generateUser(); } diff --git a/brainstorm/src/infra/fluid.ts b/brainstorm/src/infra/fluid.ts index d0a45e34c..d9b584c52 100644 --- a/brainstorm/src/infra/fluid.ts +++ b/brainstorm/src/infra/fluid.ts @@ -3,10 +3,10 @@ * Licensed under the MIT License. */ +import type { AzureClient, AzureContainerServices } from "@fluidframework/azure-client"; import type { ITelemetryBaseLogger } from "@fluidframework/core-interfaces"; -import { AzureClient, AzureContainerServices } from "@fluidframework/azure-client"; -import { ContainerSchema, IFluidContainer } from "fluid-framework"; -import { OdspClient, OdspContainerServices } from "@fluidframework/odsp-client/beta"; +import type { OdspClient, OdspContainerServices } from "@fluidframework/odsp-client/beta"; +import type { ContainerSchema, IFluidContainer } from "fluid-framework"; /** * This function will create a container if no container ID is passed. diff --git a/brainstorm/src/infra/spe/graphHelper.ts b/brainstorm/src/infra/spe/graphHelper.ts index ff9cf311e..2941b429f 100644 --- a/brainstorm/src/infra/spe/graphHelper.ts +++ b/brainstorm/src/infra/spe/graphHelper.ts @@ -1,10 +1,12 @@ -import { PublicClientApplication, InteractionType, AccountInfo } from "@azure/msal-browser"; +import type { PublicClientApplication, AccountInfo } from "@azure/msal-browser"; +import { InteractionType } from "@azure/msal-browser"; import { Client } from "@microsoft/microsoft-graph-client"; +import type { + AuthCodeMSALBrowserAuthenticationProviderOptions} from "@microsoft/microsoft-graph-client/authProviders/authCodeMsalBrowser/index.js"; import { - AuthCodeMSALBrowserAuthenticationProvider, - AuthCodeMSALBrowserAuthenticationProviderOptions, + AuthCodeMSALBrowserAuthenticationProvider } from "@microsoft/microsoft-graph-client/authProviders/authCodeMsalBrowser/index.js"; -import { Site } from "@microsoft/microsoft-graph-types"; +import type { Site } from "@microsoft/microsoft-graph-types"; export interface FileStorageContainer { containerTypeId: string; @@ -56,19 +58,19 @@ export class GraphHelper { try { const response = await this.graphClient .api("/storage/fileStorage/containers") - .filter("containerTypeId eq " + containerTypeId) + .filter(`containerTypeId eq ${ containerTypeId}`) .version("beta") .get(); const fileStorageContainers: FileStorageContainer[] = response.value; - if (fileStorageContainers.length == 0) { + if (fileStorageContainers.length === 0) { throw new Error("TEST: no fileStorageContainers"); } return fileStorageContainers[0].id; } catch (error) { - console.error("Error while fetching file storage container ID: ", error); + console.error("Error while fetching file storage container ID:", error); throw error; // re-throw the error if you want it to propagate } } @@ -97,7 +99,7 @@ export class GraphHelper { .api(`/drives/${driveId}/items/${id}/createLink`) .post(permission); - console.log("createSharingLink response: ", response.link); + console.log("createSharingLink response:", response.link); return response.shareId as string; } diff --git a/brainstorm/src/infra/spe/speClientProps.ts b/brainstorm/src/infra/spe/speClientProps.ts index 111d37e6b..e2a2f4257 100644 --- a/brainstorm/src/infra/spe/speClientProps.ts +++ b/brainstorm/src/infra/spe/speClientProps.ts @@ -1,5 +1,5 @@ import type { ITelemetryBaseLogger } from "@fluidframework/core-interfaces"; -import { IOdspTokenProvider, OdspClientProps } from "@fluidframework/odsp-client/beta"; +import type { IOdspTokenProvider, OdspClientProps } from "@fluidframework/odsp-client/beta"; // Create the client props for the Fluid client export const getClientProps = ( @@ -9,9 +9,9 @@ export const getClientProps = ( logger?: ITelemetryBaseLogger, ): OdspClientProps => { const connectionConfig = { - tokenProvider: tokenProvider, - siteUrl: siteUrl, - driveId: driveId, + tokenProvider, + siteUrl, + driveId, filePath: "", }; diff --git a/brainstorm/src/infra/spe/speTokenProvider.ts b/brainstorm/src/infra/spe/speTokenProvider.ts index 3a09fb4ba..ec92dc86e 100644 --- a/brainstorm/src/infra/spe/speTokenProvider.ts +++ b/brainstorm/src/infra/spe/speTokenProvider.ts @@ -1,9 +1,10 @@ -import { +import type { AuthenticationResult, - InteractionRequiredAuthError, - PublicClientApplication, + PublicClientApplication} from "@azure/msal-browser"; +import { + InteractionRequiredAuthError } from "@azure/msal-browser"; -import { IOdspTokenProvider, TokenResponse } from "@fluidframework/odsp-client/beta"; +import type { IOdspTokenProvider, TokenResponse } from "@fluidframework/odsp-client/beta"; // Sample implementation of the IOdspTokenProvider interface // This class is used to provide the token for the Fluid container and @@ -48,7 +49,7 @@ export class SampleOdspTokenProvider implements IOdspTokenProvider { scopes: scope, }); } else { - throw new Error(`MSAL error: ${error}`); + throw new TypeError(`MSAL error: ${error}`); } } return response.accessToken; diff --git a/brainstorm/src/infra/tokenProvider.ts b/brainstorm/src/infra/tokenProvider.ts index 76194ddc8..fe738f0d5 100644 --- a/brainstorm/src/infra/tokenProvider.ts +++ b/brainstorm/src/infra/tokenProvider.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. */ -import { AzureMember, ITokenProvider, ITokenResponse, IUser } from "@fluidframework/azure-client"; +import type { AzureMember, ITokenProvider, ITokenResponse, IUser } from "@fluidframework/azure-client"; import { ScopeType } from "@fluidframework/protocol-definitions"; import axios from "axios"; import { KJUR as jsrsasign } from "jsrsasign"; @@ -153,7 +153,7 @@ export function generateToken( lifetime: number = 60 * 60, ver = "1.0", ): string { - let userClaim = user ? user : generateUser(); + let userClaim = user ?? generateUser(); if (userClaim.id === "" || userClaim.id === undefined) { userClaim = generateUser(); } diff --git a/brainstorm/src/react/buttonux.tsx b/brainstorm/src/react/buttonux.tsx index efb9a623d..543fddcb0 100644 --- a/brainstorm/src/react/buttonux.tsx +++ b/brainstorm/src/react/buttonux.tsx @@ -3,9 +3,6 @@ * Licensed under the MIT License. */ -import React, { JSX } from "react"; -import { Items, Note } from "../schema/app_schema.js"; -import { moveItem, findNote } from "../utils/app_helpers.js"; import { ThumbLikeFilled, DismissFilled, @@ -15,9 +12,16 @@ import { ArrowUndoFilled, ArrowRedoFilled, } from "@fluentui/react-icons"; -import { Session } from "../schema/session_schema.js"; -import { getSelectedNotes } from "../utils/session_helpers.js"; import { Tree } from "fluid-framework"; +import type { JSX } from "react"; +import type React from "react"; + +import type { Items} from "../schema/app_schema.js"; +import { Note } from "../schema/app_schema.js"; +import type { Session } from "../schema/session_schema.js"; +import { moveItem, findNote } from "../utils/app_helpers.js"; +import { getSelectedNotes } from "../utils/session_helpers.js"; + export function NewGroupButton(props: { items: Items; @@ -159,10 +163,10 @@ export function IconButton(props: { return (