@fluidframework/routerlicious-urlresolver 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.225277
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/.eslintrc.js +29 -32
- package/.mocharc.js +12 -0
- package/CHANGELOG.md +117 -0
- package/README.md +37 -1
- package/api-extractor-esm.json +4 -0
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +4 -0
- package/api-report/routerlicious-urlresolver.api.md +47 -0
- package/dist/index.cjs +10 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/routerlicious-urlresolver-alpha.d.ts +13 -0
- package/dist/routerlicious-urlresolver-beta.d.ts +17 -0
- package/dist/routerlicious-urlresolver-public.d.ts +17 -0
- package/dist/routerlicious-urlresolver-untrimmed.d.ts +44 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/{urlResolver.js → urlResolver.cjs} +20 -15
- package/dist/urlResolver.cjs.map +1 -0
- package/dist/urlResolver.d.ts +9 -0
- package/dist/urlResolver.d.ts.map +1 -1
- package/lib/index.d.mts +6 -0
- package/lib/index.d.mts.map +1 -0
- package/lib/{index.js → index.mjs} +2 -2
- package/lib/index.mjs.map +1 -0
- package/lib/routerlicious-urlresolver-alpha.d.mts +13 -0
- package/lib/routerlicious-urlresolver-beta.d.mts +17 -0
- package/lib/routerlicious-urlresolver-public.d.mts +17 -0
- package/lib/routerlicious-urlresolver-untrimmed.d.mts +44 -0
- package/lib/{urlResolver.d.ts → urlResolver.d.mts} +10 -1
- package/lib/urlResolver.d.mts.map +1 -0
- package/lib/{urlResolver.js → urlResolver.mjs} +17 -12
- package/lib/urlResolver.mjs.map +1 -0
- package/package.json +121 -47
- package/{lib/index.d.ts → prettier.config.cjs} +4 -2
- package/src/index.ts +1 -1
- package/src/urlResolver.ts +158 -143
- package/tsc-multi.test.json +4 -0
- package/tsconfig.json +12 -16
- package/dist/index.js +0 -18
- package/dist/index.js.map +0 -1
- package/dist/packageVersion.d.ts +0 -9
- package/dist/packageVersion.d.ts.map +0 -1
- package/dist/packageVersion.js +0 -12
- package/dist/packageVersion.js.map +0 -1
- package/dist/urlResolver.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/packageVersion.d.ts +0 -9
- package/lib/packageVersion.d.ts.map +0 -1
- package/lib/packageVersion.js +0 -9
- package/lib/packageVersion.js.map +0 -1
- package/lib/urlResolver.d.ts.map +0 -1
- package/lib/urlResolver.js.map +0 -1
- package/src/packageVersion.ts +0 -9
- package/tsconfig.esnext.json +0 -7
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IRequest } from '@fluidframework/core-interfaces';
|
|
2
|
+
import { IResolvedUrl } from '@fluidframework/driver-definitions';
|
|
3
|
+
import { IUrlResolver } from '@fluidframework/driver-definitions';
|
|
4
|
+
import { IUser } from '@fluidframework/protocol-definitions';
|
|
5
|
+
import { Provider } from 'nconf';
|
|
6
|
+
|
|
7
|
+
/* Excluded from this release type: IAlfredUser */
|
|
8
|
+
|
|
9
|
+
/* Excluded from this release type: IConfig */
|
|
10
|
+
|
|
11
|
+
/* Excluded from this release type: IResolvedUrl */
|
|
12
|
+
|
|
13
|
+
/* Excluded from this release type: IUrlResolver */
|
|
14
|
+
|
|
15
|
+
/* Excluded from this release type: RouterliciousUrlResolver */
|
|
16
|
+
|
|
17
|
+
export { }
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { IRequest } from '@fluidframework/core-interfaces';
|
|
2
|
+
import { IResolvedUrl } from '@fluidframework/driver-definitions';
|
|
3
|
+
import { IUrlResolver } from '@fluidframework/driver-definitions';
|
|
4
|
+
import { IUser } from '@fluidframework/protocol-definitions';
|
|
5
|
+
import { Provider } from 'nconf';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare interface IAlfredUser extends IUser {
|
|
11
|
+
displayName: string;
|
|
12
|
+
name: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export declare interface IConfig {
|
|
19
|
+
serverUrl: string;
|
|
20
|
+
blobStorageUrl: string;
|
|
21
|
+
tenantId: string;
|
|
22
|
+
documentId: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export declare class RouterliciousUrlResolver implements IUrlResolver {
|
|
29
|
+
private readonly config;
|
|
30
|
+
private readonly getToken;
|
|
31
|
+
private readonly hostUrl;
|
|
32
|
+
constructor(config: {
|
|
33
|
+
provider: Provider;
|
|
34
|
+
tenantId: string;
|
|
35
|
+
documentId: string;
|
|
36
|
+
} | undefined, getToken: () => Promise<string>, hostUrl: string);
|
|
37
|
+
/**
|
|
38
|
+
* Handles a request and returns the relevant endpoints for the environment
|
|
39
|
+
*/
|
|
40
|
+
resolve(request: IRequest): Promise<IResolvedUrl | undefined>;
|
|
41
|
+
getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { }
|
|
@@ -6,6 +6,9 @@ import { IRequest } from "@fluidframework/core-interfaces";
|
|
|
6
6
|
import { IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
|
|
7
7
|
import { IUser } from "@fluidframework/protocol-definitions";
|
|
8
8
|
import { Provider } from "nconf";
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
9
12
|
export declare class RouterliciousUrlResolver implements IUrlResolver {
|
|
10
13
|
private readonly config;
|
|
11
14
|
private readonly getToken;
|
|
@@ -21,14 +24,20 @@ export declare class RouterliciousUrlResolver implements IUrlResolver {
|
|
|
21
24
|
resolve(request: IRequest): Promise<IResolvedUrl | undefined>;
|
|
22
25
|
getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string>;
|
|
23
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
24
30
|
export interface IAlfredUser extends IUser {
|
|
25
31
|
displayName: string;
|
|
26
32
|
name: string;
|
|
27
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
28
37
|
export interface IConfig {
|
|
29
38
|
serverUrl: string;
|
|
30
39
|
blobStorageUrl: string;
|
|
31
40
|
tenantId: string;
|
|
32
41
|
documentId: string;
|
|
33
42
|
}
|
|
34
|
-
//# sourceMappingURL=urlResolver.d.
|
|
43
|
+
//# sourceMappingURL=urlResolver.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urlResolver.d.mts","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAII,EAAE,QAAQ,EAAE,MAAM,iCAAiC;OACnD,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oCAAoC;OACxE,EAAE,KAAK,EAAE,MAAM,sCAAsC;OACrD,EAAE,QAAQ,EAAE,MAAM,OAAO;AAQhC;;GAEG;AACH,qBAAa,wBAAyB,YAAW,YAAY;IAE3D,OAAO,CAAC,QAAQ,CAAC,MAAM;IAGvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAJP,MAAM,EACpB;QAAE,QAAQ,EAAE,QAAQ,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,GAC5D,SAAS,EACK,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EAC/B,OAAO,EAAE,MAAM;IAGjC;;OAEG;IACU,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IA8G7D,cAAc,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAgB5F;AAED;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,KAAK;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { parse } from "url";
|
|
6
|
-
import { assert } from "@fluidframework/
|
|
6
|
+
import { assert } from "@fluidframework/core-utils";
|
|
7
7
|
const r11sServers = [
|
|
8
8
|
"www.wu2-ppe.prague.office-int.com",
|
|
9
9
|
"www.wu2.prague.office-int.com",
|
|
10
10
|
"www.eu.prague.office-int.com",
|
|
11
11
|
];
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
12
15
|
export class RouterliciousUrlResolver {
|
|
13
16
|
constructor(config, getToken, hostUrl) {
|
|
14
17
|
this.config = config;
|
|
@@ -27,7 +30,9 @@ export class RouterliciousUrlResolver {
|
|
|
27
30
|
const reqUrl = new URL(requestedUrl);
|
|
28
31
|
const server = reqUrl.hostname.toLowerCase();
|
|
29
32
|
// If we don't have a valid server or a prescriptive config, we cannot resolve the URL
|
|
30
|
-
if (!(r11sServers.includes(server) ||
|
|
33
|
+
if (!(r11sServers.includes(server) ||
|
|
34
|
+
(server === "localhost" && reqUrl.port === "3000") ||
|
|
35
|
+
this.config)) {
|
|
31
36
|
return undefined;
|
|
32
37
|
}
|
|
33
38
|
const path = reqUrl.pathname.split("/");
|
|
@@ -52,7 +57,9 @@ export class RouterliciousUrlResolver {
|
|
|
52
57
|
const isInternalRequest = server.includes("gateway"); // e.g. gateway:3000 || fierce-dog-gateway:3000
|
|
53
58
|
const serverSuffix = isLocalHost ? `${server}:3003` : server.substring(4);
|
|
54
59
|
let fluidUrl = "fluid://" +
|
|
55
|
-
`${this.config
|
|
60
|
+
`${this.config
|
|
61
|
+
? parse(this.config.provider.get("worker:serverUrl")).host
|
|
62
|
+
: serverSuffix}/` +
|
|
56
63
|
`${encodeURIComponent(tenantId)}/` +
|
|
57
64
|
`${encodeURIComponent(documentId)}`;
|
|
58
65
|
// In case of any additional parameters add them back to the url
|
|
@@ -69,15 +76,14 @@ export class RouterliciousUrlResolver {
|
|
|
69
76
|
if (provider && isInternalRequest) {
|
|
70
77
|
storageUrl = provider.get("worker:internalBlobStorageUrl");
|
|
71
78
|
ordererUrl = provider.get("worker:alfredUrl");
|
|
72
|
-
deltaStorageUrl =
|
|
73
|
-
// eslint-disable-next-line max-len
|
|
74
|
-
`${provider.get("worker:alfredUrl")}/deltas/${encodeURIComponent(tenantId)}/${encodeURIComponent(documentId)}`;
|
|
79
|
+
deltaStorageUrl = `${provider.get("worker:alfredUrl")}/deltas/${encodeURIComponent(tenantId)}/${encodeURIComponent(documentId)}`;
|
|
75
80
|
}
|
|
76
81
|
else if (provider) {
|
|
77
|
-
storageUrl = provider
|
|
82
|
+
storageUrl = provider
|
|
83
|
+
.get("worker:blobStorageUrl")
|
|
84
|
+
.replace("historian:3000", "localhost:3001");
|
|
78
85
|
ordererUrl = provider.get("worker:serverUrl");
|
|
79
|
-
deltaStorageUrl =
|
|
80
|
-
`${ordererUrl}/deltas/${encodeURIComponent(tenantId)}/${encodeURIComponent(documentId)}`;
|
|
86
|
+
deltaStorageUrl = `${ordererUrl}/deltas/${encodeURIComponent(tenantId)}/${encodeURIComponent(documentId)}`;
|
|
81
87
|
}
|
|
82
88
|
else if (isLocalHost) {
|
|
83
89
|
storageUrl = `http://localhost:3001`;
|
|
@@ -106,8 +112,7 @@ export class RouterliciousUrlResolver {
|
|
|
106
112
|
return resolved;
|
|
107
113
|
}
|
|
108
114
|
async getAbsoluteUrl(resolvedUrl, relativeUrl) {
|
|
109
|
-
const
|
|
110
|
-
const parsedUrl = parse(fluidResolvedUrl.url);
|
|
115
|
+
const parsedUrl = parse(resolvedUrl.url);
|
|
111
116
|
assert(!!parsedUrl.pathname, 0x0b9 /* "PathName should exist" */);
|
|
112
117
|
const [, tenantId, documentId] = parsedUrl.pathname.split("/");
|
|
113
118
|
assert(!!tenantId, 0x0ba /* "Tenant id should exist" */);
|
|
@@ -119,4 +124,4 @@ export class RouterliciousUrlResolver {
|
|
|
119
124
|
return `${this.hostUrl}/${encodeURIComponent(tenantId)}/${encodeURIComponent(documentId)}/${url}`;
|
|
120
125
|
}
|
|
121
126
|
}
|
|
122
|
-
//# sourceMappingURL=urlResolver.
|
|
127
|
+
//# sourceMappingURL=urlResolver.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urlResolver.mjs","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,KAAK,EAAE,MAAM,KAAK;OACpB,EAAE,MAAM,EAAE,MAAM,4BAA4B;AAMnD,MAAM,WAAW,GAAG;IACnB,mCAAmC;IACnC,+BAA+B;IAC/B,8BAA8B;CAC9B,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,wBAAwB;IACpC,YACkB,MAEL,EACK,QAA+B,EAC/B,OAAe;QAJf,WAAM,GAAN,MAAM,CAEX;QACK,aAAQ,GAAR,QAAQ,CAAuB;QAC/B,YAAO,GAAP,OAAO,CAAQ;IAC9B,CAAC;IAEJ;;OAEG;IACI,KAAK,CAAC,OAAO,CAAC,OAAiB;QACrC,IAAI,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC;QAE/B,gDAAgD;QAChD,IAAI,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YAC/C,YAAY,GAAG,oBAAoB,OAAO,CAAC,GAAG,EAAE,CAAC;SACj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C,UAAU,CAAC,GAAG,CAAC,EAAE;YACxB,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SACpB;QAED,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,kBAAkB,CAAC,QAAQ,CAAC,IAAI,kBAAkB,CAC3E,UAAU,CACV,IAAI,GAAG,EAAE,CAAC;IACZ,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { parse } from \"url\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { IResolvedUrl, IUrlResolver } from \"@fluidframework/driver-definitions\";\nimport { IUser } from \"@fluidframework/protocol-definitions\";\nimport { Provider } from \"nconf\";\n\nconst r11sServers = [\n\t\"www.wu2-ppe.prague.office-int.com\",\n\t\"www.wu2.prague.office-int.com\",\n\t\"www.eu.prague.office-int.com\",\n];\n\n/**\n * @internal\n */\nexport class RouterliciousUrlResolver implements IUrlResolver {\n\tconstructor(\n\t\tprivate readonly config:\n\t\t\t| { provider: Provider; tenantId: string; documentId: string }\n\t\t\t| undefined,\n\t\tprivate readonly getToken: () => Promise<string>,\n\t\tprivate readonly hostUrl: string,\n\t) {}\n\n\t/**\n\t * Handles a request and returns the relevant endpoints for the environment\n\t */\n\tpublic async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {\n\t\tlet requestedUrl = request.url;\n\n\t\t// If we know the original hostname, reinsert it\n\t\tif (this.config && request.url.startsWith(\"/\")) {\n\t\t\trequestedUrl = `http://dummy:3000${request.url}`;\n\t\t}\n\n\t\tconst reqUrl = new URL(requestedUrl);\n\t\tconst server = reqUrl.hostname.toLowerCase();\n\n\t\t// If we don't have a valid server or a prescriptive config, we cannot resolve the URL\n\t\tif (\n\t\t\t!(\n\t\t\t\tr11sServers.includes(server) ||\n\t\t\t\t(server === \"localhost\" && reqUrl.port === \"3000\") ||\n\t\t\t\tthis.config\n\t\t\t)\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst path = reqUrl.pathname.split(\"/\");\n\t\tlet tenantId: string;\n\t\tlet documentId: string;\n\t\tlet provider: Provider | undefined;\n\t\tif (this.config) {\n\t\t\ttenantId = this.config.tenantId;\n\t\t\tdocumentId = this.config.documentId;\n\t\t\tprovider = this.config.provider;\n\t\t} else if (path.length >= 4) {\n\t\t\ttenantId = path[2];\n\t\t\tdocumentId = path[3];\n\t\t} else {\n\t\t\ttenantId = \"fluid\";\n\t\t\tdocumentId = path[2];\n\t\t}\n\n\t\tconst token = await this.getToken();\n\n\t\tconst isLocalHost = server === \"localhost\";\n\t\tconst isInternalRequest = server.includes(\"gateway\"); // e.g. gateway:3000 || fierce-dog-gateway:3000\n\n\t\tconst serverSuffix = isLocalHost ? `${server}:3003` : server.substring(4);\n\n\t\tlet fluidUrl =\n\t\t\t\"fluid://\" +\n\t\t\t`${\n\t\t\t\tthis.config\n\t\t\t\t\t? parse(this.config.provider.get(\"worker:serverUrl\")).host\n\t\t\t\t\t: serverSuffix\n\t\t\t}/` +\n\t\t\t`${encodeURIComponent(tenantId)}/` +\n\t\t\t`${encodeURIComponent(documentId)}`;\n\n\t\t// In case of any additional parameters add them back to the url\n\t\tif (reqUrl.search) {\n\t\t\tconst searchParams = reqUrl.search;\n\t\t\tif (searchParams) {\n\t\t\t\tfluidUrl += searchParams;\n\t\t\t}\n\t\t}\n\n\t\tlet storageUrl = \"\";\n\t\tlet ordererUrl = \"\";\n\t\tlet deltaStorageUrl = \"\";\n\n\t\t// There is no provider when using debugging tooling\n\t\tif (provider && isInternalRequest) {\n\t\t\tstorageUrl = provider.get(\"worker:internalBlobStorageUrl\");\n\t\t\tordererUrl = provider.get(\"worker:alfredUrl\");\n\t\t\tdeltaStorageUrl = `${provider.get(\"worker:alfredUrl\")}/deltas/${encodeURIComponent(\n\t\t\t\ttenantId,\n\t\t\t)}/${encodeURIComponent(documentId)}`;\n\t\t} else if (provider) {\n\t\t\tstorageUrl = provider\n\t\t\t\t.get(\"worker:blobStorageUrl\")\n\t\t\t\t.replace(\"historian:3000\", \"localhost:3001\");\n\t\t\tordererUrl = provider.get(\"worker:serverUrl\");\n\t\t\tdeltaStorageUrl = `${ordererUrl}/deltas/${encodeURIComponent(\n\t\t\t\ttenantId,\n\t\t\t)}/${encodeURIComponent(documentId)}`;\n\t\t} else if (isLocalHost) {\n\t\t\tstorageUrl = `http://localhost:3001`;\n\t\t\tordererUrl = `http://localhost:3003`;\n\t\t\tdeltaStorageUrl = `http://localhost:3003/deltas/${tenantId}/${documentId}`;\n\t\t} else {\n\t\t\tstorageUrl = `https://historian.${serverSuffix}`;\n\t\t\tordererUrl = `https://alfred.${serverSuffix}`;\n\t\t\tdeltaStorageUrl = `https://alfred.${serverSuffix}/deltas/${tenantId}/${documentId}`;\n\t\t}\n\n\t\tstorageUrl += `/repos/${tenantId}`;\n\t\tordererUrl += ``;\n\t\tdeltaStorageUrl += ``;\n\n\t\tconst resolved: IResolvedUrl = {\n\t\t\tendpoints: {\n\t\t\t\tstorageUrl,\n\t\t\t\tdeltaStorageUrl,\n\t\t\t\tordererUrl,\n\t\t\t},\n\t\t\tid: documentId,\n\t\t\ttokens: { jwt: token },\n\t\t\ttype: \"fluid\",\n\t\t\turl: fluidUrl,\n\t\t};\n\t\treturn resolved;\n\t}\n\n\tpublic async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {\n\t\tconst parsedUrl = parse(resolvedUrl.url);\n\t\tassert(!!parsedUrl.pathname, 0x0b9 /* \"PathName should exist\" */);\n\t\tconst [, tenantId, documentId] = parsedUrl.pathname.split(\"/\");\n\t\tassert(!!tenantId, 0x0ba /* \"Tenant id should exist\" */);\n\t\tassert(!!documentId, 0x0bb /* \"Document id should exist\" */);\n\n\t\tlet url = relativeUrl;\n\t\tif (url.startsWith(\"/\")) {\n\t\t\turl = url.substr(1);\n\t\t}\n\n\t\treturn `${this.hostUrl}/${encodeURIComponent(tenantId)}/${encodeURIComponent(\n\t\t\tdocumentId,\n\t\t)}/${url}`;\n\t}\n}\n\n/**\n * @internal\n */\nexport interface IAlfredUser extends IUser {\n\tdisplayName: string;\n\tname: string;\n}\n\n/**\n * @internal\n */\nexport interface IConfig {\n\tserverUrl: string;\n\tblobStorageUrl: string;\n\ttenantId: string;\n\tdocumentId: string;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/routerlicious-urlresolver",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.0.0-dev-rc.1.0.0.225277",
|
|
4
4
|
"description": "Url Resolver for routerlicious urls.",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -11,61 +11,135 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Microsoft and contributors",
|
|
13
13
|
"sideEffects": false,
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": {
|
|
17
|
+
"types": "./lib/index.d.mts",
|
|
18
|
+
"default": "./lib/index.mjs"
|
|
19
|
+
},
|
|
20
|
+
"require": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"default": "./dist/index.cjs"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"./alpha": {
|
|
26
|
+
"import": {
|
|
27
|
+
"types": "./lib/routerlicious-urlresolver-alpha.d.mts",
|
|
28
|
+
"default": "./lib/index.mjs"
|
|
29
|
+
},
|
|
30
|
+
"require": {
|
|
31
|
+
"types": "./dist/routerlicious-urlresolver-alpha.d.ts",
|
|
32
|
+
"default": "./dist/index.cjs"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"./beta": {
|
|
36
|
+
"import": {
|
|
37
|
+
"types": "./lib/routerlicious-urlresolver-beta.d.mts",
|
|
38
|
+
"default": "./lib/index.mjs"
|
|
39
|
+
},
|
|
40
|
+
"require": {
|
|
41
|
+
"types": "./dist/routerlicious-urlresolver-beta.d.ts",
|
|
42
|
+
"default": "./dist/index.cjs"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"./internal": {
|
|
46
|
+
"import": {
|
|
47
|
+
"types": "./lib/index.d.mts",
|
|
48
|
+
"default": "./lib/index.mjs"
|
|
49
|
+
},
|
|
50
|
+
"require": {
|
|
51
|
+
"types": "./dist/index.d.ts",
|
|
52
|
+
"default": "./dist/index.cjs"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"./public": {
|
|
56
|
+
"import": {
|
|
57
|
+
"types": "./lib/routerlicious-urlresolver-public.d.mts",
|
|
58
|
+
"default": "./lib/index.mjs"
|
|
59
|
+
},
|
|
60
|
+
"require": {
|
|
61
|
+
"types": "./dist/routerlicious-urlresolver-public.d.ts",
|
|
62
|
+
"default": "./dist/index.cjs"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
37
65
|
},
|
|
66
|
+
"main": "dist/index.cjs",
|
|
67
|
+
"module": "lib/index.mjs",
|
|
68
|
+
"types": "dist/index.d.ts",
|
|
38
69
|
"dependencies": {
|
|
39
|
-
"@fluidframework/
|
|
40
|
-
"@fluidframework/core-
|
|
41
|
-
"@fluidframework/driver-definitions": "1.
|
|
42
|
-
"@fluidframework/protocol-definitions": "^
|
|
43
|
-
"nconf": "^0.
|
|
70
|
+
"@fluidframework/core-interfaces": "2.0.0-dev-rc.1.0.0.225277",
|
|
71
|
+
"@fluidframework/core-utils": "2.0.0-dev-rc.1.0.0.225277",
|
|
72
|
+
"@fluidframework/driver-definitions": "2.0.0-dev-rc.1.0.0.225277",
|
|
73
|
+
"@fluidframework/protocol-definitions": "^3.1.0-223007",
|
|
74
|
+
"nconf": "^0.12.0",
|
|
44
75
|
"url": "^0.11.0"
|
|
45
76
|
},
|
|
46
77
|
"devDependencies": {
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
49
|
-
"@fluidframework/
|
|
50
|
-
"@fluidframework/
|
|
51
|
-
"@fluidframework/
|
|
52
|
-
"@
|
|
78
|
+
"@arethetypeswrong/cli": "^0.13.3",
|
|
79
|
+
"@fluid-tools/build-cli": "0.29.0-222379",
|
|
80
|
+
"@fluidframework/build-common": "^2.0.3",
|
|
81
|
+
"@fluidframework/build-tools": "0.29.0-222379",
|
|
82
|
+
"@fluidframework/eslint-config-fluid": "^3.1.0",
|
|
83
|
+
"@fluidframework/mocha-test-setup": "2.0.0-dev-rc.1.0.0.225277",
|
|
84
|
+
"@fluidframework/routerlicious-urlresolver-previous": "npm:@fluidframework/routerlicious-urlresolver@2.0.0-internal.8.0.0",
|
|
85
|
+
"@microsoft/api-extractor": "^7.38.3",
|
|
53
86
|
"@types/mocha": "^9.1.1",
|
|
54
87
|
"@types/nconf": "^0.10.0",
|
|
55
|
-
"@types/node": "^
|
|
88
|
+
"@types/node": "^18.19.0",
|
|
56
89
|
"assert": "^2.0.0",
|
|
57
|
-
"
|
|
58
|
-
"cross-env": "^7.0.
|
|
59
|
-
"eslint": "~8.
|
|
60
|
-
"mocha": "^10.
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
90
|
+
"copyfiles": "^2.4.1",
|
|
91
|
+
"cross-env": "^7.0.3",
|
|
92
|
+
"eslint": "~8.50.0",
|
|
93
|
+
"mocha": "^10.2.0",
|
|
94
|
+
"mocha-json-output-reporter": "^2.0.1",
|
|
95
|
+
"mocha-multi-reporters": "^1.5.1",
|
|
96
|
+
"moment": "^2.21.0",
|
|
97
|
+
"prettier": "~3.0.3",
|
|
98
|
+
"rimraf": "^4.4.0",
|
|
99
|
+
"tsc-multi": "^1.1.0",
|
|
100
|
+
"typescript": "~5.1.6"
|
|
101
|
+
},
|
|
102
|
+
"fluidBuild": {
|
|
103
|
+
"tasks": {
|
|
104
|
+
"build:docs": {
|
|
105
|
+
"dependsOn": [
|
|
106
|
+
"...",
|
|
107
|
+
"api-extractor:commonjs",
|
|
108
|
+
"api-extractor:esnext"
|
|
109
|
+
],
|
|
110
|
+
"script": false
|
|
111
|
+
}
|
|
112
|
+
}
|
|
64
113
|
},
|
|
65
114
|
"typeValidation": {
|
|
66
|
-
"version": "1.4.0",
|
|
67
|
-
"baselineRange": "~1.3.0",
|
|
68
|
-
"baselineVersion": "1.3.1",
|
|
69
115
|
"broken": {}
|
|
116
|
+
},
|
|
117
|
+
"scripts": {
|
|
118
|
+
"api": "fluid-build . --task api",
|
|
119
|
+
"api-extractor:commonjs": "api-extractor run --local",
|
|
120
|
+
"api-extractor:esnext": "api-extractor run --config ./api-extractor-esm.json",
|
|
121
|
+
"build": "fluid-build . --task build",
|
|
122
|
+
"build:commonjs": "fluid-build . --task commonjs",
|
|
123
|
+
"build:compile": "fluid-build . --task compile",
|
|
124
|
+
"build:docs": "fluid-build . --task api",
|
|
125
|
+
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
|
|
126
|
+
"build:test": "tsc-multi --config ./tsc-multi.test.json",
|
|
127
|
+
"check:are-the-types-wrong": "attw --pack . --entrypoints .",
|
|
128
|
+
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
|
|
129
|
+
"ci:build:docs": "api-extractor run",
|
|
130
|
+
"clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
|
|
131
|
+
"eslint": "eslint --format stylish src",
|
|
132
|
+
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
133
|
+
"format": "npm run prettier:fix",
|
|
134
|
+
"lint": "npm run prettier && npm run check:release-tags && npm run eslint",
|
|
135
|
+
"lint:fix": "npm run prettier:fix && npm run eslint:fix",
|
|
136
|
+
"prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
|
|
137
|
+
"prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
138
|
+
"test": "npm run test:mocha",
|
|
139
|
+
"test:mocha": "mocha --ignore \"dist/test/types/*\" --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup",
|
|
140
|
+
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
141
|
+
"tsc": "tsc-multi --config ../../../common/build/build-common/tsc-multi.cjs.json",
|
|
142
|
+
"typetests:gen": "fluid-type-test-generator",
|
|
143
|
+
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
|
|
70
144
|
}
|
|
71
|
-
}
|
|
145
|
+
}
|
|
@@ -2,5 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
...require("@fluidframework/build-common/prettier.config.cjs"),
|
|
8
|
+
};
|
package/src/index.ts
CHANGED