Skip to main content
Version: v1

@fluidframework/odsp-driver Package

Interfaces​

InterfaceDescription
IClpCompliantAppHeader
ISharingLinkHeader
ISnapshotContents
OdspFluidDataStoreLocator
ShareLinkFetcherPropsProperties passed to the code responsible for fetching share link for a file.

Classes​

ClassDescription
OdspDocumentServiceFactoryFactory for creating the sharepoint document service. Use this if you want to use the sharepoint implementation.
OdspDocumentServiceFactoryCore

Factory for creating the sharepoint document service. Use this if you want to use the sharepoint implementation.

This constructor should be used by environments that support dynamic imports and that wish to leverage code splitting as a means to keep bundles as small as possible.

OdspDocumentServiceFactoryWithCodeSplit
OdspDriverUrlResolverResolver to resolve urls like the ones created by createOdspUrl which is driver inner url format. Ex: ${siteUrl}?driveId=${driveId}&itemId=${itemId}&path=${path}
OdspDriverUrlResolverForShareLinkResolver to resolve urls like the ones created by createOdspUrl which is driver inner url format and the ones which have things like driveId, siteId, itemId etc encoded in nav param. This resolver also handles share links and try to generate one for the use by the app.
ReadBufferBuffer class, used to sequentially read data. Used by tree code to reconstruct a tree from binary representation.

Enumerations​

EnumDescription
ClpCompliantAppHeader
SharingLinkHeader

Functions​

FunctionAlertsReturn TypeDescription
checkUrl(documentUrl)DriverPreCheckInfo | undefinedA check that returns DriverPreCheckInfo if the URL format is likely supported by this driver. Note that returning information here is NOT a full guarantee that resolve will ultimately be successful. Instead, this should be used as a lightweight check that can filter out easily detectable unsupported URLs before the entire Fluid loading process needs to be kicked off.
createLocalOdspDocumentServiceFactory(localSnapshot)IDocumentServiceFactory
createOdspCreateContainerRequest(siteUrl, driveId, filePath, fileName, createLinkType)IRequestCreate the request object with url and headers for creating a new file on OneDrive Sharepoint
createOdspUrl(l)stringEncodes ODC/SPO information into a URL format that can be handled by the Loader
encodeOdspFluidDataStoreLocator(locator)stringTransforms given Fluid data store locator into string that can be embedded into url
getApiRoot(origin)stringGets the correct API root for the given ODSP url, e.g. 'https://foo-my.sharepoint.com/_api/v2.1'
getHashedDocumentId(driveId, itemId)Promise<string>
getLocatorFromOdspUrl(url)OdspFluidDataStoreLocator | undefinedExtract ODSP Fluid data store locator object from given ODSP url. This extracts things like driveId, ItemId, siteUrl etc from a url where these are encoded in nav query param.
getOdspUrlParts(url)Promise<IOdspUrlParts | undefined>Breaks an ODSP URL into its parts, extracting the site, drive ID, and item ID. Returns undefined for invalid/malformed URLs.
isOdcOrigin(origin)booleanChecks whether or not the given URL origin is an ODC origin
isOdcUrl(url)booleanWhether or not the given URL is a valid ODC URL
isSpoUrl(url)booleanWhether or not the given URL is a valid SPO/ODB URL
parseCompactSnapshotResponse(buffer)ISnapshotContentsConverts snapshot from binary compact representation to tree/blobs/ops.
prefetchLatestSnapshot(resolvedUrl, getStorageToken, persistedCache, forceAccessTokenViaAuthorizationHeader, logger, hostSnapshotFetchOptions, enableRedeemFallback, fetchBinarySnapshotFormat, snapshotFormatFetchType)DeprecatedPromise<boolean>Function to prefetch the snapshot and cached it in the persistant cache, so that when the container is loaded the cached latest snapshot could be used and removes the network call from the critical path.
storeLocatorInOdspUrl(url, locator)voidEmbeds Fluid data store locator data into given ODSP url

Variables​

VariableTypeDescription
currentReadVersion
locatorQueryParamName
OdcApiSiteOrigin
OdcFileSiteOrigin
snapshotMinReadVersion

Function Details​

checkUrl​

A check that returns DriverPreCheckInfo if the URL format is likely supported by this driver. Note that returning information here is NOT a full guarantee that resolve will ultimately be successful. Instead, this should be used as a lightweight check that can filter out easily detectable unsupported URLs before the entire Fluid loading process needs to be kicked off.

Signature​

export declare function checkUrl(documentUrl: URL): DriverPreCheckInfo | undefined;

Parameters​

ParameterTypeDescription
documentUrlURL

Returns​

Return type: DriverPreCheckInfo | undefined

createLocalOdspDocumentServiceFactory​

Signature​

export declare function createLocalOdspDocumentServiceFactory(localSnapshot: Uint8Array | string): IDocumentServiceFactory;

Parameters​

ParameterTypeDescription
localSnapshotUint8Array | string

Returns​

Return type: IDocumentServiceFactory

createOdspCreateContainerRequest​

Create the request object with url and headers for creating a new file on OneDrive Sharepoint

Signature​

export declare function createOdspCreateContainerRequest(siteUrl: string, driveId: string, filePath: string, fileName: string, createLinkType?: ShareLinkTypes): IRequest;

Parameters​

ParameterModifiersTypeDescription
siteUrlstringBase url for OneDrive
driveIdstringdrive identifier
filePathstringpath where file needs to be created
fileNamestringname of the new file to be created
createLinkTypeoptionalShareLinkTypestype of sharing link you would like to create for this file

Returns​

Return type: IRequest

createOdspUrl​

Encodes ODC/SPO information into a URL format that can be handled by the Loader

Signature​

export declare function createOdspUrl(l: OdspFluidDataStoreLocator): string;

Parameters​

ParameterTypeDescription
lOdspFluidDataStoreLocatorThe property bag of necessary properties to locate a Fluid data store and craft a url for it

Returns​

Return type: string

encodeOdspFluidDataStoreLocator​

Transforms given Fluid data store locator into string that can be embedded into url

Signature​

export declare function encodeOdspFluidDataStoreLocator(locator: OdspFluidDataStoreLocator): string;

Parameters​

ParameterTypeDescription
locatorOdspFluidDataStoreLocatordescribes Fluid data store locator info to be encoded

Returns​

string representing encoded Fluid data store locator info

Return type: string

getApiRoot​

Gets the correct API root for the given ODSP url, e.g. 'https://foo-my.sharepoint.com/_api/v2.1'

Signature​

export declare function getApiRoot(origin: string): string;

Parameters​

ParameterTypeDescription
originstringThe URL origin

Returns​

Return type: string

getHashedDocumentId​

Signature​

export declare function getHashedDocumentId(driveId: string, itemId: string): Promise<string>;

Parameters​

ParameterTypeDescription
driveIdstring
itemIdstring

Returns​

Return type: Promise<string>

getLocatorFromOdspUrl​

Extract ODSP Fluid data store locator object from given ODSP url. This extracts things like driveId, ItemId, siteUrl etc from a url where these are encoded in nav query param.

Signature​

export declare function getLocatorFromOdspUrl(url: URL): OdspFluidDataStoreLocator | undefined;

Parameters​

ParameterTypeDescription
urlURLODSP url representing Fluid file link

Returns​

object representing Fluid data store location in ODSP terms

Return type: OdspFluidDataStoreLocator | undefined

getOdspUrlParts​

Breaks an ODSP URL into its parts, extracting the site, drive ID, and item ID. Returns undefined for invalid/malformed URLs.

Signature​

export declare function getOdspUrlParts(url: URL): Promise<IOdspUrlParts | undefined>;

Parameters​

ParameterTypeDescription
urlURLThe (raw) URL to parse

Returns​

Return type: Promise<IOdspUrlParts | undefined>

isOdcOrigin​

Checks whether or not the given URL origin is an ODC origin

Signature​

export declare function isOdcOrigin(origin: string): boolean;

Parameters​

ParameterTypeDescription
originstringThe URL origin to check

Returns​

Return type: boolean

isOdcUrl​

Whether or not the given URL is a valid ODC URL

Signature​

export declare function isOdcUrl(url: string | URL): boolean;

Parameters​

ParameterTypeDescription
urlstring | URLThe URL to check

Returns​

Return type: boolean

isSpoUrl​

Whether or not the given URL is a valid SPO/ODB URL

Signature​

export declare function isSpoUrl(url: string): boolean;

Parameters​

ParameterTypeDescription
urlstringThe URL to check

Returns​

Return type: boolean

parseCompactSnapshotResponse​

Converts snapshot from binary compact representation to tree/blobs/ops.

Signature​

export declare function parseCompactSnapshotResponse(buffer: ReadBuffer): ISnapshotContents;

Parameters​

ParameterTypeDescription
bufferReadBufferCompact snapshot to be parsed into tree/blobs/ops.

Returns​

  • tree, blobs and ops from the snapshot.

Return type: ISnapshotContents

prefetchLatestSnapshot​

Function to prefetch the snapshot and cached it in the persistant cache, so that when the container is loaded the cached latest snapshot could be used and removes the network call from the critical path.

This API is deprecated and will be removed in a future release.
  • This will be replaced with snapshotFormatFetchType.

Signature​

export declare function prefetchLatestSnapshot(resolvedUrl: IResolvedUrl, getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>, persistedCache: IPersistedCache, forceAccessTokenViaAuthorizationHeader: boolean, logger: ITelemetryBaseLogger, hostSnapshotFetchOptions: ISnapshotOptions | undefined, enableRedeemFallback?: boolean, fetchBinarySnapshotFormat?: boolean, snapshotFormatFetchType?: SnapshotFormatSupportType): Promise<boolean>;

Parameters​

ParameterModifiersTypeDescription
resolvedUrlIResolvedUrlResolved url to fetch the snapshot.
getStorageTokenTokenFetcher<OdspResourceTokenFetchOptions>function that can provide the storage token for a given site. This is is also referred to as the "VROOM" token in SPO.
persistedCacheIPersistedCacheCache to store the fetched snapshot.
forceAccessTokenViaAuthorizationHeaderbooleanwhether to force passing given token via authorization header.
loggerITelemetryBaseLoggerLogger to have telemetry events.
hostSnapshotFetchOptionsISnapshotOptions | undefinedOptions to fetch the snapshot if any. Otherwise default will be used.
enableRedeemFallbackoptionalbooleanTrue to have the sharing link redeem fallback in case the Trees Latest/Redeem 1RT call fails with redeem error. During fallback it will first redeem the sharing link and then make the Trees latest call.
fetchBinarySnapshotFormatoptionalbooleanControl if we want to fetch binary format snapshot.
snapshotFormatFetchTypeoptionalSnapshotFormatSupportTypeSnapshot format to fetch.

Returns​

  • True if the snapshot is cached, false otherwise.

Return type: Promise<boolean>

storeLocatorInOdspUrl​

Embeds Fluid data store locator data into given ODSP url

Signature​

export declare function storeLocatorInOdspUrl(url: URL, locator: OdspFluidDataStoreLocator): void;

Parameters​

ParameterTypeDescription
urlURLfile url in ODSP format (can be either canonical or share link)
locatorOdspFluidDataStoreLocatorobject representing Fluid data store location in ODSP terms

Variable Details​

currentReadVersion​

Signature​

currentReadVersion = "1.0"

locatorQueryParamName​

Signature​

locatorQueryParamName = "nav"

OdcApiSiteOrigin​

Signature​

OdcApiSiteOrigin = "https://my.microsoftpersonalcontent.com"

OdcFileSiteOrigin​

Signature​

OdcFileSiteOrigin = "https://1drv.ms"

snapshotMinReadVersion​

Signature​

snapshotMinReadVersion = "1.0"