@fluidframework/odsp-urlresolver 2.1.0-276985 → 2.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @fluidframework/odsp-urlresolver
2
2
 
3
+ ## 2.1.0
4
+
5
+ Dependency updates only.
6
+
3
7
  ## 2.0.0-rc.5.0.0
4
8
 
5
9
  ### Minor Changes
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  This is an implementation of a url resolver which resolves onedrive and sharepoint URLs.
4
4
 
5
- <!-- AUTO-GENERATED-CONTENT:START (README_DEPENDENCY_GUIDELINES_SECTION:includeHeading=TRUE) -->
5
+ <!-- AUTO-GENERATED-CONTENT:START (LIBRARY_PACKAGE_README_HEADER) -->
6
6
 
7
7
  <!-- prettier-ignore-start -->
8
8
  <!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
@@ -15,15 +15,97 @@ library consumers should always prefer `^`.
15
15
 
16
16
  If using any of Fluid Framework's unstable APIs (for example, its `beta` APIs), we recommend using a more constrained version range, such as `~`.
17
17
 
18
+ ## Installation
19
+
20
+ To get started, install the package by running the following command:
21
+
22
+ ```bash
23
+ npm i @fluidframework/odsp-urlresolver
24
+ ```
25
+
26
+ ## API Documentation
27
+
28
+ API documentation for **@fluidframework/odsp-urlresolver** is available at <https://fluidframework.com/docs/apis/odsp-urlresolver>.
29
+
18
30
  <!-- prettier-ignore-end -->
19
31
 
20
32
  <!-- AUTO-GENERATED-CONTENT:END -->
21
33
 
22
- <!-- AUTO-GENERATED-CONTENT:START (README_TRADEMARK_SECTION:includeHeading=TRUE) -->
34
+ <!-- AUTO-GENERATED-CONTENT:START (LIBRARY_PACKAGE_README_FOOTER) -->
23
35
 
24
36
  <!-- prettier-ignore-start -->
25
37
  <!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
26
38
 
39
+ ## Minimum Client Requirements
40
+
41
+ These are the platform requirements for the current version of Fluid Framework Client Packages.
42
+ These requirements err on the side of being too strict since within a major version they can be relaxed over time, but not made stricter.
43
+ For Long Term Support (LTS) versions this can require supporting these platforms for several years.
44
+
45
+ It is likely that other configurations will work, but they are not supported: if they stop working, we do not consider that a bug.
46
+ If you would benefit from support for something not listed here, file an issue and the product team will evaluate your request.
47
+ When making such a request please include if the configuration already works (and thus the request is just that it becomes officially supported), or if changes are required to get it working.
48
+
49
+ ### Supported Runtimes
50
+
51
+ - NodeJs ^20.10.0 except that we will drop support for it [when NodeJs 20 loses its upstream support on 2026-04-30](https://github.com/nodejs/release#release-schedule), and will support a newer LTS version of NodeJS (22) at least 1 year before 20 is end-of-life. This same policy applies to NodeJS 22 when it is end of life (2027-04-30).
52
+ - Modern browsers supporting the es2022 standard library: in response to asks we can add explicit support for using babel to polyfill to target specific standards or runtimes (meaning we can avoid/remove use of things that don't polyfill robustly, but otherwise target modern standards).
53
+
54
+ ### Supported Tools
55
+
56
+ - TypeScript 5.4:
57
+ - All [`strict`](https://www.typescriptlang.org/tsconfig) options are supported.
58
+ - [`strictNullChecks`](https://www.typescriptlang.org/tsconfig) is required.
59
+ - [Configuration options deprecated in 5.0](https://github.com/microsoft/TypeScript/issues/51909) are not supported.
60
+ - `exactOptionalPropertyTypes` is currently not fully supported.
61
+ If used, narrowing members of Fluid Framework types types using `in`, `Reflect.has`, `Object.hasOwn` or `Object.prototype.hasOwnProperty` should be avoided as they may incorrectly exclude `undefined` from the possible values in some cases.
62
+ - [webpack](https://webpack.js.org/) 5
63
+ - We are not intending to be prescriptive about what bundler to use.
64
+ Other bundlers which can handle ES Modules should work, but webpack is the only one we actively test.
65
+
66
+ ### Module Resolution
67
+
68
+ [`Node16`, `NodeNext`, or `Bundler`](https://www.typescriptlang.org/tsconfig#moduleResolution) resolution should be used with TypeScript compilerOptions to follow the [Node.js v12+ ESM Resolution and Loading algorithm](https://nodejs.github.io/nodejs.dev/en/api/v20/esm/#resolution-and-loading-algorithm).
69
+ Node10 resolution is not supported as it does not support Fluid Framework's API structuring pattern that is used to distinguish stable APIs from those that are in development.
70
+
71
+ ### Module Formats
72
+
73
+ - ES Modules:
74
+ ES Modules are the preferred way to consume our client packages (including in NodeJs) and consuming our client packages from ES Modules is fully supported.
75
+ - CommonJs:
76
+ Consuming our client packages as CommonJs is supported only in NodeJS and only for the cases listed below.
77
+ This is done to accommodate some workflows without good ES Module support.
78
+ If you have a workflow you would like included in this list, file an issue.
79
+ Once this list of workflows motivating CommonJS support is empty, we may drop support for CommonJS one year after notice of the change is posted here.
80
+
81
+ - Testing with Jest (which lacks [stable ESM support](https://jestjs.io/docs/ecmascript-modules) due to [unstable APIs in NodeJs](https://github.com/nodejs/node/issues/37648))
82
+
83
+ ## Contribution Guidelines
84
+
85
+ There are many ways to [contribute](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md) to Fluid.
86
+
87
+ - Participate in Q&A in our [GitHub Discussions](https://github.com/microsoft/FluidFramework/discussions).
88
+ - [Submit bugs](https://github.com/microsoft/FluidFramework/issues) and help us verify fixes as they are checked in.
89
+ - Review the [source code changes](https://github.com/microsoft/FluidFramework/pulls).
90
+ - [Contribute bug fixes](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md).
91
+
92
+ Detailed instructions for working in the repo can be found in the [Wiki](https://github.com/microsoft/FluidFramework/wiki).
93
+
94
+ This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
95
+ For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
96
+
97
+ This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
98
+ Use of these trademarks or logos must follow Microsoft’s [Trademark & Brand Guidelines](https://www.microsoft.com/trademarks).
99
+ Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
100
+
101
+ ## Help
102
+
103
+ Not finding what you're looking for in this README? Check out [fluidframework.com](https://fluidframework.com/docs/).
104
+
105
+ Still not finding what you're looking for? Please [file an issue](https://github.com/microsoft/FluidFramework/wiki/Submitting-Bugs-and-Feature-Requests).
106
+
107
+ Thank you!
108
+
27
109
  ## Trademark
28
110
 
29
111
  This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
package/dist/public.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  /*
7
7
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints" in @fluidframework/build-tools.
8
+ * Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  export {}
@@ -92,6 +92,8 @@ async function initializeFluidOfficeOrOneNote(urlSource) {
92
92
  if (siteDriveItemMatch === null) {
93
93
  return undefined;
94
94
  }
95
+ // TODO Why are we non null asserting here
96
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
95
97
  const site = decodeURIComponent(siteDriveItemMatch[2]);
96
98
  // Path value is base64 encoded so need to decode first
97
99
  const decodedSite = (0, client_utils_1.fromBase64ToUtf8)(site);
@@ -103,7 +105,11 @@ async function initializeFluidOfficeOrOneNote(urlSource) {
103
105
  }
104
106
  // Since we have the drive and item, only take the host ignore the rest
105
107
  const siteUrl = decodedSite.slice(Math.max(0, storageType.length + 1));
108
+ // TODO Why are we non null asserting here
109
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
106
110
  const driveId = decodeURIComponent(siteDriveItemMatch[3]);
111
+ // TODO Why are we non null asserting here
112
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
107
113
  const itemId = decodeURIComponent(siteDriveItemMatch[4]);
108
114
  return { siteUrl, driveId, itemId };
109
115
  }
@@ -1 +1 @@
1
- {"version":3,"file":"urlResolver.js","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA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AC;CACD;AArCD,0DAqCC;AAED,KAAK,UAAU,8BAA8B,CAC5C,SAAc;IAEd,MAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;IACpC,MAAM,kBAAkB,GAAG,QAAQ,CAAC,KAAK,CACxC,6DAA6D,CAC7D,CAAC;IACF,IAAI,kBAAkB,KAAK,IAAI,EAAE,CAAC;QACjC,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,MAAM,IAAI,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;IAEvD,uDAAuD;IACvD,MAAM,WAAW,GAAG,IAAA,+BAAgB,EAAC,IAAI,CAAC,CAAC;IAE3C,mCAAmC;IACnC,MAAM,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,MAAM,mBAAmB,GAAG,KAAK,CAAC,CAAC,2BAA2B;IAC9D,IAAI,WAAW,KAAK,mBAAmB,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CACd,2BAA2B,WAAW,eAAe,mBAAmB,EAAE,CAC1E,CAAC;IACH,CAAC;IAED,uEAAuE;IACvE,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IACvE,MAAM,OAAO,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,MAAM,MAAM,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACrC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fromBase64ToUtf8 } from \"@fluid-internal/client-utils\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIContainerPackageInfo,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tOdspDriverUrlResolver,\n\tcreateOdspUrl,\n\tgetOdspUrlParts,\n\tisOdcUrl,\n\tisSpoUrl,\n} from \"@fluidframework/odsp-driver/internal\";\nimport { IOdspUrlParts } from \"@fluidframework/odsp-driver-definitions/internal\";\n\nconst fluidOfficeAndOneNoteServers = new Set([\n\t\"dev.fluidpreview.office.net\",\n\t\"fluidpreview.office.net\",\n\t\"www.onenote.com\",\n]);\n\n/**\n * @internal\n */\nexport class OdspUrlResolver implements IUrlResolver {\n\tpublic async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {\n\t\tconst reqUrl = new URL(request.url);\n\t\tif (isOdspUrl(reqUrl)) {\n\t\t\tconst contents = await getOdspUrlParts(reqUrl);\n\t\t\tif (!contents) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst urlToBeResolved = createOdspUrl({ ...contents, dataStorePath: \"\" });\n\t\t\tconst odspDriverUrlResolver: IUrlResolver = new OdspDriverUrlResolver();\n\t\t\treturn odspDriverUrlResolver.resolve({\n\t\t\t\turl: urlToBeResolved,\n\t\t\t\theaders: request.headers,\n\t\t\t});\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\trelativeUrl: string,\n\t): Promise<string> {\n\t\tthrow new Error(\"Not implemented\");\n\t}\n}\n\n/**\n * Returns true if the given string is a valid SPO/ODB or ODC URL.\n *\n * @internal\n */\nconst isOdspUrl = (url: URL): boolean => {\n\treturn isSpoUrl(url) || isOdcUrl(url);\n};\n\n/**\n * This class helps to resolve Fluid URLs from Office and OneNote. Construct the resolver class and invoke its resolve function to retrieve the content parameters.\n * @internal\n */\nexport class FluidAppOdspUrlResolver implements IUrlResolver {\n\tpublic async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {\n\t\tconst reqUrl = new URL(request.url);\n\t\tconst server = reqUrl.hostname.toLowerCase();\n\t\tlet contents: IOdspUrlParts | undefined;\n\t\tif (fluidOfficeAndOneNoteServers.has(server)) {\n\t\t\tcontents = await initializeFluidOfficeOrOneNote(reqUrl);\n\t\t} else if (server === \"www.office.com\") {\n\t\t\tconst getRequiredParam = (name: string): string => {\n\t\t\t\tconst value = reqUrl.searchParams.get(name);\n\t\t\t\tassert(!!value, 0x097 /* Missing param from office.com URL parameter */);\n\t\t\t\treturn value;\n\t\t\t};\n\t\t\tcontents = {\n\t\t\t\tdriveId: getRequiredParam(\"drive\"),\n\t\t\t\titemId: getRequiredParam(\"item\"),\n\t\t\t\tsiteUrl: getRequiredParam(\"siteUrl\"),\n\t\t\t};\n\t\t} else {\n\t\t\treturn undefined;\n\t\t}\n\t\tif (!contents) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst urlToBeResolved = createOdspUrl({ ...contents, dataStorePath: \"\" });\n\t\tconst odspDriverUrlResolver: IUrlResolver = new OdspDriverUrlResolver();\n\t\treturn odspDriverUrlResolver.resolve({ url: urlToBeResolved });\n\t}\n\n\t// TODO: Issue-2109 Implement detach container api or put appropriate comment.\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\trelativeUrl: string,\n\t\tpackageInfoSource?: IContainerPackageInfo,\n\t): Promise<string> {\n\t\tthrow new Error(\"Not implemented\");\n\t}\n}\n\nasync function initializeFluidOfficeOrOneNote(\n\turlSource: URL,\n): Promise<IOdspUrlParts | undefined> {\n\tconst pathname = urlSource.pathname;\n\tconst siteDriveItemMatch = pathname.match(\n\t\t/\\/(p|preview|meetingnotes|notes)\\/([^/]*)\\/([^/]*)\\/([^/]*)/,\n\t);\n\tif (siteDriveItemMatch === null) {\n\t\treturn undefined;\n\t}\n\n\tconst site = decodeURIComponent(siteDriveItemMatch[2]);\n\n\t// Path value is base64 encoded so need to decode first\n\tconst decodedSite = fromBase64ToUtf8(site);\n\n\t// Site value includes storage type\n\tconst storageType = decodedSite.split(\":\")[0];\n\tconst expectedStorageType = \"spo\"; // Only support spo for now\n\tif (storageType !== expectedStorageType) {\n\t\tthrow new Error(\n\t\t\t`Unexpected storage type ${storageType}, expected: ${expectedStorageType}`,\n\t\t);\n\t}\n\n\t// Since we have the drive and item, only take the host ignore the rest\n\tconst siteUrl = decodedSite.slice(Math.max(0, storageType.length + 1));\n\tconst driveId = decodeURIComponent(siteDriveItemMatch[3]);\n\tconst itemId = decodeURIComponent(siteDriveItemMatch[4]);\n\treturn { siteUrl, driveId, itemId };\n}\n"]}
1
+ {"version":3,"file":"urlResolver.js","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAgE;AAEhE,kEAA6D;AAM7D,mEAM8C;AAG9C,MAAM,4BAA4B,GAAG,IAAI,GAAG,CAAC;IAC5C,6BAA6B;IAC7B,yBAAyB;IACzB,iBAAiB;CACjB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAa,eAAe;IACpB,KAAK,CAAC,OAAO,CAAC,OAAiB;QACrC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACpC,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YACvB,MAAM,QAAQ,GAAG,MAAM,IAAA,0BAAe,EAAC,MAAM,CAAC,CAAC;YAC/C,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACf,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,MAAM,eAAe,GAAG,IAAA,wBAAa,EAAC,EAAE,GAAG,QAAQ,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC;YAC1E,MAAM,qBAAqB,GAAiB,IAAI,gCAAqB,EAAE,CAAC;YACxE,OAAO,qBAAqB,CAAC,OAAO,CAAC;gBACpC,GAAG,EAAE,eAAe;gBACpB,OAAO,EAAE,OAAO,CAAC,OAAO;aACxB,CAAC,C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IACvE,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IACvE,0CAA0C;IAC1C,oEAAoE;IACpE,MAAM,OAAO,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,CAAC,CAAE,CAAC,CAAC;IAC3D,0CAA0C;IAC1C,oEAAoE;IACpE,MAAM,MAAM,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,CAAC,CAAE,CAAC,CAAC;IAC1D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACrC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fromBase64ToUtf8 } from \"@fluid-internal/client-utils\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIContainerPackageInfo,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tOdspDriverUrlResolver,\n\tcreateOdspUrl,\n\tgetOdspUrlParts,\n\tisOdcUrl,\n\tisSpoUrl,\n} from \"@fluidframework/odsp-driver/internal\";\nimport { IOdspUrlParts } from \"@fluidframework/odsp-driver-definitions/internal\";\n\nconst fluidOfficeAndOneNoteServers = new Set([\n\t\"dev.fluidpreview.office.net\",\n\t\"fluidpreview.office.net\",\n\t\"www.onenote.com\",\n]);\n\n/**\n * @internal\n */\nexport class OdspUrlResolver implements IUrlResolver {\n\tpublic async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {\n\t\tconst reqUrl = new URL(request.url);\n\t\tif (isOdspUrl(reqUrl)) {\n\t\t\tconst contents = await getOdspUrlParts(reqUrl);\n\t\t\tif (!contents) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst urlToBeResolved = createOdspUrl({ ...contents, dataStorePath: \"\" });\n\t\t\tconst odspDriverUrlResolver: IUrlResolver = new OdspDriverUrlResolver();\n\t\t\treturn odspDriverUrlResolver.resolve({\n\t\t\t\turl: urlToBeResolved,\n\t\t\t\theaders: request.headers,\n\t\t\t});\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\trelativeUrl: string,\n\t): Promise<string> {\n\t\tthrow new Error(\"Not implemented\");\n\t}\n}\n\n/**\n * Returns true if the given string is a valid SPO/ODB or ODC URL.\n *\n * @internal\n */\nconst isOdspUrl = (url: URL): boolean => {\n\treturn isSpoUrl(url) || isOdcUrl(url);\n};\n\n/**\n * This class helps to resolve Fluid URLs from Office and OneNote. Construct the resolver class and invoke its resolve function to retrieve the content parameters.\n * @internal\n */\nexport class FluidAppOdspUrlResolver implements IUrlResolver {\n\tpublic async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {\n\t\tconst reqUrl = new URL(request.url);\n\t\tconst server = reqUrl.hostname.toLowerCase();\n\t\tlet contents: IOdspUrlParts | undefined;\n\t\tif (fluidOfficeAndOneNoteServers.has(server)) {\n\t\t\tcontents = await initializeFluidOfficeOrOneNote(reqUrl);\n\t\t} else if (server === \"www.office.com\") {\n\t\t\tconst getRequiredParam = (name: string): string => {\n\t\t\t\tconst value = reqUrl.searchParams.get(name);\n\t\t\t\tassert(!!value, 0x097 /* Missing param from office.com URL parameter */);\n\t\t\t\treturn value;\n\t\t\t};\n\t\t\tcontents = {\n\t\t\t\tdriveId: getRequiredParam(\"drive\"),\n\t\t\t\titemId: getRequiredParam(\"item\"),\n\t\t\t\tsiteUrl: getRequiredParam(\"siteUrl\"),\n\t\t\t};\n\t\t} else {\n\t\t\treturn undefined;\n\t\t}\n\t\tif (!contents) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst urlToBeResolved = createOdspUrl({ ...contents, dataStorePath: \"\" });\n\t\tconst odspDriverUrlResolver: IUrlResolver = new OdspDriverUrlResolver();\n\t\treturn odspDriverUrlResolver.resolve({ url: urlToBeResolved });\n\t}\n\n\t// TODO: Issue-2109 Implement detach container api or put appropriate comment.\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\trelativeUrl: string,\n\t\tpackageInfoSource?: IContainerPackageInfo,\n\t): Promise<string> {\n\t\tthrow new Error(\"Not implemented\");\n\t}\n}\n\nasync function initializeFluidOfficeOrOneNote(\n\turlSource: URL,\n): Promise<IOdspUrlParts | undefined> {\n\tconst pathname = urlSource.pathname;\n\tconst siteDriveItemMatch = pathname.match(\n\t\t/\\/(p|preview|meetingnotes|notes)\\/([^/]*)\\/([^/]*)\\/([^/]*)/,\n\t);\n\tif (siteDriveItemMatch === null) {\n\t\treturn undefined;\n\t}\n\n\t// TODO Why are we non null asserting here\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst site = decodeURIComponent(siteDriveItemMatch[2]!);\n\n\t// Path value is base64 encoded so need to decode first\n\tconst decodedSite = fromBase64ToUtf8(site);\n\n\t// Site value includes storage type\n\tconst storageType = decodedSite.split(\":\")[0];\n\tconst expectedStorageType = \"spo\"; // Only support spo for now\n\tif (storageType !== expectedStorageType) {\n\t\tthrow new Error(\n\t\t\t`Unexpected storage type ${storageType}, expected: ${expectedStorageType}`,\n\t\t);\n\t}\n\n\t// Since we have the drive and item, only take the host ignore the rest\n\tconst siteUrl = decodedSite.slice(Math.max(0, storageType.length + 1));\n\t// TODO Why are we non null asserting here\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst driveId = decodeURIComponent(siteDriveItemMatch[3]!);\n\t// TODO Why are we non null asserting here\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst itemId = decodeURIComponent(siteDriveItemMatch[4]!);\n\treturn { siteUrl, driveId, itemId };\n}\n"]}
package/internal.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  /*
7
7
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints" in @fluidframework/build-tools.
8
+ * Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  export * from "./lib/index.js";
package/lib/public.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  /*
7
7
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints" in @fluidframework/build-tools.
8
+ * Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  export {}
@@ -87,6 +87,8 @@ async function initializeFluidOfficeOrOneNote(urlSource) {
87
87
  if (siteDriveItemMatch === null) {
88
88
  return undefined;
89
89
  }
90
+ // TODO Why are we non null asserting here
91
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
90
92
  const site = decodeURIComponent(siteDriveItemMatch[2]);
91
93
  // Path value is base64 encoded so need to decode first
92
94
  const decodedSite = fromBase64ToUtf8(site);
@@ -98,7 +100,11 @@ async function initializeFluidOfficeOrOneNote(urlSource) {
98
100
  }
99
101
  // Since we have the drive and item, only take the host ignore the rest
100
102
  const siteUrl = decodedSite.slice(Math.max(0, storageType.length + 1));
103
+ // TODO Why are we non null asserting here
104
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
101
105
  const driveId = decodeURIComponent(siteDriveItemMatch[3]);
106
+ // TODO Why are we non null asserting here
107
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
102
108
  const itemId = decodeURIComponent(siteDriveItemMatch[4]);
103
109
  return { siteUrl, driveId, itemId };
104
110
  }
@@ -1 +1 @@
1
- {"version":3,"file":"urlResolver.js","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAM7D,OAAO,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,CAAC;CACD;AAED,KAAK,UAAU,8BAA8B,CAC5C,SAAc;IAEd,MAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;IACpC,MAAM,kBAAkB,GAAG,QAAQ,CAAC,KAAK,CACxC,6DAA6D,CAC7D,CAAC;IACF,IAAI,kBAAkB,KAAK,IAAI,EAAE,CAAC;QACjC,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,MAAM,IAAI,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;IAEvD,uDAAuD;IACvD,MAAM,WAAW,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAE3C,mCAAmC;IACnC,MAAM,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,MAAM,mBAAmB,GAAG,KAAK,CAAC,CAAC,2BAA2B;IAC9D,IAAI,WAAW,KAAK,mBAAmB,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CACd,2BAA2B,WAAW,eAAe,mBAAmB,EAAE,CAC1E,CAAC;IACH,CAAC;IAED,uEAAuE;IACvE,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IACvE,MAAM,OAAO,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,MAAM,MAAM,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACrC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fromBase64ToUtf8 } from \"@fluid-internal/client-utils\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIContainerPackageInfo,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tOdspDriverUrlResolver,\n\tcreateOdspUrl,\n\tgetOdspUrlParts,\n\tisOdcUrl,\n\tisSpoUrl,\n} from \"@fluidframework/odsp-driver/internal\";\nimport { IOdspUrlParts } from \"@fluidframework/odsp-driver-definitions/internal\";\n\nconst fluidOfficeAndOneNoteServers = new Set([\n\t\"dev.fluidpreview.office.net\",\n\t\"fluidpreview.office.net\",\n\t\"www.onenote.com\",\n]);\n\n/**\n * @internal\n */\nexport class OdspUrlResolver implements IUrlResolver {\n\tpublic async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {\n\t\tconst reqUrl = new URL(request.url);\n\t\tif (isOdspUrl(reqUrl)) {\n\t\t\tconst contents = await getOdspUrlParts(reqUrl);\n\t\t\tif (!contents) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst urlToBeResolved = createOdspUrl({ ...contents, dataStorePath: \"\" });\n\t\t\tconst odspDriverUrlResolver: IUrlResolver = new OdspDriverUrlResolver();\n\t\t\treturn odspDriverUrlResolver.resolve({\n\t\t\t\turl: urlToBeResolved,\n\t\t\t\theaders: request.headers,\n\t\t\t});\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\trelativeUrl: string,\n\t): Promise<string> {\n\t\tthrow new Error(\"Not implemented\");\n\t}\n}\n\n/**\n * Returns true if the given string is a valid SPO/ODB or ODC URL.\n *\n * @internal\n */\nconst isOdspUrl = (url: URL): boolean => {\n\treturn isSpoUrl(url) || isOdcUrl(url);\n};\n\n/**\n * This class helps to resolve Fluid URLs from Office and OneNote. Construct the resolver class and invoke its resolve function to retrieve the content parameters.\n * @internal\n */\nexport class FluidAppOdspUrlResolver implements IUrlResolver {\n\tpublic async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {\n\t\tconst reqUrl = new URL(request.url);\n\t\tconst server = reqUrl.hostname.toLowerCase();\n\t\tlet contents: IOdspUrlParts | undefined;\n\t\tif (fluidOfficeAndOneNoteServers.has(server)) {\n\t\t\tcontents = await initializeFluidOfficeOrOneNote(reqUrl);\n\t\t} else if (server === \"www.office.com\") {\n\t\t\tconst getRequiredParam = (name: string): string => {\n\t\t\t\tconst value = reqUrl.searchParams.get(name);\n\t\t\t\tassert(!!value, 0x097 /* Missing param from office.com URL parameter */);\n\t\t\t\treturn value;\n\t\t\t};\n\t\t\tcontents = {\n\t\t\t\tdriveId: getRequiredParam(\"drive\"),\n\t\t\t\titemId: getRequiredParam(\"item\"),\n\t\t\t\tsiteUrl: getRequiredParam(\"siteUrl\"),\n\t\t\t};\n\t\t} else {\n\t\t\treturn undefined;\n\t\t}\n\t\tif (!contents) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst urlToBeResolved = createOdspUrl({ ...contents, dataStorePath: \"\" });\n\t\tconst odspDriverUrlResolver: IUrlResolver = new OdspDriverUrlResolver();\n\t\treturn odspDriverUrlResolver.resolve({ url: urlToBeResolved });\n\t}\n\n\t// TODO: Issue-2109 Implement detach container api or put appropriate comment.\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\trelativeUrl: string,\n\t\tpackageInfoSource?: IContainerPackageInfo,\n\t): Promise<string> {\n\t\tthrow new Error(\"Not implemented\");\n\t}\n}\n\nasync function initializeFluidOfficeOrOneNote(\n\turlSource: URL,\n): Promise<IOdspUrlParts | undefined> {\n\tconst pathname = urlSource.pathname;\n\tconst siteDriveItemMatch = pathname.match(\n\t\t/\\/(p|preview|meetingnotes|notes)\\/([^/]*)\\/([^/]*)\\/([^/]*)/,\n\t);\n\tif (siteDriveItemMatch === null) {\n\t\treturn undefined;\n\t}\n\n\tconst site = decodeURIComponent(siteDriveItemMatch[2]);\n\n\t// Path value is base64 encoded so need to decode first\n\tconst decodedSite = fromBase64ToUtf8(site);\n\n\t// Site value includes storage type\n\tconst storageType = decodedSite.split(\":\")[0];\n\tconst expectedStorageType = \"spo\"; // Only support spo for now\n\tif (storageType !== expectedStorageType) {\n\t\tthrow new Error(\n\t\t\t`Unexpected storage type ${storageType}, expected: ${expectedStorageType}`,\n\t\t);\n\t}\n\n\t// Since we have the drive and item, only take the host ignore the rest\n\tconst siteUrl = decodedSite.slice(Math.max(0, storageType.length + 1));\n\tconst driveId = decodeURIComponent(siteDriveItemMatch[3]);\n\tconst itemId = decodeURIComponent(siteDriveItemMatch[4]);\n\treturn { siteUrl, driveId, itemId };\n}\n"]}
1
+ {"version":3,"file":"urlResolver.js","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAM7D,OAAO,EACN,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,QAAQ,EACR,QAAQ,GACR,MAAM,sCAAsC,CAAC;AAG9C,MAAM,4BAA4B,GAAG,IAAI,GAAG,CAAC;IAC5C,6BAA6B;IAC7B,yBAAyB;IACzB,iBAAiB;CACjB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,OAAO,eAAe;IACpB,KAAK,CAAC,OAAO,CAAC,OAAiB;QACrC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACpC,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YACvB,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,MAAM,CAAC,CAAC;YAC/C,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACf,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,MAAM,eAAe,GAAG,aAAa,CAAC,EAAE,GAAG,QAAQ,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC;YAC1E,MAAM,qBAAqB,GAAiB,IAAI,qBAA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BAA2B,WAAW,eAAe,mBAAmB,EAAE,CAC1E,CAAC;IACH,CAAC;IAED,uEAAuE;IACvE,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IACvE,0CAA0C;IAC1C,oEAAoE;IACpE,MAAM,OAAO,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,CAAC,CAAE,CAAC,CAAC;IAC3D,0CAA0C;IAC1C,oEAAoE;IACpE,MAAM,MAAM,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,CAAC,CAAE,CAAC,CAAC;IAC1D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACrC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fromBase64ToUtf8 } from \"@fluid-internal/client-utils\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIContainerPackageInfo,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tOdspDriverUrlResolver,\n\tcreateOdspUrl,\n\tgetOdspUrlParts,\n\tisOdcUrl,\n\tisSpoUrl,\n} from \"@fluidframework/odsp-driver/internal\";\nimport { IOdspUrlParts } from \"@fluidframework/odsp-driver-definitions/internal\";\n\nconst fluidOfficeAndOneNoteServers = new Set([\n\t\"dev.fluidpreview.office.net\",\n\t\"fluidpreview.office.net\",\n\t\"www.onenote.com\",\n]);\n\n/**\n * @internal\n */\nexport class OdspUrlResolver implements IUrlResolver {\n\tpublic async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {\n\t\tconst reqUrl = new URL(request.url);\n\t\tif (isOdspUrl(reqUrl)) {\n\t\t\tconst contents = await getOdspUrlParts(reqUrl);\n\t\t\tif (!contents) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst urlToBeResolved = createOdspUrl({ ...contents, dataStorePath: \"\" });\n\t\t\tconst odspDriverUrlResolver: IUrlResolver = new OdspDriverUrlResolver();\n\t\t\treturn odspDriverUrlResolver.resolve({\n\t\t\t\turl: urlToBeResolved,\n\t\t\t\theaders: request.headers,\n\t\t\t});\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\trelativeUrl: string,\n\t): Promise<string> {\n\t\tthrow new Error(\"Not implemented\");\n\t}\n}\n\n/**\n * Returns true if the given string is a valid SPO/ODB or ODC URL.\n *\n * @internal\n */\nconst isOdspUrl = (url: URL): boolean => {\n\treturn isSpoUrl(url) || isOdcUrl(url);\n};\n\n/**\n * This class helps to resolve Fluid URLs from Office and OneNote. Construct the resolver class and invoke its resolve function to retrieve the content parameters.\n * @internal\n */\nexport class FluidAppOdspUrlResolver implements IUrlResolver {\n\tpublic async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {\n\t\tconst reqUrl = new URL(request.url);\n\t\tconst server = reqUrl.hostname.toLowerCase();\n\t\tlet contents: IOdspUrlParts | undefined;\n\t\tif (fluidOfficeAndOneNoteServers.has(server)) {\n\t\t\tcontents = await initializeFluidOfficeOrOneNote(reqUrl);\n\t\t} else if (server === \"www.office.com\") {\n\t\t\tconst getRequiredParam = (name: string): string => {\n\t\t\t\tconst value = reqUrl.searchParams.get(name);\n\t\t\t\tassert(!!value, 0x097 /* Missing param from office.com URL parameter */);\n\t\t\t\treturn value;\n\t\t\t};\n\t\t\tcontents = {\n\t\t\t\tdriveId: getRequiredParam(\"drive\"),\n\t\t\t\titemId: getRequiredParam(\"item\"),\n\t\t\t\tsiteUrl: getRequiredParam(\"siteUrl\"),\n\t\t\t};\n\t\t} else {\n\t\t\treturn undefined;\n\t\t}\n\t\tif (!contents) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst urlToBeResolved = createOdspUrl({ ...contents, dataStorePath: \"\" });\n\t\tconst odspDriverUrlResolver: IUrlResolver = new OdspDriverUrlResolver();\n\t\treturn odspDriverUrlResolver.resolve({ url: urlToBeResolved });\n\t}\n\n\t// TODO: Issue-2109 Implement detach container api or put appropriate comment.\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\trelativeUrl: string,\n\t\tpackageInfoSource?: IContainerPackageInfo,\n\t): Promise<string> {\n\t\tthrow new Error(\"Not implemented\");\n\t}\n}\n\nasync function initializeFluidOfficeOrOneNote(\n\turlSource: URL,\n): Promise<IOdspUrlParts | undefined> {\n\tconst pathname = urlSource.pathname;\n\tconst siteDriveItemMatch = pathname.match(\n\t\t/\\/(p|preview|meetingnotes|notes)\\/([^/]*)\\/([^/]*)\\/([^/]*)/,\n\t);\n\tif (siteDriveItemMatch === null) {\n\t\treturn undefined;\n\t}\n\n\t// TODO Why are we non null asserting here\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst site = decodeURIComponent(siteDriveItemMatch[2]!);\n\n\t// Path value is base64 encoded so need to decode first\n\tconst decodedSite = fromBase64ToUtf8(site);\n\n\t// Site value includes storage type\n\tconst storageType = decodedSite.split(\":\")[0];\n\tconst expectedStorageType = \"spo\"; // Only support spo for now\n\tif (storageType !== expectedStorageType) {\n\t\tthrow new Error(\n\t\t\t`Unexpected storage type ${storageType}, expected: ${expectedStorageType}`,\n\t\t);\n\t}\n\n\t// Since we have the drive and item, only take the host ignore the rest\n\tconst siteUrl = decodedSite.slice(Math.max(0, storageType.length + 1));\n\t// TODO Why are we non null asserting here\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst driveId = decodeURIComponent(siteDriveItemMatch[3]!);\n\t// TODO Why are we non null asserting here\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst itemId = decodeURIComponent(siteDriveItemMatch[4]!);\n\treturn { siteUrl, driveId, itemId };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/odsp-urlresolver",
3
- "version": "2.1.0-276985",
3
+ "version": "2.1.0",
4
4
  "description": "Url Resolver for odsp urls.",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -37,22 +37,22 @@
37
37
  "main": "lib/index.js",
38
38
  "types": "lib/public.d.ts",
39
39
  "dependencies": {
40
- "@fluid-internal/client-utils": "2.1.0-276985",
41
- "@fluidframework/core-interfaces": "2.1.0-276985",
42
- "@fluidframework/core-utils": "2.1.0-276985",
43
- "@fluidframework/driver-definitions": "2.1.0-276985",
44
- "@fluidframework/odsp-driver": "2.1.0-276985",
45
- "@fluidframework/odsp-driver-definitions": "2.1.0-276985"
40
+ "@fluid-internal/client-utils": "~2.1.0",
41
+ "@fluidframework/core-interfaces": "~2.1.0",
42
+ "@fluidframework/core-utils": "~2.1.0",
43
+ "@fluidframework/driver-definitions": "~2.1.0",
44
+ "@fluidframework/odsp-driver": "~2.1.0",
45
+ "@fluidframework/odsp-driver-definitions": "~2.1.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@arethetypeswrong/cli": "^0.15.2",
49
- "@biomejs/biome": "^1.7.3",
50
- "@fluid-internal/mocha-test-setup": "2.1.0-276985",
51
- "@fluid-tools/build-cli": "^0.39.0",
49
+ "@biomejs/biome": "~1.8.3",
50
+ "@fluid-internal/mocha-test-setup": "~2.1.0",
51
+ "@fluid-tools/build-cli": "^0.41.0",
52
52
  "@fluidframework/build-common": "^2.0.3",
53
- "@fluidframework/build-tools": "^0.39.0",
53
+ "@fluidframework/build-tools": "^0.41.0",
54
54
  "@fluidframework/eslint-config-fluid": "^5.3.0",
55
- "@fluidframework/odsp-urlresolver-previous": "npm:@fluidframework/odsp-urlresolver@2.0.0-rc.5.0.0",
55
+ "@fluidframework/odsp-urlresolver-previous": "npm:@fluidframework/odsp-urlresolver@2.0.0",
56
56
  "@microsoft/api-extractor": "^7.45.1",
57
57
  "@types/mocha": "^9.1.1",
58
58
  "@types/node": "^18.19.0",
@@ -84,7 +84,7 @@
84
84
  "build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
85
85
  "build:test:esm": "tsc --project ./src/test/tsconfig.json",
86
86
  "check:are-the-types-wrong": "attw --pack .",
87
- "check:biome": "biome check . --formatter-enabled=true",
87
+ "check:biome": "biome check .",
88
88
  "check:exports": "concurrently \"npm:check:exports:*\"",
89
89
  "check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
90
90
  "check:exports:cjs:public": "api-extractor run --config api-extractor/api-extractor-lint-public.cjs.json",
@@ -96,7 +96,7 @@
96
96
  "eslint": "eslint --format stylish src",
97
97
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
98
98
  "format": "npm run format:biome",
99
- "format:biome": "biome check . --formatter-enabled=true --apply",
99
+ "format:biome": "biome check . --write",
100
100
  "format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
101
101
  "lint": "fluid-build . --task lint",
102
102
  "lint:fix": "fluid-build . --task eslint:fix --task format",
@@ -118,7 +118,9 @@ async function initializeFluidOfficeOrOneNote(
118
118
  return undefined;
119
119
  }
120
120
 
121
- const site = decodeURIComponent(siteDriveItemMatch[2]);
121
+ // TODO Why are we non null asserting here
122
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
123
+ const site = decodeURIComponent(siteDriveItemMatch[2]!);
122
124
 
123
125
  // Path value is base64 encoded so need to decode first
124
126
  const decodedSite = fromBase64ToUtf8(site);
@@ -134,7 +136,11 @@ async function initializeFluidOfficeOrOneNote(
134
136
 
135
137
  // Since we have the drive and item, only take the host ignore the rest
136
138
  const siteUrl = decodedSite.slice(Math.max(0, storageType.length + 1));
137
- const driveId = decodeURIComponent(siteDriveItemMatch[3]);
138
- const itemId = decodeURIComponent(siteDriveItemMatch[4]);
139
+ // TODO Why are we non null asserting here
140
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
141
+ const driveId = decodeURIComponent(siteDriveItemMatch[3]!);
142
+ // TODO Why are we non null asserting here
143
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
144
+ const itemId = decodeURIComponent(siteDriveItemMatch[4]!);
139
145
  return { siteUrl, driveId, itemId };
140
146
  }
package/tsconfig.json CHANGED
@@ -5,7 +5,6 @@
5
5
  "compilerOptions": {
6
6
  "rootDir": "./src",
7
7
  "outDir": "./lib",
8
- "noUncheckedIndexedAccess": false,
9
8
  "exactOptionalPropertyTypes": false,
10
9
  },
11
10
  }