@fluidframework/odsp-driver 1.1.0 → 1.2.0

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.
Files changed (127) hide show
  1. package/dist/checkUrl.d.ts +1 -1
  2. package/dist/checkUrl.js +1 -1
  3. package/dist/checkUrl.js.map +1 -1
  4. package/dist/constants.d.ts +1 -1
  5. package/dist/constants.d.ts.map +1 -1
  6. package/dist/constants.js +1 -1
  7. package/dist/constants.js.map +1 -1
  8. package/dist/contractsPublic.d.ts +1 -0
  9. package/dist/contractsPublic.d.ts.map +1 -1
  10. package/dist/contractsPublic.js.map +1 -1
  11. package/dist/getFileLink.js +0 -4
  12. package/dist/getFileLink.js.map +1 -1
  13. package/dist/localOdspDriver/localOdspDocumentService.d.ts +26 -0
  14. package/dist/localOdspDriver/localOdspDocumentService.d.ts.map +1 -0
  15. package/dist/localOdspDriver/localOdspDocumentService.js +39 -0
  16. package/dist/localOdspDriver/localOdspDocumentService.js.map +1 -0
  17. package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts +24 -0
  18. package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -0
  19. package/dist/localOdspDriver/localOdspDocumentServiceFactory.js +45 -0
  20. package/dist/localOdspDriver/localOdspDocumentServiceFactory.js.map +1 -0
  21. package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts +27 -0
  22. package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -0
  23. package/dist/localOdspDriver/localOdspDocumentStorageManager.js +66 -0
  24. package/dist/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -0
  25. package/dist/odspDeltaStorageService.js.map +1 -1
  26. package/dist/odspDocumentService.d.ts.map +1 -1
  27. package/dist/odspDocumentService.js.map +1 -1
  28. package/dist/odspDocumentServiceFactory.d.ts +2 -1
  29. package/dist/odspDocumentServiceFactory.d.ts.map +1 -1
  30. package/dist/odspDocumentServiceFactory.js +7 -1
  31. package/dist/odspDocumentServiceFactory.js.map +1 -1
  32. package/dist/odspDocumentServiceFactoryCore.d.ts +3 -1
  33. package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  34. package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
  35. package/dist/odspDocumentStorageManager.d.ts +5 -23
  36. package/dist/odspDocumentStorageManager.d.ts.map +1 -1
  37. package/dist/odspDocumentStorageManager.js +52 -245
  38. package/dist/odspDocumentStorageManager.js.map +1 -1
  39. package/dist/odspDocumentStorageServiceBase.d.ts +58 -0
  40. package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -0
  41. package/dist/odspDocumentStorageServiceBase.js +216 -0
  42. package/dist/odspDocumentStorageServiceBase.js.map +1 -0
  43. package/dist/odspDriverUrlResolver.js +1 -1
  44. package/dist/odspDriverUrlResolver.js.map +1 -1
  45. package/dist/odspDriverUrlResolverForShareLink.d.ts +8 -2
  46. package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
  47. package/dist/odspDriverUrlResolverForShareLink.js +11 -3
  48. package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
  49. package/dist/odspFluidFileLink.d.ts.map +1 -1
  50. package/dist/odspFluidFileLink.js +27 -21
  51. package/dist/odspFluidFileLink.js.map +1 -1
  52. package/dist/packageVersion.d.ts +1 -1
  53. package/dist/packageVersion.js +1 -1
  54. package/dist/packageVersion.js.map +1 -1
  55. package/lib/checkUrl.d.ts +1 -1
  56. package/lib/checkUrl.js +1 -1
  57. package/lib/checkUrl.js.map +1 -1
  58. package/lib/constants.d.ts +1 -1
  59. package/lib/constants.d.ts.map +1 -1
  60. package/lib/constants.js +1 -1
  61. package/lib/constants.js.map +1 -1
  62. package/lib/contractsPublic.d.ts +1 -0
  63. package/lib/contractsPublic.d.ts.map +1 -1
  64. package/lib/contractsPublic.js.map +1 -1
  65. package/lib/getFileLink.js +0 -4
  66. package/lib/getFileLink.js.map +1 -1
  67. package/lib/localOdspDriver/localOdspDocumentService.d.ts +26 -0
  68. package/lib/localOdspDriver/localOdspDocumentService.d.ts.map +1 -0
  69. package/lib/localOdspDriver/localOdspDocumentService.js +35 -0
  70. package/lib/localOdspDriver/localOdspDocumentService.js.map +1 -0
  71. package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.ts +24 -0
  72. package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -0
  73. package/lib/localOdspDriver/localOdspDocumentServiceFactory.js +41 -0
  74. package/lib/localOdspDriver/localOdspDocumentServiceFactory.js.map +1 -0
  75. package/lib/localOdspDriver/localOdspDocumentStorageManager.d.ts +27 -0
  76. package/lib/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -0
  77. package/lib/localOdspDriver/localOdspDocumentStorageManager.js +62 -0
  78. package/lib/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -0
  79. package/lib/odspDeltaStorageService.js.map +1 -1
  80. package/lib/odspDocumentService.d.ts.map +1 -1
  81. package/lib/odspDocumentService.js +1 -1
  82. package/lib/odspDocumentService.js.map +1 -1
  83. package/lib/odspDocumentServiceFactory.d.ts +2 -1
  84. package/lib/odspDocumentServiceFactory.d.ts.map +1 -1
  85. package/lib/odspDocumentServiceFactory.js +5 -0
  86. package/lib/odspDocumentServiceFactory.js.map +1 -1
  87. package/lib/odspDocumentServiceFactoryCore.d.ts +3 -1
  88. package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  89. package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
  90. package/lib/odspDocumentStorageManager.d.ts +5 -23
  91. package/lib/odspDocumentStorageManager.d.ts.map +1 -1
  92. package/lib/odspDocumentStorageManager.js +53 -246
  93. package/lib/odspDocumentStorageManager.js.map +1 -1
  94. package/lib/odspDocumentStorageServiceBase.d.ts +58 -0
  95. package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -0
  96. package/lib/odspDocumentStorageServiceBase.js +212 -0
  97. package/lib/odspDocumentStorageServiceBase.js.map +1 -0
  98. package/lib/odspDriverUrlResolver.js +1 -1
  99. package/lib/odspDriverUrlResolver.js.map +1 -1
  100. package/lib/odspDriverUrlResolverForShareLink.d.ts +8 -2
  101. package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
  102. package/lib/odspDriverUrlResolverForShareLink.js +11 -3
  103. package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
  104. package/lib/odspFluidFileLink.d.ts.map +1 -1
  105. package/lib/odspFluidFileLink.js +27 -21
  106. package/lib/odspFluidFileLink.js.map +1 -1
  107. package/lib/packageVersion.d.ts +1 -1
  108. package/lib/packageVersion.js +1 -1
  109. package/lib/packageVersion.js.map +1 -1
  110. package/package.json +17 -12
  111. package/src/checkUrl.ts +1 -1
  112. package/src/constants.ts +1 -1
  113. package/src/contractsPublic.ts +1 -0
  114. package/src/getFileLink.ts +0 -5
  115. package/src/localOdspDriver/localOdspDocumentService.ts +54 -0
  116. package/src/localOdspDriver/localOdspDocumentServiceFactory.ts +67 -0
  117. package/src/localOdspDriver/localOdspDocumentStorageManager.ts +83 -0
  118. package/src/odspDeltaStorageService.ts +1 -1
  119. package/src/odspDocumentService.ts +5 -1
  120. package/src/odspDocumentServiceFactory.ts +7 -3
  121. package/src/odspDocumentServiceFactoryCore.ts +1 -1
  122. package/src/odspDocumentStorageManager.ts +81 -312
  123. package/src/odspDocumentStorageServiceBase.ts +268 -0
  124. package/src/odspDriverUrlResolver.ts +1 -1
  125. package/src/odspDriverUrlResolverForShareLink.ts +13 -1
  126. package/src/odspFluidFileLink.ts +26 -22
  127. package/src/packageVersion.ts +1 -1
@@ -6,13 +6,14 @@ import { fromBase64ToUtf8, fromUtf8ToBase64 } from "@fluidframework/common-utils
6
6
  import { OdcFileSiteOrigin, OdcApiSiteOrigin } from "./constants";
7
7
  const fluidSignature = "1";
8
8
  const fluidSignatureParamName = "fluid";
9
- const fluidSitePathParamName = "s";
10
- const fluidDriveIdParamName = "d";
11
- const fluidItemIdParamName = "f";
12
- const fluidDataStorePathParamName = "c";
13
- const fluidAppNameParamName = "a";
14
- const fluidContainerPackageNameParamName = "p";
15
- const fluidFileVersionParamName = "v";
9
+ const sitePathParamName = "s";
10
+ const driveIdParamName = "d";
11
+ const itemIdParamName = "f";
12
+ const dataStorePathParamName = "c";
13
+ const appNameParamName = "a";
14
+ const containerPackageNameParamName = "p";
15
+ const fileVersionParamName = "v";
16
+ const additionalContextParamName = "x";
16
17
  /**
17
18
  * Transforms given Fluid data store locator into string that can be embedded into url
18
19
  * @param locator - describes Fluid data store locator info to be encoded
@@ -24,15 +25,18 @@ export function encodeOdspFluidDataStoreLocator(locator) {
24
25
  const driveId = encodeURIComponent(locator.driveId);
25
26
  const itemId = encodeURIComponent(locator.itemId);
26
27
  const dataStorePath = encodeURIComponent(locator.dataStorePath);
27
- let locatorSerialized = `${fluidSitePathParamName}=${sitePath}&${fluidDriveIdParamName}=${driveId}&${fluidItemIdParamName}=${itemId}&${fluidDataStorePathParamName}=${dataStorePath}&${fluidSignatureParamName}=${fluidSignature}`;
28
+ let locatorSerialized = `${sitePathParamName}=${sitePath}&${driveIdParamName}=${driveId}&${itemIdParamName}=${itemId}&${dataStorePathParamName}=${dataStorePath}&${fluidSignatureParamName}=${fluidSignature}`;
28
29
  if (locator.appName) {
29
- locatorSerialized += `&${fluidAppNameParamName}=${encodeURIComponent(locator.appName)}`;
30
+ locatorSerialized += `&${appNameParamName}=${encodeURIComponent(locator.appName)}`;
30
31
  }
31
32
  if (locator.containerPackageName) {
32
- locatorSerialized += `&${fluidContainerPackageNameParamName}=${encodeURIComponent(locator.containerPackageName)}`;
33
+ locatorSerialized += `&${containerPackageNameParamName}=${encodeURIComponent(locator.containerPackageName)}`;
33
34
  }
34
35
  if (locator.fileVersion) {
35
- locatorSerialized += `&${fluidFileVersionParamName}=${encodeURIComponent(locator.fileVersion)}`;
36
+ locatorSerialized += `&${fileVersionParamName}=${encodeURIComponent(locator.fileVersion)}`;
37
+ }
38
+ if (locator.context) {
39
+ locatorSerialized += `&${additionalContextParamName}=${encodeURIComponent(locator.context)}`;
36
40
  }
37
41
  return fromUtf8ToBase64(locatorSerialized);
38
42
  }
@@ -44,21 +48,22 @@ export function encodeOdspFluidDataStoreLocator(locator) {
44
48
  * @returns object representing Fluid data store location in ODSP terms
45
49
  */
46
50
  function decodeOdspFluidDataStoreLocator(encodedLocatorValue, siteOriginUrl) {
47
- var _a, _b, _c;
51
+ var _a, _b, _c, _d;
48
52
  const locatorInfo = new URLSearchParams(fromBase64ToUtf8(encodedLocatorValue));
49
53
  const signatureValue = locatorInfo.get(fluidSignatureParamName);
50
54
  if (signatureValue !== "1") {
51
55
  return undefined;
52
56
  }
53
- const sitePath = locatorInfo.get(fluidSitePathParamName);
54
- const driveId = locatorInfo.get(fluidDriveIdParamName);
55
- const itemId = locatorInfo.get(fluidItemIdParamName);
56
- const dataStorePath = locatorInfo.get(fluidDataStorePathParamName);
57
- const appName = (_a = locatorInfo.get(fluidAppNameParamName)) !== null && _a !== void 0 ? _a : undefined;
58
- const containerPackageName = (_b = locatorInfo.get(fluidContainerPackageNameParamName)) !== null && _b !== void 0 ? _b : undefined;
59
- const fileVersion = (_c = locatorInfo.get(fluidFileVersionParamName)) !== null && _c !== void 0 ? _c : undefined;
57
+ const sitePath = locatorInfo.get(sitePathParamName);
58
+ const driveId = locatorInfo.get(driveIdParamName);
59
+ const itemId = locatorInfo.get(itemIdParamName);
60
+ const dataStorePath = locatorInfo.get(dataStorePathParamName);
61
+ const appName = (_a = locatorInfo.get(appNameParamName)) !== null && _a !== void 0 ? _a : undefined;
62
+ const containerPackageName = (_b = locatorInfo.get(containerPackageNameParamName)) !== null && _b !== void 0 ? _b : undefined;
63
+ const fileVersion = (_c = locatorInfo.get(fileVersionParamName)) !== null && _c !== void 0 ? _c : undefined;
64
+ const context = (_d = locatorInfo.get(additionalContextParamName)) !== null && _d !== void 0 ? _d : undefined;
60
65
  // "" is a valid value for dataStorePath so simply check for absence of the param;
61
- // the rest of params must be present and non-empty
66
+ // file storage locator params must be present and non-empty
62
67
  if (!sitePath || !driveId || !itemId || dataStorePath === null) {
63
68
  return undefined;
64
69
  }
@@ -66,7 +71,7 @@ function decodeOdspFluidDataStoreLocator(encodedLocatorValue, siteOriginUrl) {
66
71
  try {
67
72
  siteUrl = new URL(sitePath, siteOriginUrl);
68
73
  }
69
- catch (_d) {
74
+ catch (_e) {
70
75
  // Ignore failure to parse url as input might be malformed
71
76
  }
72
77
  if (!siteUrl) {
@@ -80,6 +85,7 @@ function decodeOdspFluidDataStoreLocator(encodedLocatorValue, siteOriginUrl) {
80
85
  appName,
81
86
  containerPackageName,
82
87
  fileVersion,
88
+ context,
83
89
  };
84
90
  }
85
91
  // This parameter is provided by host in the resolve request and it contains information about the file
@@ -1 +1 @@
1
- {"version":3,"file":"odspFluidFileLink.js","sourceRoot":"","sources":["../src/odspFluidFileLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAElE,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,uBAAuB,GAAG,OAAO,CAAC;AACxC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AACxC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,MAAM,kCAAkC,GAAG,GAAG,CAAC;AAC/C,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAEtC;;;;GAIG;AACH,MAAM,UAAU,+BAA+B,CAAC,OAAkC;IAC9E,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtD,MAAM,OAAO,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ACrE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAQ;IAC1C,mGAAmG;IACnG,MAAM,mBAAmB,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACxE,IAAI,CAAC,mBAAmB,EAAE;QACtB,OAAO,SAAS,CAAC;KACpB;IAED,qGAAqG;IACrG,oFAAoF;IACpF,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;IAErG,OAAO,+BAA+B,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;AAC/E,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fromBase64ToUtf8, fromUtf8ToBase64 } from \"@fluidframework/common-utils\";\nimport { OdspFluidDataStoreLocator } from \"./contractsPublic\";\nimport { OdcFileSiteOrigin, OdcApiSiteOrigin } from \"./constants\";\n\nconst fluidSignature = \"1\";\nconst fluidSignatureParamName = \"fluid\";\nconst fluidSitePathParamName = \"s\";\nconst fluidDriveIdParamName = \"d\";\nconst fluidItemIdParamName = \"f\";\nconst fluidDataStorePathParamName = \"c\";\nconst fluidAppNameParamName = \"a\";\nconst fluidContainerPackageNameParamName = \"p\";\nconst fluidFileVersionParamName = \"v\";\n\n/**\n * Transforms given Fluid data store locator into string that can be embedded into url\n * @param locator - describes Fluid data store locator info to be encoded\n * @returns string representing encoded Fluid data store locator info\n */\nexport function encodeOdspFluidDataStoreLocator(locator: OdspFluidDataStoreLocator): string {\n const siteUrl = new URL(locator.siteUrl);\n const sitePath = encodeURIComponent(siteUrl.pathname);\n const driveId = encodeURIComponent(locator.driveId);\n const itemId = encodeURIComponent(locator.itemId);\n const dataStorePath = encodeURIComponent(locator.dataStorePath);\n\n let locatorSerialized = `${fluidSitePathParamName}=${sitePath}&${fluidDriveIdParamName}=${driveId}&${\n fluidItemIdParamName}=${itemId}&${fluidDataStorePathParamName}=${dataStorePath}&${\n fluidSignatureParamName}=${fluidSignature}`;\n if (locator.appName) {\n locatorSerialized += `&${fluidAppNameParamName}=${encodeURIComponent(locator.appName)}`;\n }\n if (locator.containerPackageName) {\n locatorSerialized += `&${fluidContainerPackageNameParamName}=${\n encodeURIComponent(locator.containerPackageName)}`;\n }\n if (locator.fileVersion) {\n locatorSerialized += `&${fluidFileVersionParamName}=${\n encodeURIComponent(locator.fileVersion)}`;\n }\n\n return fromUtf8ToBase64(locatorSerialized);\n}\n\n/**\n * Decodes given encoded value representing Fluid data store locator extracted from ODSP Fluid file link\n * @param encodedLocatorValue - encoded Fluid data store locator value which was produced by\n * encodeOdspFluidDataStoreLocator method\n * @param siteOriginUrl - site origin that will be appended to encoded relative path to form absolute file url\n * @returns object representing Fluid data store location in ODSP terms\n */\nfunction decodeOdspFluidDataStoreLocator(\n encodedLocatorValue: string,\n siteOriginUrl: string,\n): OdspFluidDataStoreLocator | undefined {\n const locatorInfo = new URLSearchParams(fromBase64ToUtf8(encodedLocatorValue));\n\n const signatureValue = locatorInfo.get(fluidSignatureParamName);\n if (signatureValue !== \"1\") {\n return undefined;\n }\n\n const sitePath = locatorInfo.get(fluidSitePathParamName);\n const driveId = locatorInfo.get(fluidDriveIdParamName);\n const itemId = locatorInfo.get(fluidItemIdParamName);\n const dataStorePath = locatorInfo.get(fluidDataStorePathParamName);\n const appName = locatorInfo.get(fluidAppNameParamName) ?? undefined;\n const containerPackageName = locatorInfo.get(fluidContainerPackageNameParamName) ?? undefined;\n const fileVersion = locatorInfo.get(fluidFileVersionParamName) ?? undefined;\n // \"\" is a valid value for dataStorePath so simply check for absence of the param;\n // the rest of params must be present and non-empty\n if (!sitePath || !driveId || !itemId || dataStorePath === null) {\n return undefined;\n }\n\n let siteUrl: URL | undefined;\n try {\n siteUrl = new URL(sitePath, siteOriginUrl);\n } catch {\n // Ignore failure to parse url as input might be malformed\n }\n\n if (!siteUrl) {\n return undefined;\n }\n\n return {\n siteUrl: siteUrl.href,\n driveId,\n itemId,\n dataStorePath,\n appName,\n containerPackageName,\n fileVersion,\n };\n}\n\n// This parameter is provided by host in the resolve request and it contains information about the file\n// like driveId, itemId, siteUrl, datastorePath, packageName etc.\nexport const locatorQueryParamName = \"nav\";\n\n/**\n * Embeds Fluid data store locator data into given ODSP url\n * @param url - file url in ODSP format (can be either canonical or share link)\n * @param locator - object representing Fluid data store location in ODSP terms\n */\nexport function storeLocatorInOdspUrl(url: URL, locator: OdspFluidDataStoreLocator) {\n const encodedLocatorValue = encodeOdspFluidDataStoreLocator(locator);\n // IMPORTANT: Do not apply encodeURIComponent to encodedLocatorValue, param value is automatically encoded\n // when set via URLSearchParams class\n url.searchParams.set(locatorQueryParamName, encodedLocatorValue);\n}\n\n/**\n * Extract ODSP Fluid data store locator object from given ODSP url. This extracts things like\n * driveId, ItemId, siteUrl etc from a url where these are encoded in nav query param.\n * @param url - ODSP url representing Fluid file link\n * @returns object representing Fluid data store location in ODSP terms\n */\nexport function getLocatorFromOdspUrl(url: URL): OdspFluidDataStoreLocator | undefined {\n // NOTE: No need to apply decodeURIComponent when accessing query params via URLSearchParams class.\n const encodedLocatorValue = url.searchParams.get(locatorQueryParamName);\n if (!encodedLocatorValue) {\n return undefined;\n }\n\n // IMPORTANT: ODC deviates from ODSP in that its file link origin is different from vroom api origin.\n // The following code passes vroom api origin as site origin instead of file origin.\n const siteOriginUrl = url.origin.toLowerCase() === OdcFileSiteOrigin ? OdcApiSiteOrigin : url.origin;\n\n return decodeOdspFluidDataStoreLocator(encodedLocatorValue, siteOriginUrl);\n}\n"]}
1
+ {"version":3,"file":"odspFluidFileLink.js","sourceRoot":"","sources":["../src/odspFluidFileLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAElF,OAAO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AgB,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;IAErG,OAAO,+BAA+B,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;AAC/E,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fromBase64ToUtf8, fromUtf8ToBase64 } from \"@fluidframework/common-utils\";\nimport { OdspFluidDataStoreLocator } from \"./contractsPublic\";\nimport { OdcFileSiteOrigin, OdcApiSiteOrigin } from \"./constants\";\n\nconst fluidSignature = \"1\";\nconst fluidSignatureParamName = \"fluid\";\nconst sitePathParamName = \"s\";\nconst driveIdParamName = \"d\";\nconst itemIdParamName = \"f\";\nconst dataStorePathParamName = \"c\";\nconst appNameParamName = \"a\";\nconst containerPackageNameParamName = \"p\";\nconst fileVersionParamName = \"v\";\nconst additionalContextParamName = \"x\";\n\n/**\n * Transforms given Fluid data store locator into string that can be embedded into url\n * @param locator - describes Fluid data store locator info to be encoded\n * @returns string representing encoded Fluid data store locator info\n */\nexport function encodeOdspFluidDataStoreLocator(locator: OdspFluidDataStoreLocator): string {\n const siteUrl = new URL(locator.siteUrl);\n const sitePath = encodeURIComponent(siteUrl.pathname);\n const driveId = encodeURIComponent(locator.driveId);\n const itemId = encodeURIComponent(locator.itemId);\n const dataStorePath = encodeURIComponent(locator.dataStorePath);\n\n let locatorSerialized = `${sitePathParamName}=${sitePath}&${driveIdParamName}=${driveId}&${\n itemIdParamName}=${itemId}&${dataStorePathParamName}=${dataStorePath}&${\n fluidSignatureParamName}=${fluidSignature}`;\n if (locator.appName) {\n locatorSerialized += `&${appNameParamName}=${encodeURIComponent(locator.appName)}`;\n }\n if (locator.containerPackageName) {\n locatorSerialized += `&${containerPackageNameParamName}=${encodeURIComponent(locator.containerPackageName)}`;\n }\n if (locator.fileVersion) {\n locatorSerialized += `&${fileVersionParamName}=${encodeURIComponent(locator.fileVersion)}`;\n }\n if (locator.context) {\n locatorSerialized += `&${additionalContextParamName}=${encodeURIComponent(locator.context)}`;\n }\n\n return fromUtf8ToBase64(locatorSerialized);\n}\n\n/**\n * Decodes given encoded value representing Fluid data store locator extracted from ODSP Fluid file link\n * @param encodedLocatorValue - encoded Fluid data store locator value which was produced by\n * encodeOdspFluidDataStoreLocator method\n * @param siteOriginUrl - site origin that will be appended to encoded relative path to form absolute file url\n * @returns object representing Fluid data store location in ODSP terms\n */\nfunction decodeOdspFluidDataStoreLocator(\n encodedLocatorValue: string,\n siteOriginUrl: string,\n): OdspFluidDataStoreLocator | undefined {\n const locatorInfo = new URLSearchParams(fromBase64ToUtf8(encodedLocatorValue));\n\n const signatureValue = locatorInfo.get(fluidSignatureParamName);\n if (signatureValue !== \"1\") {\n return undefined;\n }\n\n const sitePath = locatorInfo.get(sitePathParamName);\n const driveId = locatorInfo.get(driveIdParamName);\n const itemId = locatorInfo.get(itemIdParamName);\n const dataStorePath = locatorInfo.get(dataStorePathParamName);\n const appName = locatorInfo.get(appNameParamName) ?? undefined;\n const containerPackageName = locatorInfo.get(containerPackageNameParamName) ?? undefined;\n const fileVersion = locatorInfo.get(fileVersionParamName) ?? undefined;\n const context = locatorInfo.get(additionalContextParamName) ?? undefined;\n // \"\" is a valid value for dataStorePath so simply check for absence of the param;\n // file storage locator params must be present and non-empty\n if (!sitePath || !driveId || !itemId || dataStorePath === null) {\n return undefined;\n }\n\n let siteUrl: URL | undefined;\n try {\n siteUrl = new URL(sitePath, siteOriginUrl);\n } catch {\n // Ignore failure to parse url as input might be malformed\n }\n\n if (!siteUrl) {\n return undefined;\n }\n\n return {\n siteUrl: siteUrl.href,\n driveId,\n itemId,\n dataStorePath,\n appName,\n containerPackageName,\n fileVersion,\n context,\n };\n}\n\n// This parameter is provided by host in the resolve request and it contains information about the file\n// like driveId, itemId, siteUrl, datastorePath, packageName etc.\nexport const locatorQueryParamName = \"nav\";\n\n/**\n * Embeds Fluid data store locator data into given ODSP url\n * @param url - file url in ODSP format (can be either canonical or share link)\n * @param locator - object representing Fluid data store location in ODSP terms\n */\nexport function storeLocatorInOdspUrl(url: URL, locator: OdspFluidDataStoreLocator) {\n const encodedLocatorValue = encodeOdspFluidDataStoreLocator(locator);\n // IMPORTANT: Do not apply encodeURIComponent to encodedLocatorValue, param value is automatically encoded\n // when set via URLSearchParams class\n url.searchParams.set(locatorQueryParamName, encodedLocatorValue);\n}\n\n/**\n * Extract ODSP Fluid data store locator object from given ODSP url. This extracts things like\n * driveId, ItemId, siteUrl etc from a url where these are encoded in nav query param.\n * @param url - ODSP url representing Fluid file link\n * @returns object representing Fluid data store location in ODSP terms\n */\nexport function getLocatorFromOdspUrl(url: URL): OdspFluidDataStoreLocator | undefined {\n // NOTE: No need to apply decodeURIComponent when accessing query params via URLSearchParams class.\n const encodedLocatorValue = url.searchParams.get(locatorQueryParamName);\n if (!encodedLocatorValue) {\n return undefined;\n }\n\n // IMPORTANT: ODC deviates from ODSP in that its file link origin is different from vroom api origin.\n // The following code passes vroom api origin as site origin instead of file origin.\n const siteOriginUrl = url.origin.toLowerCase() === OdcFileSiteOrigin ? OdcApiSiteOrigin : url.origin;\n\n return decodeOdspFluidDataStoreLocator(encodedLocatorValue, siteOriginUrl);\n}\n"]}
@@ -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 = "1.1.0";
8
+ export declare const pkgVersion = "1.2.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/odsp-driver";
8
- export const pkgVersion = "1.1.0";
8
+ export const pkgVersion = "1.2.0";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -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,OAAO,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 = \"1.1.0\";\n"]}
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,OAAO,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 = \"1.2.0\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/odsp-driver",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Socket storage implementation for SPO and ODC",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -62,16 +62,16 @@
62
62
  "dependencies": {
63
63
  "@fluidframework/common-definitions": "^0.20.1",
64
64
  "@fluidframework/common-utils": "^0.32.1",
65
- "@fluidframework/core-interfaces": "^1.1.0",
66
- "@fluidframework/driver-base": "^1.1.0",
67
- "@fluidframework/driver-definitions": "^1.1.0",
68
- "@fluidframework/driver-utils": "^1.1.0",
65
+ "@fluidframework/core-interfaces": "^1.2.0",
66
+ "@fluidframework/driver-base": "^1.2.0",
67
+ "@fluidframework/driver-definitions": "^1.2.0",
68
+ "@fluidframework/driver-utils": "^1.2.0",
69
69
  "@fluidframework/gitresources": "^0.1036.5000",
70
- "@fluidframework/odsp-doclib-utils": "^1.1.0",
71
- "@fluidframework/odsp-driver-definitions": "^1.1.0",
70
+ "@fluidframework/odsp-doclib-utils": "^1.2.0",
71
+ "@fluidframework/odsp-driver-definitions": "^1.2.0",
72
72
  "@fluidframework/protocol-base": "^0.1036.5000",
73
73
  "@fluidframework/protocol-definitions": "^0.1028.2000",
74
- "@fluidframework/telemetry-utils": "^1.1.0",
74
+ "@fluidframework/telemetry-utils": "^1.2.0",
75
75
  "abort-controller": "^3.0.0",
76
76
  "node-fetch": "^2.6.1",
77
77
  "socket.io-client": "^4.4.1",
@@ -81,8 +81,8 @@
81
81
  "@fluidframework/build-common": "^0.24.0",
82
82
  "@fluidframework/build-tools": "^0.2.74327",
83
83
  "@fluidframework/eslint-config-fluid": "^0.28.2000",
84
- "@fluidframework/mocha-test-setup": "^1.1.0",
85
- "@fluidframework/odsp-driver-previous": "npm:@fluidframework/odsp-driver@^1.0.0",
84
+ "@fluidframework/mocha-test-setup": "^1.2.0",
85
+ "@fluidframework/odsp-driver-previous": "npm:@fluidframework/odsp-driver@1.1.0",
86
86
  "@microsoft/api-extractor": "^7.22.2",
87
87
  "@rushstack/eslint-config": "^2.5.1",
88
88
  "@types/mocha": "^9.1.1",
@@ -100,7 +100,12 @@
100
100
  "typescript-formatter": "7.1.0"
101
101
  },
102
102
  "typeValidation": {
103
- "version": "1.1.0",
104
- "broken": {}
103
+ "version": "1.2.0",
104
+ "broken": {
105
+ "VariableDeclaration_OdcApiSiteOrigin": {
106
+ "forwardCompat": false,
107
+ "backCompat": false
108
+ }
109
+ }
105
110
  }
106
111
  }
package/src/checkUrl.ts CHANGED
@@ -8,7 +8,7 @@ import { getLocatorFromOdspUrl } from "./odspFluidFileLink";
8
8
 
9
9
  /**
10
10
  * A check that returns DriverPreCheckInfo if the URL format is likely supported by this driver.
11
- * Note that returning information here is NOT a full guarentee that resolve will ultimately be successsful.
11
+ * Note that returning information here is NOT a full guarantee that resolve will ultimately be successful.
12
12
  * Instead, this should be used as a lightweight check that can filter out easily detectable unsupported URLs
13
13
  * before the entire Fluid loading process needs to be kicked off.
14
14
  */
package/src/constants.ts CHANGED
@@ -3,5 +3,5 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- export const OdcApiSiteOrigin = "https://api.onedrive.com";
6
+ export const OdcApiSiteOrigin = "https://my.microsoftpersonalcontent.com";
7
7
  export const OdcFileSiteOrigin = "https://1drv.ms";
@@ -10,6 +10,7 @@ export interface OdspFluidDataStoreLocator extends IOdspUrlParts {
10
10
  appName?: string;
11
11
  containerPackageName?: string;
12
12
  fileVersion?: string;
13
+ context?: string;
13
14
  }
14
15
 
15
16
  export enum SharingLinkHeader {
@@ -86,11 +86,6 @@ async function getFileLinkCore(
86
86
  ): Promise<string> {
87
87
  const fileItem = await getFileItemLite(getToken, odspUrlParts, logger, identityType === "Consumer");
88
88
 
89
- // ODC canonical link does not require any additional processing
90
- if (identityType === "Consumer") {
91
- return fileItem.webUrl;
92
- }
93
-
94
89
  // ODSP link requires extra call to return link that is resistant to file being renamed or moved to different folder
95
90
  return PerformanceEvent.timedExecAsync(
96
91
  logger,
@@ -0,0 +1,54 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { ITelemetryLogger } from "@fluidframework/common-definitions";
7
+ import {
8
+ IDocumentDeltaStorageService,
9
+ IDocumentService,
10
+ IDocumentStorageService,
11
+ IResolvedUrl,
12
+ } from "@fluidframework/driver-definitions";
13
+ import { UsageError, EmptyDocumentDeltaStorageService } from "@fluidframework/driver-utils";
14
+ import { IOdspResolvedUrl } from "@fluidframework/odsp-driver-definitions";
15
+ import { IClient } from "@fluidframework/protocol-definitions";
16
+ import { LocalOdspDocumentStorageService } from "./localOdspDocumentStorageManager";
17
+
18
+ /**
19
+ * IDocumentService implementation that provides explicit snapshot to the document storage service.
20
+ */
21
+ export class LocalOdspDocumentService implements IDocumentService {
22
+ public policies = { storageOnly: true };
23
+
24
+ constructor(
25
+ private readonly odspResolvedUrl: IOdspResolvedUrl,
26
+ private readonly logger: ITelemetryLogger,
27
+ private readonly localSnapshot: Uint8Array | string,
28
+ ) { }
29
+
30
+ public get resolvedUrl(): IResolvedUrl {
31
+ return this.odspResolvedUrl;
32
+ }
33
+
34
+ public async connectToStorage(): Promise<IDocumentStorageService> {
35
+ return new LocalOdspDocumentStorageService(
36
+ this.logger,
37
+ this.localSnapshot,
38
+ );
39
+ }
40
+
41
+ public async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {
42
+ return new EmptyDocumentDeltaStorageService();
43
+ }
44
+
45
+ public connectToDeltaStream(_client: IClient): never {
46
+ const toThrow = new UsageError("\"connectToDeltaStream\" is not supported by LocalOdspDocumentService");
47
+ this.logger.sendErrorEvent({ eventName: "UnsupportedUsage" }, toThrow);
48
+ throw toThrow;
49
+ }
50
+
51
+ public dispose(_error?: any): void {
52
+ // Do nothing
53
+ }
54
+ }
@@ -0,0 +1,67 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { IDocumentService, IResolvedUrl } from "@fluidframework/driver-definitions";
7
+ import { UsageError } from "@fluidframework/driver-utils";
8
+ import { TelemetryLogger } from "@fluidframework/telemetry-utils";
9
+ import { ISummaryTree } from "@fluidframework/protocol-definitions";
10
+ import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
11
+ import { createOdspLogger, getOdspResolvedUrl } from "../odspUtils";
12
+ import { ICacheAndTracker } from "../epochTracker";
13
+ import { OdspDocumentServiceFactoryCore } from "../odspDocumentServiceFactoryCore";
14
+ import { LocalOdspDocumentService } from "./localOdspDocumentService";
15
+
16
+ /**
17
+ * Factory for creating sharepoint document service with a provided snapshot.
18
+ * Use if you don't want to connect to any kind of external/internal storages and want to provide
19
+ * content directly.
20
+ */
21
+ export class LocalOdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore {
22
+ private logger: TelemetryLogger | undefined;
23
+
24
+ constructor(
25
+ private readonly localSnapshot: Uint8Array | string,
26
+ ) {
27
+ super(
28
+ (_options) => this.throwUnsupportedUsageError("Getting storage token"),
29
+ (_options) => this.throwUnsupportedUsageError("Getting websocket token"),
30
+ () => this.throwUnsupportedUsageError("Getting SocketIO Client"),
31
+ );
32
+ }
33
+
34
+ private throwUnsupportedUsageError(unsupportedFuncName: string): never {
35
+ const toThrow = new UsageError(
36
+ `${unsupportedFuncName} is not supported by LocalOdspDocumentServiceFactory`);
37
+ this.logger?.sendErrorEvent({ eventName: "UnsupportedUsage" }, toThrow);
38
+ throw toThrow;
39
+ }
40
+
41
+ public createContainer(
42
+ _createNewSummary: ISummaryTree | undefined,
43
+ _createNewResolvedUrl: IResolvedUrl,
44
+ logger?: ITelemetryBaseLogger,
45
+ _clientIsSummarizer?: boolean,
46
+ ): never {
47
+ const toThrow = new UsageError("\"createContainer\" is not supported by LocalOdspDocumentServiceFactory");
48
+ createOdspLogger(logger).sendErrorEvent({ eventName: "UnsupportedUsage" }, toThrow);
49
+ throw toThrow;
50
+ }
51
+
52
+ protected async createDocumentServiceCore(
53
+ resolvedUrl: IResolvedUrl,
54
+ odspLogger: TelemetryLogger,
55
+ _cacheAndTrackerArg?: ICacheAndTracker,
56
+ _clientIsSummarizer?: boolean,
57
+ ): Promise<IDocumentService> {
58
+ if (_cacheAndTrackerArg !== undefined) {
59
+ throw new UsageError("Invalid usage. \"_cacheAndTrackerArg\" should not be provided");
60
+ }
61
+ if (_clientIsSummarizer) {
62
+ throw new UsageError("Invalid usage. \"_clientIsSummarizer\" should not be provided");
63
+ }
64
+ this.logger = odspLogger;
65
+ return new LocalOdspDocumentService(getOdspResolvedUrl(resolvedUrl), odspLogger, this.localSnapshot);
66
+ }
67
+ }
@@ -0,0 +1,83 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { assert } from "@fluidframework/common-utils";
7
+ import { ITelemetryLogger } from "@fluidframework/common-definitions";
8
+ import { ISummaryContext } from "@fluidframework/driver-definitions";
9
+ import { UsageError } from "@fluidframework/driver-utils";
10
+ import * as api from "@fluidframework/protocol-definitions";
11
+ import { OdspDocumentStorageServiceBase } from "../odspDocumentStorageServiceBase";
12
+ import { ISnapshotContents } from "../odspPublicUtils";
13
+ import { IOdspSnapshot } from "../contracts";
14
+ import { convertOdspSnapshotToSnapshotTreeAndBlobs } from "../odspSnapshotParser";
15
+ import { parseCompactSnapshotResponse } from "../compactSnapshotParser";
16
+ import { ReadBuffer } from "../ReadBufferUtils";
17
+
18
+ /**
19
+ * ODSP document storage service that works on a provided snapshot for all its processing.
20
+ * Attempting to use unsupported actions/methods will result in errors being thrown.
21
+ */
22
+ export class LocalOdspDocumentStorageService extends OdspDocumentStorageServiceBase {
23
+ private snapshotTreeId: string | undefined;
24
+
25
+ constructor(
26
+ private readonly logger: ITelemetryLogger,
27
+ private readonly localSnapshot: Uint8Array | string,
28
+ ) {
29
+ super();
30
+ }
31
+
32
+ private calledGetVersions = false;
33
+
34
+ public async getVersions(blobid: string | null, count: number, _scenarioName?: string): Promise<api.IVersion[]> {
35
+ assert(blobid === null, 0x342 /* Invalid usage. "blobid" should always be null */);
36
+ assert(count === 1, 0x343 /* Invalid usage. "count" should always be 1 */);
37
+
38
+ // No reason to re-parse the data since it will never change
39
+ if (this.calledGetVersions) {
40
+ return this.getSnapshotVersion();
41
+ }
42
+ this.calledGetVersions = true;
43
+
44
+ let snapshotContents: ISnapshotContents;
45
+
46
+ if (typeof this.localSnapshot === "string") {
47
+ const content: IOdspSnapshot = JSON.parse(this.localSnapshot);
48
+ snapshotContents = convertOdspSnapshotToSnapshotTreeAndBlobs(content);
49
+ } else {
50
+ snapshotContents = parseCompactSnapshotResponse(
51
+ new ReadBuffer(this.localSnapshot));
52
+ }
53
+
54
+ this.snapshotTreeId = this.initializeFromSnapshot(snapshotContents);
55
+ return this.getSnapshotVersion();
56
+ }
57
+
58
+ private getSnapshotVersion(): api.IVersion[] {
59
+ return this.snapshotTreeId ? [{ id: this.snapshotTreeId, treeId: undefined! }] : [];
60
+ }
61
+
62
+ protected fetchTreeFromSnapshot(_id: string, _scenarioName?: string): never {
63
+ this.throwUsageError("fetchTreeFromSnapshot");
64
+ }
65
+
66
+ protected fetchBlobFromStorage(_blobId: string, _evicted: boolean): never {
67
+ this.throwUsageError("fetchBlobFromStorage");
68
+ }
69
+
70
+ public uploadSummaryWithContext(_summary: api.ISummaryTree, _context: ISummaryContext): never {
71
+ this.throwUsageError("uploadSummaryWithContext");
72
+ }
73
+
74
+ public createBlob(_file: ArrayBufferLike): never {
75
+ this.throwUsageError("createBlob");
76
+ }
77
+
78
+ private throwUsageError(methodName: string): never {
79
+ const toThrow = new UsageError(`"${methodName}" is not supported by LocalOdspDocumentStorageService`);
80
+ this.logger.sendErrorEvent({ eventName: "UnsupportedUsage" }, toThrow);
81
+ throw toThrow;
82
+ }
83
+ }
@@ -236,5 +236,5 @@ export class OdspDeltaStorageWithCache implements IDocumentDeltaStorageService {
236
236
  });
237
237
  }
238
238
  });
239
- }
239
+ }
240
240
  }
@@ -21,7 +21,11 @@ import {
21
21
  IDocumentServicePolicies,
22
22
  DriverErrorType,
23
23
  } from "@fluidframework/driver-definitions";
24
- import { canRetryOnError, DeltaStreamConnectionForbiddenError, NonRetryableError } from "@fluidframework/driver-utils";
24
+ import {
25
+ canRetryOnError,
26
+ DeltaStreamConnectionForbiddenError,
27
+ NonRetryableError,
28
+ } from "@fluidframework/driver-utils";
25
29
  import { IFacetCodes } from "@fluidframework/odsp-doclib-utils";
26
30
  import {
27
31
  IClient,
@@ -12,14 +12,14 @@ import {
12
12
  } from "@fluidframework/odsp-driver-definitions";
13
13
  import { OdspDocumentServiceFactoryCore } from "./odspDocumentServiceFactoryCore";
14
14
  import { getSocketIo } from "./getSocketIo";
15
+ // eslint-disable-next-line import/no-internal-modules
16
+ import { LocalOdspDocumentServiceFactory } from "./localOdspDriver/localOdspDocumentServiceFactory";
15
17
 
16
18
  /**
17
19
  * Factory for creating the sharepoint document service. Use this if you want to
18
20
  * use the sharepoint implementation.
19
21
  */
20
- export class OdspDocumentServiceFactory
21
- extends OdspDocumentServiceFactoryCore
22
- implements IDocumentServiceFactory {
22
+ export class OdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore {
23
23
  constructor(
24
24
  getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,
25
25
  getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined,
@@ -35,3 +35,7 @@ export class OdspDocumentServiceFactory
35
35
  );
36
36
  }
37
37
  }
38
+
39
+ export function createLocalOdspDocumentServiceFactory(localSnapshot: Uint8Array | string): IDocumentServiceFactory {
40
+ return new LocalOdspDocumentServiceFactory(localSnapshot);
41
+ }
@@ -174,7 +174,7 @@ export class OdspDocumentServiceFactoryCore implements IDocumentServiceFactory {
174
174
  return this.createDocumentServiceCore(resolvedUrl, createOdspLogger(logger), undefined, clientIsSummarizer);
175
175
  }
176
176
 
177
- private async createDocumentServiceCore(
177
+ protected async createDocumentServiceCore(
178
178
  resolvedUrl: IResolvedUrl,
179
179
  odspLogger: TelemetryLogger,
180
180
  cacheAndTrackerArg?: ICacheAndTracker,