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

Remove deprecated SingleRT flow in odsp-driver #18690

Merged
8 changes: 8 additions & 0 deletions .changeset/slow-seas-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@fluidframework/odsp-driver": major
"@fluidframework/odsp-driver-definitions": major
---

Removed deprecated implementation of SingleRT feature which was enabled via enableShareLinkWithCreate boolean flag in HostStoragePolicy

Removed the deprecated logic of creating sharing-links with container attach (called SingleRT) which was enabled via enableShareLinkWithCreate flag in HostStoragePolicy. This change removes SharingLinkTypes interface definition, removes other deprecated properties from the odsp-driver's resolvedUrl object and also removes the enableShareLinkWithCreate flag. The newer version of SingleRT feature continues to exist, which can be enabled via enableSingleRequestForShareLinkWithCreate feature flag in HostStoragePolicy.
Original file line number Diff line number Diff line change
Expand Up @@ -244,20 +244,13 @@ export interface OdspResourceTokenFetchOptions extends TokenFetchOptions {
// @alpha
export interface ShareLinkInfoType {
createLink?: {
type?: ShareLinkTypes | ISharingLinkKind;
link?: string | ISharingLink;
link?: ISharingLink;
error?: any;
shareId?: string;
};
sharingLinkToRedeem?: string;
}

// @alpha @deprecated (undocumented)
export enum ShareLinkTypes {
// (undocumented)
csl = "csl"
}

// @alpha
export enum SharingLinkRole {
// (undocumented)
Expand Down
4 changes: 4 additions & 0 deletions packages/drivers/odsp-driver-definitions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@
"RemovedEnumDeclaration_OdspErrorType": {
"forwardCompat": false,
"backCompat": false
},
"RemovedEnumDeclaration_ShareLinkTypes": {
"backCompat": false,
"forwardCompat": false
}
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/drivers/odsp-driver-definitions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export {
ISharingLink,
ISharingLinkKind,
ShareLinkInfoType,
ShareLinkTypes,
SharingLinkRole,
SharingLinkScope,
} from "./resolvedUrl";
Expand Down
19 changes: 1 addition & 18 deletions packages/drivers/odsp-driver-definitions/src/resolvedUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ export interface IOdspUrlParts {
itemId: string;
}

/**
* @deprecated Use ISharingLinkKind type instead.
* Type of shareLink requested/created when creating the file for the first time.
* @alpha
*/
export enum ShareLinkTypes {
csl = "csl",
}

/**
* Sharing scope of the share links created for a file.
* @alpha
Expand Down Expand Up @@ -80,18 +71,10 @@ export interface ShareLinkInfoType {
* from the /snapshot api response.
*/
createLink?: {
/**
* @deprecated
* Type of shareLink requested/created when creating the file for the first time. The 'type' property here
* represents the type of sharing link requested.
* Will be deprecated soon. Type of sharing link will be present in the link:ISharingLink property below.
*/
type?: ShareLinkTypes | ISharingLinkKind;

/**
* Share link created when the file is created for the first time with /snapshot api call.
*/
link?: string | ISharingLink;
link?: ISharingLink;

/**
* Error message if creation of sharing link fails with /snapshot api call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,26 +636,14 @@ use_old_InterfaceDeclaration_ShareLinkInfoType(
/*
* Validate forward compat by using old type in place of current type
* If breaking change required, add in package.json under typeValidation.broken:
* "EnumDeclaration_ShareLinkTypes": {"forwardCompat": false}
* "RemovedEnumDeclaration_ShareLinkTypes": {"forwardCompat": false}
*/
declare function get_old_EnumDeclaration_ShareLinkTypes():
TypeOnly<old.ShareLinkTypes>;
declare function use_current_EnumDeclaration_ShareLinkTypes(
use: TypeOnly<current.ShareLinkTypes>): void;
use_current_EnumDeclaration_ShareLinkTypes(
get_old_EnumDeclaration_ShareLinkTypes());

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

/*
* Validate forward compat by using old type in place of current type
Expand Down
3 changes: 1 addition & 2 deletions packages/drivers/odsp-driver/api-report/odsp-driver.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { IUrlResolver } from '@fluidframework/driver-definitions';
import { OdspResourceTokenFetchOptions } from '@fluidframework/odsp-driver-definitions';
import { PromiseCache } from '@fluidframework/core-utils';
import { RateLimiter } from '@fluidframework/driver-utils';
import { ShareLinkTypes } from '@fluidframework/odsp-driver-definitions';
import { TokenFetcher } from '@fluidframework/odsp-driver-definitions';

// @alpha
Expand All @@ -48,7 +47,7 @@ export enum ClpCompliantAppHeader {
export function createLocalOdspDocumentServiceFactory(localSnapshot: Uint8Array | string): IDocumentServiceFactory;

// @alpha
export function createOdspCreateContainerRequest(siteUrl: string, driveId: string, filePath: string, fileName: string, createShareLinkType?: ShareLinkTypes | ISharingLinkKind): IRequest;
export function createOdspCreateContainerRequest(siteUrl: string, driveId: string, filePath: string, fileName: string, createShareLinkType?: ISharingLinkKind): IRequest;

// @alpha
export function createOdspUrl(l: OdspFluidDataStoreLocator): string;
Expand Down
35 changes: 4 additions & 31 deletions packages/drivers/odsp-driver/src/createFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import {
IOdspResolvedUrl,
OdspErrorTypes,
ShareLinkInfoType,
ISharingLinkKind,
ShareLinkTypes,
IFileEntry,
} from "@fluidframework/odsp-driver-definitions";
import { ICreateFileResponse } from "./contracts";
Expand Down Expand Up @@ -59,7 +57,6 @@ export async function createNewFluidFile(
forceAccessTokenViaAuthorizationHeader: boolean,
isClpCompliantApp?: boolean,
enableSingleRequestForShareLinkWithCreate?: boolean,
enableShareLinkWithCreate?: boolean,
): Promise<IOdspResolvedUrl> {
// Check for valid filename before the request to create file is actually made.
if (isInvalidFileName(newFileInfo.filename)) {
Expand Down Expand Up @@ -94,12 +91,7 @@ export async function createNewFluidFile(
itemId = content.itemId;
summaryHandle = content.id;

shareLinkInfo = extractShareLinkData(
newFileInfo.createLinkType,
content,
enableSingleRequestForShareLinkWithCreate,
enableShareLinkWithCreate,
);
shareLinkInfo = extractShareLinkData(content, enableSingleRequestForShareLinkWithCreate);
}

const odspUrl = createOdspUrl({ ...newFileInfo, itemId, dataStorePath: "/" });
Expand Down Expand Up @@ -127,24 +119,19 @@ export async function createNewFluidFile(
}

/**
* If user requested creation of a sharing link along with the creation of the file by providing either
* createLinkType (now deprecated) or createLinkScope in the request parameters, extract and save
* sharing link information from the response if it is available.
* If user requested creation of a sharing link along with the creation of the file by providing
* createLinkScope in the request parameters then extract and save the sharing link information from
* the response if it is available.
* In case there was an error in creation of the sharing link, error is provided back in the response,
* and does not impact the creation of file in ODSP.
* @param requestedSharingLinkKind - Kind of sharing link requested to be created along with the creation of file.
* @param response - Response object received from the /snapshot api call
* @returns Sharing link information received in the response from a successful creation of a file.
*/
function extractShareLinkData(
requestedSharingLinkKind: ShareLinkTypes | ISharingLinkKind | undefined,
response: ICreateFileResponse,
enableSingleRequestForShareLinkWithCreate?: boolean,
enableShareLinkWithCreate?: boolean,
): ShareLinkInfoType | undefined {
if (!requestedSharingLinkKind) {
return;
}
let shareLinkInfo: ShareLinkInfoType | undefined;
if (enableSingleRequestForShareLinkWithCreate) {
const { sharing } = response;
Expand All @@ -153,7 +140,6 @@ function extractShareLinkData(
}
shareLinkInfo = {
createLink: {
type: requestedSharingLinkKind,
link: sharing.sharingLink
? {
scope: sharing.sharingLink.scope,
Expand All @@ -166,19 +152,6 @@ function extractShareLinkData(
shareId: sharing.shareId,
},
};
} else if (enableShareLinkWithCreate) {
const { sharing, sharingLink, sharingLinkErrorReason } = response;
if (!sharingLink && !sharingLinkErrorReason) {
return;
}
shareLinkInfo = {
createLink: {
type: requestedSharingLinkKind,
link: sharingLink,
error: sharingLinkErrorReason,
shareId: sharing?.shareId,
},
};
}
return shareLinkInfo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
import { IRequest } from "@fluidframework/core-interfaces";
import { DriverHeader } from "@fluidframework/driver-definitions";
import { ShareLinkTypes, ISharingLinkKind } from "@fluidframework/odsp-driver-definitions";
import { ISharingLinkKind } from "@fluidframework/odsp-driver-definitions";
import { buildOdspShareLinkReqParams } from "./odspUtils";

/**
Expand All @@ -22,7 +22,7 @@ export function createOdspCreateContainerRequest(
driveId: string,
filePath: string,
fileName: string,
createShareLinkType?: ShareLinkTypes | ISharingLinkKind,
createShareLinkType?: ISharingLinkKind,
): IRequest {
const shareLinkRequestParams = buildOdspShareLinkReqParams(createShareLinkType);
const createNewRequest: IRequest = {
Expand Down
14 changes: 3 additions & 11 deletions packages/drivers/odsp-driver/src/odspDocumentServiceFactoryCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
IOdspUrlParts,
SharingLinkScope,
SharingLinkRole,
ShareLinkTypes,
ISharingLinkKind,
ISocketStorageDiscovery,
IRelaySessionAwareDriverFactory,
Expand Down Expand Up @@ -102,7 +101,7 @@ export class OdspDocumentServiceFactoryCore
};

let fileInfo: INewFileInfo | IExistingFileInfo;
let createShareLinkParam: ShareLinkTypes | ISharingLinkKind | undefined;
let createShareLinkParam: ISharingLinkKind | undefined;
if (odspResolvedUrl.itemId) {
fileInfo = {
type: "Existing",
Expand Down Expand Up @@ -161,7 +160,6 @@ export class OdspDocumentServiceFactoryCore
createShareLinkParam: createShareLinkParam
? JSON.stringify(createShareLinkParam)
: undefined,
enableShareLinkWithCreate: this.hostPolicy.enableShareLinkWithCreate,
enableSingleRequestForShareLinkWithCreate:
this.hostPolicy.enableSingleRequestForShareLinkWithCreate,
},
Expand Down Expand Up @@ -202,7 +200,6 @@ export class OdspDocumentServiceFactoryCore
?.forceAccessTokenViaAuthorizationHeader,
odspResolvedUrl.isClpCompliantApp,
this.hostPolicy.enableSingleRequestForShareLinkWithCreate,
this.hostPolicy.enableShareLinkWithCreate,
)
: await module.createNewContainerOnExistingFile(
getStorageToken,
Expand Down Expand Up @@ -330,9 +327,9 @@ export class OdspDocumentServiceFactoryCore
function getSharingLinkParams(
hostPolicy: HostStoragePolicy,
searchParams: URLSearchParams,
): ShareLinkTypes | ISharingLinkKind | undefined {
): ISharingLinkKind | undefined {
// extract request parameters for creation of sharing link (if provided) if the feature is enabled
let createShareLinkParam: ShareLinkTypes | ISharingLinkKind | undefined;
let createShareLinkParam: ISharingLinkKind | undefined;
if (hostPolicy.enableSingleRequestForShareLinkWithCreate) {
const createLinkScope = searchParams.get("createLinkScope");
const createLinkRole = searchParams.get("createLinkRole");
Expand All @@ -344,11 +341,6 @@ function getSharingLinkParams(
: {}),
};
}
} else if (hostPolicy.enableShareLinkWithCreate) {
const createLinkType = searchParams.get("createLinkType");
if (createLinkType && ShareLinkTypes[createLinkType]) {
createShareLinkParam = ShareLinkTypes[createLinkType || ""];
}
}
return createShareLinkParam;
}
18 changes: 2 additions & 16 deletions packages/drivers/odsp-driver/src/odspDriverUrlResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ import {
IResolvedUrl,
IUrlResolver,
} from "@fluidframework/driver-definitions";
import {
IOdspResolvedUrl,
OdspErrorTypes,
ShareLinkTypes,
ShareLinkInfoType,
} from "@fluidframework/odsp-driver-definitions";
import { IOdspResolvedUrl, OdspErrorTypes } from "@fluidframework/odsp-driver-definitions";
import { NonRetryableError } from "@fluidframework/driver-utils";
import { createOdspUrl } from "./createOdspUrl";
import { getApiRoot } from "./odspUrlHelper";
Expand Down Expand Up @@ -97,7 +92,6 @@ export class OdspDriverUrlResolver implements IUrlResolver {
const driveID = searchParams.get("driveId");
const filePath = searchParams.get("path");
const packageName = searchParams.get("containerPackageName");
const createLinkType = searchParams.get("createLinkType");
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- false positive
if (!(fileName && siteURL && driveID && filePath !== null && filePath !== undefined)) {
throw new NonRetryableError(
Expand All @@ -106,14 +100,6 @@ export class OdspDriverUrlResolver implements IUrlResolver {
{ driverVersion: pkgVersion },
);
}
let shareLinkInfo: ShareLinkInfoType | undefined;
if (createLinkType && createLinkType in ShareLinkTypes) {
shareLinkInfo = {
createLink: {
type: ShareLinkTypes[createLinkType],
},
};
}
return {
endpoints: {
snapshotStorageUrl: "",
Expand All @@ -136,7 +122,7 @@ export class OdspDriverUrlResolver implements IUrlResolver {
containerPackageName: packageName ?? undefined,
},
fileVersion: undefined,
shareLinkInfo,
shareLinkInfo: undefined,
isClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],
};
}
Expand Down
18 changes: 4 additions & 14 deletions packages/drivers/odsp-driver/src/odspUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {
tokenFromResponse,
isTokenFromCache,
OdspResourceTokenFetchOptions,
ShareLinkTypes,
ISharingLinkKind,
TokenFetcher,
ICacheEntry,
Expand Down Expand Up @@ -283,11 +282,8 @@ export interface INewFileInfo extends IFileInfoBase {
/**
* application can request creation of a share link along with the creation of a new file
* by passing in an optional param to specify the kind of sharing link
* (at the time of adding this comment Sept/2021), odsp only supports csl
* ShareLinkTypes will deprecated in future. Use ISharingLinkKind instead which specifies both
* share link type and the role type.
*/
createLinkType?: ShareLinkTypes | ISharingLinkKind;
createLinkType?: ISharingLinkKind;
}

export interface IExistingFileInfo extends IFileInfoBase {
Expand Down Expand Up @@ -447,19 +443,13 @@ export const maxUmpPostBodySize = 79872;
* @param shareLinkType - Kind of sharing link requested
* @returns A string of request parameters that can be concatenated with the base URI
*/
export function buildOdspShareLinkReqParams(
shareLinkType: ShareLinkTypes | ISharingLinkKind | undefined,
) {
export function buildOdspShareLinkReqParams(shareLinkType: ISharingLinkKind | undefined) {
if (!shareLinkType) {
return;
}
const scope = (shareLinkType as ISharingLinkKind).scope;
if (!scope) {
// eslint-disable-next-line @typescript-eslint/no-base-to-string
return `createLinkType=${shareLinkType}`;
}
const scope = shareLinkType.scope;
let shareLinkRequestParams = `createLinkScope=${scope}`;
const role = (shareLinkType as ISharingLinkKind).role;
const role = shareLinkType.role;
shareLinkRequestParams = role
? `${shareLinkRequestParams}&createLinkRole=${role}`
: shareLinkRequestParams;
Expand Down
Loading