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

Updates to run dev tool with shared tree demo #1

Open
wants to merge 1 commit into
base: debug_shared_tree
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -421,54 +421,6 @@ declare function use_old_InterfaceDeclaration_ITokenClaims(
use_old_InterfaceDeclaration_ITokenClaims(
get_current_InterfaceDeclaration_ITokenClaims());

/*
* Validate forward compat by using old type in place of current type
* If breaking change required, add in package.json under typeValidation.broken:
* "InterfaceDeclaration_ITokenProvider": {"forwardCompat": false}
*/
declare function get_old_InterfaceDeclaration_ITokenProvider():
TypeOnly<old.ITokenProvider>;
declare function use_current_InterfaceDeclaration_ITokenProvider(
use: TypeOnly<current.ITokenProvider>);
use_current_InterfaceDeclaration_ITokenProvider(
get_old_InterfaceDeclaration_ITokenProvider());

/*
* Validate back compat by using current type in place of old type
* If breaking change required, add in package.json under typeValidation.broken:
* "InterfaceDeclaration_ITokenProvider": {"backCompat": false}
*/
declare function get_current_InterfaceDeclaration_ITokenProvider():
TypeOnly<current.ITokenProvider>;
declare function use_old_InterfaceDeclaration_ITokenProvider(
use: TypeOnly<old.ITokenProvider>);
use_old_InterfaceDeclaration_ITokenProvider(
get_current_InterfaceDeclaration_ITokenProvider());

/*
* Validate forward compat by using old type in place of current type
* If breaking change required, add in package.json under typeValidation.broken:
* "InterfaceDeclaration_ITokenResponse": {"forwardCompat": false}
*/
declare function get_old_InterfaceDeclaration_ITokenResponse():
TypeOnly<old.ITokenResponse>;
declare function use_current_InterfaceDeclaration_ITokenResponse(
use: TypeOnly<current.ITokenResponse>);
use_current_InterfaceDeclaration_ITokenResponse(
get_old_InterfaceDeclaration_ITokenResponse());

/*
* Validate back compat by using current type in place of old type
* If breaking change required, add in package.json under typeValidation.broken:
* "InterfaceDeclaration_ITokenResponse": {"backCompat": false}
*/
declare function get_current_InterfaceDeclaration_ITokenResponse():
TypeOnly<current.ITokenResponse>;
declare function use_old_InterfaceDeclaration_ITokenResponse(
use: TypeOnly<old.ITokenResponse>);
use_old_InterfaceDeclaration_ITokenResponse(
get_current_InterfaceDeclaration_ITokenResponse());

/*
* Validate forward compat by using old type in place of current type
* If breaking change required, add in package.json under typeValidation.broken:
Expand Down
16 changes: 9 additions & 7 deletions examples/data-objects/shared-tree-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@
},
"dependencies": {
"@fluidframework/telemetry-utils": "workspace:~",
"@fluid-experimental/data-objects": "2.0.0-dev.4.4.0.161322",
"@fluid-experimental/tree-react-api": "2.0.0-dev.4.4.0.161322",
"@fluid-experimental/tree2": "2.0.0-dev.4.4.0.161322",
"@fluidframework/azure-client": "2.0.0-dev.4.4.0.161322",
"@fluidframework/counter": "2.0.0-dev.4.4.0.161322",
"@fluidframework/test-client-utils": "2.0.0-dev.4.4.0.161322",
"@fluid-experimental/data-objects": "workspace:~",
"@fluid-experimental/tree-react-api": "workspace:~",
"@fluid-experimental/tree2": "workspace:~",
"@fluidframework/azure-client": "workspace:~",
"@fluidframework/counter": "workspace:~",
"@fluidframework/test-client-utils": "workspace:~",
"@mdi/font": "^6.9.96",
"@mdi/js": "^6.9.96",
"@mdi/react": "^1.6.1",
"@types/react": "^17.0.50",
"@types/react-dom": "^17.0.17",
"axios": "^1.4.0",
"dotenv": "^16.0.2",
"fluid-framework": "2.0.0-dev.4.4.0.161322",
"fluid-framework": "workspace:~",
"guid-typescript": "^1.0.9",
"hashids": "^2.2.10",
"randomcolor": "^0.6.2",
Expand All @@ -37,6 +38,7 @@
},
"devDependencies": {
"@fluidframework/telemetry-utils": "workspace:~",
"@fluid-experimental/devtools": "workspace:~",
"@types/debug": "^4.1.7",
"@types/node": "^17.0.45",
"@types/randomcolor": "^0.5.6",
Expand Down
57 changes: 39 additions & 18 deletions examples/data-objects/shared-tree-demo/src/fluid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
AzureClientProps,
AzureMember,
ITokenProvider,
ITokenResponse
ITokenResponse,
} from '@fluidframework/azure-client';
import {
generateTestUser,
Expand All @@ -17,9 +17,9 @@ import { Signaler } from '@fluid-experimental/data-objects';
import { SharedCounter } from '@fluidframework/counter';
import { SharedTreeFactory } from '@fluid-experimental/tree2';

import axios from "axios";
// import { DevtoolsLogger, initializeDevtools } from "@fluid-experimental/devtools";
// import { TelemetryNullLogger } from "@fluidframework/telemetry-utils";
import axios from 'axios';
import { DevtoolsLogger, initializeDevtools } from '@fluid-experimental/devtools';
import { TelemetryNullLogger } from '@fluidframework/telemetry-utils';

/**
* Token Provider implementation for connecting to an Azure Function endpoint for
Expand All @@ -33,22 +33,34 @@ export class AzureFunctionTokenProvider implements ITokenProvider {
*/
constructor(
private readonly azFunctionUrl: string,
private readonly user?: Pick<AzureMember, "userId" | "userName" | "additionalDetails">,
) { }

public async fetchOrdererToken(tenantId: string, documentId?: string): Promise<ITokenResponse> {
private readonly user?: Pick<
AzureMember,
'userId' | 'userName' | 'additionalDetails'
>
) {}

public async fetchOrdererToken(
tenantId: string,
documentId?: string
): Promise<ITokenResponse> {
return {
jwt: await this.getToken(tenantId, documentId),
};
}

public async fetchStorageToken(tenantId: string, documentId: string): Promise<ITokenResponse> {
public async fetchStorageToken(
tenantId: string,
documentId: string
): Promise<ITokenResponse> {
return {
jwt: await this.getToken(tenantId, documentId),
};
}

private async getToken(tenantId: string, documentId: string | undefined): Promise<string> {
private async getToken(
tenantId: string,
documentId: string | undefined
): Promise<string> {
const response = await axios.get(this.azFunctionUrl, {
params: {
tenantId,
Expand Down Expand Up @@ -97,18 +109,17 @@ const localConnectionConfig: AzureLocalConnectionConfig = {
endpoint: 'http://localhost:7070',
};

const connectionConfig: AzureRemoteConnectionConfig | AzureLocalConnectionConfig = useAzure
? remoteConnectionConfig
: localConnectionConfig;
const connectionConfig: AzureRemoteConnectionConfig | AzureLocalConnectionConfig =
useAzure ? remoteConnectionConfig : localConnectionConfig;

// const baseLogger = new TelemetryNullLogger();
const baseLogger = new TelemetryNullLogger();

// Wrap telemetry logger for use with Devtools
// const devtoolsLogger = new DevtoolsLogger(baseLogger);
const devtoolsLogger = new DevtoolsLogger(baseLogger);

const clientProps: AzureClientProps = {
connection: connectionConfig,
// logger: devtoolsLogger
logger: devtoolsLogger,
};

const client = new AzureClient(clientProps);
Expand All @@ -120,7 +131,7 @@ const containerSchema: ContainerSchema = {
initialObjects: {
signalManager: Signaler,
maxZOrder: SharedCounter,
tree: MySharedTree
tree: MySharedTree,
},
};

Expand Down Expand Up @@ -165,6 +176,16 @@ export const loadFluidData = async (): Promise<{
({ container, services } = await client.getContainer(id, containerSchema));
}

initializeDevtools({
logger: devtoolsLogger,
initialContainers: [
{
container,
containerId: id,
containerNickname: 'Shared Tree Demo Container',
},
],
});

return { container, services };
};

Loading