@fluidframework/odsp-urlresolver 2.0.0-dev-rc.1.0.0.225277 → 2.0.0-dev-rc.1.0.0.232845
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 +4 -0
- package/README.md +0 -6
- package/api-report/odsp-urlresolver.api.md +9 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/{index.cjs → index.js} +4 -3
- package/dist/index.js.map +1 -0
- package/dist/odsp-urlresolver-alpha.d.ts +3 -0
- package/dist/odsp-urlresolver-beta.d.ts +5 -0
- package/dist/odsp-urlresolver-public.d.ts +5 -0
- package/dist/odsp-urlresolver-untrimmed.d.ts +10 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/urlResolver.d.ts +9 -1
- package/dist/urlResolver.d.ts.map +1 -1
- package/dist/urlResolver.js +111 -0
- package/dist/urlResolver.js.map +1 -0
- package/lib/index.d.mts +1 -1
- package/lib/index.d.mts.map +1 -1
- package/lib/index.mjs +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/odsp-urlresolver-alpha.d.mts +3 -0
- package/lib/odsp-urlresolver-beta.d.mts +5 -0
- package/lib/odsp-urlresolver-public.d.mts +5 -0
- package/lib/odsp-urlresolver-untrimmed.d.mts +10 -0
- package/lib/urlResolver.d.mts +9 -1
- package/lib/urlResolver.d.mts.map +1 -1
- package/lib/urlResolver.mjs +67 -0
- package/lib/urlResolver.mjs.map +1 -1
- package/package.json +20 -18
- package/src/index.ts +1 -1
- package/src/urlResolver.ts +85 -1
- package/dist/index.cjs.map +0 -1
- package/dist/urlResolver.cjs +0 -43
- package/dist/urlResolver.cjs.map +0 -1
- package/tsc-multi.test.json +0 -4
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -13,12 +13,6 @@ When taking a dependency on a Fluid Framework library, we recommend using a `^`
|
|
|
13
13
|
While Fluid Framework libraries may use different ranges with interdependencies between other Fluid Framework libraries,
|
|
14
14
|
library consumers should always prefer `^`.
|
|
15
15
|
|
|
16
|
-
Note that when depending on a library version of the form `2.0.0-internal.x.y.z`, called the Fluid internal version scheme,
|
|
17
|
-
you must use a `>= <` dependency range (such as `>=2.0.0-internal.x.y.z <2.0.0-internal.w.0.0` where `w` is `x+1`).
|
|
18
|
-
Standard `^` and `~` ranges will not work as expected.
|
|
19
|
-
See the [@fluid-tools/version-tools](https://github.com/microsoft/FluidFramework/blob/main/build-tools/packages/version-tools/README.md)
|
|
20
|
-
package for more information including tools to convert between version schemes.
|
|
21
|
-
|
|
22
16
|
<!-- prettier-ignore-end -->
|
|
23
17
|
|
|
24
18
|
<!-- AUTO-GENERATED-CONTENT:END -->
|
|
@@ -4,10 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
|
|
7
|
+
import { IContainerPackageInfo } from '@fluidframework/driver-definitions';
|
|
7
8
|
import { IRequest } from '@fluidframework/core-interfaces';
|
|
8
9
|
import { IResolvedUrl } from '@fluidframework/driver-definitions';
|
|
9
10
|
import { IUrlResolver } from '@fluidframework/driver-definitions';
|
|
10
11
|
|
|
12
|
+
// @internal
|
|
13
|
+
export class FluidAppOdspUrlResolver implements IUrlResolver {
|
|
14
|
+
// (undocumented)
|
|
15
|
+
getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string, packageInfoSource?: IContainerPackageInfo): Promise<string>;
|
|
16
|
+
// (undocumented)
|
|
17
|
+
resolve(request: IRequest): Promise<IResolvedUrl | undefined>;
|
|
18
|
+
}
|
|
19
|
+
|
|
11
20
|
// @internal
|
|
12
21
|
export const isOdspUrl: (url: string) => boolean;
|
|
13
22
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { isOdspUrl, OdspUrlResolver } from "./urlResolver";
|
|
5
|
+
export { isOdspUrl, FluidAppOdspUrlResolver, OdspUrlResolver } from "./urlResolver";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.OdspUrlResolver = exports.isOdspUrl = void 0;
|
|
8
|
-
var urlResolver_1 = require("./urlResolver
|
|
7
|
+
exports.OdspUrlResolver = exports.FluidAppOdspUrlResolver = exports.isOdspUrl = void 0;
|
|
8
|
+
var urlResolver_1 = require("./urlResolver");
|
|
9
9
|
Object.defineProperty(exports, "isOdspUrl", { enumerable: true, get: function () { return urlResolver_1.isOdspUrl; } });
|
|
10
|
+
Object.defineProperty(exports, "FluidAppOdspUrlResolver", { enumerable: true, get: function () { return urlResolver_1.FluidAppOdspUrlResolver; } });
|
|
10
11
|
Object.defineProperty(exports, "OdspUrlResolver", { enumerable: true, get: function () { return urlResolver_1.OdspUrlResolver; } });
|
|
11
|
-
//# sourceMappingURL=index.
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6CAAoF;AAA3E,wGAAA,SAAS,OAAA;AAAE,sHAAA,uBAAuB,OAAA;AAAE,8GAAA,eAAe,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { isOdspUrl, FluidAppOdspUrlResolver, OdspUrlResolver } from \"./urlResolver\";\n"]}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { IContainerPackageInfo } from '@fluidframework/driver-definitions';
|
|
1
2
|
import { IRequest } from '@fluidframework/core-interfaces';
|
|
2
3
|
import { IResolvedUrl } from '@fluidframework/driver-definitions';
|
|
3
4
|
import { IUrlResolver } from '@fluidframework/driver-definitions';
|
|
4
5
|
|
|
6
|
+
/* Excluded from this release type: FluidAppOdspUrlResolver */
|
|
7
|
+
|
|
5
8
|
/* Excluded from this release type: isOdspUrl */
|
|
6
9
|
|
|
7
10
|
/* Excluded from this release type: OdspUrlResolver */
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { IContainerPackageInfo } from '@fluidframework/driver-definitions';
|
|
1
2
|
import { IRequest } from '@fluidframework/core-interfaces';
|
|
2
3
|
import { IResolvedUrl } from '@fluidframework/driver-definitions';
|
|
3
4
|
import { IUrlResolver } from '@fluidframework/driver-definitions';
|
|
4
5
|
|
|
6
|
+
/* Excluded from this release type: FluidAppOdspUrlResolver */
|
|
7
|
+
|
|
8
|
+
/* Excluded from this release type: IContainerPackageInfo */
|
|
9
|
+
|
|
5
10
|
/* Excluded from this release type: IResolvedUrl */
|
|
6
11
|
|
|
7
12
|
/* Excluded from this release type: isOdspUrl */
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { IContainerPackageInfo } from '@fluidframework/driver-definitions';
|
|
1
2
|
import { IRequest } from '@fluidframework/core-interfaces';
|
|
2
3
|
import { IResolvedUrl } from '@fluidframework/driver-definitions';
|
|
3
4
|
import { IUrlResolver } from '@fluidframework/driver-definitions';
|
|
4
5
|
|
|
6
|
+
/* Excluded from this release type: FluidAppOdspUrlResolver */
|
|
7
|
+
|
|
8
|
+
/* Excluded from this release type: IContainerPackageInfo */
|
|
9
|
+
|
|
5
10
|
/* Excluded from this release type: IResolvedUrl */
|
|
6
11
|
|
|
7
12
|
/* Excluded from this release type: isOdspUrl */
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
+
import { IContainerPackageInfo } from '@fluidframework/driver-definitions';
|
|
1
2
|
import { IRequest } from '@fluidframework/core-interfaces';
|
|
2
3
|
import { IResolvedUrl } from '@fluidframework/driver-definitions';
|
|
3
4
|
import { IUrlResolver } from '@fluidframework/driver-definitions';
|
|
4
5
|
|
|
6
|
+
/**
|
|
7
|
+
* 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.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare class FluidAppOdspUrlResolver implements IUrlResolver {
|
|
11
|
+
resolve(request: IRequest): Promise<IResolvedUrl | undefined>;
|
|
12
|
+
getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string, packageInfoSource?: IContainerPackageInfo): Promise<string>;
|
|
13
|
+
}
|
|
14
|
+
|
|
5
15
|
/**
|
|
6
16
|
* Returns true if the given string is a valid SPO/ODB or ODC URL.
|
|
7
17
|
*
|
package/dist/tsdoc-metadata.json
CHANGED
package/dist/urlResolver.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { IRequest } from "@fluidframework/core-interfaces";
|
|
6
|
-
import { IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
|
|
6
|
+
import { IContainerPackageInfo, IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
|
|
7
7
|
/**
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
@@ -17,4 +17,12 @@ export declare class OdspUrlResolver implements IUrlResolver {
|
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
|
19
19
|
export declare const isOdspUrl: (url: string) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* 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.
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export declare class FluidAppOdspUrlResolver implements IUrlResolver {
|
|
25
|
+
resolve(request: IRequest): Promise<IResolvedUrl | undefined>;
|
|
26
|
+
getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string, packageInfoSource?: IContainerPackageInfo): Promise<string>;
|
|
27
|
+
}
|
|
20
28
|
//# sourceMappingURL=urlResolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlResolver.d.ts","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,
|
|
1
|
+
{"version":3,"file":"urlResolver.d.ts","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EACN,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAkB5C;;GAEG;AACH,qBAAa,eAAgB,YAAW,YAAY;IACtC,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IAiB7D,cAAc,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAG5F;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,QAAS,MAAM,KAAG,OAEvC,CAAC;AAEF;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,YAAY;IAC9C,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IA6B7D,cAAc,CAC1B,WAAW,EAAE,YAAY,EACzB,WAAW,EAAE,MAAM,EACnB,iBAAiB,CAAC,EAAE,qBAAqB,GACvC,OAAO,CAAC,MAAM,CAAC;CAGlB"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.FluidAppOdspUrlResolver = exports.isOdspUrl = exports.OdspUrlResolver = void 0;
|
|
8
|
+
const odsp_driver_1 = require("@fluidframework/odsp-driver");
|
|
9
|
+
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
10
|
+
const core_utils_1 = require("@fluidframework/core-utils");
|
|
11
|
+
const fluidOfficeAndOneNoteServers = new Set([
|
|
12
|
+
"dev.fluidpreview.office.net",
|
|
13
|
+
"fluidpreview.office.net",
|
|
14
|
+
"www.onenote.com",
|
|
15
|
+
]);
|
|
16
|
+
/**
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
class OdspUrlResolver {
|
|
20
|
+
async resolve(request) {
|
|
21
|
+
if ((0, exports.isOdspUrl)(request.url)) {
|
|
22
|
+
const reqUrl = new URL(request.url);
|
|
23
|
+
const contents = await (0, odsp_driver_1.getOdspUrlParts)(reqUrl);
|
|
24
|
+
if (!contents) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const urlToBeResolved = (0, odsp_driver_1.createOdspUrl)({ ...contents, dataStorePath: "" });
|
|
28
|
+
const odspDriverUrlResolver = new odsp_driver_1.OdspDriverUrlResolver();
|
|
29
|
+
return odspDriverUrlResolver.resolve({
|
|
30
|
+
url: urlToBeResolved,
|
|
31
|
+
headers: request.headers,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
async getAbsoluteUrl(resolvedUrl, relativeUrl) {
|
|
37
|
+
throw new Error("Not implemented");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.OdspUrlResolver = OdspUrlResolver;
|
|
41
|
+
/**
|
|
42
|
+
* Returns true if the given string is a valid SPO/ODB or ODC URL.
|
|
43
|
+
*
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
const isOdspUrl = (url) => {
|
|
47
|
+
return (0, odsp_driver_1.isSpoUrl)(url) || (0, odsp_driver_1.isOdcUrl)(url);
|
|
48
|
+
};
|
|
49
|
+
exports.isOdspUrl = isOdspUrl;
|
|
50
|
+
/**
|
|
51
|
+
* 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.
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
class FluidAppOdspUrlResolver {
|
|
55
|
+
async resolve(request) {
|
|
56
|
+
const reqUrl = new URL(request.url);
|
|
57
|
+
const server = reqUrl.hostname.toLowerCase();
|
|
58
|
+
let contents;
|
|
59
|
+
if (fluidOfficeAndOneNoteServers.has(server)) {
|
|
60
|
+
contents = await initializeFluidOfficeOrOneNote(reqUrl);
|
|
61
|
+
}
|
|
62
|
+
else if (server === "www.office.com") {
|
|
63
|
+
const getRequiredParam = (name) => {
|
|
64
|
+
const value = reqUrl.searchParams.get(name);
|
|
65
|
+
(0, core_utils_1.assert)(!!value, 0x097 /* Missing param from office.com URL parameter */);
|
|
66
|
+
return value;
|
|
67
|
+
};
|
|
68
|
+
contents = {
|
|
69
|
+
driveId: getRequiredParam("drive"),
|
|
70
|
+
itemId: getRequiredParam("item"),
|
|
71
|
+
siteUrl: getRequiredParam("siteUrl"),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
if (!contents) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
const urlToBeResolved = (0, odsp_driver_1.createOdspUrl)({ ...contents, dataStorePath: "" });
|
|
81
|
+
const odspDriverUrlResolver = new odsp_driver_1.OdspDriverUrlResolver();
|
|
82
|
+
return odspDriverUrlResolver.resolve({ url: urlToBeResolved });
|
|
83
|
+
}
|
|
84
|
+
// TODO: Issue-2109 Implement detach container api or put appropriate comment.
|
|
85
|
+
async getAbsoluteUrl(resolvedUrl, relativeUrl, packageInfoSource) {
|
|
86
|
+
throw new Error("Not implemented");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.FluidAppOdspUrlResolver = FluidAppOdspUrlResolver;
|
|
90
|
+
async function initializeFluidOfficeOrOneNote(urlSource) {
|
|
91
|
+
const pathname = urlSource.pathname;
|
|
92
|
+
const siteDriveItemMatch = pathname.match(/\/(p|preview|meetingnotes|notes)\/([^/]*)\/([^/]*)\/([^/]*)/);
|
|
93
|
+
if (siteDriveItemMatch === null) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
const site = decodeURIComponent(siteDriveItemMatch[2]);
|
|
97
|
+
// Path value is base64 encoded so need to decode first
|
|
98
|
+
const decodedSite = (0, client_utils_1.fromBase64ToUtf8)(site);
|
|
99
|
+
// Site value includes storage type
|
|
100
|
+
const storageType = decodedSite.split(":")[0];
|
|
101
|
+
const expectedStorageType = "spo"; // Only support spo for now
|
|
102
|
+
if (storageType !== expectedStorageType) {
|
|
103
|
+
throw new Error(`Unexpected storage type ${storageType}, expected: ${expectedStorageType}`);
|
|
104
|
+
}
|
|
105
|
+
// Since we have the drive and item, only take the host ignore the rest
|
|
106
|
+
const siteUrl = decodedSite.slice(Math.max(0, storageType.length + 1));
|
|
107
|
+
const driveId = decodeURIComponent(siteDriveItemMatch[3]);
|
|
108
|
+
const itemId = decodeURIComponent(siteDriveItemMatch[4]);
|
|
109
|
+
return { siteUrl, driveId, itemId };
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=urlResolver.js.map
|
|
@@ -0,0 +1 @@
|
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B,iBAAyC;QAEzC,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD;AArCD,0DAqCC;AAED,KAAK,UAAU,8BAA8B,CAAC,SAAc;IAC3D,MAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;IACpC,MAAM,kBAAkB,GAAG,QAAQ,CAAC,KAAK,CACxC,6DAA6D,CAC7D,CAAC;IACF,IAAI,kBAAkB,KAAK,IAAI,EAAE;QAChC,OAAO,SAAS,CAAC;KACjB;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;QACxC,MAAM,IAAI,KAAK,CAAC,2BAA2B,WAAW,eAAe,mBAAmB,EAAE,CAAC,CAAC;KAC5F;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 { IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n\tIContainerPackageInfo,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tcreateOdspUrl,\n\tOdspDriverUrlResolver,\n\tisSpoUrl,\n\tisOdcUrl,\n\tgetOdspUrlParts,\n} from \"@fluidframework/odsp-driver\";\nimport { fromBase64ToUtf8 } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IOdspUrlParts } from \"@fluidframework/odsp-driver-definitions\";\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\tif (isOdspUrl(request.url)) {\n\t\t\tconst reqUrl = new URL(request.url);\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(resolvedUrl: IResolvedUrl, relativeUrl: string): 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 */\nexport const isOdspUrl = (url: string): 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(urlSource: URL): 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(`Unexpected storage type ${storageType}, expected: ${expectedStorageType}`);\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"]}
|
package/lib/index.d.mts
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { isOdspUrl, OdspUrlResolver } from "./urlResolver.mjs";
|
|
5
|
+
export { isOdspUrl, FluidAppOdspUrlResolver, OdspUrlResolver } from "./urlResolver.mjs";
|
|
6
6
|
//# sourceMappingURL=index.d.mts.map
|
package/lib/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,SAAS,EAAE,eAAe,EAAE"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,SAAS,EAAE,uBAAuB,EAAE,eAAe,EAAE"}
|
package/lib/index.mjs
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { isOdspUrl, OdspUrlResolver } from "./urlResolver.mjs";
|
|
5
|
+
export { isOdspUrl, FluidAppOdspUrlResolver, OdspUrlResolver } from "./urlResolver.mjs";
|
|
6
6
|
//# sourceMappingURL=index.mjs.map
|
package/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,SAAS,EAAE,eAAe,EAAE","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { isOdspUrl, OdspUrlResolver } from \"./urlResolver\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,SAAS,EAAE,uBAAuB,EAAE,eAAe,EAAE","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { isOdspUrl, FluidAppOdspUrlResolver, OdspUrlResolver } from \"./urlResolver\";\n"]}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { IContainerPackageInfo } from '@fluidframework/driver-definitions';
|
|
1
2
|
import { IRequest } from '@fluidframework/core-interfaces';
|
|
2
3
|
import { IResolvedUrl } from '@fluidframework/driver-definitions';
|
|
3
4
|
import { IUrlResolver } from '@fluidframework/driver-definitions';
|
|
4
5
|
|
|
6
|
+
/* Excluded from this release type: FluidAppOdspUrlResolver */
|
|
7
|
+
|
|
5
8
|
/* Excluded from this release type: isOdspUrl */
|
|
6
9
|
|
|
7
10
|
/* Excluded from this release type: OdspUrlResolver */
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { IContainerPackageInfo } from '@fluidframework/driver-definitions';
|
|
1
2
|
import { IRequest } from '@fluidframework/core-interfaces';
|
|
2
3
|
import { IResolvedUrl } from '@fluidframework/driver-definitions';
|
|
3
4
|
import { IUrlResolver } from '@fluidframework/driver-definitions';
|
|
4
5
|
|
|
6
|
+
/* Excluded from this release type: FluidAppOdspUrlResolver */
|
|
7
|
+
|
|
8
|
+
/* Excluded from this release type: IContainerPackageInfo */
|
|
9
|
+
|
|
5
10
|
/* Excluded from this release type: IResolvedUrl */
|
|
6
11
|
|
|
7
12
|
/* Excluded from this release type: isOdspUrl */
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { IContainerPackageInfo } from '@fluidframework/driver-definitions';
|
|
1
2
|
import { IRequest } from '@fluidframework/core-interfaces';
|
|
2
3
|
import { IResolvedUrl } from '@fluidframework/driver-definitions';
|
|
3
4
|
import { IUrlResolver } from '@fluidframework/driver-definitions';
|
|
4
5
|
|
|
6
|
+
/* Excluded from this release type: FluidAppOdspUrlResolver */
|
|
7
|
+
|
|
8
|
+
/* Excluded from this release type: IContainerPackageInfo */
|
|
9
|
+
|
|
5
10
|
/* Excluded from this release type: IResolvedUrl */
|
|
6
11
|
|
|
7
12
|
/* Excluded from this release type: isOdspUrl */
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
+
import { IContainerPackageInfo } from '@fluidframework/driver-definitions';
|
|
1
2
|
import { IRequest } from '@fluidframework/core-interfaces';
|
|
2
3
|
import { IResolvedUrl } from '@fluidframework/driver-definitions';
|
|
3
4
|
import { IUrlResolver } from '@fluidframework/driver-definitions';
|
|
4
5
|
|
|
6
|
+
/**
|
|
7
|
+
* 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.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare class FluidAppOdspUrlResolver implements IUrlResolver {
|
|
11
|
+
resolve(request: IRequest): Promise<IResolvedUrl | undefined>;
|
|
12
|
+
getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string, packageInfoSource?: IContainerPackageInfo): Promise<string>;
|
|
13
|
+
}
|
|
14
|
+
|
|
5
15
|
/**
|
|
6
16
|
* Returns true if the given string is a valid SPO/ODB or ODC URL.
|
|
7
17
|
*
|
package/lib/urlResolver.d.mts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { IRequest } from "@fluidframework/core-interfaces";
|
|
6
|
-
import { IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
|
|
6
|
+
import { IContainerPackageInfo, IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
|
|
7
7
|
/**
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
@@ -17,4 +17,12 @@ export declare class OdspUrlResolver implements IUrlResolver {
|
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
|
19
19
|
export declare const isOdspUrl: (url: string) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* 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.
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export declare class FluidAppOdspUrlResolver implements IUrlResolver {
|
|
25
|
+
resolve(request: IRequest): Promise<IResolvedUrl | undefined>;
|
|
26
|
+
getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string, packageInfoSource?: IContainerPackageInfo): Promise<string>;
|
|
27
|
+
}
|
|
20
28
|
//# sourceMappingURL=urlResolver.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlResolver.d.mts","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,QAAQ,EAAE,MAAM,iCAAiC;OACnD,
|
|
1
|
+
{"version":3,"file":"urlResolver.d.mts","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,QAAQ,EAAE,MAAM,iCAAiC;OACnD,EACN,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACZ,MAAM,oCAAoC;AAkB3C;;GAEG;AACH,qBAAa,eAAgB,YAAW,YAAY;IACtC,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IAiB7D,cAAc,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAG5F;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,QAAS,MAAM,KAAG,OAEvC,CAAC;AAEF;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,YAAY;IAC9C,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IA6B7D,cAAc,CAC1B,WAAW,EAAE,YAAY,EACzB,WAAW,EAAE,MAAM,EACnB,iBAAiB,CAAC,EAAE,qBAAqB,GACvC,OAAO,CAAC,MAAM,CAAC;CAGlB"}
|
package/lib/urlResolver.mjs
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { createOdspUrl, OdspDriverUrlResolver, isSpoUrl, isOdcUrl, getOdspUrlParts, } from "@fluidframework/odsp-driver";
|
|
6
|
+
import { fromBase64ToUtf8 } from "@fluid-internal/client-utils";
|
|
7
|
+
import { assert } from "@fluidframework/core-utils";
|
|
8
|
+
const fluidOfficeAndOneNoteServers = new Set([
|
|
9
|
+
"dev.fluidpreview.office.net",
|
|
10
|
+
"fluidpreview.office.net",
|
|
11
|
+
"www.onenote.com",
|
|
12
|
+
]);
|
|
6
13
|
/**
|
|
7
14
|
* @internal
|
|
8
15
|
*/
|
|
@@ -35,4 +42,64 @@ export class OdspUrlResolver {
|
|
|
35
42
|
export const isOdspUrl = (url) => {
|
|
36
43
|
return isSpoUrl(url) || isOdcUrl(url);
|
|
37
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* 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.
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
export class FluidAppOdspUrlResolver {
|
|
50
|
+
async resolve(request) {
|
|
51
|
+
const reqUrl = new URL(request.url);
|
|
52
|
+
const server = reqUrl.hostname.toLowerCase();
|
|
53
|
+
let contents;
|
|
54
|
+
if (fluidOfficeAndOneNoteServers.has(server)) {
|
|
55
|
+
contents = await initializeFluidOfficeOrOneNote(reqUrl);
|
|
56
|
+
}
|
|
57
|
+
else if (server === "www.office.com") {
|
|
58
|
+
const getRequiredParam = (name) => {
|
|
59
|
+
const value = reqUrl.searchParams.get(name);
|
|
60
|
+
assert(!!value, 0x097 /* Missing param from office.com URL parameter */);
|
|
61
|
+
return value;
|
|
62
|
+
};
|
|
63
|
+
contents = {
|
|
64
|
+
driveId: getRequiredParam("drive"),
|
|
65
|
+
itemId: getRequiredParam("item"),
|
|
66
|
+
siteUrl: getRequiredParam("siteUrl"),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
if (!contents) {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
const urlToBeResolved = createOdspUrl({ ...contents, dataStorePath: "" });
|
|
76
|
+
const odspDriverUrlResolver = new OdspDriverUrlResolver();
|
|
77
|
+
return odspDriverUrlResolver.resolve({ url: urlToBeResolved });
|
|
78
|
+
}
|
|
79
|
+
// TODO: Issue-2109 Implement detach container api or put appropriate comment.
|
|
80
|
+
async getAbsoluteUrl(resolvedUrl, relativeUrl, packageInfoSource) {
|
|
81
|
+
throw new Error("Not implemented");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async function initializeFluidOfficeOrOneNote(urlSource) {
|
|
85
|
+
const pathname = urlSource.pathname;
|
|
86
|
+
const siteDriveItemMatch = pathname.match(/\/(p|preview|meetingnotes|notes)\/([^/]*)\/([^/]*)\/([^/]*)/);
|
|
87
|
+
if (siteDriveItemMatch === null) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
const site = decodeURIComponent(siteDriveItemMatch[2]);
|
|
91
|
+
// Path value is base64 encoded so need to decode first
|
|
92
|
+
const decodedSite = fromBase64ToUtf8(site);
|
|
93
|
+
// Site value includes storage type
|
|
94
|
+
const storageType = decodedSite.split(":")[0];
|
|
95
|
+
const expectedStorageType = "spo"; // Only support spo for now
|
|
96
|
+
if (storageType !== expectedStorageType) {
|
|
97
|
+
throw new Error(`Unexpected storage type ${storageType}, expected: ${expectedStorageType}`);
|
|
98
|
+
}
|
|
99
|
+
// Since we have the drive and item, only take the host ignore the rest
|
|
100
|
+
const siteUrl = decodedSite.slice(Math.max(0, storageType.length + 1));
|
|
101
|
+
const driveId = decodeURIComponent(siteDriveItemMatch[3]);
|
|
102
|
+
const itemId = decodeURIComponent(siteDriveItemMatch[4]);
|
|
103
|
+
return { siteUrl, driveId, itemId };
|
|
104
|
+
}
|
|
38
105
|
//# sourceMappingURL=urlResolver.mjs.map
|
package/lib/urlResolver.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlResolver.mjs","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"urlResolver.mjs","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAQI,EACN,aAAa,EACb,qBAAqB,EACrB,QAAQ,EACR,QAAQ,EACR,eAAe,GACf,MAAM,6BAA6B;OAC7B,EAAE,gBAAgB,EAAE,MAAM,8BAA8B;OACxD,EAAE,MAAM,EAAE,MAAM,4BAA4B;AAGnD,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,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC3B,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAA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W,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,MAAM,mBAAmB,GAAG,KAAK,CAAC,CAAC,2BAA2B;IAC9D,IAAI,WAAW,KAAK,mBAAmB,EAAE;QACxC,MAAM,IAAI,KAAK,CAAC,2BAA2B,WAAW,eAAe,mBAAmB,EAAE,CAAC,CAAC;KAC5F;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 { IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n\tIContainerPackageInfo,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tcreateOdspUrl,\n\tOdspDriverUrlResolver,\n\tisSpoUrl,\n\tisOdcUrl,\n\tgetOdspUrlParts,\n} from \"@fluidframework/odsp-driver\";\nimport { fromBase64ToUtf8 } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IOdspUrlParts } from \"@fluidframework/odsp-driver-definitions\";\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\tif (isOdspUrl(request.url)) {\n\t\t\tconst reqUrl = new URL(request.url);\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(resolvedUrl: IResolvedUrl, relativeUrl: string): 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 */\nexport const isOdspUrl = (url: string): 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(urlSource: URL): 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(`Unexpected storage type ${storageType}, expected: ${expectedStorageType}`);\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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/odsp-urlresolver",
|
|
3
|
-
"version": "2.0.0-dev-rc.1.0.0.
|
|
3
|
+
"version": "2.0.0-dev-rc.1.0.0.232845",
|
|
4
4
|
"description": "Url Resolver for odsp urls.",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"require": {
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
|
-
"default": "./dist/index.
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"./alpha": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"require": {
|
|
31
31
|
"types": "./dist/odsp-urlresolver-alpha.d.ts",
|
|
32
|
-
"default": "./dist/index.
|
|
32
|
+
"default": "./dist/index.js"
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"./beta": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"require": {
|
|
41
41
|
"types": "./dist/odsp-urlresolver-beta.d.ts",
|
|
42
|
-
"default": "./dist/index.
|
|
42
|
+
"default": "./dist/index.js"
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
"./internal": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"require": {
|
|
51
51
|
"types": "./dist/index.d.ts",
|
|
52
|
-
"default": "./dist/index.
|
|
52
|
+
"default": "./dist/index.js"
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"./public": {
|
|
@@ -59,28 +59,30 @@
|
|
|
59
59
|
},
|
|
60
60
|
"require": {
|
|
61
61
|
"types": "./dist/odsp-urlresolver-public.d.ts",
|
|
62
|
-
"default": "./dist/index.
|
|
62
|
+
"default": "./dist/index.js"
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
|
-
"main": "dist/index.
|
|
66
|
+
"main": "dist/index.js",
|
|
67
67
|
"module": "lib/index.mjs",
|
|
68
68
|
"types": "dist/index.d.ts",
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@
|
|
71
|
-
"@fluidframework/
|
|
72
|
-
"@fluidframework/
|
|
73
|
-
"@fluidframework/
|
|
70
|
+
"@fluid-internal/client-utils": "2.0.0-dev-rc.1.0.0.232845",
|
|
71
|
+
"@fluidframework/core-interfaces": "2.0.0-dev-rc.1.0.0.232845",
|
|
72
|
+
"@fluidframework/core-utils": "2.0.0-dev-rc.1.0.0.232845",
|
|
73
|
+
"@fluidframework/driver-definitions": "2.0.0-dev-rc.1.0.0.232845",
|
|
74
|
+
"@fluidframework/odsp-driver": "2.0.0-dev-rc.1.0.0.232845",
|
|
75
|
+
"@fluidframework/odsp-driver-definitions": "2.0.0-dev-rc.1.0.0.232845"
|
|
74
76
|
},
|
|
75
77
|
"devDependencies": {
|
|
76
78
|
"@arethetypeswrong/cli": "^0.13.3",
|
|
77
|
-
"@fluid-tools/build-cli": "0.29.0
|
|
79
|
+
"@fluid-tools/build-cli": "^0.29.0",
|
|
78
80
|
"@fluidframework/build-common": "^2.0.3",
|
|
79
|
-
"@fluidframework/build-tools": "0.29.0
|
|
80
|
-
"@fluidframework/eslint-config-fluid": "^3.
|
|
81
|
-
"@fluidframework/mocha-test-setup": "2.0.0-dev-rc.1.0.0.
|
|
81
|
+
"@fluidframework/build-tools": "^0.29.0",
|
|
82
|
+
"@fluidframework/eslint-config-fluid": "^3.3.0",
|
|
83
|
+
"@fluidframework/mocha-test-setup": "2.0.0-dev-rc.1.0.0.232845",
|
|
82
84
|
"@fluidframework/odsp-urlresolver-previous": "npm:@fluidframework/odsp-urlresolver@2.0.0-internal.8.0.0",
|
|
83
|
-
"@microsoft/api-extractor": "^7.
|
|
85
|
+
"@microsoft/api-extractor": "^7.39.1",
|
|
84
86
|
"@types/mocha": "^9.1.1",
|
|
85
87
|
"@types/node": "^18.19.0",
|
|
86
88
|
"copyfiles": "^2.4.1",
|
|
@@ -119,7 +121,7 @@
|
|
|
119
121
|
"build:compile": "fluid-build . --task compile",
|
|
120
122
|
"build:docs": "fluid-build . --task api",
|
|
121
123
|
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
|
|
122
|
-
"build:test": "tsc
|
|
124
|
+
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
123
125
|
"check:are-the-types-wrong": "attw --pack . --entrypoints .",
|
|
124
126
|
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
|
|
125
127
|
"ci:build:docs": "api-extractor run",
|
|
@@ -134,7 +136,7 @@
|
|
|
134
136
|
"test": "npm run test:mocha",
|
|
135
137
|
"test:mocha": "mocha --ignore \"dist/test/types/*\" --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup",
|
|
136
138
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
137
|
-
"tsc": "tsc
|
|
139
|
+
"tsc": "tsc",
|
|
138
140
|
"typetests:gen": "fluid-type-test-generator",
|
|
139
141
|
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
|
|
140
142
|
}
|
package/src/index.ts
CHANGED
package/src/urlResolver.ts
CHANGED
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { IRequest } from "@fluidframework/core-interfaces";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
IContainerPackageInfo,
|
|
9
|
+
IResolvedUrl,
|
|
10
|
+
IUrlResolver,
|
|
11
|
+
} from "@fluidframework/driver-definitions";
|
|
8
12
|
import {
|
|
9
13
|
createOdspUrl,
|
|
10
14
|
OdspDriverUrlResolver,
|
|
@@ -12,6 +16,15 @@ import {
|
|
|
12
16
|
isOdcUrl,
|
|
13
17
|
getOdspUrlParts,
|
|
14
18
|
} from "@fluidframework/odsp-driver";
|
|
19
|
+
import { fromBase64ToUtf8 } from "@fluid-internal/client-utils";
|
|
20
|
+
import { assert } from "@fluidframework/core-utils";
|
|
21
|
+
import { IOdspUrlParts } from "@fluidframework/odsp-driver-definitions";
|
|
22
|
+
|
|
23
|
+
const fluidOfficeAndOneNoteServers = new Set([
|
|
24
|
+
"dev.fluidpreview.office.net",
|
|
25
|
+
"fluidpreview.office.net",
|
|
26
|
+
"www.onenote.com",
|
|
27
|
+
]);
|
|
15
28
|
|
|
16
29
|
/**
|
|
17
30
|
* @internal
|
|
@@ -47,3 +60,74 @@ export class OdspUrlResolver implements IUrlResolver {
|
|
|
47
60
|
export const isOdspUrl = (url: string): boolean => {
|
|
48
61
|
return isSpoUrl(url) || isOdcUrl(url);
|
|
49
62
|
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 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.
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
export class FluidAppOdspUrlResolver implements IUrlResolver {
|
|
69
|
+
public async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {
|
|
70
|
+
const reqUrl = new URL(request.url);
|
|
71
|
+
const server = reqUrl.hostname.toLowerCase();
|
|
72
|
+
let contents: IOdspUrlParts | undefined;
|
|
73
|
+
if (fluidOfficeAndOneNoteServers.has(server)) {
|
|
74
|
+
contents = await initializeFluidOfficeOrOneNote(reqUrl);
|
|
75
|
+
} else if (server === "www.office.com") {
|
|
76
|
+
const getRequiredParam = (name: string): string => {
|
|
77
|
+
const value = reqUrl.searchParams.get(name);
|
|
78
|
+
assert(!!value, 0x097 /* Missing param from office.com URL parameter */);
|
|
79
|
+
return value;
|
|
80
|
+
};
|
|
81
|
+
contents = {
|
|
82
|
+
driveId: getRequiredParam("drive"),
|
|
83
|
+
itemId: getRequiredParam("item"),
|
|
84
|
+
siteUrl: getRequiredParam("siteUrl"),
|
|
85
|
+
};
|
|
86
|
+
} else {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
if (!contents) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
const urlToBeResolved = createOdspUrl({ ...contents, dataStorePath: "" });
|
|
93
|
+
const odspDriverUrlResolver: IUrlResolver = new OdspDriverUrlResolver();
|
|
94
|
+
return odspDriverUrlResolver.resolve({ url: urlToBeResolved });
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// TODO: Issue-2109 Implement detach container api or put appropriate comment.
|
|
98
|
+
public async getAbsoluteUrl(
|
|
99
|
+
resolvedUrl: IResolvedUrl,
|
|
100
|
+
relativeUrl: string,
|
|
101
|
+
packageInfoSource?: IContainerPackageInfo,
|
|
102
|
+
): Promise<string> {
|
|
103
|
+
throw new Error("Not implemented");
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function initializeFluidOfficeOrOneNote(urlSource: URL): Promise<IOdspUrlParts | undefined> {
|
|
108
|
+
const pathname = urlSource.pathname;
|
|
109
|
+
const siteDriveItemMatch = pathname.match(
|
|
110
|
+
/\/(p|preview|meetingnotes|notes)\/([^/]*)\/([^/]*)\/([^/]*)/,
|
|
111
|
+
);
|
|
112
|
+
if (siteDriveItemMatch === null) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const site = decodeURIComponent(siteDriveItemMatch[2]);
|
|
117
|
+
|
|
118
|
+
// Path value is base64 encoded so need to decode first
|
|
119
|
+
const decodedSite = fromBase64ToUtf8(site);
|
|
120
|
+
|
|
121
|
+
// Site value includes storage type
|
|
122
|
+
const storageType = decodedSite.split(":")[0];
|
|
123
|
+
const expectedStorageType = "spo"; // Only support spo for now
|
|
124
|
+
if (storageType !== expectedStorageType) {
|
|
125
|
+
throw new Error(`Unexpected storage type ${storageType}, expected: ${expectedStorageType}`);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Since we have the drive and item, only take the host ignore the rest
|
|
129
|
+
const siteUrl = decodedSite.slice(Math.max(0, storageType.length + 1));
|
|
130
|
+
const driveId = decodeURIComponent(siteDriveItemMatch[3]);
|
|
131
|
+
const itemId = decodeURIComponent(siteDriveItemMatch[4]);
|
|
132
|
+
return { siteUrl, driveId, itemId };
|
|
133
|
+
}
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iDAA2D;AAAlD,wGAAA,SAAS,OAAA;AAAE,8GAAA,eAAe,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { isOdspUrl, OdspUrlResolver } from \"./urlResolver\";\n"]}
|
package/dist/urlResolver.cjs
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.isOdspUrl = exports.OdspUrlResolver = void 0;
|
|
8
|
-
const odsp_driver_1 = require("@fluidframework/odsp-driver");
|
|
9
|
-
/**
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
class OdspUrlResolver {
|
|
13
|
-
async resolve(request) {
|
|
14
|
-
if ((0, exports.isOdspUrl)(request.url)) {
|
|
15
|
-
const reqUrl = new URL(request.url);
|
|
16
|
-
const contents = await (0, odsp_driver_1.getOdspUrlParts)(reqUrl);
|
|
17
|
-
if (!contents) {
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
const urlToBeResolved = (0, odsp_driver_1.createOdspUrl)({ ...contents, dataStorePath: "" });
|
|
21
|
-
const odspDriverUrlResolver = new odsp_driver_1.OdspDriverUrlResolver();
|
|
22
|
-
return odspDriverUrlResolver.resolve({
|
|
23
|
-
url: urlToBeResolved,
|
|
24
|
-
headers: request.headers,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
async getAbsoluteUrl(resolvedUrl, relativeUrl) {
|
|
30
|
-
throw new Error("Not implemented");
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.OdspUrlResolver = OdspUrlResolver;
|
|
34
|
-
/**
|
|
35
|
-
* Returns true if the given string is a valid SPO/ODB or ODC URL.
|
|
36
|
-
*
|
|
37
|
-
* @internal
|
|
38
|
-
*/
|
|
39
|
-
const isOdspUrl = (url) => {
|
|
40
|
-
return (0, odsp_driver_1.isSpoUrl)(url) || (0, odsp_driver_1.isOdcUrl)(url);
|
|
41
|
-
};
|
|
42
|
-
exports.isOdspUrl = isOdspUrl;
|
|
43
|
-
//# sourceMappingURL=urlResolver.cjs.map
|
package/dist/urlResolver.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"urlResolver.cjs","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,6DAMqC;AAErC;;GAEG;AACH,MAAa,eAAe;IACpB,KAAK,CAAC,OAAO,CAAC,OAAiB;QACrC,IAAI,IAAA,iBAAS,EAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC3B,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACpC,MAAM,QAAQ,GAAG,MAAM,IAAA,6BAAe,EAAC,MAAM,CAAC,CAAC;YAC/C,IAAI,CAAC,QAAQ,EAAE;gBACd,OAAO,SAAS,CAAC;aACjB;YACD,MAAM,eAAe,GAAG,IAAA,2BAAa,EAAC,EAAE,GAAG,QAAQ,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC;YAC1E,MAAM,qBAAqB,GAAiB,IAAI,mCAAqB,EAAE,CAAC;YACxE,OAAO,qBAAqB,CAAC,OAAO,CAAC;gBACpC,GAAG,EAAE,eAAe;gBACpB,OAAO,EAAE,OAAO,CAAC,OAAO;aACxB,CAAC,CAAC;SACH;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,WAAyB,EAAE,WAAmB;QACzE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD;AArBD,0CAqBC;AAED;;;;GAIG;AACI,MAAM,SAAS,GAAG,CAAC,GAAW,EAAW,EAAE;IACjD,OAAO,IAAA,sBAAQ,EAAC,GAAG,CAAC,IAAI,IAAA,sBAAQ,EAAC,GAAG,CAAC,CAAC;AACvC,CAAC,CAAC;AAFW,QAAA,SAAS,aAEpB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { IResolvedUrl, IUrlResolver } from \"@fluidframework/driver-definitions\";\nimport {\n\tcreateOdspUrl,\n\tOdspDriverUrlResolver,\n\tisSpoUrl,\n\tisOdcUrl,\n\tgetOdspUrlParts,\n} from \"@fluidframework/odsp-driver\";\n\n/**\n * @internal\n */\nexport class OdspUrlResolver implements IUrlResolver {\n\tpublic async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {\n\t\tif (isOdspUrl(request.url)) {\n\t\t\tconst reqUrl = new URL(request.url);\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(resolvedUrl: IResolvedUrl, relativeUrl: string): 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 */\nexport const isOdspUrl = (url: string): boolean => {\n\treturn isSpoUrl(url) || isOdcUrl(url);\n};\n"]}
|
package/tsc-multi.test.json
DELETED
|
File without changes
|