@fluidframework/routerlicious-urlresolver 2.0.0-rc.4.0.6 → 2.0.0-rc.5.0.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,13 @@
1
1
  # @fluidframework/routerlicious-urlresolver
2
2
 
3
+ ## 2.0.0-rc.5.0.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Update to TypeScript 5.4 ([#21214](https://github.com/microsoft/FluidFramework/pull/21214)) [0e6256c722](https://github.com/microsoft/FluidFramework/commit/0e6256c722d8bf024f4325bf02547daeeb18bfa6)
8
+
9
+ Update package implementations to use TypeScript 5.4.5.
10
+
3
11
  ## 2.0.0-rc.4.0.0
4
12
 
5
13
  Dependency updates only.
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
+ "extends": "<projectFolder>/../../../common/build/build-common/api-extractor-lint.json",
4
+ "mainEntryPointFilePath": "<projectFolder>/lib/index.d.ts"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
+ "extends": "<projectFolder>/../../../common/build/build-common/api-extractor-lint.entrypoint.json",
4
+ "mainEntryPointFilePath": "<projectFolder>/dist/public.d.ts"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
+ "extends": "<projectFolder>/../../../common/build/build-common/api-extractor-lint.entrypoint.json",
4
+ "mainEntryPointFilePath": "<projectFolder>/lib/public.d.ts"
5
+ }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
- "extends": "../../../common/build/build-common/api-extractor-base.esm.primary.json"
3
+ "extends": "../../../common/build/build-common/api-extractor-base.esm.no-legacy.json"
4
4
  }
@@ -0,0 +1,15 @@
1
+ ## Alpha API Report File for "@fluidframework/routerlicious-urlresolver"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ import { IRequest } from '@fluidframework/core-interfaces';
8
+ import { IResolvedUrl } from '@fluidframework/driver-definitions/internal';
9
+ import { IUrlResolver } from '@fluidframework/driver-definitions/internal';
10
+ import { IUser } from '@fluidframework/driver-definitions';
11
+ import { Provider } from 'nconf';
12
+
13
+ // (No @packageDocumentation comment for this package)
14
+
15
+ ```
@@ -0,0 +1,15 @@
1
+ ## Beta API Report File for "@fluidframework/routerlicious-urlresolver"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ import { IRequest } from '@fluidframework/core-interfaces';
8
+ import { IResolvedUrl } from '@fluidframework/driver-definitions/internal';
9
+ import { IUrlResolver } from '@fluidframework/driver-definitions/internal';
10
+ import { IUser } from '@fluidframework/driver-definitions';
11
+ import { Provider } from 'nconf';
12
+
13
+ // (No @packageDocumentation comment for this package)
14
+
15
+ ```
@@ -0,0 +1,15 @@
1
+ ## Public API Report File for "@fluidframework/routerlicious-urlresolver"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ import { IRequest } from '@fluidframework/core-interfaces';
8
+ import { IResolvedUrl } from '@fluidframework/driver-definitions/internal';
9
+ import { IUrlResolver } from '@fluidframework/driver-definitions/internal';
10
+ import { IUser } from '@fluidframework/driver-definitions';
11
+ import { Provider } from 'nconf';
12
+
13
+ // (No @packageDocumentation comment for this package)
14
+
15
+ ```
package/biome.jsonc ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3
+ "extends": ["../../../biome.jsonc"]
4
+ }
@@ -3,8 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { IRequest } from "@fluidframework/core-interfaces";
6
+ import { IUser } from "@fluidframework/driver-definitions";
6
7
  import { IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions/internal";
7
- import { IUser } from "@fluidframework/protocol-definitions";
8
8
  import { Provider } from "./nconf.cjs";
9
9
  /**
10
10
  * @internal
@@ -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;AAE3D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAQvC;;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,OAA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AM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACnB"}
@@ -59,9 +59,7 @@ class RouterliciousUrlResolver {
59
59
  const isInternalRequest = server.includes("gateway"); // e.g. gateway:3000 || fierce-dog-gateway:3000
60
60
  const serverSuffix = isLocalHost ? `${server}:3003` : server.substring(4);
61
61
  let fluidUrl = "https://" +
62
- `${this.config
63
- ? new URL(this.config.provider.get("worker:serverUrl")).host
64
- : serverSuffix}/` +
62
+ `${this.config ? new URL(this.config.provider.get("worker:serverUrl")).host : serverSuffix}/` +
65
63
  `${encodeURIComponent(tenantId)}/` +
66
64
  `${encodeURIComponent(documentId)}`;
67
65
  // In case of any additional parameters add them back to the url
@@ -1 +1 @@
1
- {"version":3,"file":"urlResolver.js","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAA6D;AAM7D,MAAM,WAAW,GAAG;IACnB,mCAAmC;IACnC,+BAA+B;IAC/B,8BAA8B;CAC9B,CAAC;AAEF;;GAEG;AACH,MAAa,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;SACjD;QAED,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;QAE7C,sFAAsF;QACtF,IACC,CAAC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C,OAAO,IAAI,kBAAkB,CAAC,QAAQ,CAAC,IAAI,kBAAkB,CAC3E,UAAU,CACV,IAAI,GAAG,EAAE,CAAC;IACZ,CAAC;CACD;AA1ID,4DA0IC","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 { assert } from \"@fluidframework/core-utils/internal\";\nimport { IResolvedUrl, IUrlResolver } from \"@fluidframework/driver-definitions/internal\";\nimport { IUser } from \"@fluidframework/protocol-definitions\";\n\nimport { Provider } from \"./nconf.cjs\";\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\"https://\" +\n\t\t\t`${\n\t\t\t\tthis.config\n\t\t\t\t\t? new URL(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 = new URL(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"]}
1
+ {"version":3,"file":"urlResolver.js","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAA6D;AAM7D,MAAM,WAAW,GAAG;IACnB,mCAAmC;IACnC,+BAA+B;IAC/B,8BAA8B;CAC9B,CAAC;AAEF;;GAEG;AACH,MAAa,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,CAAC;YAChD,YAAY,GAAG,oBAAoB,OAAO,CAAC,GAAG,EAAE,CAAC;QAClD,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;QAE7C,sFAAsF;QACtF,IACC,CAAC,CACA,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC;YAC5B,CAAC,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC;YAClD,IAAI,CAAC,MAAM,CACX,EACA,CAAC;YACF,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACxC,IAAI,QAAgB,CAAC;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oft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IUser } from \"@fluidframework/driver-definitions\";\nimport { IResolvedUrl, IUrlResolver } from \"@fluidframework/driver-definitions/internal\";\n\nimport { Provider } from \"./nconf.cjs\";\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\"https://\" +\n\t\t\t`${\n\t\t\t\tthis.config ? new URL(this.config.provider.get(\"worker:serverUrl\")).host : 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(\n\t\tresolvedUrl: IResolvedUrl,\n\t\trelativeUrl: string,\n\t): Promise<string> {\n\t\tconst parsedUrl = new URL(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"]}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.43.1"
8
+ "packageVersion": "7.45.1"
9
9
  }
10
10
  ]
11
11
  }
@@ -3,8 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { IRequest } from "@fluidframework/core-interfaces";
6
+ import { IUser } from "@fluidframework/driver-definitions";
6
7
  import { IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions/internal";
7
- import { IUser } from "@fluidframework/protocol-definitions";
8
8
  import { Provider } from "./nconf.cjs";
9
9
  /**
10
10
  * @internal
@@ -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;AAE3D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAQvC;;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;C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;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"}
@@ -56,9 +56,7 @@ export class RouterliciousUrlResolver {
56
56
  const isInternalRequest = server.includes("gateway"); // e.g. gateway:3000 || fierce-dog-gateway:3000
57
57
  const serverSuffix = isLocalHost ? `${server}:3003` : server.substring(4);
58
58
  let fluidUrl = "https://" +
59
- `${this.config
60
- ? new URL(this.config.provider.get("worker:serverUrl")).host
61
- : serverSuffix}/` +
59
+ `${this.config ? new URL(this.config.provider.get("worker:serverUrl")).host : serverSuffix}/` +
62
60
  `${encodeURIComponent(tenantId)}/` +
63
61
  `${encodeURIComponent(documentId)}`;
64
62
  // In case of any additional parameters add them back to the url
@@ -1 +1 @@
1
- {"version":3,"file":"urlResolver.js","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAM7D,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,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,GAAG,GAAG,WAAW,CAAC;QACtB,IAAI,GAAG,CAAC,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 { IRequest } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IResolvedUrl, IUrlResolver } from \"@fluidframework/driver-definitions/internal\";\nimport { IUser } from \"@fluidframework/protocol-definitions\";\n\nimport { Provider } from \"./nconf.cjs\";\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\"https://\" +\n\t\t\t`${\n\t\t\t\tthis.config\n\t\t\t\t\t? new URL(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 = new URL(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"]}
1
+ {"version":3,"file":"urlResolver.js","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAM7D,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,CAAC;YAChD,YAAY,GAAG,oBAAoB,OAAO,CAAC,GAAG,EAAE,CAAC;QAClD,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;QAE7C,sFAAsF;QACtF,IACC,CAAC,CACA,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC;YAC5B,CAAC,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,IAAI,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AAG,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 { IRequest } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IUser } from \"@fluidframework/driver-definitions\";\nimport { IResolvedUrl, IUrlResolver } from \"@fluidframework/driver-definitions/internal\";\n\nimport { Provider } from \"./nconf.cjs\";\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\"https://\" +\n\t\t\t`${\n\t\t\t\tthis.config ? new URL(this.config.provider.get(\"worker:serverUrl\")).host : 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(\n\t\tresolvedUrl: IResolvedUrl,\n\t\trelativeUrl: string,\n\t): Promise<string> {\n\t\tconst parsedUrl = new URL(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": "2.0.0-rc.4.0.6",
3
+ "version": "2.0.0-rc.5.0.0",
4
4
  "description": "Url Resolver for routerlicious urls.",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -37,26 +37,26 @@
37
37
  "main": "lib/index.js",
38
38
  "types": "lib/public.d.ts",
39
39
  "dependencies": {
40
- "@fluidframework/core-interfaces": ">=2.0.0-rc.4.0.6 <2.0.0-rc.4.1.0",
41
- "@fluidframework/core-utils": ">=2.0.0-rc.4.0.6 <2.0.0-rc.4.1.0",
42
- "@fluidframework/driver-definitions": ">=2.0.0-rc.4.0.6 <2.0.0-rc.4.1.0",
43
- "@fluidframework/protocol-definitions": "^3.2.0",
40
+ "@fluidframework/core-interfaces": ">=2.0.0-rc.5.0.0 <2.0.0-rc.5.1.0",
41
+ "@fluidframework/core-utils": ">=2.0.0-rc.5.0.0 <2.0.0-rc.5.1.0",
42
+ "@fluidframework/driver-definitions": ">=2.0.0-rc.5.0.0 <2.0.0-rc.5.1.0",
44
43
  "nconf": "^0.12.0"
45
44
  },
46
45
  "devDependencies": {
47
46
  "@arethetypeswrong/cli": "^0.15.2",
48
- "@biomejs/biome": "^1.6.2",
49
- "@fluid-internal/mocha-test-setup": ">=2.0.0-rc.4.0.6 <2.0.0-rc.4.1.0",
50
- "@fluid-tools/build-cli": "^0.38.0",
47
+ "@biomejs/biome": "^1.7.3",
48
+ "@fluid-internal/mocha-test-setup": ">=2.0.0-rc.5.0.0 <2.0.0-rc.5.1.0",
49
+ "@fluid-tools/build-cli": "^0.39.0",
51
50
  "@fluidframework/build-common": "^2.0.3",
52
- "@fluidframework/build-tools": "^0.38.0",
53
- "@fluidframework/eslint-config-fluid": "^5.1.0",
54
- "@fluidframework/routerlicious-urlresolver-previous": "npm:@fluidframework/routerlicious-urlresolver@2.0.0-rc.3.0.0",
55
- "@microsoft/api-extractor": "^7.43.1",
51
+ "@fluidframework/build-tools": "^0.39.0",
52
+ "@fluidframework/eslint-config-fluid": "^5.3.0",
53
+ "@fluidframework/routerlicious-urlresolver-previous": "npm:@fluidframework/routerlicious-urlresolver@2.0.0-rc.4.0.0",
54
+ "@microsoft/api-extractor": "^7.45.1",
56
55
  "@types/mocha": "^9.1.1",
57
56
  "@types/nconf": "^0.10.0",
58
57
  "@types/node": "^18.19.0",
59
58
  "assert": "^2.0.0",
59
+ "concurrently": "^8.2.1",
60
60
  "copyfiles": "^2.4.1",
61
61
  "cross-env": "^7.0.3",
62
62
  "eslint": "~8.55.0",
@@ -66,7 +66,7 @@
66
66
  "moment": "^2.21.0",
67
67
  "prettier": "~3.0.3",
68
68
  "rimraf": "^4.4.0",
69
- "typescript": "~5.1.6"
69
+ "typescript": "~5.4.5"
70
70
  },
71
71
  "typeValidation": {
72
72
  "broken": {}
@@ -84,13 +84,19 @@
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",
88
+ "check:exports": "concurrently \"npm:check:exports:*\"",
89
+ "check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
90
+ "check:exports:cjs:public": "api-extractor run --config api-extractor/api-extractor-lint-public.cjs.json",
91
+ "check:exports:esm:public": "api-extractor run --config api-extractor/api-extractor-lint-public.esm.json",
92
+ "check:format": "npm run check:biome",
87
93
  "check:prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
88
- "check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
89
94
  "ci:build:docs": "api-extractor run",
90
95
  "clean": "rimraf --glob dist lib \"*.d.ts\" \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
91
96
  "eslint": "eslint --format stylish src",
92
97
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
93
- "format": "fluid-build --task format .",
98
+ "format": "npm run format:biome",
99
+ "format:biome": "biome check . --formatter-enabled=true --apply",
94
100
  "format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
95
101
  "lint": "fluid-build . --task lint",
96
102
  "lint:fix": "fluid-build . --task eslint:fix --task format",
@@ -5,8 +5,8 @@
5
5
 
6
6
  import { IRequest } from "@fluidframework/core-interfaces";
7
7
  import { assert } from "@fluidframework/core-utils/internal";
8
+ import { IUser } from "@fluidframework/driver-definitions";
8
9
  import { IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions/internal";
9
- import { IUser } from "@fluidframework/protocol-definitions";
10
10
 
11
11
  import { Provider } from "./nconf.cjs";
12
12
 
@@ -79,9 +79,7 @@ export class RouterliciousUrlResolver implements IUrlResolver {
79
79
  let fluidUrl =
80
80
  "https://" +
81
81
  `${
82
- this.config
83
- ? new URL(this.config.provider.get("worker:serverUrl")).host
84
- : serverSuffix
82
+ this.config ? new URL(this.config.provider.get("worker:serverUrl")).host : serverSuffix
85
83
  }/` +
86
84
  `${encodeURIComponent(tenantId)}/` +
87
85
  `${encodeURIComponent(documentId)}`;
@@ -141,7 +139,10 @@ export class RouterliciousUrlResolver implements IUrlResolver {
141
139
  return resolved;
142
140
  }
143
141
 
144
- public async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {
142
+ public async getAbsoluteUrl(
143
+ resolvedUrl: IResolvedUrl,
144
+ relativeUrl: string,
145
+ ): Promise<string> {
145
146
  const parsedUrl = new URL(resolvedUrl.url);
146
147
  assert(!!parsedUrl.pathname, 0x0b9 /* "PathName should exist" */);
147
148
  const [, tenantId, documentId] = parsedUrl.pathname.split("/");
package/tsconfig.json CHANGED
@@ -6,5 +6,6 @@
6
6
  "rootDir": "./src",
7
7
  "outDir": "./lib",
8
8
  "types": ["node"],
9
+ "noUncheckedIndexedAccess": false,
9
10
  },
10
11
  }
package/tsdoc.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
3
+ "extends": ["../../../common/build/build-common/tsdoc-base.json"]
4
+ }
@@ -1,47 +0,0 @@
1
- ## API Report File for "@fluidframework/routerlicious-urlresolver"
2
-
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
-
5
- ```ts
6
-
7
- import { IRequest } from '@fluidframework/core-interfaces';
8
- import { IResolvedUrl } from '@fluidframework/driver-definitions/internal';
9
- import { IUrlResolver } from '@fluidframework/driver-definitions/internal';
10
- import { IUser } from '@fluidframework/protocol-definitions';
11
- import { Provider } from 'nconf';
12
-
13
- // @internal (undocumented)
14
- export interface IAlfredUser extends IUser {
15
- // (undocumented)
16
- displayName: string;
17
- // (undocumented)
18
- name: string;
19
- }
20
-
21
- // @internal (undocumented)
22
- export interface IConfig {
23
- // (undocumented)
24
- blobStorageUrl: string;
25
- // (undocumented)
26
- documentId: string;
27
- // (undocumented)
28
- serverUrl: string;
29
- // (undocumented)
30
- tenantId: string;
31
- }
32
-
33
- // @internal (undocumented)
34
- export class RouterliciousUrlResolver implements IUrlResolver {
35
- constructor(config: {
36
- provider: Provider;
37
- tenantId: string;
38
- documentId: string;
39
- } | undefined, getToken: () => Promise<string>, hostUrl: string);
40
- // (undocumented)
41
- getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string>;
42
- resolve(request: IRequest): Promise<IResolvedUrl | undefined>;
43
- }
44
-
45
- // (No @packageDocumentation comment for this package)
46
-
47
- ```