@fluidframework/odsp-driver 0.58.2002 → 0.59.1000
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compactSnapshotParser.d.ts +1 -0
- package/dist/compactSnapshotParser.d.ts.map +1 -1
- package/dist/compactSnapshotParser.js +8 -7
- package/dist/compactSnapshotParser.js.map +1 -1
- package/dist/createNewUtils.js +0 -1
- package/dist/createNewUtils.js.map +1 -1
- package/dist/epochTracker.d.ts +12 -0
- package/dist/epochTracker.d.ts.map +1 -1
- package/dist/epochTracker.js +18 -22
- package/dist/epochTracker.js.map +1 -1
- package/dist/fetchSnapshot.d.ts +11 -0
- package/dist/fetchSnapshot.d.ts.map +1 -1
- package/dist/fetchSnapshot.js +53 -68
- package/dist/fetchSnapshot.js.map +1 -1
- package/dist/odspDocumentService.d.ts +2 -1
- package/dist/odspDocumentService.d.ts.map +1 -1
- package/dist/odspDocumentService.js +14 -7
- package/dist/odspDocumentService.js.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.d.ts +2 -2
- package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.js +6 -6
- package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
- package/dist/odspDocumentStorageManager.d.ts +0 -6
- package/dist/odspDocumentStorageManager.d.ts.map +1 -1
- package/dist/odspDocumentStorageManager.js +9 -58
- package/dist/odspDocumentStorageManager.js.map +1 -1
- package/dist/odspDriverUrlResolver.d.ts +2 -6
- package/dist/odspDriverUrlResolver.d.ts.map +1 -1
- package/dist/odspDriverUrlResolver.js +15 -10
- package/dist/odspDriverUrlResolver.js.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.d.ts +2 -6
- package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.js +12 -9
- package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/dist/odspSnapshotParser.d.ts.map +1 -1
- package/dist/odspSnapshotParser.js +1 -5
- package/dist/odspSnapshotParser.js.map +1 -1
- package/dist/odspSummaryUploadManager.d.ts.map +1 -1
- package/dist/odspSummaryUploadManager.js +9 -6
- package/dist/odspSummaryUploadManager.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/compactSnapshotParser.d.ts +1 -0
- package/lib/compactSnapshotParser.d.ts.map +1 -1
- package/lib/compactSnapshotParser.js +7 -6
- package/lib/compactSnapshotParser.js.map +1 -1
- package/lib/createNewUtils.js +0 -1
- package/lib/createNewUtils.js.map +1 -1
- package/lib/epochTracker.d.ts +12 -0
- package/lib/epochTracker.d.ts.map +1 -1
- package/lib/epochTracker.js +19 -23
- package/lib/epochTracker.js.map +1 -1
- package/lib/fetchSnapshot.d.ts +11 -0
- package/lib/fetchSnapshot.d.ts.map +1 -1
- package/lib/fetchSnapshot.js +55 -70
- package/lib/fetchSnapshot.js.map +1 -1
- package/lib/odspDocumentService.d.ts +2 -1
- package/lib/odspDocumentService.d.ts.map +1 -1
- package/lib/odspDocumentService.js +14 -7
- package/lib/odspDocumentService.js.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.d.ts +2 -2
- package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.js +6 -6
- package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
- package/lib/odspDocumentStorageManager.d.ts +0 -6
- package/lib/odspDocumentStorageManager.d.ts.map +1 -1
- package/lib/odspDocumentStorageManager.js +9 -58
- package/lib/odspDocumentStorageManager.js.map +1 -1
- package/lib/odspDriverUrlResolver.d.ts +2 -6
- package/lib/odspDriverUrlResolver.d.ts.map +1 -1
- package/lib/odspDriverUrlResolver.js +14 -9
- package/lib/odspDriverUrlResolver.js.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.d.ts +2 -6
- package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.js +10 -7
- package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/lib/odspSnapshotParser.d.ts.map +1 -1
- package/lib/odspSnapshotParser.js +1 -5
- package/lib/odspSnapshotParser.js.map +1 -1
- package/lib/odspSummaryUploadManager.d.ts.map +1 -1
- package/lib/odspSummaryUploadManager.js +9 -6
- package/lib/odspSummaryUploadManager.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +19 -14
- package/src/compactSnapshotParser.ts +14 -12
- package/src/createNewUtils.ts +0 -1
- package/src/epochTracker.ts +34 -25
- package/src/fetchSnapshot.ts +57 -89
- package/src/odspDocumentService.ts +8 -5
- package/src/odspDocumentServiceFactoryCore.ts +7 -2
- package/src/odspDocumentStorageManager.ts +10 -64
- package/src/odspDriverUrlResolver.ts +18 -9
- package/src/odspDriverUrlResolverForShareLink.ts +11 -8
- package/src/odspSnapshotParser.ts +1 -4
- package/src/odspSummaryUploadManager.ts +7 -6
- package/src/packageVersion.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDriverUrlResolver.js","sourceRoot":"","sources":["../src/odspDriverUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAA+B,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAC9F,OAAO,EACH,YAAY,GAIf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAoB,cAAc,EAAqB,MAAM,yCAAyC,CAAC;AAC9G,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,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CAAC;KAC1D;IAED,IAAI,MAAM,KAAK,IAAI,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;KAC1D;IAED,IAAI,IAAI,KAAK,IAAI,EAAE;QACf,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;KACtD;IAED,OAAO;QACH,OAAO;QACP,OAAO,EAAE,kBAAkB,CAAC,OAAO,CAAC;QACpC,MAAM,EAAE,kBAAkB,CAAC,MAAM,CAAC;QAClC,IAAI,EAAE,kBAAkB,CAAC,IAAI,CAAC;QAC9B,oBAAoB,EAAE,oBAAoB,CAAC,CAAC,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,SAAS;QACjG,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;KACzE,CAAC;AACN,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IFluidCodeDetails, IRequest, isFluidPackage } from \"@fluidframework/core-interfaces\";\nimport {\n DriverHeader,\n IContainerPackageInfo,\n IResolvedUrl,\n IUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { IOdspResolvedUrl, ShareLinkTypes, ShareLinkInfoType } from \"@fluidframework/odsp-driver-definitions\";\nimport { createOdspUrl } from \"./createOdspUrl\";\nimport { getApiRoot } from \"./odspUrlHelper\";\nimport { getOdspResolvedUrl } from \"./odspUtils\";\nimport { getHashedDocumentId } from \"./odspPublicUtils\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic\";\n\nfunction getUrlBase(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n const siteOrigin = new URL(siteUrl).origin;\n const version = fileVersion ? `versions/${fileVersion}/` : \"\";\n return `${getApiRoot(siteOrigin)}/drives/${driveId}/items/${itemId}/${version}`;\n}\n\nfunction getSnapshotUrl(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n const urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n return `${urlBase}opStream/snapshots`;\n}\n\nfunction getAttachmentPOSTUrl(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n const urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n return `${urlBase}opStream/attachment`;\n}\n\nfunction getAttachmentGETUrl(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n const urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n return `${urlBase}opStream/attachments`;\n}\n\nfunction getDeltaStorageUrl(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n const urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n return `${urlBase}opStream`;\n}\n\n/**\n * Utility that enables us to handle paths provided with a beginning slash.\n * For example if a value of '/id1/id2' is provided, id1/id2 is returned.\n */\nfunction removeBeginningSlash(str: string): string {\n if (str.startsWith(\"/\")) {\n return str.substr(1);\n }\n\n return str;\n}\n\n/**\n * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner\n * url format. Ex: `${siteUrl}?driveId=${driveId}&itemId=${itemId}&path=${path}`\n */\nexport class OdspDriverUrlResolver implements IUrlResolver {\n constructor() { }\n\n public async resolve(request: IRequest): Promise<IOdspResolvedUrl> {\n if (request.headers && request.headers[DriverHeader.createNew]) {\n const [siteURL, queryString] = request.url.split(\"?\");\n\n const searchParams = new URLSearchParams(queryString);\n const fileName = request.headers[DriverHeader.createNew].fileName;\n const driveID = searchParams.get(\"driveId\");\n const filePath = searchParams.get(\"path\");\n const packageName = searchParams.get(\"containerPackageName\");\n const createLinkType = searchParams.get(\"createLinkType\");\n if (!(fileName && siteURL && driveID && filePath !== null && filePath !== undefined)) {\n throw new Error(\"Proper new file params should be there!!\");\n }\n let shareLinkInfo: ShareLinkInfoType | undefined;\n if(createLinkType && createLinkType in ShareLinkTypes) {\n shareLinkInfo = {\n createLink: {\n type: ShareLinkTypes[createLinkType],\n },\n };\n }\n return {\n endpoints: {\n snapshotStorageUrl: \"\",\n attachmentGETStorageUrl: \"\",\n attachmentPOSTStorageUrl: \"\",\n deltaStorageUrl: \"\",\n },\n tokens: {},\n type: \"fluid\",\n odspResolvedUrl: true,\n id: \"odspCreateNew\",\n url: `fluid-odsp://${siteURL}?${queryString}&version=null`,\n siteUrl: siteURL,\n hashedDocumentId: \"\",\n driveId: driveID,\n itemId: \"\",\n fileName,\n summarizer: false,\n codeHint: {\n containerPackageName: packageName ? packageName : undefined,\n },\n fileVersion: undefined,\n shareLinkInfo,\n isClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n };\n }\n const { siteUrl, driveId, itemId, path, containerPackageName, fileVersion } = decodeOdspUrl(request.url);\n const hashedDocumentId = await getHashedDocumentId(driveId, itemId);\n assert(!hashedDocumentId.includes(\"/\"), 0x0a8 /* \"Docid should not contain slashes!!\" */);\n\n let documentUrl = `fluid-odsp://placeholder/placeholder/${hashedDocumentId}/${removeBeginningSlash(path)}`;\n\n if (request.url.length > 0) {\n // In case of any additional parameters add them back to the url\n const requestURL = new URL(request.url);\n const searchParams = requestURL.search;\n if (searchParams) {\n documentUrl += searchParams;\n }\n }\n\n const summarizer = !!request.headers?.[DriverHeader.summarizingClient];\n\n return {\n type: \"fluid\",\n odspResolvedUrl: true,\n endpoints: {\n snapshotStorageUrl: getSnapshotUrl(siteUrl, driveId, itemId, fileVersion),\n attachmentPOSTStorageUrl: getAttachmentPOSTUrl(siteUrl, driveId, itemId, fileVersion),\n attachmentGETStorageUrl: getAttachmentGETUrl(siteUrl, driveId, itemId, fileVersion),\n deltaStorageUrl: getDeltaStorageUrl(siteUrl, driveId, itemId, fileVersion),\n },\n id: hashedDocumentId,\n tokens: {},\n url: documentUrl,\n hashedDocumentId,\n siteUrl,\n driveId,\n itemId,\n fileName: \"\",\n summarizer,\n codeHint: {\n containerPackageName,\n },\n fileVersion,\n isClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n };\n }\n\n public async getAbsoluteUrl(\n resolvedUrl: IResolvedUrl,\n relativeUrl: string,\n packageInfoSource?: IContainerPackageInfo | IFluidCodeDetails,\n ): Promise<string> {\n let dataStorePath = relativeUrl;\n if (dataStorePath.startsWith(\"/\")) {\n dataStorePath = dataStorePath.substr(1);\n }\n const odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n // back-compat: IFluidCodeDetails usage to be removed in 0.58.0\n let containerPackageName;\n if (packageInfoSource && \"name\" in packageInfoSource) {\n containerPackageName = packageInfoSource.name;\n } else if (isFluidPackage(packageInfoSource?.package)) {\n containerPackageName = packageInfoSource?.package.name;\n } else {\n containerPackageName = packageInfoSource?.package;\n }\n containerPackageName = containerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName;\n\n return createOdspUrl({\n ... odspResolvedUrl,\n containerPackageName,\n dataStorePath,\n });\n }\n}\n\nfunction decodeOdspUrl(url: string): {\n siteUrl: string;\n driveId: string;\n itemId: string;\n path: string;\n containerPackageName?: string;\n fileVersion?: string;\n} {\n const [siteUrl, queryString] = url.split(\"?\");\n\n const searchParams = new URLSearchParams(queryString);\n\n const driveId = searchParams.get(\"driveId\");\n const itemId = searchParams.get(\"itemId\");\n const path = searchParams.get(\"path\");\n const containerPackageName = searchParams.get(\"containerPackageName\");\n const fileVersion = searchParams.get(\"fileVersion\");\n\n if (driveId === null) {\n throw new Error(\"ODSP URL did not contain a drive id\");\n }\n\n if (itemId === null) {\n throw new Error(\"ODSP Url did not contain an item id\");\n }\n\n if (path === null) {\n throw new Error(\"ODSP Url did not contain a path\");\n }\n\n return {\n siteUrl,\n driveId: decodeURIComponent(driveId),\n itemId: decodeURIComponent(itemId),\n path: decodeURIComponent(path),\n containerPackageName: containerPackageName ? decodeURIComponent(containerPackageName) : undefined,\n fileVersion: fileVersion ? decodeURIComponent(fileVersion) : undefined,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"odspDriverUrlResol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AE,WAAW,CAAC,CAAC,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;KACzE,CAAC;AACN,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n DriverErrorType,\n DriverHeader,\n IContainerPackageInfo,\n IResolvedUrl,\n IUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { IOdspResolvedUrl, ShareLinkTypes, ShareLinkInfoType } from \"@fluidframework/odsp-driver-definitions\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { createOdspUrl } from \"./createOdspUrl\";\nimport { getApiRoot } from \"./odspUrlHelper\";\nimport { getOdspResolvedUrl } from \"./odspUtils\";\nimport { getHashedDocumentId } from \"./odspPublicUtils\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic\";\nimport { pkgVersion } from \"./packageVersion\";\n\nfunction getUrlBase(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n const siteOrigin = new URL(siteUrl).origin;\n const version = fileVersion ? `versions/${fileVersion}/` : \"\";\n return `${getApiRoot(siteOrigin)}/drives/${driveId}/items/${itemId}/${version}`;\n}\n\nfunction getSnapshotUrl(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n const urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n return `${urlBase}opStream/snapshots`;\n}\n\nfunction getAttachmentPOSTUrl(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n const urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n return `${urlBase}opStream/attachment`;\n}\n\nfunction getAttachmentGETUrl(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n const urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n return `${urlBase}opStream/attachments`;\n}\n\nfunction getDeltaStorageUrl(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n const urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n return `${urlBase}opStream`;\n}\n\n/**\n * Utility that enables us to handle paths provided with a beginning slash.\n * For example if a value of '/id1/id2' is provided, id1/id2 is returned.\n */\nfunction removeBeginningSlash(str: string): string {\n if (str.startsWith(\"/\")) {\n return str.substr(1);\n }\n\n return str;\n}\n\n/**\n * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner\n * url format. Ex: `${siteUrl}?driveId=${driveId}&itemId=${itemId}&path=${path}`\n */\nexport class OdspDriverUrlResolver implements IUrlResolver {\n constructor() { }\n\n public async resolve(request: IRequest): Promise<IOdspResolvedUrl> {\n if (request.headers && request.headers[DriverHeader.createNew]) {\n const [siteURL, queryString] = request.url.split(\"?\");\n\n const searchParams = new URLSearchParams(queryString);\n const fileName = request.headers[DriverHeader.createNew].fileName;\n const driveID = searchParams.get(\"driveId\");\n const filePath = searchParams.get(\"path\");\n const packageName = searchParams.get(\"containerPackageName\");\n const createLinkType = searchParams.get(\"createLinkType\");\n if (!(fileName && siteURL && driveID && filePath !== null && filePath !== undefined)) {\n throw new NonRetryableError(\n \"Proper new file params should be there!!\",\n DriverErrorType.genericError,\n { driverVersion: pkgVersion });\n }\n let shareLinkInfo: ShareLinkInfoType | undefined;\n if(createLinkType && createLinkType in ShareLinkTypes) {\n shareLinkInfo = {\n createLink: {\n type: ShareLinkTypes[createLinkType],\n },\n };\n }\n return {\n endpoints: {\n snapshotStorageUrl: \"\",\n attachmentGETStorageUrl: \"\",\n attachmentPOSTStorageUrl: \"\",\n deltaStorageUrl: \"\",\n },\n tokens: {},\n type: \"fluid\",\n odspResolvedUrl: true,\n id: \"odspCreateNew\",\n url: `fluid-odsp://${siteURL}?${queryString}&version=null`,\n siteUrl: siteURL,\n hashedDocumentId: \"\",\n driveId: driveID,\n itemId: \"\",\n fileName,\n summarizer: false,\n codeHint: {\n containerPackageName: packageName ? packageName : undefined,\n },\n fileVersion: undefined,\n shareLinkInfo,\n isClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n };\n }\n const { siteUrl, driveId, itemId, path, containerPackageName, fileVersion } = decodeOdspUrl(request.url);\n const hashedDocumentId = await getHashedDocumentId(driveId, itemId);\n assert(!hashedDocumentId.includes(\"/\"), 0x0a8 /* \"Docid should not contain slashes!!\" */);\n\n let documentUrl = `fluid-odsp://placeholder/placeholder/${hashedDocumentId}/${removeBeginningSlash(path)}`;\n\n if (request.url.length > 0) {\n // In case of any additional parameters add them back to the url\n const requestURL = new URL(request.url);\n const searchParams = requestURL.search;\n if (searchParams) {\n documentUrl += searchParams;\n }\n }\n\n const summarizer = !!request.headers?.[DriverHeader.summarizingClient];\n\n return {\n type: \"fluid\",\n odspResolvedUrl: true,\n endpoints: {\n snapshotStorageUrl: getSnapshotUrl(siteUrl, driveId, itemId, fileVersion),\n attachmentPOSTStorageUrl: getAttachmentPOSTUrl(siteUrl, driveId, itemId, fileVersion),\n attachmentGETStorageUrl: getAttachmentGETUrl(siteUrl, driveId, itemId, fileVersion),\n deltaStorageUrl: getDeltaStorageUrl(siteUrl, driveId, itemId, fileVersion),\n },\n id: hashedDocumentId,\n tokens: {},\n url: documentUrl,\n hashedDocumentId,\n siteUrl,\n driveId,\n itemId,\n fileName: \"\",\n summarizer,\n codeHint: {\n containerPackageName,\n },\n fileVersion,\n isClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n };\n }\n\n public async getAbsoluteUrl(\n resolvedUrl: IResolvedUrl,\n relativeUrl: string,\n packageInfoSource?: IContainerPackageInfo,\n ): Promise<string> {\n let dataStorePath = relativeUrl;\n if (dataStorePath.startsWith(\"/\")) {\n dataStorePath = dataStorePath.substr(1);\n }\n const odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n // back-compat: GitHub #9653\n const isFluidPackage = (pkg: any) =>\n typeof pkg === \"object\"\n && typeof pkg?.name === \"string\"\n && typeof pkg?.fluid === \"object\";\n let containerPackageName;\n if (packageInfoSource && \"name\" in packageInfoSource) {\n containerPackageName = packageInfoSource.name;\n // packageInfoSource is cast to any as it is typed to IContainerPackageInfo instead of IFluidCodeDetails\n } else if (isFluidPackage((packageInfoSource as any)?.package)) {\n containerPackageName = (packageInfoSource as any)?.package.name;\n } else {\n containerPackageName = (packageInfoSource as any)?.package;\n }\n containerPackageName = containerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName;\n\n return createOdspUrl({\n ... odspResolvedUrl,\n containerPackageName,\n dataStorePath,\n });\n }\n}\n\nfunction decodeOdspUrl(url: string): {\n siteUrl: string;\n driveId: string;\n itemId: string;\n path: string;\n containerPackageName?: string;\n fileVersion?: string;\n} {\n const [siteUrl, queryString] = url.split(\"?\");\n\n const searchParams = new URLSearchParams(queryString);\n\n const driveId = searchParams.get(\"driveId\");\n const itemId = searchParams.get(\"itemId\");\n const path = searchParams.get(\"path\");\n const containerPackageName = searchParams.get(\"containerPackageName\");\n const fileVersion = searchParams.get(\"fileVersion\");\n\n if (driveId === null) {\n throw new Error(\"ODSP URL did not contain a drive id\");\n }\n\n if (itemId === null) {\n throw new Error(\"ODSP Url did not contain an item id\");\n }\n\n if (path === null) {\n throw new Error(\"ODSP Url did not contain a path\");\n }\n\n return {\n siteUrl,\n driveId: decodeURIComponent(driveId),\n itemId: decodeURIComponent(itemId),\n path: decodeURIComponent(path),\n containerPackageName: containerPackageName ? decodeURIComponent(containerPackageName) : undefined,\n fileVersion: fileVersion ? decodeURIComponent(fileVersion) : undefined,\n };\n}\n"]}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { IFluidCodeDetails, IRequest } from "@fluidframework/core-interfaces";
|
|
1
|
+
import { IRequest } from "@fluidframework/core-interfaces";
|
|
6
2
|
import { IContainerPackageInfo, IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
|
|
7
3
|
import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
|
|
8
4
|
import { IOdspResolvedUrl, IdentityType, OdspResourceTokenFetchOptions, TokenFetcher } from "@fluidframework/odsp-driver-definitions";
|
|
@@ -59,7 +55,7 @@ export declare class OdspDriverUrlResolverForShareLink implements IUrlResolver {
|
|
|
59
55
|
* @param resolvedUrl - The driver resolved URL
|
|
60
56
|
* @param request - The relative data store path URL. For requesting a driver URL, this value should always be '/'
|
|
61
57
|
*/
|
|
62
|
-
getAbsoluteUrl(resolvedUrl: IResolvedUrl, dataStorePath: string, packageInfoSource?: IContainerPackageInfo
|
|
58
|
+
getAbsoluteUrl(resolvedUrl: IResolvedUrl, dataStorePath: string, packageInfoSource?: IContainerPackageInfo): Promise<string>;
|
|
63
59
|
/**
|
|
64
60
|
* Crafts a supported document/driver URL
|
|
65
61
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDriverUrlResolverForShareLink.d.ts","sourceRoot":"","sources":["../src/odspDriverUrlResolverForShareLink.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"odspDriverUrlResolverForShareLink.d.ts","sourceRoot":"","sources":["../src/odspDriverUrlResolverForShareLink.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EACH,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAoB,MAAM,oCAAoC,CAAC;AAC5F,OAAO,EACH,gBAAgB,EAChB,YAAY,EACZ,6BAA6B,EAC7B,YAAY,EACf,MAAM,yCAAyC,CAAC;AAOjD,OAAO,EAAE,yBAAyB,EAAqB,MAAM,mBAAmB,CAAC;AAMjF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC;;OAEG;IACH,YAAY,EAAE,YAAY,CAAC,6BAA6B,CAAC,CAAC;IAC1D;;OAEG;IACH,YAAY,EAAE,YAAY,CAAC;CAC9B;AAED;;;;GAIG;AACH,qBAAa,iCAAkC,YAAW,YAAY;IAkB9D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IAjB7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmB;IAC1C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAsC;IACvE,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAoC;IAE1E;;;;;;;;;OASG;gBAEC,qBAAqB,CAAC,EAAE,qBAAqB,GAAG,SAAS,EACzD,MAAM,CAAC,EAAE,oBAAoB,EACZ,OAAO,CAAC,oBAAQ;IAWrC;;;OAGG;IACI,mBAAmB,CAAC,UAAU,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAyBrF,OAAO,CAAC,MAAM;IAId;;OAEG;IACU,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA+BlE,OAAO,CAAC,cAAc;YAQR,mBAAmB;IA8BjC;;;;;OAKG;IACU,cAAc,CACvB,WAAW,EAAE,YAAY,EACzB,aAAa,EAAE,MAAM,EACrB,iBAAiB,CAAC,EAAE,qBAAqB,GAC1C,OAAO,CAAC,MAAM,CAAC;IAiClB;;OAEG;WACW,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,yBAAyB;IAQtF;;OAEG;WACW,cAAc,CAAC,OAAO,EAAE,yBAAyB;CAGlE"}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { PromiseCache } from "@fluidframework/common-utils";
|
|
6
|
-
import { isFluidPackage } from "@fluidframework/core-interfaces";
|
|
7
6
|
import { getLocatorFromOdspUrl, storeLocatorInOdspUrl, encodeOdspFluidDataStoreLocator, locatorQueryParamName, } from "./odspFluidFileLink";
|
|
8
7
|
import { SharingLinkHeader } from "./contractsPublic";
|
|
9
8
|
import { createOdspUrl } from "./createOdspUrl";
|
|
@@ -128,22 +127,26 @@ export class OdspDriverUrlResolverForShareLink {
|
|
|
128
127
|
* @param request - The relative data store path URL. For requesting a driver URL, this value should always be '/'
|
|
129
128
|
*/
|
|
130
129
|
async getAbsoluteUrl(resolvedUrl, dataStorePath, packageInfoSource) {
|
|
131
|
-
var _a;
|
|
130
|
+
var _a, _b, _c, _d;
|
|
132
131
|
const odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);
|
|
133
132
|
const shareLink = await this.getShareLinkPromise(odspResolvedUrl);
|
|
134
133
|
const shareLinkUrl = new URL(shareLink);
|
|
135
|
-
// back-compat:
|
|
134
|
+
// back-compat: GitHub #9653
|
|
135
|
+
const isFluidPackage = (pkg) => typeof pkg === "object"
|
|
136
|
+
&& typeof (pkg === null || pkg === void 0 ? void 0 : pkg.name) === "string"
|
|
137
|
+
&& typeof (pkg === null || pkg === void 0 ? void 0 : pkg.fluid) === "object";
|
|
136
138
|
let containerPackageName;
|
|
137
139
|
if (packageInfoSource && "name" in packageInfoSource) {
|
|
138
140
|
containerPackageName = packageInfoSource.name;
|
|
141
|
+
// packageInfoSource is cast to any as it is typed to IContainerPackageInfo instead of IFluidCodeDetails
|
|
139
142
|
}
|
|
140
|
-
else if (isFluidPackage(packageInfoSource === null ||
|
|
141
|
-
containerPackageName = packageInfoSource === null ||
|
|
143
|
+
else if (isFluidPackage((_a = packageInfoSource) === null || _a === void 0 ? void 0 : _a.package)) {
|
|
144
|
+
containerPackageName = (_b = packageInfoSource) === null || _b === void 0 ? void 0 : _b.package.name;
|
|
142
145
|
}
|
|
143
146
|
else {
|
|
144
|
-
containerPackageName = packageInfoSource === null ||
|
|
147
|
+
containerPackageName = (_c = packageInfoSource) === null || _c === void 0 ? void 0 : _c.package;
|
|
145
148
|
}
|
|
146
|
-
containerPackageName = containerPackageName !== null && containerPackageName !== void 0 ? containerPackageName : (
|
|
149
|
+
containerPackageName = containerPackageName !== null && containerPackageName !== void 0 ? containerPackageName : (_d = odspResolvedUrl.codeHint) === null || _d === void 0 ? void 0 : _d.containerPackageName;
|
|
147
150
|
storeLocatorInOdspUrl(shareLinkUrl, {
|
|
148
151
|
siteUrl: odspResolvedUrl.siteUrl,
|
|
149
152
|
driveId: odspResolvedUrl.driveId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDriverUrlResolverForShareLink.js","sourceRoot":"","sources":["../src/odspDriverUrlResolverForShareLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAA+B,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAa9F,OAAO,EACH,qBAAqB,EACrB,qBAAqB,EACrB,+BAA+B,EAC/B,qBAAqB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAA6B,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAgB5C;;;;GAIG;AACH,MAAM,OAAO,iCAAiC;IAK1C;;;;;;;;;OASG;IACH,YACI,qBAAyD,EACzD,MAA6B,EACZ,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;QAhBpB,qBAAgB,GAAG,IAAI,YAAY,EAAkB,CAAC;QAkBnE,IAAI,CAAC,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,qBAAqB,EAAE;YACvB,IAAI,CAAC,qBAAqB,mCACnB,qBAAqB,KACxB,YAAY,EAAE,qBAAqB,CAAC,YAAY,GACnD,CAAC;SACL;IACL,CAAC;IAED;;;OAGG;IACI,mBAAmB,CAAC,UAAe,EAAE,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,EAAE,UAAU,CAAC,CAAC;QAEvC,OAAO,GAAG,CAAC,IAAI,CAAC;IACpB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,cAAc,CAAC,OAAkC;QAC3D,OAAO,+BAA+B,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { PromiseCache } from \"@fluidframework/common-utils\";\nimport { IFluidCodeDetails, IRequest, isFluidPackage } from \"@fluidframework/core-interfaces\";\nimport {\n IContainerPackageInfo,\n IResolvedUrl,\n IUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { ITelemetryBaseLogger, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n IOdspResolvedUrl,\n IdentityType,\n OdspResourceTokenFetchOptions,\n TokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport {\n getLocatorFromOdspUrl,\n storeLocatorInOdspUrl,\n encodeOdspFluidDataStoreLocator,\n locatorQueryParamName,\n} from \"./odspFluidFileLink\";\nimport { OdspFluidDataStoreLocator, SharingLinkHeader } from \"./contractsPublic\";\nimport { createOdspUrl } from \"./createOdspUrl\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver\";\nimport { getOdspResolvedUrl, createOdspLogger } from \"./odspUtils\";\nimport { getFileLink } from \"./getFileLink\";\n\n/**\n * Properties passed to the code responsible for fetching share link for a file.\n */\nexport interface ShareLinkFetcherProps {\n /**\n * Callback method that is used to fetch access token necessary to call API that produces share link\n */\n tokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>;\n /**\n * Identity type determining the shape of share link as it differs for Enterprise and Consumer users.\n */\n identityType: IdentityType;\n}\n\n/**\n * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner\n * url format and the ones which have things like driveId, siteId, itemId etc encoded in nav param.\n * This resolver also handles share links and try to generate one for the use by the app.\n */\nexport class OdspDriverUrlResolverForShareLink implements IUrlResolver {\n private readonly logger: ITelemetryLogger;\n private readonly sharingLinkCache = new PromiseCache<string, string>();\n private readonly shareLinkFetcherProps: ShareLinkFetcherProps | undefined;\n\n /**\n * Creates url resolver instance\n * @param shareLinkFetcherProps - properties used when fetching share link.\n * Can be set as 'undefined' for cases where share link is not needed. Currently, only\n * getAbsoluteUrl() method requires share link.\n * @param logger - logger object that is used as telemetry sink\n * @param appName - application name hint that is encoded with url produced by getAbsoluteUrl() method.\n * This hint is used by link handling logic which determines which app to redirect to when user\n * navigates directly to the link.\n */\n public constructor(\n shareLinkFetcherProps?: ShareLinkFetcherProps | undefined,\n logger?: ITelemetryBaseLogger,\n private readonly appName?: string,\n ) {\n this.logger = createOdspLogger(logger);\n if (shareLinkFetcherProps) {\n this.shareLinkFetcherProps = {\n ...shareLinkFetcherProps,\n tokenFetcher: shareLinkFetcherProps.tokenFetcher,\n };\n }\n }\n\n /**\n * Takes an already generated data store url (from requestUrl) and appends a path to the\n * existing data store information.\n */\n public appendDataStorePath(requestUrl: URL, pathToAppend: string): string | undefined {\n const fluidInfo = getLocatorFromOdspUrl(requestUrl);\n\n if (!fluidInfo) {\n return undefined;\n }\n\n const parsingUrl = new URL(fluidInfo.dataStorePath, `${requestUrl.protocol}//${requestUrl.hostname}`);\n // Determine if the caller is passing a query parameter or path since processing will be different.\n if (pathToAppend.startsWith(\"/?\") || pathToAppend.startsWith(\"?\")) {\n const queryParams = new URLSearchParams(pathToAppend);\n queryParams.forEach((value: string, key: string) => {\n parsingUrl.searchParams.append(key, value);\n });\n fluidInfo.dataStorePath = `${parsingUrl.pathname}${parsingUrl.search}`;\n } else {\n fluidInfo.dataStorePath = `${parsingUrl.pathname}${\n parsingUrl.pathname.endsWith(\"/\") || pathToAppend.startsWith(\"/\") ? \"\" : \"/\"\n }${pathToAppend}/${parsingUrl.search}`;\n }\n storeLocatorInOdspUrl(requestUrl, fluidInfo);\n\n return requestUrl.href;\n }\n\n private getKey(resolvedUrl: IOdspResolvedUrl): string {\n return `${resolvedUrl.siteUrl},${resolvedUrl.driveId},${resolvedUrl.itemId}`;\n }\n\n /**\n * Resolves request URL into driver details\n */\n public async resolve(request: IRequest): Promise<IOdspResolvedUrl> {\n const requestToBeResolved = { headers: request.headers, url: request.url };\n const isSharingLinkToRedeem = requestToBeResolved.headers?.[SharingLinkHeader.isSharingLinkToRedeem];\n try {\n const url = new URL(request.url);\n\n const odspFluidInfo = getLocatorFromOdspUrl(url);\n if (odspFluidInfo) {\n requestToBeResolved.url = createOdspUrl(odspFluidInfo);\n }\n } catch {\n // If the locator throws some error, then try to resolve the request as it is.\n }\n\n const odspResolvedUrl = await new OdspDriverUrlResolver().resolve(requestToBeResolved);\n\n if (isSharingLinkToRedeem) {\n // We need to remove the nav param if set by host when setting the sharelink as otherwise the shareLinkId\n // when redeeming the share link during the redeem fallback for trees latest call becomes greater than\n // the eligible length.\n odspResolvedUrl.shareLinkInfo = Object.assign(odspResolvedUrl.shareLinkInfo || {},\n {sharingLinkToRedeem: this.removeNavParam(request.url)});\n }\n if (odspResolvedUrl.itemId) {\n // Kick start the sharing link request if we don't have it already as a performance optimization.\n // For detached create new, we don't have an item id yet and therefore cannot generate a share link\n this.getShareLinkPromise(odspResolvedUrl).catch(() => {});\n }\n return odspResolvedUrl;\n }\n\n private removeNavParam(link: string): string {\n const url = new URL(link);\n const params = new URLSearchParams(url.search);\n params.delete(locatorQueryParamName);\n url.search = params.toString();\n return url.href;\n }\n\n private async getShareLinkPromise(resolvedUrl: IOdspResolvedUrl): Promise<string> {\n if (this.shareLinkFetcherProps === undefined) {\n throw new Error(\"Failed to get share link because share link fetcher props are missing\");\n }\n\n if (!(resolvedUrl.siteUrl && resolvedUrl.driveId && resolvedUrl.itemId)) {\n throw new Error(\"Failed to get share link because necessary information is missing \" +\n \"(e.g. siteUrl, driveId or itemId)\");\n }\n\n const key = this.getKey(resolvedUrl);\n const cachedLinkPromise = this.sharingLinkCache.get(key);\n if (cachedLinkPromise) {\n return cachedLinkPromise;\n }\n const newLinkPromise = getFileLink(\n this.shareLinkFetcherProps.tokenFetcher,\n resolvedUrl,\n this.shareLinkFetcherProps.identityType,\n this.logger,\n ).catch((error) => {\n // This should imply that error is a non-retriable error.\n this.logger.sendErrorEvent({ eventName: \"FluidFileUrlError\" }, error);\n this.sharingLinkCache.remove(key);\n throw error;\n });\n this.sharingLinkCache.add(key, async () => newLinkPromise);\n return newLinkPromise;\n }\n\n /**\n * Requests a driver + data store storage URL. Note that this method requires share link to be fetched\n * and it will throw in case share link fetcher props were not specified when instance was created.\n * @param resolvedUrl - The driver resolved URL\n * @param request - The relative data store path URL. For requesting a driver URL, this value should always be '/'\n */\n public async getAbsoluteUrl(\n resolvedUrl: IResolvedUrl,\n dataStorePath: string,\n packageInfoSource?: IContainerPackageInfo | IFluidCodeDetails,\n ): Promise<string> {\n const odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n const shareLink = await this.getShareLinkPromise(odspResolvedUrl);\n const shareLinkUrl = new URL(shareLink);\n\n // back-compat: IFluidCodeDetails usage to be removed in 0.58.0\n let containerPackageName;\n if (packageInfoSource && \"name\" in packageInfoSource) {\n containerPackageName = packageInfoSource.name;\n } else if (isFluidPackage(packageInfoSource?.package)) {\n containerPackageName = packageInfoSource?.package.name;\n } else {\n containerPackageName = packageInfoSource?.package;\n }\n containerPackageName = containerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName;\n\n storeLocatorInOdspUrl(shareLinkUrl, {\n siteUrl: odspResolvedUrl.siteUrl,\n driveId: odspResolvedUrl.driveId,\n itemId: odspResolvedUrl.itemId,\n dataStorePath,\n appName: this.appName,\n containerPackageName,\n fileVersion: odspResolvedUrl.fileVersion,\n });\n\n return shareLinkUrl.href;\n }\n\n /**\n * Crafts a supported document/driver URL\n */\n public static createDocumentUrl(baseUrl: string, driverInfo: OdspFluidDataStoreLocator) {\n const url = new URL(baseUrl);\n\n storeLocatorInOdspUrl(url, driverInfo);\n\n return url.href;\n }\n\n /**\n * Crafts a supported data store nav param\n */\n public static createNavParam(locator: OdspFluidDataStoreLocator) {\n return encodeOdspFluidDataStoreLocator(locator);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"odspDriverUrlResolverForShareLink.js","sourceRoot":"","sources":["../src/odspDriverUrlResolverForShareLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAc5D,OAAO,EACH,qBAAqB,EACrB,qBAAqB,EACrB,+BAA+B,EAC/B,qBAAqB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAA6B,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAgB5C;;;;GAIG;AACH,MAAM,OAAO,iCAAiC;IAK1C;;;;;;;;;OASG;IACH,YACI,qBAAyD,EACzD,MAA6B,EACZ,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;QAhBpB,qBAAgB,GAAG,IAAI,YAAY,EAAkB,CAAC;QAkBnE,IAAI,CAAC,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,qBAAqB,EAAE;YACvB,IAAI,CAAC,qBAAqB,mCACnB,qBAAqB,KACxB,YAAY,EAAE,qBAAqB,CAAC,YAAY,GACnD,CAAC;SACL;IACL,CAAC;IAED;;;OAGG;IACI,mBAAmB,CAAC,UAAe,EAAE,YAAoB;QAC5D,MAAM,SAAS,GAAG,qBAAqB,CAAC,UAAU,CAAC,CAAC;QAEpD,IAAI,CAAC,SAAS,EAAE;YACZ,OAAO,SAAS,CAAC;SACpB;QAED,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,SAAS,C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CAAC,CAAC;QAEvC,OAAO,GAAG,CAAC,IAAI,CAAC;IACpB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,cAAc,CAAC,OAAkC;QAC3D,OAAO,+BAA+B,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { PromiseCache } from \"@fluidframework/common-utils\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n IContainerPackageInfo,\n IResolvedUrl,\n IUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { ITelemetryBaseLogger, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n IOdspResolvedUrl,\n IdentityType,\n OdspResourceTokenFetchOptions,\n TokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport {\n getLocatorFromOdspUrl,\n storeLocatorInOdspUrl,\n encodeOdspFluidDataStoreLocator,\n locatorQueryParamName,\n} from \"./odspFluidFileLink\";\nimport { OdspFluidDataStoreLocator, SharingLinkHeader } from \"./contractsPublic\";\nimport { createOdspUrl } from \"./createOdspUrl\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver\";\nimport { getOdspResolvedUrl, createOdspLogger } from \"./odspUtils\";\nimport { getFileLink } from \"./getFileLink\";\n\n/**\n * Properties passed to the code responsible for fetching share link for a file.\n */\nexport interface ShareLinkFetcherProps {\n /**\n * Callback method that is used to fetch access token necessary to call API that produces share link\n */\n tokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>;\n /**\n * Identity type determining the shape of share link as it differs for Enterprise and Consumer users.\n */\n identityType: IdentityType;\n}\n\n/**\n * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner\n * url format and the ones which have things like driveId, siteId, itemId etc encoded in nav param.\n * This resolver also handles share links and try to generate one for the use by the app.\n */\nexport class OdspDriverUrlResolverForShareLink implements IUrlResolver {\n private readonly logger: ITelemetryLogger;\n private readonly sharingLinkCache = new PromiseCache<string, string>();\n private readonly shareLinkFetcherProps: ShareLinkFetcherProps | undefined;\n\n /**\n * Creates url resolver instance\n * @param shareLinkFetcherProps - properties used when fetching share link.\n * Can be set as 'undefined' for cases where share link is not needed. Currently, only\n * getAbsoluteUrl() method requires share link.\n * @param logger - logger object that is used as telemetry sink\n * @param appName - application name hint that is encoded with url produced by getAbsoluteUrl() method.\n * This hint is used by link handling logic which determines which app to redirect to when user\n * navigates directly to the link.\n */\n public constructor(\n shareLinkFetcherProps?: ShareLinkFetcherProps | undefined,\n logger?: ITelemetryBaseLogger,\n private readonly appName?: string,\n ) {\n this.logger = createOdspLogger(logger);\n if (shareLinkFetcherProps) {\n this.shareLinkFetcherProps = {\n ...shareLinkFetcherProps,\n tokenFetcher: shareLinkFetcherProps.tokenFetcher,\n };\n }\n }\n\n /**\n * Takes an already generated data store url (from requestUrl) and appends a path to the\n * existing data store information.\n */\n public appendDataStorePath(requestUrl: URL, pathToAppend: string): string | undefined {\n const fluidInfo = getLocatorFromOdspUrl(requestUrl);\n\n if (!fluidInfo) {\n return undefined;\n }\n\n const parsingUrl = new URL(fluidInfo.dataStorePath, `${requestUrl.protocol}//${requestUrl.hostname}`);\n // Determine if the caller is passing a query parameter or path since processing will be different.\n if (pathToAppend.startsWith(\"/?\") || pathToAppend.startsWith(\"?\")) {\n const queryParams = new URLSearchParams(pathToAppend);\n queryParams.forEach((value: string, key: string) => {\n parsingUrl.searchParams.append(key, value);\n });\n fluidInfo.dataStorePath = `${parsingUrl.pathname}${parsingUrl.search}`;\n } else {\n fluidInfo.dataStorePath = `${parsingUrl.pathname}${\n parsingUrl.pathname.endsWith(\"/\") || pathToAppend.startsWith(\"/\") ? \"\" : \"/\"\n }${pathToAppend}/${parsingUrl.search}`;\n }\n storeLocatorInOdspUrl(requestUrl, fluidInfo);\n\n return requestUrl.href;\n }\n\n private getKey(resolvedUrl: IOdspResolvedUrl): string {\n return `${resolvedUrl.siteUrl},${resolvedUrl.driveId},${resolvedUrl.itemId}`;\n }\n\n /**\n * Resolves request URL into driver details\n */\n public async resolve(request: IRequest): Promise<IOdspResolvedUrl> {\n const requestToBeResolved = { headers: request.headers, url: request.url };\n const isSharingLinkToRedeem = requestToBeResolved.headers?.[SharingLinkHeader.isSharingLinkToRedeem];\n try {\n const url = new URL(request.url);\n\n const odspFluidInfo = getLocatorFromOdspUrl(url);\n if (odspFluidInfo) {\n requestToBeResolved.url = createOdspUrl(odspFluidInfo);\n }\n } catch {\n // If the locator throws some error, then try to resolve the request as it is.\n }\n\n const odspResolvedUrl = await new OdspDriverUrlResolver().resolve(requestToBeResolved);\n\n if (isSharingLinkToRedeem) {\n // We need to remove the nav param if set by host when setting the sharelink as otherwise the shareLinkId\n // when redeeming the share link during the redeem fallback for trees latest call becomes greater than\n // the eligible length.\n odspResolvedUrl.shareLinkInfo = Object.assign(odspResolvedUrl.shareLinkInfo || {},\n {sharingLinkToRedeem: this.removeNavParam(request.url)});\n }\n if (odspResolvedUrl.itemId) {\n // Kick start the sharing link request if we don't have it already as a performance optimization.\n // For detached create new, we don't have an item id yet and therefore cannot generate a share link\n this.getShareLinkPromise(odspResolvedUrl).catch(() => {});\n }\n return odspResolvedUrl;\n }\n\n private removeNavParam(link: string): string {\n const url = new URL(link);\n const params = new URLSearchParams(url.search);\n params.delete(locatorQueryParamName);\n url.search = params.toString();\n return url.href;\n }\n\n private async getShareLinkPromise(resolvedUrl: IOdspResolvedUrl): Promise<string> {\n if (this.shareLinkFetcherProps === undefined) {\n throw new Error(\"Failed to get share link because share link fetcher props are missing\");\n }\n\n if (!(resolvedUrl.siteUrl && resolvedUrl.driveId && resolvedUrl.itemId)) {\n throw new Error(\"Failed to get share link because necessary information is missing \" +\n \"(e.g. siteUrl, driveId or itemId)\");\n }\n\n const key = this.getKey(resolvedUrl);\n const cachedLinkPromise = this.sharingLinkCache.get(key);\n if (cachedLinkPromise) {\n return cachedLinkPromise;\n }\n const newLinkPromise = getFileLink(\n this.shareLinkFetcherProps.tokenFetcher,\n resolvedUrl,\n this.shareLinkFetcherProps.identityType,\n this.logger,\n ).catch((error) => {\n // This should imply that error is a non-retriable error.\n this.logger.sendErrorEvent({ eventName: \"FluidFileUrlError\" }, error);\n this.sharingLinkCache.remove(key);\n throw error;\n });\n this.sharingLinkCache.add(key, async () => newLinkPromise);\n return newLinkPromise;\n }\n\n /**\n * Requests a driver + data store storage URL. Note that this method requires share link to be fetched\n * and it will throw in case share link fetcher props were not specified when instance was created.\n * @param resolvedUrl - The driver resolved URL\n * @param request - The relative data store path URL. For requesting a driver URL, this value should always be '/'\n */\n public async getAbsoluteUrl(\n resolvedUrl: IResolvedUrl,\n dataStorePath: string,\n packageInfoSource?: IContainerPackageInfo,\n ): Promise<string> {\n const odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n const shareLink = await this.getShareLinkPromise(odspResolvedUrl);\n const shareLinkUrl = new URL(shareLink);\n // back-compat: GitHub #9653\n const isFluidPackage = (pkg: any) =>\n typeof pkg === \"object\"\n && typeof pkg?.name === \"string\"\n && typeof pkg?.fluid === \"object\";\n let containerPackageName;\n if (packageInfoSource && \"name\" in packageInfoSource) {\n containerPackageName = packageInfoSource.name;\n // packageInfoSource is cast to any as it is typed to IContainerPackageInfo instead of IFluidCodeDetails\n } else if (isFluidPackage((packageInfoSource as any)?.package)) {\n containerPackageName = (packageInfoSource as any)?.package.name;\n } else {\n containerPackageName = (packageInfoSource as any)?.package;\n }\n containerPackageName = containerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName;\n\n storeLocatorInOdspUrl(shareLinkUrl, {\n siteUrl: odspResolvedUrl.siteUrl,\n driveId: odspResolvedUrl.driveId,\n itemId: odspResolvedUrl.itemId,\n dataStorePath,\n appName: this.appName,\n containerPackageName,\n fileVersion: odspResolvedUrl.fileVersion,\n });\n\n return shareLinkUrl.href;\n }\n\n /**\n * Crafts a supported document/driver URL\n */\n public static createDocumentUrl(baseUrl: string, driverInfo: OdspFluidDataStoreLocator) {\n const url = new URL(baseUrl);\n\n storeLocatorInOdspUrl(url, driverInfo);\n\n return url.href;\n }\n\n /**\n * Crafts a supported data store nav param\n */\n public static createNavParam(locator: OdspFluidDataStoreLocator) {\n return encodeOdspFluidDataStoreLocator(locator);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspSnapshotParser.d.ts","sourceRoot":"","sources":["../src/odspSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,aAAa,EAAuB,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"odspSnapshotParser.d.ts","sourceRoot":"","sources":["../src/odspSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,aAAa,EAAuB,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAwChD;;;GAGG;AACH,wBAAgB,yCAAyC,CACrD,YAAY,EAAE,aAAa,GAC5B,iBAAiB,CAgBnB"}
|
|
@@ -13,7 +13,7 @@ import { assert, stringToBuffer } from "@fluidframework/common-utils";
|
|
|
13
13
|
function buildHierarchy(flatTree) {
|
|
14
14
|
const lookup = {};
|
|
15
15
|
// id is required for root tree as it will be used to determine the version we loaded from.
|
|
16
|
-
const root = { id: flatTree.id, blobs: {},
|
|
16
|
+
const root = { id: flatTree.id, blobs: {}, trees: {} };
|
|
17
17
|
lookup[""] = root;
|
|
18
18
|
for (const entry of flatTree.entries) {
|
|
19
19
|
const lastIndex = entry.path.lastIndexOf("/");
|
|
@@ -25,7 +25,6 @@ function buildHierarchy(flatTree) {
|
|
|
25
25
|
if (entry.type === "tree") {
|
|
26
26
|
const newTree = {
|
|
27
27
|
blobs: {},
|
|
28
|
-
commits: {},
|
|
29
28
|
trees: {},
|
|
30
29
|
unreferenced: entry.unreferenced,
|
|
31
30
|
};
|
|
@@ -35,9 +34,6 @@ function buildHierarchy(flatTree) {
|
|
|
35
34
|
else if (entry.type === "blob") {
|
|
36
35
|
node.blobs[decodeURIComponent(entryPathBase)] = entry.id;
|
|
37
36
|
}
|
|
38
|
-
else if (entry.type === "commit") {
|
|
39
|
-
node.commits[decodeURIComponent(entryPathBase)] = entry.id;
|
|
40
|
-
}
|
|
41
37
|
}
|
|
42
38
|
return root;
|
|
43
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspSnapshotParser.js","sourceRoot":"","sources":["../src/odspSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAKtE;;;;;;GAMG;AACH,SAAS,cAAc,CAAC,QAA6B;IACjD,MAAM,MAAM,GAA0C,EAAE,CAAC;IACzD,2FAA2F;IAC3F,MAAM,IAAI,GAAsB,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"odspSnapshotParser.js","sourceRoot":"","sources":["../src/odspSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAKtE;;;;;;GAMG;AACH,SAAS,cAAc,CAAC,QAA6B;IACjD,MAAM,MAAM,GAA0C,EAAE,CAAC;IACzD,2FAA2F;IAC3F,MAAM,IAAI,GAAsB,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAC1E,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;IAElB,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,OAAO,EAAE;QAClC,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC9C,MAAM,YAAY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I,CAAC,QAAQ,mCAAI,MAAM,CAAC,CAAC,CAAC;QAC/F,CAAC,CAAC,CAAC;KACN;IACD,MAAM,GAAG,GAAsB;QAC3B,KAAK,EAAE,sBAAsB;QAC7B,GAAG,cAAE,YAAY,CAAC,GAAG,0CAAE,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,oCAAK,EAAE;QAC/C,cAAc,EAAE,YAAY,CAAC,KAAK,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc;QAC5E,YAAY,EAAE,cAAc,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACtD,CAAC;IACF,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, stringToBuffer } from \"@fluidframework/common-utils\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { IOdspSnapshot, IOdspSnapshotCommit } from \"./contracts\";\nimport { ISnapshotContents } from \"./odspUtils\";\n\n/**\n * Build a tree hierarchy base on a flat tree\n *\n * @param flatTree - a flat tree\n * @param blobsShaToPathCache - Map with blobs sha as keys and values as path of the blob.\n * @returns the hierarchical tree\n */\nfunction buildHierarchy(flatTree: IOdspSnapshotCommit): api.ISnapshotTree {\n const lookup: { [path: string]: api.ISnapshotTree } = {};\n // id is required for root tree as it will be used to determine the version we loaded from.\n const root: api.ISnapshotTree = { id: flatTree.id, blobs: {}, trees: {} };\n lookup[\"\"] = root;\n\n for (const entry of flatTree.entries) {\n const lastIndex = entry.path.lastIndexOf(\"/\");\n const entryPathDir = entry.path.slice(0, Math.max(0, lastIndex));\n const entryPathBase = entry.path.slice(lastIndex + 1);\n\n // ODSP snapshots are created breadth-first so we can assume we see tree nodes prior to their contents\n const node = lookup[entryPathDir];\n\n // Add in either the blob or tree\n if (entry.type === \"tree\") {\n const newTree: api.ISnapshotTree = {\n blobs: {},\n trees: {},\n unreferenced: entry.unreferenced,\n };\n node.trees[decodeURIComponent(entryPathBase)] = newTree;\n lookup[entry.path] = newTree;\n } else if (entry.type === \"blob\") {\n node.blobs[decodeURIComponent(entryPathBase)] = entry.id;\n }\n }\n\n return root;\n}\n\n/**\n * Converts existing IOdspSnapshot to snapshot tree, blob array and ops\n * @param odspSnapshot - snapshot\n */\nexport function convertOdspSnapshotToSnapsohtTreeAndBlobs(\n odspSnapshot: IOdspSnapshot,\n): ISnapshotContents {\n const blobsWithBufferContent = new Map<string, ArrayBuffer>();\n if (odspSnapshot.blobs) {\n odspSnapshot.blobs.forEach((blob) => {\n assert(blob.encoding === \"base64\" || blob.encoding === undefined,\n 0x0a4 /* `Unexpected blob encoding type: '${blob.encoding}'` */);\n blobsWithBufferContent.set(blob.id, stringToBuffer(blob.content, blob.encoding ?? \"utf8\"));\n });\n }\n const val: ISnapshotContents = {\n blobs: blobsWithBufferContent,\n ops: odspSnapshot.ops?.map((op) => op.op) ?? [],\n sequenceNumber: odspSnapshot.trees && (odspSnapshot.trees[0]).sequenceNumber,\n snapshotTree: buildHierarchy(odspSnapshot.trees[0]),\n };\n return val;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspSummaryUploadManager.d.ts","sourceRoot":"","sources":["../src/odspSummaryUploadManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EAAE,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAU1F,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAM9C;;;GAGG;AACH,qBAAa,wBAAwB;IAM7B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,C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AAe;YAqBhE,oBAAoB;IAgElC;;;;;;;;OAQG;YACW,4BAA4B;CAoG7C"}
|
|
@@ -42,14 +42,17 @@ export class OdspSummaryUploadManager {
|
|
|
42
42
|
return id;
|
|
43
43
|
}
|
|
44
44
|
async writeSummaryTreeCore(parentHandle, referenceSequenceNumber, tree) {
|
|
45
|
-
const
|
|
45
|
+
const enableContainerTypeSummaryUpload = this.mc.config.getBoolean("Fluid.Driver.Odsp.EnableContainerTypeSummaryUpload");
|
|
46
|
+
const containsProtocolTree = enableContainerTypeSummaryUpload &&
|
|
47
|
+
Object.keys(tree.tree).includes(".protocol");
|
|
48
|
+
const { snapshotTree, blobs } = await this.convertSummaryToSnapshotTree(parentHandle, tree, ".app");
|
|
46
49
|
const snapshot = {
|
|
47
50
|
entries: snapshotTree.entries,
|
|
48
51
|
message: "app",
|
|
49
52
|
sequenceNumber: referenceSequenceNumber,
|
|
50
53
|
// no ack handle implies this is initial summary after empty file creation.
|
|
51
54
|
// send container payload so server will use it without a summary op
|
|
52
|
-
type: parentHandle === undefined ? "container" : "channel",
|
|
55
|
+
type: containsProtocolTree || parentHandle === undefined ? "container" : "channel",
|
|
53
56
|
};
|
|
54
57
|
return getWithRetryForTokenRefresh(async (options) => {
|
|
55
58
|
const storageToken = await this.getStorageToken(options, "WriteSummaryTree");
|
|
@@ -68,6 +71,8 @@ export class OdspSummaryUploadManager {
|
|
|
68
71
|
blobs,
|
|
69
72
|
size: postBody.length,
|
|
70
73
|
referenceSequenceNumber,
|
|
74
|
+
type: snapshot.type,
|
|
75
|
+
enableContainerTypeSummaryUpload,
|
|
71
76
|
}, async () => {
|
|
72
77
|
const response = await this.epochTracker.fetchAndParseAsJSON(url, {
|
|
73
78
|
body: postBody,
|
|
@@ -87,9 +92,8 @@ export class OdspSummaryUploadManager {
|
|
|
87
92
|
* @param path - Current path of node which is getting evaluated.
|
|
88
93
|
* @param markUnreferencedNodes - True if we should mark unreferenced nodes.
|
|
89
94
|
*/
|
|
90
|
-
async convertSummaryToSnapshotTree(parentHandle, tree, rootNodeName,
|
|
95
|
+
async convertSummaryToSnapshotTree(parentHandle, tree, rootNodeName, markUnreferencedNodes) {
|
|
91
96
|
var _a;
|
|
92
|
-
if (path === void 0) { path = ""; }
|
|
93
97
|
if (markUnreferencedNodes === void 0) { markUnreferencedNodes = (_a = this.mc.config.getBoolean("Fluid.Driver.Odsp.MarkUnreferencedNodes")) !== null && _a !== void 0 ? _a : true; }
|
|
94
98
|
const snapshotTree = {
|
|
95
99
|
type: "tree",
|
|
@@ -105,10 +109,9 @@ export class OdspSummaryUploadManager {
|
|
|
105
109
|
// property is not present, the tree entry is considered referenced. If the property is present and is
|
|
106
110
|
// true (which is the only value it can have), the tree entry is considered unreferenced.
|
|
107
111
|
let unreferenced;
|
|
108
|
-
const currentPath = path === "" ? `${rootNodeName}/${key}` : `${path}/${key}`;
|
|
109
112
|
switch (summaryObject.type) {
|
|
110
113
|
case api.SummaryType.Tree: {
|
|
111
|
-
const result = await this.convertSummaryToSnapshotTree(parentHandle, summaryObject, rootNodeName
|
|
114
|
+
const result = await this.convertSummaryToSnapshotTree(parentHandle, summaryObject, rootNodeName);
|
|
112
115
|
value = result.snapshotTree;
|
|
113
116
|
unreferenced = markUnreferencedNodes ? summaryObject.unreferenced : undefined;
|
|
114
117
|
blobs += result.blobs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspSummaryUploadManager.js","sourceRoot":"","sources":["../src/odspSummaryUploadManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE3F,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAE5D,OAAO,EAAE,yBAAyB,EAAqB,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAUjH,OAAO,EAAE,wBAAwB,EAAE,MA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E,CAAC;qBACjC;oBACD,MAAM,OAAO,GAAG,GAAG,YAAY,GAAG,UAAU,EAAE,CAAC;oBAC/C,EAAE,GAAG,GAAG,YAAY,IAAI,OAAO,EAAE,CAAC;oBAClC,MAAM;iBACT;gBACD,KAAK,GAAG,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;oBAC7B,EAAE,GAAG,aAAa,CAAC,EAAE,CAAC;oBACtB,MAAM;iBACT;gBACD,OAAO,CAAC,CAAC;oBACL,eAAe,CAAC,aAAa,EAAE,iBAAkB,aAAqB,CAAC,IAAI,EAAE,CAAC,CAAC;iBAClF;aACJ;YAED,MAAM,SAAS,GAA8B;gBACzC,IAAI,EAAE,kBAAkB,CAAC,GAAG,CAAC;gBAC7B,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC;aAClC,CAAC;YAEF,IAAI,KAA2B,CAAC;YAEhC,IAAI,KAAK,EAAE;gBACP,MAAM,CAAC,EAAE,KAAK,SAAS,EAAE,KAAK,CAAC,iEAAiE,CAAC,CAAC;gBAClG,KAAK,iCACD,KAAK,IACF,SAAS,KACZ,YAAY,GACf,CAAC;aACL;iBAAM,IAAI,EAAE,EAAE;gBACX,KAAK,mCACE,SAAS,KACZ,EAAE,GACL,CAAC;aACL;iBAAM;gBACH,MAAM,IAAI,KAAK,CAAC,0BAA0B,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;aACnE;YAED,YAAY,CAAC,OAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACrC;QAED,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;IACnC,CAAC;CACJ;AAED,2BAA2B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, Uint8ArrayToString, unreachableCase } from \"@fluidframework/common-utils\";\nimport { ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { getGitType } from \"@fluidframework/protocol-base\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport { loggerToMonitoringContext, MonitoringContext, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n IOdspSummaryPayload,\n IWriteSummaryResponse,\n IOdspSummaryTree,\n IOdspSummaryTreeBaseEntry,\n OdspSummaryTreeEntry,\n OdspSummaryTreeValue,\n} from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport { getWithRetryForTokenRefresh } from \"./odspUtils\";\n\n/* eslint-disable max-len */\n\n/**\n * This class manages a summary upload. When it receives a call to upload summary, it converts the summary tree into\n * a snapshot tree and then uploads that to the server.\n */\nexport class OdspSummaryUploadManager {\n // Last proposed handle of the uploaded app summary.\n private lastSummaryProposalHandle: string | undefined;\n private readonly mc: MonitoringContext;\n\n constructor(\n private readonly snapshotUrl: string,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n logger: ITelemetryLogger,\n private readonly epochTracker: EpochTracker,\n private readonly forceAccessTokenViaAuthorizationHeader: boolean,\n ) {\n this.mc = loggerToMonitoringContext(logger);\n }\n\n public async writeSummaryTree(tree: api.ISummaryTree, context: ISummaryContext) {\n // If the last proposed handle is not the proposed handle of the acked summary(could happen when the last summary get nacked),\n // then re-initialize the caches with the previous ones else just update the previous caches with the caches from acked summary.\n // Don't bother logging if lastSummaryProposalHandle hasn't been set before; only log on a positive mismatch.\n if (this.lastSummaryProposalHandle !== undefined &&\n this.lastSummaryProposalHandle !== context.proposalHandle) {\n this.mc.logger.sendTelemetryEvent({\n eventName: \"LastSummaryProposedHandleMismatch\",\n ackedSummaryProposedHandle: context.proposalHandle,\n lastSummaryProposalHandle: this.lastSummaryProposalHandle,\n });\n }\n const result = await this.writeSummaryTreeCore(context.ackHandle, context.referenceSequenceNumber, tree);\n const id = result ? result.id : undefined;\n if (!result || !id) {\n throw new Error(`Failed to write summary tree`);\n }\n this.lastSummaryProposalHandle = id;\n return id;\n }\n\n private async writeSummaryTreeCore(\n parentHandle: string | undefined,\n referenceSequenceNumber: number,\n tree: api.ISummaryTree,\n ): Promise<IWriteSummaryResponse> {\n const { snapshotTree, blobs } = await this.convertSummaryToSnapshotTree(\n parentHandle,\n tree,\n \".app\",\n \"\",\n );\n const snapshot: IOdspSummaryPayload = {\n entries: snapshotTree.entries!,\n message: \"app\",\n sequenceNumber: referenceSequenceNumber,\n // no ack handle implies this is initial summary after empty file creation.\n // send container payload so server will use it without a summary op\n type: parentHandle === undefined ? \"container\" : \"channel\",\n };\n\n return getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"WriteSummaryTree\");\n\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${this.snapshotUrl}/snapshot`,\n storageToken,\n this.forceAccessTokenViaAuthorizationHeader,\n );\n headers[\"Content-Type\"] = \"application/json\";\n if (parentHandle) {\n headers[\"If-Match\"] = `fluid:containerid=${parentHandle}`;\n }\n\n const postBody = JSON.stringify(snapshot);\n\n return PerformanceEvent.timedExecAsync(this.mc.logger,\n {\n eventName: \"uploadSummary\",\n attempt: options.refresh ? 2 : 1,\n hasClaims: !!options.claims,\n hasTenantId: !!options.tenantId,\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n blobs,\n size: postBody.length,\n referenceSequenceNumber,\n },\n async () => {\n const response = await this.epochTracker.fetchAndParseAsJSON<IWriteSummaryResponse>(\n url,\n {\n body: postBody,\n headers,\n method: \"POST\",\n },\n \"uploadSummary\");\n return response.content;\n });\n });\n }\n\n /**\n * Following are the goals of this function.\n * a.) Converts the summary tree to a snapshot/odsp tree to be uploaded. Always upload full snapshot tree.\n * @param parentHandle - Handle of the last uploaded summary or detach new summary.\n * @param tree - Summary Tree which will be converted to snapshot tree to be uploaded.\n * @param rootNodeName - Root node name of the summary tree.\n * @param path - Current path of node which is getting evaluated.\n * @param markUnreferencedNodes - True if we should mark unreferenced nodes.\n */\n private async convertSummaryToSnapshotTree(\n parentHandle: string | undefined,\n tree: api.ISummaryTree,\n rootNodeName: string,\n path: string = \"\",\n markUnreferencedNodes: boolean = this.mc.config.getBoolean(\"Fluid.Driver.Odsp.MarkUnreferencedNodes\") ?? true,\n ) {\n const snapshotTree: IOdspSummaryTree = {\n type: \"tree\",\n entries: [] as OdspSummaryTreeEntry[],\n };\n\n let blobs = 0;\n const keys = Object.keys(tree.tree);\n for (const key of keys) {\n const summaryObject = tree.tree[key];\n\n let id: string | undefined;\n let value: OdspSummaryTreeValue | undefined;\n\n // Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the\n // property is not present, the tree entry is considered referenced. If the property is present and is\n // true (which is the only value it can have), the tree entry is considered unreferenced.\n let unreferenced: true | undefined;\n const currentPath = path === \"\" ? `${rootNodeName}/${key}` : `${path}/${key}`;\n switch (summaryObject.type) {\n case api.SummaryType.Tree: {\n const result = await this.convertSummaryToSnapshotTree(\n parentHandle,\n summaryObject,\n rootNodeName,\n currentPath);\n value = result.snapshotTree;\n unreferenced = markUnreferencedNodes ? summaryObject.unreferenced : undefined;\n blobs += result.blobs;\n break;\n }\n case api.SummaryType.Blob: {\n if (typeof summaryObject.content === \"string\") {\n value = {\n type: \"blob\",\n content: summaryObject.content,\n encoding: \"utf-8\",\n };\n } else {\n value = {\n type: \"blob\",\n content: Uint8ArrayToString(summaryObject.content, \"base64\"),\n encoding: \"base64\",\n };\n }\n blobs++;\n break;\n }\n case api.SummaryType.Handle: {\n if (!parentHandle) {\n throw Error(\"Parent summary does not exist to reference by handle.\");\n }\n let handlePath = summaryObject.handle;\n if (handlePath.length > 0 && !handlePath.startsWith(\"/\")) {\n handlePath = `/${handlePath}`;\n }\n const pathKey = `${rootNodeName}${handlePath}`;\n id = `${parentHandle}/${pathKey}`;\n break;\n }\n case api.SummaryType.Attachment: {\n id = summaryObject.id;\n break;\n }\n default: {\n unreachableCase(summaryObject, `Unknown type: ${(summaryObject as any).type}`);\n }\n }\n\n const baseEntry: IOdspSummaryTreeBaseEntry = {\n path: encodeURIComponent(key),\n type: getGitType(summaryObject),\n };\n\n let entry: OdspSummaryTreeEntry;\n\n if (value) {\n assert(id === undefined, 0x0ad /* \"Snapshot entry has both a tree value and a referenced id!\" */);\n entry = {\n value,\n ...baseEntry,\n unreferenced,\n };\n } else if (id) {\n entry = {\n ...baseEntry,\n id,\n };\n } else {\n throw new Error(`Invalid tree entry for ${summaryObject.type}`);\n }\n\n snapshotTree.entries!.push(entry);\n }\n\n return { snapshotTree, blobs };\n }\n}\n\n/* eslint-enable max-len */\n"]}
|
|
1
|
+
{"version":3,"file":"odspSummaryUploadManager.js","sourceRoot":"","sources":["../src/odspSummaryUploadManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE3F,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAE5D,OAAO,EAAE,yBAAyB,EAAqB,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAUjH,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAE1D,4BAA4B;AAE5B;;;GAGG;AACH,MAAM,OAAO,wBAAwB;IAKjC,YACqB,WAAmB,EACnB,eAAgD,EACjE,MAAwB,EACP,YAA0B,EAC1B,sCAA+C;QAJ/C,gBAAW,GAAX,WAAW,CAAQ;QACnB,oBAAe,GAAf,eAAe,CAAiC;QAEhD,iBAAY,GAAZ,YAAY,CAAc;QAC1B,2CAAsC,GAAtC,sCAAsC,CAAS;QAEhE,IAAI,CAAC,EAAE,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,IAAs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AC;iBAClF;aACJ;YAED,MAAM,SAAS,GAA8B;gBACzC,IAAI,EAAE,kBAAkB,CAAC,GAAG,CAAC;gBAC7B,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC;aAClC,CAAC;YAEF,IAAI,KAA2B,CAAC;YAEhC,IAAI,KAAK,EAAE;gBACP,MAAM,CAAC,EAAE,KAAK,SAAS,EAAE,KAAK,CAAC,iEAAiE,CAAC,CAAC;gBAClG,KAAK,iCACD,KAAK,IACF,SAAS,KACZ,YAAY,GACf,CAAC;aACL;iBAAM,IAAI,EAAE,EAAE;gBACX,KAAK,mCACE,SAAS,KACZ,EAAE,GACL,CAAC;aACL;iBAAM;gBACH,MAAM,IAAI,KAAK,CAAC,0BAA0B,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;aACnE;YAED,YAAY,CAAC,OAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACrC;QAED,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;IACnC,CAAC;CACJ;AAED,2BAA2B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, Uint8ArrayToString, unreachableCase } from \"@fluidframework/common-utils\";\nimport { ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { getGitType } from \"@fluidframework/protocol-base\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport { loggerToMonitoringContext, MonitoringContext, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n IOdspSummaryPayload,\n IWriteSummaryResponse,\n IOdspSummaryTree,\n IOdspSummaryTreeBaseEntry,\n OdspSummaryTreeEntry,\n OdspSummaryTreeValue,\n} from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport { getWithRetryForTokenRefresh } from \"./odspUtils\";\n\n/* eslint-disable max-len */\n\n/**\n * This class manages a summary upload. When it receives a call to upload summary, it converts the summary tree into\n * a snapshot tree and then uploads that to the server.\n */\nexport class OdspSummaryUploadManager {\n // Last proposed handle of the uploaded app summary.\n private lastSummaryProposalHandle: string | undefined;\n private readonly mc: MonitoringContext;\n\n constructor(\n private readonly snapshotUrl: string,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n logger: ITelemetryLogger,\n private readonly epochTracker: EpochTracker,\n private readonly forceAccessTokenViaAuthorizationHeader: boolean,\n ) {\n this.mc = loggerToMonitoringContext(logger);\n }\n\n public async writeSummaryTree(tree: api.ISummaryTree, context: ISummaryContext) {\n // If the last proposed handle is not the proposed handle of the acked summary(could happen when the last summary get nacked),\n // then re-initialize the caches with the previous ones else just update the previous caches with the caches from acked summary.\n // Don't bother logging if lastSummaryProposalHandle hasn't been set before; only log on a positive mismatch.\n if (this.lastSummaryProposalHandle !== undefined &&\n this.lastSummaryProposalHandle !== context.proposalHandle) {\n this.mc.logger.sendTelemetryEvent({\n eventName: \"LastSummaryProposedHandleMismatch\",\n ackedSummaryProposedHandle: context.proposalHandle,\n lastSummaryProposalHandle: this.lastSummaryProposalHandle,\n });\n }\n const result = await this.writeSummaryTreeCore(context.ackHandle, context.referenceSequenceNumber, tree);\n const id = result ? result.id : undefined;\n if (!result || !id) {\n throw new Error(`Failed to write summary tree`);\n }\n this.lastSummaryProposalHandle = id;\n return id;\n }\n\n private async writeSummaryTreeCore(\n parentHandle: string | undefined,\n referenceSequenceNumber: number,\n tree: api.ISummaryTree,\n ): Promise<IWriteSummaryResponse> {\n const enableContainerTypeSummaryUpload = this.mc.config.getBoolean(\"Fluid.Driver.Odsp.EnableContainerTypeSummaryUpload\");\n const containsProtocolTree = enableContainerTypeSummaryUpload &&\n Object.keys(tree.tree).includes(\".protocol\");\n const { snapshotTree, blobs } = await this.convertSummaryToSnapshotTree(\n parentHandle,\n tree,\n \".app\",\n );\n const snapshot: IOdspSummaryPayload = {\n entries: snapshotTree.entries!,\n message: \"app\",\n sequenceNumber: referenceSequenceNumber,\n // no ack handle implies this is initial summary after empty file creation.\n // send container payload so server will use it without a summary op\n type: containsProtocolTree || parentHandle === undefined ? \"container\" : \"channel\",\n };\n\n return getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"WriteSummaryTree\");\n\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${this.snapshotUrl}/snapshot`,\n storageToken,\n this.forceAccessTokenViaAuthorizationHeader,\n );\n headers[\"Content-Type\"] = \"application/json\";\n if (parentHandle) {\n headers[\"If-Match\"] = `fluid:containerid=${parentHandle}`;\n }\n\n const postBody = JSON.stringify(snapshot);\n\n return PerformanceEvent.timedExecAsync(this.mc.logger,\n {\n eventName: \"uploadSummary\",\n attempt: options.refresh ? 2 : 1,\n hasClaims: !!options.claims,\n hasTenantId: !!options.tenantId,\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n blobs,\n size: postBody.length,\n referenceSequenceNumber,\n type: snapshot.type,\n enableContainerTypeSummaryUpload,\n },\n async () => {\n const response = await this.epochTracker.fetchAndParseAsJSON<IWriteSummaryResponse>(\n url,\n {\n body: postBody,\n headers,\n method: \"POST\",\n },\n \"uploadSummary\");\n return response.content;\n });\n });\n }\n\n /**\n * Following are the goals of this function.\n * a.) Converts the summary tree to a snapshot/odsp tree to be uploaded. Always upload full snapshot tree.\n * @param parentHandle - Handle of the last uploaded summary or detach new summary.\n * @param tree - Summary Tree which will be converted to snapshot tree to be uploaded.\n * @param rootNodeName - Root node name of the summary tree.\n * @param path - Current path of node which is getting evaluated.\n * @param markUnreferencedNodes - True if we should mark unreferenced nodes.\n */\n private async convertSummaryToSnapshotTree(\n parentHandle: string | undefined,\n tree: api.ISummaryTree,\n rootNodeName: string,\n markUnreferencedNodes: boolean = this.mc.config.getBoolean(\"Fluid.Driver.Odsp.MarkUnreferencedNodes\") ?? true,\n ) {\n const snapshotTree: IOdspSummaryTree = {\n type: \"tree\",\n entries: [] as OdspSummaryTreeEntry[],\n };\n\n let blobs = 0;\n const keys = Object.keys(tree.tree);\n for (const key of keys) {\n const summaryObject = tree.tree[key];\n\n let id: string | undefined;\n let value: OdspSummaryTreeValue | undefined;\n\n // Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the\n // property is not present, the tree entry is considered referenced. If the property is present and is\n // true (which is the only value it can have), the tree entry is considered unreferenced.\n let unreferenced: true | undefined;\n switch (summaryObject.type) {\n case api.SummaryType.Tree: {\n const result = await this.convertSummaryToSnapshotTree(\n parentHandle,\n summaryObject,\n rootNodeName);\n value = result.snapshotTree;\n unreferenced = markUnreferencedNodes ? summaryObject.unreferenced : undefined;\n blobs += result.blobs;\n break;\n }\n case api.SummaryType.Blob: {\n if (typeof summaryObject.content === \"string\") {\n value = {\n type: \"blob\",\n content: summaryObject.content,\n encoding: \"utf-8\",\n };\n } else {\n value = {\n type: \"blob\",\n content: Uint8ArrayToString(summaryObject.content, \"base64\"),\n encoding: \"base64\",\n };\n }\n blobs++;\n break;\n }\n case api.SummaryType.Handle: {\n if (!parentHandle) {\n throw Error(\"Parent summary does not exist to reference by handle.\");\n }\n let handlePath = summaryObject.handle;\n if (handlePath.length > 0 && !handlePath.startsWith(\"/\")) {\n handlePath = `/${handlePath}`;\n }\n const pathKey = `${rootNodeName}${handlePath}`;\n id = `${parentHandle}/${pathKey}`;\n break;\n }\n case api.SummaryType.Attachment: {\n id = summaryObject.id;\n break;\n }\n default: {\n unreachableCase(summaryObject, `Unknown type: ${(summaryObject as any).type}`);\n }\n }\n\n const baseEntry: IOdspSummaryTreeBaseEntry = {\n path: encodeURIComponent(key),\n type: getGitType(summaryObject),\n };\n\n let entry: OdspSummaryTreeEntry;\n\n if (value) {\n assert(id === undefined, 0x0ad /* \"Snapshot entry has both a tree value and a referenced id!\" */);\n entry = {\n value,\n ...baseEntry,\n unreferenced,\n };\n } else if (id) {\n entry = {\n ...baseEntry,\n id,\n };\n } else {\n throw new Error(`Invalid tree entry for ${summaryObject.type}`);\n }\n\n snapshotTree.entries!.push(entry);\n }\n\n return { snapshotTree, blobs };\n }\n}\n\n/* eslint-enable max-len */\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/odsp-driver";
|
|
8
|
-
export declare const pkgVersion = "0.
|
|
8
|
+
export declare const pkgVersion = "0.59.1000";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,6BAA6B,CAAC;AACrD,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/odsp-driver\";\nexport const pkgVersion = \"0.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,6BAA6B,CAAC;AACrD,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/odsp-driver\";\nexport const pkgVersion = \"0.59.1000\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/odsp-driver",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.59.1000",
|
|
4
4
|
"description": "Socket storage implementation for SPO and ODC",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"lint:fix": "npm run eslint:fix",
|
|
33
33
|
"test": "npm run test:mocha",
|
|
34
34
|
"test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
|
|
35
|
-
"test:mocha": "mocha --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
|
|
35
|
+
"test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
|
|
36
36
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
37
37
|
"tsc": "tsc",
|
|
38
38
|
"tsfmt": "tsfmt --verify",
|
|
@@ -61,16 +61,16 @@
|
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
63
63
|
"@fluidframework/common-utils": "^0.32.1",
|
|
64
|
-
"@fluidframework/core-interfaces": "^0.
|
|
65
|
-
"@fluidframework/driver-base": "^0.
|
|
66
|
-
"@fluidframework/driver-definitions": "^0.
|
|
67
|
-
"@fluidframework/driver-utils": "^0.
|
|
68
|
-
"@fluidframework/gitresources": "^0.
|
|
69
|
-
"@fluidframework/odsp-doclib-utils": "^0.
|
|
70
|
-
"@fluidframework/odsp-driver-definitions": "^0.
|
|
71
|
-
"@fluidframework/protocol-base": "^0.
|
|
72
|
-
"@fluidframework/protocol-definitions": "^0.
|
|
73
|
-
"@fluidframework/telemetry-utils": "^0.
|
|
64
|
+
"@fluidframework/core-interfaces": "^0.43.1000",
|
|
65
|
+
"@fluidframework/driver-base": "^0.59.1000",
|
|
66
|
+
"@fluidframework/driver-definitions": "^0.46.1000",
|
|
67
|
+
"@fluidframework/driver-utils": "^0.59.1000",
|
|
68
|
+
"@fluidframework/gitresources": "^0.1036.1000",
|
|
69
|
+
"@fluidframework/odsp-doclib-utils": "^0.59.1000",
|
|
70
|
+
"@fluidframework/odsp-driver-definitions": "^0.59.1000",
|
|
71
|
+
"@fluidframework/protocol-base": "^0.1036.1000",
|
|
72
|
+
"@fluidframework/protocol-definitions": "^0.1028.1000",
|
|
73
|
+
"@fluidframework/telemetry-utils": "^0.59.1000",
|
|
74
74
|
"abort-controller": "^3.0.0",
|
|
75
75
|
"node-fetch": "^2.6.1",
|
|
76
76
|
"socket.io-client": "^4.4.1",
|
|
@@ -78,8 +78,9 @@
|
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@fluidframework/build-common": "^0.23.0",
|
|
81
|
-
"@fluidframework/eslint-config-fluid": "^0.
|
|
82
|
-
"@fluidframework/mocha-test-setup": "^0.
|
|
81
|
+
"@fluidframework/eslint-config-fluid": "^0.28.1000",
|
|
82
|
+
"@fluidframework/mocha-test-setup": "^0.59.1000",
|
|
83
|
+
"@fluidframework/odsp-driver-previous": "npm:@fluidframework/odsp-driver@^0.58.0",
|
|
83
84
|
"@microsoft/api-extractor": "^7.16.1",
|
|
84
85
|
"@rushstack/eslint-config": "^2.5.1",
|
|
85
86
|
"@types/mocha": "^8.2.2",
|
|
@@ -103,5 +104,9 @@
|
|
|
103
104
|
"sinon": "^7.4.2",
|
|
104
105
|
"typescript": "~4.1.3",
|
|
105
106
|
"typescript-formatter": "7.1.0"
|
|
107
|
+
},
|
|
108
|
+
"typeValidation": {
|
|
109
|
+
"version": "0.59.1000",
|
|
110
|
+
"broken": {}
|
|
106
111
|
}
|
|
107
112
|
}
|
|
@@ -14,10 +14,12 @@ import {
|
|
|
14
14
|
assertNumberInstance,
|
|
15
15
|
getAndValidateNodeProps,
|
|
16
16
|
NodeCore,
|
|
17
|
+
NodeTypes,
|
|
17
18
|
TreeBuilder,
|
|
18
19
|
} from "./zipItDataRepresentationUtils";
|
|
19
20
|
|
|
20
21
|
export const snapshotMinReadVersion = "1.0";
|
|
22
|
+
export const currentReadVersion = "1.0";
|
|
21
23
|
|
|
22
24
|
interface ISnapshotSection {
|
|
23
25
|
snapshotTree: ISnapshotTree,
|
|
@@ -28,7 +30,8 @@ interface ISnapshotSection {
|
|
|
28
30
|
* Recreates blobs section of the tree.
|
|
29
31
|
* @param node - tree node to read blob section from
|
|
30
32
|
*/
|
|
31
|
-
function readBlobSection(node:
|
|
33
|
+
function readBlobSection(node: NodeTypes) {
|
|
34
|
+
assertNodeCoreInstance(node, "TreeBlobs should be of type NodeCore");
|
|
32
35
|
const blobs: Map<string, ArrayBuffer> = new Map();
|
|
33
36
|
for (let count = 0; count < node.length; ++count) {
|
|
34
37
|
const blob = node.getNode(count);
|
|
@@ -44,7 +47,8 @@ function readBlobSection(node: NodeCore) {
|
|
|
44
47
|
* Recreates ops section of the tree.
|
|
45
48
|
* @param node - tree node to read ops section from
|
|
46
49
|
*/
|
|
47
|
-
function readOpsSection(node:
|
|
50
|
+
function readOpsSection(node: NodeTypes) {
|
|
51
|
+
assertNodeCoreInstance(node, "Deltas should be of type NodeCore");
|
|
48
52
|
const ops: ISequencedDocumentMessage[] = [];
|
|
49
53
|
const records = getAndValidateNodeProps(node, ["firstSequenceNumber", "deltas"]);
|
|
50
54
|
assertNumberInstance(records.firstSequenceNumber, "Seq number should be a number");
|
|
@@ -52,7 +56,8 @@ function readOpsSection(node: NodeCore) {
|
|
|
52
56
|
for (let i = 0; i < records.deltas.length; ++i) {
|
|
53
57
|
ops.push(JSON.parse(records.deltas.getString(i)));
|
|
54
58
|
}
|
|
55
|
-
assert(records.firstSequenceNumber.valueOf() === ops[0].sequenceNumber,
|
|
59
|
+
assert(records.firstSequenceNumber.valueOf() === ops[0].sequenceNumber,
|
|
60
|
+
0x280 /* "Validate first op seq number" */);
|
|
56
61
|
return ops;
|
|
57
62
|
}
|
|
58
63
|
|
|
@@ -63,7 +68,6 @@ function readOpsSection(node: NodeCore) {
|
|
|
63
68
|
function readTreeSection(node: NodeCore) {
|
|
64
69
|
const snapshotTree: ISnapshotTree = {
|
|
65
70
|
blobs: {},
|
|
66
|
-
commits: {},
|
|
67
71
|
trees: {},
|
|
68
72
|
};
|
|
69
73
|
for (let count = 0; count < node.length; count++) {
|
|
@@ -93,7 +97,8 @@ function readTreeSection(node: NodeCore) {
|
|
|
93
97
|
* Recreates snapshot tree out of tree representation.
|
|
94
98
|
* @param node - tree node to de-serialize from
|
|
95
99
|
*/
|
|
96
|
-
function readSnapshotSection(node:
|
|
100
|
+
function readSnapshotSection(node: NodeTypes): ISnapshotSection {
|
|
101
|
+
assertNodeCoreInstance(node, "Snapshot should be of type NodeCore");
|
|
97
102
|
const records = getAndValidateNodeProps(node,
|
|
98
103
|
["id", "sequenceNumber", "treeNodes"]);
|
|
99
104
|
|
|
@@ -120,7 +125,7 @@ export function parseCompactSnapshotResponse(buffer: ReadBuffer): ISnapshotConte
|
|
|
120
125
|
const root = builder.getNode(0);
|
|
121
126
|
|
|
122
127
|
const records = getAndValidateNodeProps(root,
|
|
123
|
-
["mrv", "cv", "snapshot", "blobs", "deltas"]);
|
|
128
|
+
["mrv", "cv", "snapshot", "blobs", "deltas"], false);
|
|
124
129
|
|
|
125
130
|
assertBlobCoreInstance(records.mrv, "minReadVersion should be of BlobCore type");
|
|
126
131
|
assertBlobCoreInstance(records.cv, "createVersion should be of BlobCore type");
|
|
@@ -128,14 +133,11 @@ export function parseCompactSnapshotResponse(buffer: ReadBuffer): ISnapshotConte
|
|
|
128
133
|
0x20f /* "Driver min read version should >= to server minReadVersion" */);
|
|
129
134
|
assert(records.cv.toString() >= snapshotMinReadVersion,
|
|
130
135
|
0x210 /* "Snapshot should be created with minReadVersion or above" */);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
assertNodeCoreInstance(records.blobs, "TreeBlobs should be of type NodeCore");
|
|
134
|
-
assertNodeCoreInstance(records.deltas, "Deltas should be of type NodeCore");
|
|
135
|
-
|
|
136
|
+
assert(currentReadVersion === records.cv.toString(),
|
|
137
|
+
0x2c2 /* "Create Version should be equal to currentReadVersion" */);
|
|
136
138
|
return {
|
|
137
139
|
...readSnapshotSection(records.snapshot),
|
|
138
140
|
blobs: readBlobSection(records.blobs),
|
|
139
|
-
ops: readOpsSection(records.deltas),
|
|
141
|
+
ops: records.deltas !== undefined ? readOpsSection(records.deltas) : [],
|
|
140
142
|
};
|
|
141
143
|
}
|