@fluidframework/routerlicious-driver 0.59.2000-61729 → 0.59.2000-63294

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/documentDeltaConnection.js +1 -1
  2. package/dist/documentDeltaConnection.js.map +1 -1
  3. package/dist/documentService.d.ts.map +1 -1
  4. package/dist/documentService.js +3 -1
  5. package/dist/documentService.js.map +1 -1
  6. package/dist/documentServiceFactory.d.ts +1 -1
  7. package/dist/documentServiceFactory.d.ts.map +1 -1
  8. package/dist/documentServiceFactory.js +33 -12
  9. package/dist/documentServiceFactory.js.map +1 -1
  10. package/dist/documentStorageService.d.ts +2 -1
  11. package/dist/documentStorageService.d.ts.map +1 -1
  12. package/dist/documentStorageService.js +5 -4
  13. package/dist/documentStorageService.js.map +1 -1
  14. package/dist/errorUtils.d.ts +6 -0
  15. package/dist/errorUtils.d.ts.map +1 -1
  16. package/dist/errorUtils.js +2 -0
  17. package/dist/errorUtils.js.map +1 -1
  18. package/dist/packageVersion.d.ts +1 -1
  19. package/dist/packageVersion.js +1 -1
  20. package/dist/packageVersion.js.map +1 -1
  21. package/dist/policies.d.ts +5 -0
  22. package/dist/policies.d.ts.map +1 -1
  23. package/dist/policies.js.map +1 -1
  24. package/dist/urlUtils.d.ts +3 -0
  25. package/dist/urlUtils.d.ts.map +1 -1
  26. package/dist/urlUtils.js +28 -1
  27. package/dist/urlUtils.js.map +1 -1
  28. package/dist/wholeSummaryDocumentStorageService.d.ts +4 -1
  29. package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -1
  30. package/dist/wholeSummaryDocumentStorageService.js +11 -4
  31. package/dist/wholeSummaryDocumentStorageService.js.map +1 -1
  32. package/lib/documentDeltaConnection.js +1 -1
  33. package/lib/documentDeltaConnection.js.map +1 -1
  34. package/lib/documentService.d.ts.map +1 -1
  35. package/lib/documentService.js +3 -1
  36. package/lib/documentService.js.map +1 -1
  37. package/lib/documentServiceFactory.d.ts +1 -1
  38. package/lib/documentServiceFactory.d.ts.map +1 -1
  39. package/lib/documentServiceFactory.js +34 -13
  40. package/lib/documentServiceFactory.js.map +1 -1
  41. package/lib/documentStorageService.d.ts +2 -1
  42. package/lib/documentStorageService.d.ts.map +1 -1
  43. package/lib/documentStorageService.js +5 -4
  44. package/lib/documentStorageService.js.map +1 -1
  45. package/lib/errorUtils.d.ts +6 -0
  46. package/lib/errorUtils.d.ts.map +1 -1
  47. package/lib/errorUtils.js +2 -0
  48. package/lib/errorUtils.js.map +1 -1
  49. package/lib/packageVersion.d.ts +1 -1
  50. package/lib/packageVersion.js +1 -1
  51. package/lib/packageVersion.js.map +1 -1
  52. package/lib/policies.d.ts +5 -0
  53. package/lib/policies.d.ts.map +1 -1
  54. package/lib/policies.js.map +1 -1
  55. package/lib/urlUtils.d.ts +3 -0
  56. package/lib/urlUtils.d.ts.map +1 -1
  57. package/lib/urlUtils.js +26 -0
  58. package/lib/urlUtils.js.map +1 -1
  59. package/lib/wholeSummaryDocumentStorageService.d.ts +4 -1
  60. package/lib/wholeSummaryDocumentStorageService.d.ts.map +1 -1
  61. package/lib/wholeSummaryDocumentStorageService.js +11 -4
  62. package/lib/wholeSummaryDocumentStorageService.js.map +1 -1
  63. package/package.json +21 -17
  64. package/src/documentDeltaConnection.ts +1 -1
  65. package/src/documentService.ts +9 -2
  66. package/src/documentServiceFactory.ts +50 -19
  67. package/src/documentStorageService.ts +7 -2
  68. package/src/errorUtils.ts +9 -0
  69. package/src/packageVersion.ts +1 -1
  70. package/src/policies.ts +5 -0
  71. package/src/urlUtils.ts +31 -0
  72. package/src/wholeSummaryDocumentStorageService.ts +13 -6
@@ -37,15 +37,18 @@ export class DocumentStorageService extends DocumentStorageServiceProxy {
37
37
  policies: IDocumentStorageServicePolicies,
38
38
  driverPolicies?: IRouterliciousDriverPolicies,
39
39
  blobCache?: ICache<ArrayBufferLike>,
40
- snapshotTreeCache?: ICache<ISnapshotTreeVersion>): IDocumentStorageService {
40
+ snapshotTreeCache?: ICache<ISnapshotTreeVersion>,
41
+ noCacheGitManager?: GitManager): IDocumentStorageService {
41
42
  const storageService = driverPolicies?.enableWholeSummaryUpload ?
42
43
  new WholeSummaryDocumentStorageService(
43
44
  id,
44
45
  manager,
45
46
  logger,
46
47
  policies,
48
+ driverPolicies,
47
49
  blobCache,
48
50
  snapshotTreeCache,
51
+ noCacheGitManager,
49
52
  ) :
50
53
  new ShreddedSummaryDocumentStorageService(
51
54
  id,
@@ -70,7 +73,8 @@ export class DocumentStorageService extends DocumentStorageServiceProxy {
70
73
  policies: IDocumentStorageServicePolicies = {},
71
74
  driverPolicies?: IRouterliciousDriverPolicies,
72
75
  blobCache?: ICache<ArrayBufferLike>,
73
- snapshotTreeCache?: ICache<ISnapshotTreeVersion>) {
76
+ snapshotTreeCache?: ICache<ISnapshotTreeVersion>,
77
+ public noCacheGitManager?: GitManager) {
74
78
  super(DocumentStorageService.loadInternalDocumentStorageService(
75
79
  id,
76
80
  manager,
@@ -79,6 +83,7 @@ export class DocumentStorageService extends DocumentStorageServiceProxy {
79
83
  driverPolicies,
80
84
  blobCache,
81
85
  snapshotTreeCache,
86
+ noCacheGitManager,
82
87
  ));
83
88
  }
84
89
 
package/src/errorUtils.ts CHANGED
@@ -18,6 +18,7 @@ export enum R11sErrorType {
18
18
 
19
19
  /**
20
20
  * Interface for error responses for the WebSocket connection
21
+ * Intended to be compatible with output from {@link NetworkError.toJSON}
21
22
  */
22
23
  export interface IR11sSocketError {
23
24
  /**
@@ -36,6 +37,12 @@ export interface IR11sSocketError {
36
37
  * Optional Retry-After time in seconds.
37
38
  * The client should wait this many seconds before retrying its request.
38
39
  */
40
+ retryAfter?: number;
41
+
42
+ /**
43
+ * Optional Retry-After time in milliseconds.
44
+ * The client should wait this many milliseconds before retrying its request.
45
+ */
39
46
  retryAfterMs?: number;
40
47
  }
41
48
 
@@ -61,6 +68,8 @@ export function createR11sNetworkError(
61
68
  return new GenericNetworkError(
62
69
  errorMessage, errorMessage.startsWith("NetworkError"), props);
63
70
  case 401:
71
+ // The first 401 is manually retried in RouterliciousRestWrapper with a refreshed token,
72
+ // so we treat repeat 401s the same as 403.
64
73
  case 403:
65
74
  return new AuthorizationError(
66
75
  errorMessage, undefined, undefined, props);
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/routerlicious-driver";
9
- export const pkgVersion = "0.59.2000-61729";
9
+ export const pkgVersion = "0.59.2000-63294";
package/src/policies.ts CHANGED
@@ -32,6 +32,11 @@ export interface IRouterliciousDriverPolicies {
32
32
  * Default: false
33
33
  */
34
34
  enableWholeSummaryUpload: boolean;
35
+ /**
36
+ * Enable service endpoint discovery when creating or joining a session.
37
+ * Default: false
38
+ */
39
+ enableDiscovery?: boolean;
35
40
  /**
36
41
  * Enable using RestLess which avoids CORS preflight requests.
37
42
  * Default: true
package/src/urlUtils.ts CHANGED
@@ -3,7 +3,9 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import { IFluidResolvedUrl } from "@fluidframework/driver-definitions";
6
7
  import URLParse from "url-parse";
8
+ import { ISession } from "@fluidframework/server-services-client";
7
9
 
8
10
  export const parseFluidUrl = (fluidUrl: string): URLParse => {
9
11
  return new URLParse(fluidUrl, true);
@@ -17,3 +19,32 @@ export const parseFluidUrl = (fluidUrl: string): URLParse => {
17
19
  */
18
20
  export const replaceDocumentIdInPath = (urlPath: string, documentId: string): string =>
19
21
  urlPath.split("/").slice(0, -1).concat([documentId]).join("/");
22
+
23
+ export const getDiscoveredFluidResolvedUrl = (resolvedUrl: IFluidResolvedUrl, session: ISession): IFluidResolvedUrl => {
24
+ if (session) {
25
+ const discoveredOrdererUrl = new URLParse(session.ordererUrl);
26
+ const deltaStorageUrl = new URLParse(resolvedUrl.endpoints.deltaStorageUrl);
27
+ deltaStorageUrl.set("host", discoveredOrdererUrl.host);
28
+
29
+ const discoveredStorageUrl = new URLParse(session.historianUrl);
30
+ const storageUrl = new URLParse(resolvedUrl.endpoints.storageUrl);
31
+ storageUrl.set("host", discoveredStorageUrl.host);
32
+
33
+ const parsedUrl = parseFluidUrl(resolvedUrl.url);
34
+ const discoveredResolvedUrl: IFluidResolvedUrl = {
35
+ endpoints: {
36
+ deltaStorageUrl: deltaStorageUrl.toString(),
37
+ ordererUrl: session.ordererUrl,
38
+ storageUrl: storageUrl.toString(),
39
+ },
40
+ id: resolvedUrl.id,
41
+ tokens: resolvedUrl.tokens,
42
+ type: resolvedUrl.type,
43
+ url: new URLParse(`fluid://${discoveredOrdererUrl.host}${parsedUrl.pathname}`).toString(),
44
+ };
45
+
46
+ return discoveredResolvedUrl;
47
+ } else {
48
+ return resolvedUrl;
49
+ }
50
+ };
@@ -13,7 +13,7 @@ import {
13
13
  IDocumentStorageService,
14
14
  ISummaryContext,
15
15
  IDocumentStorageServicePolicies,
16
- } from "@fluidframework/driver-definitions";
16
+ } from "@fluidframework/driver-definitions";
17
17
  import {
18
18
  ICreateBlobResponse,
19
19
  ISnapshotTree,
@@ -31,6 +31,7 @@ import {
31
31
  import { PerformanceEvent } from "@fluidframework/telemetry-utils";
32
32
  import { ICache, InMemoryCache } from "./cache";
33
33
  import { ISnapshotTreeVersion } from "./definitions";
34
+ import { IRouterliciousDriverPolicies } from "./policies";
34
35
 
35
36
  const latestSnapshotId: string = "latest";
36
37
 
@@ -47,8 +48,10 @@ export class WholeSummaryDocumentStorageService implements IDocumentStorageServi
47
48
  protected readonly manager: GitManager,
48
49
  protected readonly logger: ITelemetryLogger,
49
50
  public readonly policies: IDocumentStorageServicePolicies = {},
51
+ private readonly driverPolicies?: IRouterliciousDriverPolicies,
50
52
  private readonly blobCache: ICache<ArrayBufferLike> = new InMemoryCache(),
51
- private readonly snapshotTreeCache: ICache<ISnapshotTreeVersion> = new InMemoryCache()) {
53
+ private readonly snapshotTreeCache: ICache<ISnapshotTreeVersion> = new InMemoryCache(),
54
+ protected readonly noCacheGitManager?: GitManager) {
52
55
  this.summaryUploadManager = new WholeSummaryUploadManager(manager);
53
56
  }
54
57
 
@@ -64,7 +67,9 @@ export class WholeSummaryDocumentStorageService implements IDocumentStorageServi
64
67
  // Fetch latest summary, cache it, and return its id.
65
68
  if (this.firstVersionsCall && count === 1) {
66
69
  this.firstVersionsCall = false;
67
- const { id: _id, snapshotTree } = await this.fetchAndCacheSnapshotTree(latestSnapshotId);
70
+ const { id: _id, snapshotTree } = !this.driverPolicies?.enableDiscovery ?
71
+ await this.fetchAndCacheSnapshotTree(latestSnapshotId, false) :
72
+ await this.fetchAndCacheSnapshotTree(latestSnapshotId, true);
68
73
  return [{
69
74
  id: _id,
70
75
  treeId: snapshotTree.id!,
@@ -170,7 +175,7 @@ export class WholeSummaryDocumentStorageService implements IDocumentStorageServi
170
175
  );
171
176
  }
172
177
 
173
- private async fetchAndCacheSnapshotTree(versionId: string): Promise<ISnapshotTreeVersion> {
178
+ private async fetchAndCacheSnapshotTree(versionId: string, disableCache?: boolean): Promise<ISnapshotTreeVersion> {
174
179
  const cachedSnapshotTreeVersion = await this.snapshotTreeCache.get(versionId);
175
180
  if (cachedSnapshotTreeVersion !== undefined) {
176
181
  return { id: cachedSnapshotTreeVersion.id, snapshotTree: cachedSnapshotTreeVersion.snapshotTree };
@@ -183,7 +188,9 @@ export class WholeSummaryDocumentStorageService implements IDocumentStorageServi
183
188
  treeId: versionId,
184
189
  },
185
190
  async (event) => {
186
- const response = await this.manager.getSummary(versionId);
191
+ const response = disableCache && this.noCacheGitManager !== undefined ?
192
+ await this.noCacheGitManager.getSummary(versionId) :
193
+ await this.manager.getSummary(versionId);
187
194
  event.end({
188
195
  size: response.trees[0]?.entries.length,
189
196
  });
@@ -194,7 +201,7 @@ export class WholeSummaryDocumentStorageService implements IDocumentStorageServi
194
201
  const wholeFlatSummaryId: string = wholeFlatSummary.id;
195
202
  const snapshotTreeId = normalizedWholeSummary.snapshotTree.id;
196
203
  assert(snapshotTreeId !== undefined, 0x275 /* "Root tree should contain the id" */);
197
- const snapshotTreeVersion = { id: wholeFlatSummaryId , snapshotTree: normalizedWholeSummary.snapshotTree };
204
+ const snapshotTreeVersion = { id: wholeFlatSummaryId, snapshotTree: normalizedWholeSummary.snapshotTree };
198
205
 
199
206
  const cachePs: Promise<any>[] = [
200
207
  this.snapshotTreeCache.put(