@fluidframework/routerlicious-driver 2.0.0-internal.3.0.0 → 2.0.0-internal.3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/.eslintrc.js +10 -12
  2. package/.mocharc.js +2 -2
  3. package/README.md +1 -1
  4. package/api-extractor.json +2 -2
  5. package/dist/cache.d.ts.map +1 -1
  6. package/dist/cache.js +2 -5
  7. package/dist/cache.js.map +1 -1
  8. package/dist/createNewUtils.d.ts.map +1 -1
  9. package/dist/createNewUtils.js +4 -2
  10. package/dist/createNewUtils.js.map +1 -1
  11. package/dist/defaultTokenProvider.d.ts.map +1 -1
  12. package/dist/defaultTokenProvider.js.map +1 -1
  13. package/dist/definitions.d.ts.map +1 -1
  14. package/dist/definitions.js.map +1 -1
  15. package/dist/deltaStorageService.d.ts.map +1 -1
  16. package/dist/deltaStorageService.js +4 -1
  17. package/dist/deltaStorageService.js.map +1 -1
  18. package/dist/documentDeltaConnection.d.ts.map +1 -1
  19. package/dist/documentDeltaConnection.js.map +1 -1
  20. package/dist/documentService.d.ts.map +1 -1
  21. package/dist/documentService.js +13 -5
  22. package/dist/documentService.js.map +1 -1
  23. package/dist/documentServiceFactory.d.ts.map +1 -1
  24. package/dist/documentServiceFactory.js +7 -4
  25. package/dist/documentServiceFactory.js.map +1 -1
  26. package/dist/documentStorageService.d.ts.map +1 -1
  27. package/dist/documentStorageService.js +7 -5
  28. package/dist/documentStorageService.js.map +1 -1
  29. package/dist/errorUtils.d.ts +9 -2
  30. package/dist/errorUtils.d.ts.map +1 -1
  31. package/dist/errorUtils.js +15 -8
  32. package/dist/errorUtils.js.map +1 -1
  33. package/dist/index.d.ts +2 -1
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +4 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/nullBlobStorageService.d.ts.map +1 -1
  38. package/dist/nullBlobStorageService.js.map +1 -1
  39. package/dist/packageVersion.d.ts +1 -1
  40. package/dist/packageVersion.js +1 -1
  41. package/dist/packageVersion.js.map +1 -1
  42. package/dist/policies.d.ts.map +1 -1
  43. package/dist/policies.js.map +1 -1
  44. package/dist/restWrapper.d.ts.map +1 -1
  45. package/dist/restWrapper.js +5 -6
  46. package/dist/restWrapper.js.map +1 -1
  47. package/dist/retriableGitManager.d.ts.map +1 -1
  48. package/dist/retriableGitManager.js.map +1 -1
  49. package/dist/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
  50. package/dist/shreddedSummaryDocumentStorageService.js +8 -4
  51. package/dist/shreddedSummaryDocumentStorageService.js.map +1 -1
  52. package/dist/tokens.d.ts +24 -7
  53. package/dist/tokens.d.ts.map +1 -1
  54. package/dist/tokens.js.map +1 -1
  55. package/dist/urlUtils.d.ts.map +1 -1
  56. package/dist/urlUtils.js.map +1 -1
  57. package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -1
  58. package/dist/wholeSummaryDocumentStorageService.js +25 -11
  59. package/dist/wholeSummaryDocumentStorageService.js.map +1 -1
  60. package/lib/cache.d.ts.map +1 -1
  61. package/lib/cache.js +2 -5
  62. package/lib/cache.js.map +1 -1
  63. package/lib/createNewUtils.d.ts.map +1 -1
  64. package/lib/createNewUtils.js +4 -2
  65. package/lib/createNewUtils.js.map +1 -1
  66. package/lib/defaultTokenProvider.d.ts.map +1 -1
  67. package/lib/defaultTokenProvider.js.map +1 -1
  68. package/lib/definitions.d.ts.map +1 -1
  69. package/lib/definitions.js.map +1 -1
  70. package/lib/deltaStorageService.d.ts.map +1 -1
  71. package/lib/deltaStorageService.js +4 -1
  72. package/lib/deltaStorageService.js.map +1 -1
  73. package/lib/documentDeltaConnection.d.ts.map +1 -1
  74. package/lib/documentDeltaConnection.js.map +1 -1
  75. package/lib/documentService.d.ts.map +1 -1
  76. package/lib/documentService.js +15 -7
  77. package/lib/documentService.js.map +1 -1
  78. package/lib/documentServiceFactory.d.ts.map +1 -1
  79. package/lib/documentServiceFactory.js +7 -4
  80. package/lib/documentServiceFactory.js.map +1 -1
  81. package/lib/documentStorageService.d.ts.map +1 -1
  82. package/lib/documentStorageService.js +8 -6
  83. package/lib/documentStorageService.js.map +1 -1
  84. package/lib/errorUtils.d.ts +9 -2
  85. package/lib/errorUtils.d.ts.map +1 -1
  86. package/lib/errorUtils.js +14 -7
  87. package/lib/errorUtils.js.map +1 -1
  88. package/lib/index.d.ts +2 -1
  89. package/lib/index.d.ts.map +1 -1
  90. package/lib/index.js +3 -1
  91. package/lib/index.js.map +1 -1
  92. package/lib/nullBlobStorageService.d.ts.map +1 -1
  93. package/lib/nullBlobStorageService.js.map +1 -1
  94. package/lib/packageVersion.d.ts +1 -1
  95. package/lib/packageVersion.js +1 -1
  96. package/lib/packageVersion.js.map +1 -1
  97. package/lib/policies.d.ts.map +1 -1
  98. package/lib/policies.js.map +1 -1
  99. package/lib/restWrapper.d.ts.map +1 -1
  100. package/lib/restWrapper.js +5 -6
  101. package/lib/restWrapper.js.map +1 -1
  102. package/lib/retriableGitManager.d.ts.map +1 -1
  103. package/lib/retriableGitManager.js.map +1 -1
  104. package/lib/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
  105. package/lib/shreddedSummaryDocumentStorageService.js +9 -5
  106. package/lib/shreddedSummaryDocumentStorageService.js.map +1 -1
  107. package/lib/tokens.d.ts +24 -7
  108. package/lib/tokens.d.ts.map +1 -1
  109. package/lib/tokens.js.map +1 -1
  110. package/lib/urlUtils.d.ts.map +1 -1
  111. package/lib/urlUtils.js.map +1 -1
  112. package/lib/wholeSummaryDocumentStorageService.d.ts.map +1 -1
  113. package/lib/wholeSummaryDocumentStorageService.js +27 -13
  114. package/lib/wholeSummaryDocumentStorageService.js.map +1 -1
  115. package/package.json +115 -114
  116. package/prettier.config.cjs +1 -1
  117. package/src/cache.ts +16 -19
  118. package/src/createNewUtils.ts +24 -22
  119. package/src/defaultTokenProvider.ts +13 -15
  120. package/src/definitions.ts +2 -2
  121. package/src/deltaStorageService.ts +99 -95
  122. package/src/documentDeltaConnection.ts +53 -47
  123. package/src/documentService.ts +260 -239
  124. package/src/documentServiceFactory.ts +263 -250
  125. package/src/documentStorageService.ts +87 -83
  126. package/src/errorUtils.ts +91 -81
  127. package/src/index.ts +7 -1
  128. package/src/nullBlobStorageService.ts +24 -21
  129. package/src/packageVersion.ts +1 -1
  130. package/src/policies.ts +44 -44
  131. package/src/restWrapper.ts +266 -216
  132. package/src/retriableGitManager.ts +152 -151
  133. package/src/shreddedSummaryDocumentStorageService.ts +202 -194
  134. package/src/tokens.ts +69 -44
  135. package/src/urlUtils.ts +26 -23
  136. package/src/wholeSummaryDocumentStorageService.ts +246 -228
  137. package/tsconfig.esnext.json +6 -6
  138. package/tsconfig.json +9 -13
@@ -5,21 +5,21 @@
5
5
 
6
6
  import { assert } from "@fluidframework/common-utils";
7
7
  import {
8
- FiveDaysMs,
9
- IDocumentService,
10
- IDocumentServiceFactory,
11
- IDocumentStorageServicePolicies,
12
- IFluidResolvedUrl,
13
- IResolvedUrl,
14
- LoaderCachingPolicy,
8
+ FiveDaysMs,
9
+ IDocumentService,
10
+ IDocumentServiceFactory,
11
+ IDocumentStorageServicePolicies,
12
+ IFluidResolvedUrl,
13
+ IResolvedUrl,
14
+ LoaderCachingPolicy,
15
15
  } from "@fluidframework/driver-definitions";
16
16
  import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
17
17
  import { ISummaryTree } from "@fluidframework/protocol-definitions";
18
18
  import {
19
- ensureFluidResolvedUrl,
20
- getDocAttributesFromProtocolSummary,
21
- getQuorumValuesFromProtocolSummary,
22
- RateLimiter,
19
+ ensureFluidResolvedUrl,
20
+ getDocAttributesFromProtocolSummary,
21
+ getQuorumValuesFromProtocolSummary,
22
+ RateLimiter,
23
23
  } from "@fluidframework/driver-utils";
24
24
  import { ChildLogger, PerformanceEvent } from "@fluidframework/telemetry-utils";
25
25
  import { ISession } from "@fluidframework/server-services-client";
@@ -36,14 +36,14 @@ import { ISnapshotTreeVersion } from "./definitions";
36
36
  const maximumSnapshotCacheDurationMs: FiveDaysMs = 432_000_000; // 5 days in ms
37
37
 
38
38
  const defaultRouterliciousDriverPolicies: IRouterliciousDriverPolicies = {
39
- enablePrefetch: true,
40
- maxConcurrentStorageRequests: 100,
41
- maxConcurrentOrdererRequests: 100,
42
- aggregateBlobsSmallerThanBytes: undefined,
43
- enableDiscovery: false,
44
- enableWholeSummaryUpload: false,
45
- enableRestLess: true,
46
- enableInternalSummaryCaching: true,
39
+ enablePrefetch: true,
40
+ maxConcurrentStorageRequests: 100,
41
+ maxConcurrentOrdererRequests: 100,
42
+ aggregateBlobsSmallerThanBytes: undefined,
43
+ enableDiscovery: false,
44
+ enableWholeSummaryUpload: false,
45
+ enableRestLess: true,
46
+ enableInternalSummaryCaching: true,
47
47
  };
48
48
 
49
49
  /**
@@ -51,246 +51,257 @@ const defaultRouterliciousDriverPolicies: IRouterliciousDriverPolicies = {
51
51
  * use the routerlicious implementation.
52
52
  */
53
53
  export class RouterliciousDocumentServiceFactory implements IDocumentServiceFactory {
54
- public readonly protocolName = "fluid:";
55
- private readonly driverPolicies: IRouterliciousDriverPolicies;
56
- private readonly blobCache: ICache<ArrayBufferLike>;
57
- private readonly snapshotTreeCache: ICache<ISnapshotTreeVersion>;
54
+ public readonly protocolName = "fluid:";
55
+ private readonly driverPolicies: IRouterliciousDriverPolicies;
56
+ private readonly blobCache: ICache<ArrayBufferLike>;
57
+ private readonly snapshotTreeCache: ICache<ISnapshotTreeVersion>;
58
58
 
59
- constructor(
60
- private readonly tokenProvider: ITokenProvider,
61
- driverPolicies: Partial<IRouterliciousDriverPolicies> = {},
62
- ) {
63
- // Use the maximum allowed by the policy (IDocumentStorageServicePolicies.maximumCacheDurationMs set below)
64
- const snapshotCacheExpiryMs: FiveDaysMs = maximumSnapshotCacheDurationMs;
59
+ constructor(
60
+ private readonly tokenProvider: ITokenProvider,
61
+ driverPolicies: Partial<IRouterliciousDriverPolicies> = {},
62
+ ) {
63
+ // Use the maximum allowed by the policy (IDocumentStorageServicePolicies.maximumCacheDurationMs set below)
64
+ const snapshotCacheExpiryMs: FiveDaysMs = maximumSnapshotCacheDurationMs;
65
65
 
66
- this.driverPolicies = {
67
- ...defaultRouterliciousDriverPolicies,
68
- ...driverPolicies,
69
- };
70
- this.blobCache = new InMemoryCache<ArrayBufferLike>();
71
- this.snapshotTreeCache = this.driverPolicies.enableInternalSummaryCaching
72
- ? new InMemoryCache<ISnapshotTreeVersion>(snapshotCacheExpiryMs)
73
- : new NullCache<ISnapshotTreeVersion>();
74
- }
66
+ this.driverPolicies = {
67
+ ...defaultRouterliciousDriverPolicies,
68
+ ...driverPolicies,
69
+ };
70
+ this.blobCache = new InMemoryCache<ArrayBufferLike>();
71
+ this.snapshotTreeCache = this.driverPolicies.enableInternalSummaryCaching
72
+ ? new InMemoryCache<ISnapshotTreeVersion>(snapshotCacheExpiryMs)
73
+ : new NullCache<ISnapshotTreeVersion>();
74
+ }
75
75
 
76
- /**
77
- * {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createContainer}
78
- *
79
- * @throws {@link DocumentPostCreateError}
80
- * If an exception is thrown while invoking the provided {@link ITokenProvider.documentPostCreateCallback}.
81
- */
82
- public async createContainer(
83
- createNewSummary: ISummaryTree | undefined,
84
- resolvedUrl: IResolvedUrl,
85
- logger?: ITelemetryBaseLogger,
86
- clientIsSummarizer?: boolean,
87
- ): Promise<IDocumentService> {
88
- ensureFluidResolvedUrl(resolvedUrl);
89
- if (createNewSummary === undefined) {
90
- throw new Error("Empty file summary creation isn't supported in this driver.");
91
- }
92
- assert(!!resolvedUrl.endpoints.ordererUrl, 0x0b2 /* "Missing orderer URL!" */);
93
- let parsedUrl = parseFluidUrl(resolvedUrl.url);
94
- if (!parsedUrl.pathname) {
95
- throw new Error("Parsed url should contain tenant and doc Id!!");
96
- }
97
- const [, tenantId] = parsedUrl.pathname.split("/");
76
+ /**
77
+ * {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createContainer}
78
+ *
79
+ * @throws {@link DocumentPostCreateError}
80
+ * If an exception is thrown while invoking the provided {@link ITokenProvider.documentPostCreateCallback}.
81
+ */
82
+ public async createContainer(
83
+ createNewSummary: ISummaryTree | undefined,
84
+ resolvedUrl: IResolvedUrl,
85
+ logger?: ITelemetryBaseLogger,
86
+ clientIsSummarizer?: boolean,
87
+ ): Promise<IDocumentService> {
88
+ ensureFluidResolvedUrl(resolvedUrl);
89
+ if (createNewSummary === undefined) {
90
+ throw new Error("Empty file summary creation isn't supported in this driver.");
91
+ }
92
+ assert(!!resolvedUrl.endpoints.ordererUrl, 0x0b2 /* "Missing orderer URL!" */);
93
+ let parsedUrl = parseFluidUrl(resolvedUrl.url);
94
+ if (!parsedUrl.pathname) {
95
+ throw new Error("Parsed url should contain tenant and doc Id!!");
96
+ }
97
+ const [, tenantId] = parsedUrl.pathname.split("/");
98
98
 
99
- const protocolSummary = createNewSummary.tree[".protocol"] as ISummaryTree;
100
- const appSummary = createNewSummary.tree[".app"] as ISummaryTree;
101
- if (!(protocolSummary && appSummary)) {
102
- throw new Error("Protocol and App Summary required in the full summary");
103
- }
104
- const documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);
105
- const quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);
99
+ const protocolSummary = createNewSummary.tree[".protocol"] as ISummaryTree;
100
+ const appSummary = createNewSummary.tree[".app"] as ISummaryTree;
101
+ if (!(protocolSummary && appSummary)) {
102
+ throw new Error("Protocol and App Summary required in the full summary");
103
+ }
104
+ const documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);
105
+ const quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);
106
106
 
107
- const logger2 = ChildLogger.create(logger, "RouterliciousDriver");
108
- const rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);
109
- const ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(
110
- tenantId,
111
- undefined,
112
- this.tokenProvider,
113
- logger2,
114
- rateLimiter,
115
- this.driverPolicies.enableRestLess,
116
- resolvedUrl.endpoints.ordererUrl,
117
- );
107
+ const logger2 = ChildLogger.create(logger, "RouterliciousDriver");
108
+ const rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);
109
+ const ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(
110
+ tenantId,
111
+ undefined,
112
+ this.tokenProvider,
113
+ logger2,
114
+ rateLimiter,
115
+ this.driverPolicies.enableRestLess,
116
+ resolvedUrl.endpoints.ordererUrl,
117
+ );
118
118
 
119
- const res = await PerformanceEvent.timedExecAsync(
120
- logger2,
121
- {
122
- eventName: "CreateNew",
123
- details: JSON.stringify({
124
- enableDiscovery: this.driverPolicies.enableDiscovery,
125
- sequenceNumber: documentAttributes.sequenceNumber,
126
- }),
127
- },
128
- async (event) => {
129
- // @TODO: Remove returned "string" type when removing back-compat code
130
- const postRes = await ordererRestWrapper.post<
131
- { id: string; token?: string; session?: ISession; } | string
132
- >(`/documents/${tenantId}`, {
133
- summary: convertSummaryToCreateNewSummary(appSummary),
134
- sequenceNumber: documentAttributes.sequenceNumber,
135
- values: quorumValues,
136
- enableDiscovery: this.driverPolicies.enableDiscovery,
137
- generateToken:
138
- this.tokenProvider.documentPostCreateCallback !==
139
- undefined,
140
- });
119
+ const res = await PerformanceEvent.timedExecAsync(
120
+ logger2,
121
+ {
122
+ eventName: "CreateNew",
123
+ details: JSON.stringify({
124
+ enableDiscovery: this.driverPolicies.enableDiscovery,
125
+ sequenceNumber: documentAttributes.sequenceNumber,
126
+ }),
127
+ },
128
+ async (event) => {
129
+ // @TODO: Remove returned "string" type when removing back-compat code
130
+ const postRes = await ordererRestWrapper.post<
131
+ { id: string; token?: string; session?: ISession } | string
132
+ >(`/documents/${tenantId}`, {
133
+ summary: convertSummaryToCreateNewSummary(appSummary),
134
+ sequenceNumber: documentAttributes.sequenceNumber,
135
+ values: quorumValues,
136
+ enableDiscovery: this.driverPolicies.enableDiscovery,
137
+ generateToken: this.tokenProvider.documentPostCreateCallback !== undefined,
138
+ });
141
139
 
142
- event.end({
143
- docId: typeof postRes === "string" ? postRes : postRes.id,
144
- });
145
- return postRes;
146
- }
147
- );
140
+ event.end({
141
+ docId: typeof postRes === "string" ? postRes : postRes.id,
142
+ });
143
+ return postRes;
144
+ },
145
+ );
148
146
 
149
- // For supporting backward compatibility, when the request has generateToken === true, it will return
150
- // an object instead of string
151
- // @TODO: Remove the logic when no need to support back-compat
147
+ // For supporting backward compatibility, when the request has generateToken === true, it will return
148
+ // an object instead of string
149
+ // @TODO: Remove the logic when no need to support back-compat
152
150
 
153
- let documentId: string;
154
- let token: string | undefined;
155
- let session: ISession | undefined;
156
- if (typeof res === "string") {
157
- documentId = res;
158
- } else {
159
- documentId = res.id;
160
- token = res.token;
161
- session = this.driverPolicies.enableDiscovery ? res.session : undefined;
162
- }
163
- parsedUrl = parseFluidUrl(resolvedUrl.url);
151
+ let documentId: string;
152
+ let token: string | undefined;
153
+ let session: ISession | undefined;
154
+ if (typeof res === "string") {
155
+ documentId = res;
156
+ } else {
157
+ documentId = res.id;
158
+ token = res.token;
159
+ session = this.driverPolicies.enableDiscovery ? res.session : undefined;
160
+ }
161
+ parsedUrl = parseFluidUrl(resolvedUrl.url);
164
162
 
165
- // @TODO: Remove token from the condition, checking the documentPostCreateCallback !== undefined
166
- // is sufficient to determine if the token will be undefined or not.
167
- try {
168
- await PerformanceEvent.timedExecAsync(
169
- logger2,
170
- {
171
- eventName: "DocPostCreateCallback",
172
- docId: documentId,
173
- },
174
- async () => {
175
- if (token && this.tokenProvider.documentPostCreateCallback !== undefined) {
176
- return this.tokenProvider.documentPostCreateCallback(documentId, token);
177
- }
178
- });
179
- } catch (error: any) {
180
- throw new DocumentPostCreateError(error);
181
- }
163
+ // @TODO: Remove token from the condition, checking the documentPostCreateCallback !== undefined
164
+ // is sufficient to determine if the token will be undefined or not.
165
+ try {
166
+ await PerformanceEvent.timedExecAsync(
167
+ logger2,
168
+ {
169
+ eventName: "DocPostCreateCallback",
170
+ docId: documentId,
171
+ },
172
+ async () => {
173
+ if (token && this.tokenProvider.documentPostCreateCallback !== undefined) {
174
+ return this.tokenProvider.documentPostCreateCallback(documentId, token);
175
+ }
176
+ },
177
+ );
178
+ } catch (error: any) {
179
+ throw new DocumentPostCreateError(error);
180
+ }
182
181
 
183
- parsedUrl.set("pathname", replaceDocumentIdInPath(parsedUrl.pathname, documentId));
184
- const deltaStorageUrl = resolvedUrl.endpoints.deltaStorageUrl;
185
- if (!deltaStorageUrl) {
186
- throw new Error(
187
- `All endpoints urls must be provided. [deltaStorageUrl:${deltaStorageUrl}]`);
188
- }
189
- const parsedDeltaStorageUrl = new URL(deltaStorageUrl);
190
- parsedDeltaStorageUrl.pathname = replaceDocumentIdInPath(parsedDeltaStorageUrl.pathname, documentId);
182
+ parsedUrl.set("pathname", replaceDocumentIdInPath(parsedUrl.pathname, documentId));
183
+ const deltaStorageUrl = resolvedUrl.endpoints.deltaStorageUrl;
184
+ if (!deltaStorageUrl) {
185
+ throw new Error(
186
+ `All endpoints urls must be provided. [deltaStorageUrl:${deltaStorageUrl}]`,
187
+ );
188
+ }
189
+ const parsedDeltaStorageUrl = new URL(deltaStorageUrl);
190
+ parsedDeltaStorageUrl.pathname = replaceDocumentIdInPath(
191
+ parsedDeltaStorageUrl.pathname,
192
+ documentId,
193
+ );
191
194
 
192
- return this.createDocumentService(
193
- {
194
- ...resolvedUrl,
195
- url: parsedUrl.toString(),
196
- id: documentId,
197
- endpoints: {
198
- ...resolvedUrl.endpoints,
199
- deltaStorageUrl: parsedDeltaStorageUrl.toString(),
200
- },
201
- },
202
- logger,
203
- clientIsSummarizer,
204
- session,
205
- );
206
- }
195
+ return this.createDocumentService(
196
+ {
197
+ ...resolvedUrl,
198
+ url: parsedUrl.toString(),
199
+ id: documentId,
200
+ endpoints: {
201
+ ...resolvedUrl.endpoints,
202
+ deltaStorageUrl: parsedDeltaStorageUrl.toString(),
203
+ },
204
+ },
205
+ logger,
206
+ clientIsSummarizer,
207
+ session,
208
+ );
209
+ }
207
210
 
208
- /**
209
- * {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createDocumentService}
210
- *
211
- * @returns Routerlicious document service.
212
- */
213
- public async createDocumentService(
214
- resolvedUrl: IResolvedUrl,
215
- logger?: ITelemetryBaseLogger,
216
- clientIsSummarizer?: boolean,
217
- session?: ISession,
218
- ): Promise<IDocumentService> {
219
- ensureFluidResolvedUrl(resolvedUrl);
220
- const parsedUrl = parseFluidUrl(resolvedUrl.url);
221
- const [, tenantId, documentId] = parsedUrl.pathname.split("/");
222
- if (!documentId || !tenantId) {
223
- throw new Error(
224
- `Couldn't parse documentId and/or tenantId. [documentId:${documentId}][tenantId:${tenantId}]`);
225
- }
226
- const logger2 = ChildLogger.create(logger, "RouterliciousDriver", { all: { driverVersion } });
211
+ /**
212
+ * {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createDocumentService}
213
+ *
214
+ * @returns Routerlicious document service.
215
+ */
216
+ public async createDocumentService(
217
+ resolvedUrl: IResolvedUrl,
218
+ logger?: ITelemetryBaseLogger,
219
+ clientIsSummarizer?: boolean,
220
+ session?: ISession,
221
+ ): Promise<IDocumentService> {
222
+ ensureFluidResolvedUrl(resolvedUrl);
223
+ const parsedUrl = parseFluidUrl(resolvedUrl.url);
224
+ const [, tenantId, documentId] = parsedUrl.pathname.split("/");
225
+ if (!documentId || !tenantId) {
226
+ throw new Error(
227
+ `Couldn't parse documentId and/or tenantId. [documentId:${documentId}][tenantId:${tenantId}]`,
228
+ );
229
+ }
230
+ const logger2 = ChildLogger.create(logger, "RouterliciousDriver", {
231
+ all: { driverVersion },
232
+ });
227
233
 
228
- const rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);
229
- const ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(
230
- tenantId,
231
- documentId,
232
- this.tokenProvider,
233
- logger2,
234
- rateLimiter,
235
- this.driverPolicies.enableRestLess,
236
- );
234
+ const rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);
235
+ const ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(
236
+ tenantId,
237
+ documentId,
238
+ this.tokenProvider,
239
+ logger2,
240
+ rateLimiter,
241
+ this.driverPolicies.enableRestLess,
242
+ );
237
243
 
238
- const discoverFluidResolvedUrl = async (): Promise<IFluidResolvedUrl> => {
239
- if (!this.driverPolicies.enableDiscovery) {
240
- return resolvedUrl;
241
- }
244
+ const discoverFluidResolvedUrl = async (): Promise<IFluidResolvedUrl> => {
245
+ if (!this.driverPolicies.enableDiscovery) {
246
+ return resolvedUrl;
247
+ }
242
248
 
243
- const discoveredSession = await PerformanceEvent.timedExecAsync(
244
- logger2,
245
- {
246
- eventName: "DiscoverSession",
247
- docId: documentId,
248
- },
249
- async () => {
250
- // The service responds with the current document session associated with the container.
251
- return ordererRestWrapper.get<ISession>(
252
- `${resolvedUrl.endpoints.ordererUrl}/documents/${tenantId}/session/${documentId}`);
253
- });
254
- return getDiscoveredFluidResolvedUrl(resolvedUrl, discoveredSession);
255
- };
256
- const fluidResolvedUrl: IFluidResolvedUrl = session !== undefined
257
- ? getDiscoveredFluidResolvedUrl(resolvedUrl, session)
258
- : await discoverFluidResolvedUrl();
249
+ const discoveredSession = await PerformanceEvent.timedExecAsync(
250
+ logger2,
251
+ {
252
+ eventName: "DiscoverSession",
253
+ docId: documentId,
254
+ },
255
+ async () => {
256
+ // The service responds with the current document session associated with the container.
257
+ return ordererRestWrapper.get<ISession>(
258
+ `${resolvedUrl.endpoints.ordererUrl}/documents/${tenantId}/session/${documentId}`,
259
+ );
260
+ },
261
+ );
262
+ return getDiscoveredFluidResolvedUrl(resolvedUrl, discoveredSession);
263
+ };
264
+ const fluidResolvedUrl: IFluidResolvedUrl =
265
+ session !== undefined
266
+ ? getDiscoveredFluidResolvedUrl(resolvedUrl, session)
267
+ : await discoverFluidResolvedUrl();
259
268
 
260
- const storageUrl = fluidResolvedUrl.endpoints.storageUrl;
261
- const ordererUrl = fluidResolvedUrl.endpoints.ordererUrl;
262
- const deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl;
263
- const deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl || ordererUrl; // backward compatibility
264
- if (!ordererUrl || !deltaStorageUrl) {
265
- throw new Error(
266
- `All endpoints urls must be provided. [ordererUrl:${ordererUrl}][deltaStorageUrl:${deltaStorageUrl}]`);
267
- }
269
+ const storageUrl = fluidResolvedUrl.endpoints.storageUrl;
270
+ const ordererUrl = fluidResolvedUrl.endpoints.ordererUrl;
271
+ const deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl;
272
+ const deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl || ordererUrl; // backward compatibility
273
+ if (!ordererUrl || !deltaStorageUrl) {
274
+ throw new Error(
275
+ `All endpoints urls must be provided. [ordererUrl:${ordererUrl}][deltaStorageUrl:${deltaStorageUrl}]`,
276
+ );
277
+ }
268
278
 
269
- const documentStorageServicePolicies: IDocumentStorageServicePolicies = {
270
- caching: this.driverPolicies.enablePrefetch
271
- ? LoaderCachingPolicy.Prefetch
272
- : LoaderCachingPolicy.NoCaching,
273
- minBlobSize: this.driverPolicies.aggregateBlobsSmallerThanBytes,
274
- maximumCacheDurationMs: maximumSnapshotCacheDurationMs,
275
- };
279
+ const documentStorageServicePolicies: IDocumentStorageServicePolicies = {
280
+ caching: this.driverPolicies.enablePrefetch
281
+ ? LoaderCachingPolicy.Prefetch
282
+ : LoaderCachingPolicy.NoCaching,
283
+ minBlobSize: this.driverPolicies.aggregateBlobsSmallerThanBytes,
284
+ maximumCacheDurationMs: maximumSnapshotCacheDurationMs,
285
+ };
276
286
 
277
- return new DocumentService(
278
- fluidResolvedUrl,
279
- ordererUrl,
280
- deltaStorageUrl,
281
- deltaStreamUrl,
282
- storageUrl,
283
- logger2,
284
- this.tokenProvider,
285
- tenantId,
286
- documentId,
287
- ordererRestWrapper,
288
- documentStorageServicePolicies,
289
- this.driverPolicies,
290
- this.blobCache,
291
- this.snapshotTreeCache,
292
- discoverFluidResolvedUrl);
293
- }
287
+ return new DocumentService(
288
+ fluidResolvedUrl,
289
+ ordererUrl,
290
+ deltaStorageUrl,
291
+ deltaStreamUrl,
292
+ storageUrl,
293
+ logger2,
294
+ this.tokenProvider,
295
+ tenantId,
296
+ documentId,
297
+ ordererRestWrapper,
298
+ documentStorageServicePolicies,
299
+ this.driverPolicies,
300
+ this.blobCache,
301
+ this.snapshotTreeCache,
302
+ discoverFluidResolvedUrl,
303
+ );
304
+ }
294
305
  }
295
306
 
296
307
  /**
@@ -305,16 +316,18 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
305
316
  * - What would a retry pattern look like here?
306
317
  */
307
318
  export class DocumentPostCreateError extends Error {
308
- public constructor(
309
- /**
310
- * Inner error being wrapped.
311
- */
312
- private readonly innerError: Error,
313
- ) {
314
- super(innerError.message);
315
- }
319
+ public constructor(
320
+ /**
321
+ * Inner error being wrapped.
322
+ */
323
+ private readonly innerError: Error,
324
+ ) {
325
+ super(innerError.message);
326
+ }
316
327
 
317
- public readonly name = "DocumentPostCreateError";
328
+ public readonly name = "DocumentPostCreateError";
318
329
 
319
- public get stack() { return this.innerError.stack; }
330
+ public get stack() {
331
+ return this.innerError.stack;
332
+ }
320
333
  }