@fluidframework/routerlicious-driver 2.0.0-dev-rc.3.0.0.250606 → 2.0.0-dev-rc.3.0.0.253463

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 (185) hide show
  1. package/api-report/routerlicious-driver.api.md +3 -3
  2. package/dist/deltaStorageService.d.ts +1 -1
  3. package/dist/deltaStorageService.d.ts.map +1 -1
  4. package/dist/deltaStorageService.js +12 -12
  5. package/dist/deltaStorageService.js.map +1 -1
  6. package/dist/documentDeltaConnection.d.ts +3 -2
  7. package/dist/documentDeltaConnection.d.ts.map +1 -1
  8. package/dist/documentDeltaConnection.js +2 -2
  9. package/dist/documentDeltaConnection.js.map +1 -1
  10. package/dist/documentService.d.ts +1 -1
  11. package/dist/documentService.d.ts.map +1 -1
  12. package/dist/documentService.js +10 -10
  13. package/dist/documentService.js.map +1 -1
  14. package/dist/documentServiceFactory.d.ts +1 -1
  15. package/dist/documentServiceFactory.d.ts.map +1 -1
  16. package/dist/documentServiceFactory.js +20 -20
  17. package/dist/documentServiceFactory.js.map +1 -1
  18. package/dist/documentStorageService.d.ts +2 -2
  19. package/dist/documentStorageService.d.ts.map +1 -1
  20. package/dist/documentStorageService.js +5 -5
  21. package/dist/documentStorageService.js.map +1 -1
  22. package/dist/errorUtils.d.ts +3 -2
  23. package/dist/errorUtils.d.ts.map +1 -1
  24. package/dist/errorUtils.js +6 -6
  25. package/dist/errorUtils.js.map +1 -1
  26. package/dist/gitManager.d.ts.map +1 -1
  27. package/dist/gitManager.js.map +1 -1
  28. package/dist/historian.d.ts.map +1 -1
  29. package/dist/historian.js.map +1 -1
  30. package/dist/mapWithExpiration.js +2 -2
  31. package/dist/mapWithExpiration.js.map +1 -1
  32. package/dist/nullBlobStorageService.d.ts +1 -1
  33. package/dist/nullBlobStorageService.d.ts.map +1 -1
  34. package/dist/nullBlobStorageService.js.map +1 -1
  35. package/dist/packageVersion.d.ts +1 -1
  36. package/dist/packageVersion.js +1 -1
  37. package/dist/packageVersion.js.map +1 -1
  38. package/dist/r11sSnapshotParser.d.ts.map +1 -1
  39. package/dist/r11sSnapshotParser.js.map +1 -1
  40. package/dist/restWrapper.d.ts +1 -1
  41. package/dist/restWrapper.d.ts.map +1 -1
  42. package/dist/restWrapper.js +9 -9
  43. package/dist/restWrapper.js.map +1 -1
  44. package/dist/retriableGitManager.d.ts.map +1 -1
  45. package/dist/retriableGitManager.js +2 -2
  46. package/dist/retriableGitManager.js.map +1 -1
  47. package/dist/routerlicious-driver-alpha.d.ts +3 -3
  48. package/dist/routerlicious-driver-beta.d.ts +3 -3
  49. package/dist/routerlicious-driver-public.d.ts +3 -3
  50. package/dist/routerlicious-driver-untrimmed.d.ts +3 -3
  51. package/dist/routerliciousResolvedUrl.d.ts +1 -1
  52. package/dist/routerliciousResolvedUrl.d.ts.map +1 -1
  53. package/dist/routerliciousResolvedUrl.js.map +1 -1
  54. package/dist/shreddedSummaryDocumentStorageService.d.ts +1 -1
  55. package/dist/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
  56. package/dist/shreddedSummaryDocumentStorageService.js +7 -7
  57. package/dist/shreddedSummaryDocumentStorageService.js.map +1 -1
  58. package/dist/storageContracts.d.ts.map +1 -1
  59. package/dist/storageContracts.js.map +1 -1
  60. package/dist/summaryTreeUploadManager.d.ts.map +1 -1
  61. package/dist/summaryTreeUploadManager.js +6 -6
  62. package/dist/summaryTreeUploadManager.js.map +1 -1
  63. package/dist/treeUtils.d.ts.map +1 -1
  64. package/dist/treeUtils.js +4 -4
  65. package/dist/treeUtils.js.map +1 -1
  66. package/dist/urlUtils.d.ts +1 -1
  67. package/dist/urlUtils.d.ts.map +1 -1
  68. package/dist/urlUtils.js.map +1 -1
  69. package/dist/wholeSummaryDocumentStorageService.d.ts +1 -1
  70. package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -1
  71. package/dist/wholeSummaryDocumentStorageService.js +14 -14
  72. package/dist/wholeSummaryDocumentStorageService.js.map +1 -1
  73. package/dist/wholeSummaryUploadManager.d.ts.map +1 -1
  74. package/dist/wholeSummaryUploadManager.js.map +1 -1
  75. package/lib/deltaStorageService.d.ts +1 -1
  76. package/lib/deltaStorageService.d.ts.map +1 -1
  77. package/lib/deltaStorageService.js +3 -3
  78. package/lib/deltaStorageService.js.map +1 -1
  79. package/lib/documentDeltaConnection.d.ts +3 -2
  80. package/lib/documentDeltaConnection.d.ts.map +1 -1
  81. package/lib/documentDeltaConnection.js +1 -1
  82. package/lib/documentDeltaConnection.js.map +1 -1
  83. package/lib/documentService.d.ts +1 -1
  84. package/lib/documentService.d.ts.map +1 -1
  85. package/lib/documentService.js +3 -3
  86. package/lib/documentService.js.map +1 -1
  87. package/lib/documentServiceFactory.d.ts +1 -1
  88. package/lib/documentServiceFactory.d.ts.map +1 -1
  89. package/lib/documentServiceFactory.js +5 -5
  90. package/lib/documentServiceFactory.js.map +1 -1
  91. package/lib/documentStorageService.d.ts +2 -2
  92. package/lib/documentStorageService.d.ts.map +1 -1
  93. package/lib/documentStorageService.js +2 -2
  94. package/lib/documentStorageService.js.map +1 -1
  95. package/lib/errorUtils.d.ts +3 -2
  96. package/lib/errorUtils.d.ts.map +1 -1
  97. package/lib/errorUtils.js +2 -2
  98. package/lib/errorUtils.js.map +1 -1
  99. package/lib/gitManager.d.ts.map +1 -1
  100. package/lib/gitManager.js.map +1 -1
  101. package/lib/historian.d.ts.map +1 -1
  102. package/lib/historian.js.map +1 -1
  103. package/lib/mapWithExpiration.js +1 -1
  104. package/lib/mapWithExpiration.js.map +1 -1
  105. package/lib/nullBlobStorageService.d.ts +1 -1
  106. package/lib/nullBlobStorageService.d.ts.map +1 -1
  107. package/lib/nullBlobStorageService.js.map +1 -1
  108. package/lib/packageVersion.d.ts +1 -1
  109. package/lib/packageVersion.js +1 -1
  110. package/lib/packageVersion.js.map +1 -1
  111. package/lib/r11sSnapshotParser.d.ts.map +1 -1
  112. package/lib/r11sSnapshotParser.js.map +1 -1
  113. package/lib/restWrapper.d.ts +1 -1
  114. package/lib/restWrapper.d.ts.map +1 -1
  115. package/lib/restWrapper.js +3 -3
  116. package/lib/restWrapper.js.map +1 -1
  117. package/lib/retriableGitManager.d.ts.map +1 -1
  118. package/lib/retriableGitManager.js +1 -1
  119. package/lib/retriableGitManager.js.map +1 -1
  120. package/lib/routerlicious-driver-alpha.d.ts +3 -3
  121. package/lib/routerlicious-driver-beta.d.ts +3 -3
  122. package/lib/routerlicious-driver-public.d.ts +3 -3
  123. package/lib/routerlicious-driver-untrimmed.d.ts +3 -3
  124. package/lib/routerliciousResolvedUrl.d.ts +1 -1
  125. package/lib/routerliciousResolvedUrl.d.ts.map +1 -1
  126. package/lib/routerliciousResolvedUrl.js.map +1 -1
  127. package/lib/shreddedSummaryDocumentStorageService.d.ts +1 -1
  128. package/lib/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
  129. package/lib/shreddedSummaryDocumentStorageService.js +1 -1
  130. package/lib/shreddedSummaryDocumentStorageService.js.map +1 -1
  131. package/lib/storageContracts.d.ts.map +1 -1
  132. package/lib/storageContracts.js.map +1 -1
  133. package/lib/summaryTreeUploadManager.d.ts.map +1 -1
  134. package/lib/summaryTreeUploadManager.js +1 -1
  135. package/lib/summaryTreeUploadManager.js.map +1 -1
  136. package/lib/treeUtils.d.ts.map +1 -1
  137. package/lib/treeUtils.js +1 -1
  138. package/lib/treeUtils.js.map +1 -1
  139. package/lib/tsdoc-metadata.json +11 -0
  140. package/lib/urlUtils.d.ts +1 -1
  141. package/lib/urlUtils.d.ts.map +1 -1
  142. package/lib/urlUtils.js.map +1 -1
  143. package/lib/wholeSummaryDocumentStorageService.d.ts +1 -1
  144. package/lib/wholeSummaryDocumentStorageService.d.ts.map +1 -1
  145. package/lib/wholeSummaryDocumentStorageService.js +3 -3
  146. package/lib/wholeSummaryDocumentStorageService.js.map +1 -1
  147. package/lib/wholeSummaryUploadManager.d.ts.map +1 -1
  148. package/lib/wholeSummaryUploadManager.js.map +1 -1
  149. package/package.json +10 -22
  150. package/src/deltaStorageService.ts +6 -4
  151. package/src/documentDeltaConnection.ts +4 -2
  152. package/src/documentService.ts +10 -4
  153. package/src/documentServiceFactory.ts +6 -5
  154. package/src/documentStorageService.ts +3 -2
  155. package/src/errorUtils.ts +5 -7
  156. package/src/gitManager.ts +1 -0
  157. package/src/historian.ts +1 -0
  158. package/src/mapWithExpiration.ts +1 -1
  159. package/src/nullBlobStorageService.ts +4 -1
  160. package/src/packageVersion.ts +1 -1
  161. package/src/r11sSnapshotParser.ts +1 -0
  162. package/src/restWrapper.ts +9 -7
  163. package/src/retriableGitManager.ts +2 -1
  164. package/src/routerliciousResolvedUrl.ts +1 -1
  165. package/src/shreddedSummaryDocumentStorageService.ts +4 -3
  166. package/src/storageContracts.ts +1 -0
  167. package/src/summaryTreeUploadManager.ts +2 -1
  168. package/src/treeUtils.ts +2 -1
  169. package/src/urlUtils.ts +1 -1
  170. package/src/wholeSummaryDocumentStorageService.ts +6 -5
  171. package/src/wholeSummaryUploadManager.ts +1 -0
  172. package/lib/test/cache.spec.js +0 -43
  173. package/lib/test/cache.spec.js.map +0 -1
  174. package/lib/test/errorUtils.spec.js +0 -227
  175. package/lib/test/errorUtils.spec.js.map +0 -1
  176. package/lib/test/mapWithExpiration.spec.js +0 -205
  177. package/lib/test/mapWithExpiration.spec.js.map +0 -1
  178. package/lib/test/restWrapper.spec.js +0 -309
  179. package/lib/test/restWrapper.spec.js.map +0 -1
  180. package/lib/test/types/validateRouterliciousDriverPrevious.generated.js +0 -22
  181. package/lib/test/types/validateRouterliciousDriverPrevious.generated.js.map +0 -1
  182. package/lib/test/urlUtils.spec.js +0 -62
  183. package/lib/test/urlUtils.spec.js.map +0 -1
  184. package/lib/test/wholeSummaryDocumentStorageService.spec.js +0 -144
  185. package/lib/test/wholeSummaryDocumentStorageService.spec.js.map +0 -1
@@ -1,309 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import assert from "assert";
6
- import { RateLimiter } from "@fluidframework/driver-utils";
7
- import { MockLogger } from "@fluidframework/telemetry-utils";
8
- import nock from "nock";
9
- import { DefaultTokenProvider } from "../defaultTokenProvider.js";
10
- import { RouterliciousErrorTypes } from "../errorUtils.js";
11
- import { RouterliciousOrdererRestWrapper, toInstrumentedR11sOrdererTokenFetcher, } from "../restWrapper.js";
12
- describe("RouterliciousDriverRestWrapper", () => {
13
- const rateLimiter = new RateLimiter(1);
14
- const testHost = "http://localhost:3030";
15
- const testPath = "/api/protected";
16
- const testUrl = `${testHost}${testPath}`;
17
- // Set up mock request authentication
18
- const token1 = "1234-auth-token-abcd";
19
- const token2 = "9876-auth-token-zyxw";
20
- const token3 = "abc-auth-token-123";
21
- let tokenQueue = [];
22
- // Set up mock throttling
23
- let throttleDurationInMs;
24
- let throttledAt;
25
- const throttle = () => {
26
- throttledAt = Date.now();
27
- };
28
- function replyWithThrottling() {
29
- const retryAfterSeconds = (throttleDurationInMs - Date.now() - throttledAt) / 1000;
30
- const throttled = retryAfterSeconds > 0;
31
- if (throttled) {
32
- return [429, { retryAfter: retryAfterSeconds }];
33
- }
34
- return [200, "OK"];
35
- }
36
- let restWrapper;
37
- const logger = new MockLogger();
38
- beforeEach(async () => {
39
- // reset auth mocking
40
- tokenQueue = [token1, token2, token3];
41
- // reset throttling mocking
42
- throttledAt = 0;
43
- throttleDurationInMs = 50;
44
- const tokenProvider = new DefaultTokenProvider("testtoken");
45
- tokenProvider.fetchOrdererToken = async () => {
46
- // Pop a token off tokenQueue
47
- const newToken = {
48
- jwt: tokenQueue.shift() ?? "testtoken",
49
- };
50
- return newToken;
51
- };
52
- restWrapper = await RouterliciousOrdererRestWrapper.load(toInstrumentedR11sOrdererTokenFetcher("dummytenantid", "dummydocumentid", tokenProvider, logger.toTelemetryLogger()), logger.toTelemetryLogger(), rateLimiter, false);
53
- });
54
- after(() => {
55
- nock.restore();
56
- });
57
- afterEach(() => {
58
- logger.assertMatchNone([{ category: "error" }]);
59
- });
60
- describe("get()", () => {
61
- it("sends a request with auth headers", async () => {
62
- nock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })
63
- .get(testPath)
64
- .reply(200);
65
- await assert.doesNotReject(restWrapper.get(testUrl));
66
- });
67
- it("retries a request with fresh auth headers on 401", async () => {
68
- nock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })
69
- .get(testPath)
70
- .reply(401);
71
- nock(testHost, { reqheaders: { authorization: `Basic ${token2}` } })
72
- .get(testPath)
73
- .reply(200);
74
- await assert.doesNotReject(restWrapper.get(testUrl));
75
- });
76
- it("throws a non-retriable error on 2nd 401", async () => {
77
- nock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })
78
- .get(testPath)
79
- .reply(401);
80
- nock(testHost, { reqheaders: { authorization: `Basic ${token2}` } })
81
- .get(testPath)
82
- .reply(401);
83
- await assert.rejects(restWrapper.get(testUrl), {
84
- canRetry: false,
85
- errorType: RouterliciousErrorTypes.authorizationError,
86
- });
87
- });
88
- it("throws a retriable error on 500", async () => {
89
- nock(testHost).get(testPath).reply(500);
90
- await assert.rejects(restWrapper.get(testUrl), {
91
- canRetry: true,
92
- errorType: RouterliciousErrorTypes.genericNetworkError,
93
- });
94
- });
95
- it("retries with delay on 429 with retryAfter", async () => {
96
- throttle();
97
- nock(testHost).get(testPath).reply(replyWithThrottling);
98
- await assert.doesNotReject(restWrapper.get(testUrl));
99
- });
100
- it("throws a retriable error on 429 without retryAfter", async () => {
101
- nock(testHost).get(testPath).reply(429, { retryAfter: undefined });
102
- await assert.rejects(restWrapper.get(testUrl), {
103
- canRetry: true,
104
- errorType: RouterliciousErrorTypes.genericNetworkError,
105
- });
106
- });
107
- it("throws a non-retriable error on 404", async () => {
108
- nock(testHost).get(testPath).reply(404);
109
- await assert.rejects(restWrapper.get(testUrl), {
110
- canRetry: false,
111
- errorType: RouterliciousErrorTypes.fileNotFoundOrAccessDeniedError,
112
- });
113
- });
114
- it("throws retriable error on Network Error", async () => {
115
- nock(testHost).get(testPath).replyWithError({ code: "ECONNRESET" });
116
- await assert.rejects(restWrapper.get(testUrl), {
117
- canRetry: true,
118
- errorType: RouterliciousErrorTypes.genericNetworkError,
119
- });
120
- });
121
- });
122
- describe("post()", () => {
123
- it("sends a request with auth headers", async () => {
124
- nock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })
125
- .post(testPath)
126
- .reply(200);
127
- await assert.doesNotReject(restWrapper.post(testUrl, { test: "payload" }));
128
- });
129
- it("retries a request with fresh auth headers on 401", async () => {
130
- nock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })
131
- .post(testPath)
132
- .reply(401);
133
- nock(testHost, { reqheaders: { authorization: `Basic ${token2}` } })
134
- .post(testPath)
135
- .reply(200);
136
- await assert.doesNotReject(restWrapper.post(testUrl, { test: "payload" }));
137
- });
138
- it("throws a non-retriable error on 2nd 401", async () => {
139
- nock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })
140
- .post(testPath)
141
- .reply(401);
142
- nock(testHost, { reqheaders: { authorization: `Basic ${token2}` } })
143
- .post(testPath)
144
- .reply(401);
145
- await assert.rejects(restWrapper.post(testUrl, { test: "payload" }), {
146
- canRetry: false,
147
- errorType: RouterliciousErrorTypes.authorizationError,
148
- });
149
- });
150
- it("throws a retriable error on 500", async () => {
151
- nock(testHost).post(testPath).reply(500);
152
- await assert.rejects(restWrapper.post(testUrl, { test: "payload" }), {
153
- canRetry: true,
154
- errorType: RouterliciousErrorTypes.genericNetworkError,
155
- });
156
- });
157
- it("retries with delay on 429 with retryAfter", async () => {
158
- throttle();
159
- nock(testHost).post(testPath).reply(replyWithThrottling);
160
- await assert.doesNotReject(restWrapper.post(testUrl, { test: "payload" }));
161
- });
162
- it("throws a retriable error on 429 without retryAfter", async () => {
163
- nock(testHost).post(testPath).reply(429, { retryAfter: undefined });
164
- await assert.rejects(restWrapper.post(testUrl, { test: "payload" }), {
165
- canRetry: true,
166
- errorType: RouterliciousErrorTypes.genericNetworkError,
167
- });
168
- });
169
- it("throws a non-retriable error on 404", async () => {
170
- nock(testHost).post(testPath).reply(404);
171
- await assert.rejects(restWrapper.post(testUrl, { test: "payload" }), {
172
- canRetry: false,
173
- errorType: RouterliciousErrorTypes.fileNotFoundOrAccessDeniedError,
174
- });
175
- });
176
- it("throws retriable error on Network Error", async () => {
177
- nock(testHost).post(testPath).replyWithError({ code: "ECONNRESET" });
178
- await assert.rejects(restWrapper.post(testUrl, { test: "payload" }), {
179
- canRetry: true,
180
- errorType: RouterliciousErrorTypes.genericNetworkError,
181
- });
182
- });
183
- });
184
- describe("patch()", () => {
185
- it("sends a request with auth headers", async () => {
186
- nock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })
187
- .patch(testPath)
188
- .reply(200);
189
- await assert.doesNotReject(restWrapper.patch(testUrl, { test: "payload" }));
190
- });
191
- it("retries a request with fresh auth headers on 401", async () => {
192
- nock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })
193
- .patch(testPath)
194
- .reply(401);
195
- nock(testHost, { reqheaders: { authorization: `Basic ${token2}` } })
196
- .patch(testPath)
197
- .reply(200);
198
- await assert.doesNotReject(restWrapper.patch(testUrl, { test: "payload" }));
199
- });
200
- it("throws a non-retriable error on 2nd 401", async () => {
201
- nock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })
202
- .patch(testPath)
203
- .reply(401);
204
- nock(testHost, { reqheaders: { authorization: `Basic ${token2}` } })
205
- .patch(testPath)
206
- .reply(401);
207
- await assert.rejects(restWrapper.patch(testUrl, { test: "payload" }), {
208
- canRetry: false,
209
- errorType: RouterliciousErrorTypes.authorizationError,
210
- });
211
- });
212
- it("throws a retriable error on 500", async () => {
213
- nock(testHost).patch(testPath).reply(500);
214
- await assert.rejects(restWrapper.patch(testUrl, { test: "payload" }), {
215
- canRetry: true,
216
- errorType: RouterliciousErrorTypes.genericNetworkError,
217
- });
218
- });
219
- it("retries with delay on 429 with retryAfter", async () => {
220
- throttle();
221
- nock(testHost).patch(testPath).reply(replyWithThrottling);
222
- await assert.doesNotReject(restWrapper.patch(testUrl, { test: "payload" }));
223
- });
224
- it("throws a retriable error on 429 without retryAfter", async () => {
225
- nock(testHost).patch(testPath).reply(429, { retryAfter: undefined });
226
- await assert.rejects(restWrapper.patch(testUrl, { test: "payload" }), {
227
- canRetry: true,
228
- errorType: RouterliciousErrorTypes.genericNetworkError,
229
- });
230
- });
231
- it("throws a non-retriable error on 404", async () => {
232
- nock(testHost).patch(testPath).reply(404);
233
- await assert.rejects(restWrapper.patch(testUrl, { test: "payload" }), {
234
- canRetry: false,
235
- errorType: RouterliciousErrorTypes.fileNotFoundOrAccessDeniedError,
236
- });
237
- });
238
- it("throws retriable error on Network Error", async () => {
239
- nock(testHost).patch(testPath).replyWithError({ code: "ECONNRESET" });
240
- await assert.rejects(restWrapper.patch(testUrl, { test: "payload" }), {
241
- canRetry: true,
242
- errorType: RouterliciousErrorTypes.genericNetworkError,
243
- });
244
- });
245
- });
246
- describe("delete()", () => {
247
- it("sends a request with auth headers", async () => {
248
- nock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })
249
- .delete(testPath)
250
- .reply(200);
251
- await assert.doesNotReject(restWrapper.delete(testUrl));
252
- });
253
- it("retries a request with fresh auth headers on 401", async () => {
254
- nock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })
255
- .delete(testPath)
256
- .reply(401);
257
- nock(testHost, { reqheaders: { authorization: `Basic ${token2}` } })
258
- .delete(testPath)
259
- .reply(200);
260
- await assert.doesNotReject(restWrapper.delete(testUrl));
261
- });
262
- it("throws a non-retriable error on 2nd 401", async () => {
263
- nock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })
264
- .delete(testPath)
265
- .reply(401);
266
- nock(testHost, { reqheaders: { authorization: `Basic ${token2}` } })
267
- .delete(testPath)
268
- .reply(401);
269
- await assert.rejects(restWrapper.delete(testUrl), {
270
- canRetry: false,
271
- errorType: RouterliciousErrorTypes.authorizationError,
272
- });
273
- });
274
- it("throws a retriable error on 500", async () => {
275
- nock(testHost).delete(testPath).reply(500);
276
- await assert.rejects(restWrapper.delete(testUrl), {
277
- canRetry: true,
278
- errorType: RouterliciousErrorTypes.genericNetworkError,
279
- });
280
- });
281
- it("retries with delay on 429 with retryAfter", async () => {
282
- throttle();
283
- nock(testHost).delete(testPath).reply(replyWithThrottling);
284
- await assert.doesNotReject(restWrapper.delete(testUrl));
285
- });
286
- it("throws a retriable error on 429 without retryAfter", async () => {
287
- nock(testHost).delete(testPath).reply(429, { retryAfter: undefined });
288
- await assert.rejects(restWrapper.delete(testUrl), {
289
- canRetry: true,
290
- errorType: RouterliciousErrorTypes.genericNetworkError,
291
- });
292
- });
293
- it("throws a non-retriable error on 404", async () => {
294
- nock(testHost).delete(testPath).reply(404);
295
- await assert.rejects(restWrapper.delete(testUrl), {
296
- canRetry: false,
297
- errorType: RouterliciousErrorTypes.fileNotFoundOrAccessDeniedError,
298
- });
299
- });
300
- it("throws retriable error on Network Error", async () => {
301
- nock(testHost).delete(testPath).replyWithError({ code: "ECONNRESET" });
302
- await assert.rejects(restWrapper.delete(testUrl), {
303
- canRetry: true,
304
- errorType: RouterliciousErrorTypes.genericNetworkError,
305
- });
306
- });
307
- });
308
- });
309
- //# sourceMappingURL=restWrapper.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"restWrapper.spec.js","sourceRoot":"","sources":["../../src/test/restWrapper.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EACN,+BAA+B,EAC/B,qCAAqC,GACrC,MAAM,mB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AC,CAAC;QACH,EAAE,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;YACxD,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;YACvE,MAAM,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;gBACjD,QAAQ,EAAE,IAAI;gBACd,SAAS,EAAE,uBAAuB,CAAC,mBAAmB;aACtD,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport assert from \"assert\";\nimport { RateLimiter } from \"@fluidframework/driver-utils\";\nimport { MockLogger } from \"@fluidframework/telemetry-utils\";\nimport nock from \"nock\";\nimport { DefaultTokenProvider } from \"../defaultTokenProvider.js\";\nimport { RouterliciousErrorTypes } from \"../errorUtils.js\";\nimport {\n\tRouterliciousOrdererRestWrapper,\n\ttoInstrumentedR11sOrdererTokenFetcher,\n} from \"../restWrapper.js\";\nimport { ITokenResponse } from \"../tokens.js\";\n\ndescribe(\"RouterliciousDriverRestWrapper\", () => {\n\tconst rateLimiter = new RateLimiter(1);\n\tconst testHost = \"http://localhost:3030\";\n\tconst testPath = \"/api/protected\";\n\tconst testUrl = `${testHost}${testPath}`;\n\n\t// Set up mock request authentication\n\tconst token1 = \"1234-auth-token-abcd\";\n\tconst token2 = \"9876-auth-token-zyxw\";\n\tconst token3 = \"abc-auth-token-123\";\n\tlet tokenQueue: string[] = [];\n\n\t// Set up mock throttling\n\tlet throttleDurationInMs: number;\n\tlet throttledAt: number;\n\tconst throttle = () => {\n\t\tthrottledAt = Date.now();\n\t};\n\tfunction replyWithThrottling() {\n\t\tconst retryAfterSeconds = (throttleDurationInMs - Date.now() - throttledAt) / 1000;\n\t\tconst throttled = retryAfterSeconds > 0;\n\t\tif (throttled) {\n\t\t\treturn [429, { retryAfter: retryAfterSeconds }];\n\t\t}\n\t\treturn [200, \"OK\"];\n\t}\n\n\tlet restWrapper: RouterliciousOrdererRestWrapper;\n\tconst logger = new MockLogger();\n\tbeforeEach(async () => {\n\t\t// reset auth mocking\n\t\ttokenQueue = [token1, token2, token3];\n\t\t// reset throttling mocking\n\t\tthrottledAt = 0;\n\t\tthrottleDurationInMs = 50;\n\t\tconst tokenProvider = new DefaultTokenProvider(\"testtoken\");\n\t\ttokenProvider.fetchOrdererToken = async () => {\n\t\t\t// Pop a token off tokenQueue\n\t\t\tconst newToken: ITokenResponse = {\n\t\t\t\tjwt: tokenQueue.shift() ?? \"testtoken\",\n\t\t\t};\n\t\t\treturn newToken;\n\t\t};\n\t\trestWrapper = await RouterliciousOrdererRestWrapper.load(\n\t\t\ttoInstrumentedR11sOrdererTokenFetcher(\n\t\t\t\t\"dummytenantid\",\n\t\t\t\t\"dummydocumentid\",\n\t\t\t\ttokenProvider,\n\t\t\t\tlogger.toTelemetryLogger(),\n\t\t\t),\n\t\t\tlogger.toTelemetryLogger(),\n\t\t\trateLimiter,\n\t\t\tfalse,\n\t\t);\n\t});\n\tafter(() => {\n\t\tnock.restore();\n\t});\n\tafterEach(() => {\n\t\tlogger.assertMatchNone([{ category: \"error\" }]);\n\t});\n\n\tdescribe(\"get()\", () => {\n\t\tit(\"sends a request with auth headers\", async () => {\n\t\t\tnock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })\n\t\t\t\t.get(testPath)\n\t\t\t\t.reply(200);\n\t\t\tawait assert.doesNotReject(restWrapper.get(testUrl));\n\t\t});\n\t\tit(\"retries a request with fresh auth headers on 401\", async () => {\n\t\t\tnock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })\n\t\t\t\t.get(testPath)\n\t\t\t\t.reply(401);\n\t\t\tnock(testHost, { reqheaders: { authorization: `Basic ${token2}` } })\n\t\t\t\t.get(testPath)\n\t\t\t\t.reply(200);\n\t\t\tawait assert.doesNotReject(restWrapper.get(testUrl));\n\t\t});\n\t\tit(\"throws a non-retriable error on 2nd 401\", async () => {\n\t\t\tnock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })\n\t\t\t\t.get(testPath)\n\t\t\t\t.reply(401);\n\t\t\tnock(testHost, { reqheaders: { authorization: `Basic ${token2}` } })\n\t\t\t\t.get(testPath)\n\t\t\t\t.reply(401);\n\t\t\tawait assert.rejects(restWrapper.get(testUrl), {\n\t\t\t\tcanRetry: false,\n\t\t\t\terrorType: RouterliciousErrorTypes.authorizationError,\n\t\t\t});\n\t\t});\n\t\tit(\"throws a retriable error on 500\", async () => {\n\t\t\tnock(testHost).get(testPath).reply(500);\n\t\t\tawait assert.rejects(restWrapper.get(testUrl), {\n\t\t\t\tcanRetry: true,\n\t\t\t\terrorType: RouterliciousErrorTypes.genericNetworkError,\n\t\t\t});\n\t\t});\n\t\tit(\"retries with delay on 429 with retryAfter\", async () => {\n\t\t\tthrottle();\n\t\t\tnock(testHost).get(testPath).reply(replyWithThrottling);\n\t\t\tawait assert.doesNotReject(restWrapper.get(testUrl));\n\t\t});\n\t\tit(\"throws a retriable error on 429 without retryAfter\", async () => {\n\t\t\tnock(testHost).get(testPath).reply(429, { retryAfter: undefined });\n\t\t\tawait assert.rejects(restWrapper.get(testUrl), {\n\t\t\t\tcanRetry: true,\n\t\t\t\terrorType: RouterliciousErrorTypes.genericNetworkError,\n\t\t\t});\n\t\t});\n\t\tit(\"throws a non-retriable error on 404\", async () => {\n\t\t\tnock(testHost).get(testPath).reply(404);\n\t\t\tawait assert.rejects(restWrapper.get(testUrl), {\n\t\t\t\tcanRetry: false,\n\t\t\t\terrorType: RouterliciousErrorTypes.fileNotFoundOrAccessDeniedError,\n\t\t\t});\n\t\t});\n\t\tit(\"throws retriable error on Network Error\", async () => {\n\t\t\tnock(testHost).get(testPath).replyWithError({ code: \"ECONNRESET\" });\n\t\t\tawait assert.rejects(restWrapper.get(testUrl), {\n\t\t\t\tcanRetry: true,\n\t\t\t\terrorType: RouterliciousErrorTypes.genericNetworkError,\n\t\t\t});\n\t\t});\n\t});\n\n\tdescribe(\"post()\", () => {\n\t\tit(\"sends a request with auth headers\", async () => {\n\t\t\tnock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })\n\t\t\t\t.post(testPath)\n\t\t\t\t.reply(200);\n\t\t\tawait assert.doesNotReject(restWrapper.post(testUrl, { test: \"payload\" }));\n\t\t});\n\t\tit(\"retries a request with fresh auth headers on 401\", async () => {\n\t\t\tnock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })\n\t\t\t\t.post(testPath)\n\t\t\t\t.reply(401);\n\t\t\tnock(testHost, { reqheaders: { authorization: `Basic ${token2}` } })\n\t\t\t\t.post(testPath)\n\t\t\t\t.reply(200);\n\t\t\tawait assert.doesNotReject(restWrapper.post(testUrl, { test: \"payload\" }));\n\t\t});\n\t\tit(\"throws a non-retriable error on 2nd 401\", async () => {\n\t\t\tnock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })\n\t\t\t\t.post(testPath)\n\t\t\t\t.reply(401);\n\t\t\tnock(testHost, { reqheaders: { authorization: `Basic ${token2}` } })\n\t\t\t\t.post(testPath)\n\t\t\t\t.reply(401);\n\t\t\tawait assert.rejects(restWrapper.post(testUrl, { test: \"payload\" }), {\n\t\t\t\tcanRetry: false,\n\t\t\t\terrorType: RouterliciousErrorTypes.authorizationError,\n\t\t\t});\n\t\t});\n\t\tit(\"throws a retriable error on 500\", async () => {\n\t\t\tnock(testHost).post(testPath).reply(500);\n\t\t\tawait assert.rejects(restWrapper.post(testUrl, { test: \"payload\" }), {\n\t\t\t\tcanRetry: true,\n\t\t\t\terrorType: RouterliciousErrorTypes.genericNetworkError,\n\t\t\t});\n\t\t});\n\t\tit(\"retries with delay on 429 with retryAfter\", async () => {\n\t\t\tthrottle();\n\t\t\tnock(testHost).post(testPath).reply(replyWithThrottling);\n\t\t\tawait assert.doesNotReject(restWrapper.post(testUrl, { test: \"payload\" }));\n\t\t});\n\t\tit(\"throws a retriable error on 429 without retryAfter\", async () => {\n\t\t\tnock(testHost).post(testPath).reply(429, { retryAfter: undefined });\n\t\t\tawait assert.rejects(restWrapper.post(testUrl, { test: \"payload\" }), {\n\t\t\t\tcanRetry: true,\n\t\t\t\terrorType: RouterliciousErrorTypes.genericNetworkError,\n\t\t\t});\n\t\t});\n\t\tit(\"throws a non-retriable error on 404\", async () => {\n\t\t\tnock(testHost).post(testPath).reply(404);\n\t\t\tawait assert.rejects(restWrapper.post(testUrl, { test: \"payload\" }), {\n\t\t\t\tcanRetry: false,\n\t\t\t\terrorType: RouterliciousErrorTypes.fileNotFoundOrAccessDeniedError,\n\t\t\t});\n\t\t});\n\t\tit(\"throws retriable error on Network Error\", async () => {\n\t\t\tnock(testHost).post(testPath).replyWithError({ code: \"ECONNRESET\" });\n\t\t\tawait assert.rejects(restWrapper.post(testUrl, { test: \"payload\" }), {\n\t\t\t\tcanRetry: true,\n\t\t\t\terrorType: RouterliciousErrorTypes.genericNetworkError,\n\t\t\t});\n\t\t});\n\t});\n\n\tdescribe(\"patch()\", () => {\n\t\tit(\"sends a request with auth headers\", async () => {\n\t\t\tnock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })\n\t\t\t\t.patch(testPath)\n\t\t\t\t.reply(200);\n\t\t\tawait assert.doesNotReject(restWrapper.patch(testUrl, { test: \"payload\" }));\n\t\t});\n\t\tit(\"retries a request with fresh auth headers on 401\", async () => {\n\t\t\tnock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })\n\t\t\t\t.patch(testPath)\n\t\t\t\t.reply(401);\n\t\t\tnock(testHost, { reqheaders: { authorization: `Basic ${token2}` } })\n\t\t\t\t.patch(testPath)\n\t\t\t\t.reply(200);\n\t\t\tawait assert.doesNotReject(restWrapper.patch(testUrl, { test: \"payload\" }));\n\t\t});\n\t\tit(\"throws a non-retriable error on 2nd 401\", async () => {\n\t\t\tnock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })\n\t\t\t\t.patch(testPath)\n\t\t\t\t.reply(401);\n\t\t\tnock(testHost, { reqheaders: { authorization: `Basic ${token2}` } })\n\t\t\t\t.patch(testPath)\n\t\t\t\t.reply(401);\n\t\t\tawait assert.rejects(restWrapper.patch(testUrl, { test: \"payload\" }), {\n\t\t\t\tcanRetry: false,\n\t\t\t\terrorType: RouterliciousErrorTypes.authorizationError,\n\t\t\t});\n\t\t});\n\t\tit(\"throws a retriable error on 500\", async () => {\n\t\t\tnock(testHost).patch(testPath).reply(500);\n\t\t\tawait assert.rejects(restWrapper.patch(testUrl, { test: \"payload\" }), {\n\t\t\t\tcanRetry: true,\n\t\t\t\terrorType: RouterliciousErrorTypes.genericNetworkError,\n\t\t\t});\n\t\t});\n\t\tit(\"retries with delay on 429 with retryAfter\", async () => {\n\t\t\tthrottle();\n\t\t\tnock(testHost).patch(testPath).reply(replyWithThrottling);\n\t\t\tawait assert.doesNotReject(restWrapper.patch(testUrl, { test: \"payload\" }));\n\t\t});\n\t\tit(\"throws a retriable error on 429 without retryAfter\", async () => {\n\t\t\tnock(testHost).patch(testPath).reply(429, { retryAfter: undefined });\n\t\t\tawait assert.rejects(restWrapper.patch(testUrl, { test: \"payload\" }), {\n\t\t\t\tcanRetry: true,\n\t\t\t\terrorType: RouterliciousErrorTypes.genericNetworkError,\n\t\t\t});\n\t\t});\n\t\tit(\"throws a non-retriable error on 404\", async () => {\n\t\t\tnock(testHost).patch(testPath).reply(404);\n\t\t\tawait assert.rejects(restWrapper.patch(testUrl, { test: \"payload\" }), {\n\t\t\t\tcanRetry: false,\n\t\t\t\terrorType: RouterliciousErrorTypes.fileNotFoundOrAccessDeniedError,\n\t\t\t});\n\t\t});\n\t\tit(\"throws retriable error on Network Error\", async () => {\n\t\t\tnock(testHost).patch(testPath).replyWithError({ code: \"ECONNRESET\" });\n\t\t\tawait assert.rejects(restWrapper.patch(testUrl, { test: \"payload\" }), {\n\t\t\t\tcanRetry: true,\n\t\t\t\terrorType: RouterliciousErrorTypes.genericNetworkError,\n\t\t\t});\n\t\t});\n\t});\n\n\tdescribe(\"delete()\", () => {\n\t\tit(\"sends a request with auth headers\", async () => {\n\t\t\tnock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })\n\t\t\t\t.delete(testPath)\n\t\t\t\t.reply(200);\n\t\t\tawait assert.doesNotReject(restWrapper.delete(testUrl));\n\t\t});\n\t\tit(\"retries a request with fresh auth headers on 401\", async () => {\n\t\t\tnock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })\n\t\t\t\t.delete(testPath)\n\t\t\t\t.reply(401);\n\t\t\tnock(testHost, { reqheaders: { authorization: `Basic ${token2}` } })\n\t\t\t\t.delete(testPath)\n\t\t\t\t.reply(200);\n\t\t\tawait assert.doesNotReject(restWrapper.delete(testUrl));\n\t\t});\n\t\tit(\"throws a non-retriable error on 2nd 401\", async () => {\n\t\t\tnock(testHost, { reqheaders: { authorization: `Basic ${token1}` } })\n\t\t\t\t.delete(testPath)\n\t\t\t\t.reply(401);\n\t\t\tnock(testHost, { reqheaders: { authorization: `Basic ${token2}` } })\n\t\t\t\t.delete(testPath)\n\t\t\t\t.reply(401);\n\t\t\tawait assert.rejects(restWrapper.delete(testUrl), {\n\t\t\t\tcanRetry: false,\n\t\t\t\terrorType: RouterliciousErrorTypes.authorizationError,\n\t\t\t});\n\t\t});\n\t\tit(\"throws a retriable error on 500\", async () => {\n\t\t\tnock(testHost).delete(testPath).reply(500);\n\t\t\tawait assert.rejects(restWrapper.delete(testUrl), {\n\t\t\t\tcanRetry: true,\n\t\t\t\terrorType: RouterliciousErrorTypes.genericNetworkError,\n\t\t\t});\n\t\t});\n\t\tit(\"retries with delay on 429 with retryAfter\", async () => {\n\t\t\tthrottle();\n\t\t\tnock(testHost).delete(testPath).reply(replyWithThrottling);\n\t\t\tawait assert.doesNotReject(restWrapper.delete(testUrl));\n\t\t});\n\t\tit(\"throws a retriable error on 429 without retryAfter\", async () => {\n\t\t\tnock(testHost).delete(testPath).reply(429, { retryAfter: undefined });\n\t\t\tawait assert.rejects(restWrapper.delete(testUrl), {\n\t\t\t\tcanRetry: true,\n\t\t\t\terrorType: RouterliciousErrorTypes.genericNetworkError,\n\t\t\t});\n\t\t});\n\t\tit(\"throws a non-retriable error on 404\", async () => {\n\t\t\tnock(testHost).delete(testPath).reply(404);\n\t\t\tawait assert.rejects(restWrapper.delete(testUrl), {\n\t\t\t\tcanRetry: false,\n\t\t\t\terrorType: RouterliciousErrorTypes.fileNotFoundOrAccessDeniedError,\n\t\t\t});\n\t\t});\n\t\tit(\"throws retriable error on Network Error\", async () => {\n\t\t\tnock(testHost).delete(testPath).replyWithError({ code: \"ECONNRESET\" });\n\t\t\tawait assert.rejects(restWrapper.delete(testUrl), {\n\t\t\t\tcanRetry: true,\n\t\t\t\terrorType: RouterliciousErrorTypes.genericNetworkError,\n\t\t\t});\n\t\t});\n\t});\n});\n"]}
@@ -1,22 +0,0 @@
1
- use_current_ClassDeclaration_DefaultTokenProvider(get_old_ClassDeclaration_DefaultTokenProvider());
2
- use_old_ClassDeclaration_DefaultTokenProvider(get_current_ClassDeclaration_DefaultTokenProvider());
3
- use_current_ClassDeclaration_DocumentPostCreateError(get_old_ClassDeclaration_DocumentPostCreateError());
4
- use_old_ClassDeclaration_DocumentPostCreateError(get_current_ClassDeclaration_DocumentPostCreateError());
5
- use_current_InterfaceDeclaration_IRouterliciousDriverPolicies(get_old_InterfaceDeclaration_IRouterliciousDriverPolicies());
6
- use_old_InterfaceDeclaration_IRouterliciousDriverPolicies(
7
- // @ts-expect-error compatibility expected to be broken
8
- get_current_InterfaceDeclaration_IRouterliciousDriverPolicies());
9
- use_current_InterfaceDeclaration_ITokenProvider(get_old_InterfaceDeclaration_ITokenProvider());
10
- use_old_InterfaceDeclaration_ITokenProvider(get_current_InterfaceDeclaration_ITokenProvider());
11
- use_current_InterfaceDeclaration_ITokenResponse(get_old_InterfaceDeclaration_ITokenResponse());
12
- use_old_InterfaceDeclaration_ITokenResponse(get_current_InterfaceDeclaration_ITokenResponse());
13
- use_current_InterfaceDeclaration_ITokenService(get_old_InterfaceDeclaration_ITokenService());
14
- use_old_InterfaceDeclaration_ITokenService(get_current_InterfaceDeclaration_ITokenService());
15
- use_current_ClassDeclaration_RouterliciousDocumentServiceFactory(get_old_ClassDeclaration_RouterliciousDocumentServiceFactory());
16
- use_old_ClassDeclaration_RouterliciousDocumentServiceFactory(get_current_ClassDeclaration_RouterliciousDocumentServiceFactory());
17
- use_current_VariableDeclaration_RouterliciousErrorTypes(get_old_VariableDeclaration_RouterliciousErrorTypes());
18
- use_old_VariableDeclaration_RouterliciousErrorTypes(get_current_VariableDeclaration_RouterliciousErrorTypes());
19
- use_current_TypeAliasDeclaration_RouterliciousErrorTypes(get_old_TypeAliasDeclaration_RouterliciousErrorTypes());
20
- use_old_TypeAliasDeclaration_RouterliciousErrorTypes(get_current_TypeAliasDeclaration_RouterliciousErrorTypes());
21
- export {};
22
- //# sourceMappingURL=validateRouterliciousDriverPrevious.generated.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validateRouterliciousDriverPrevious.generated.js","sourceRoot":"","sources":["../../../src/test/types/validateRouterliciousDriverPrevious.generated.ts"],"names":[],"mappings":"AAgCA,iDAAiD,CAC7C,6CAA6C,EAAE,CAAC,CAAC;AAWrD,6CAA6C,CACzC,iDAAiD,EAAE,CAAC,CAAC;AAWzD,oDAAoD,CAChD,gDAAgD,EAAE,CAAC,CAAC;AAWxD,gDAAgD,CAC5C,oDAAoD,EAAE,CAAC,CAAC;AAW5D,6DAA6D,CACzD,yDAAyD,EAAE,CAAC,CAAC;AAWjE,yDAAyD;AACrD,uDAAuD;AACvD,6DAA6D,EAAE,CAAC,CAAC;AAWrE,+CAA+C,CAC3C,2CAA2C,EAAE,CAAC,CAAC;AAWnD,2CAA2C,CACvC,+CAA+C,EAAE,CAAC,CAAC;AAWvD,+CAA+C,CAC3C,2CAA2C,EAAE,CAAC,CAAC;AAWnD,2CAA2C,CACvC,+CAA+C,EAAE,CAAC,CAAC;AAWvD,8CAA8C,CAC1C,0CAA0C,EAAE,CAAC,CAAC;AAWlD,0CAA0C,CACtC,8CAA8C,EAAE,CAAC,CAAC;AAWtD,gEAAgE,CAC5D,4DAA4D,EAAE,CAAC,CAAC;AAWpE,4DAA4D,CACxD,gEAAgE,EAAE,CAAC,CAAC;AAuBxE,uDAAuD,CACnD,mDAAmD,EAAE,CAAC,CAAC;AAW3D,mDAAmD,CAC/C,uDAAuD,EAAE,CAAC,CAAC;AAW/D,wDAAwD,CACpD,oDAAoD,EAAE,CAAC,CAAC;AAW5D,oDAAoD,CAChD,wDAAwD,EAAE,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/*\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.\n * Generated by fluid-type-test-generator in @fluidframework/build-tools.\n */\nimport type * as old from \"@fluidframework/routerlicious-driver-previous\";\nimport type * as current from \"../../index.js\";\n\n\n// See 'build-tools/src/type-test-generator/compatibility.ts' for more information.\ntype TypeOnly<T> = T extends number\n\t? number\n\t: T extends string\n\t? string\n\t: T extends boolean | bigint | symbol\n\t? T\n\t: {\n\t\t\t[P in keyof T]: TypeOnly<T[P]>;\n\t };\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"ClassDeclaration_DefaultTokenProvider\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_ClassDeclaration_DefaultTokenProvider():\n TypeOnly<old.DefaultTokenProvider>;\ndeclare function use_current_ClassDeclaration_DefaultTokenProvider(\n use: TypeOnly<current.DefaultTokenProvider>): void;\nuse_current_ClassDeclaration_DefaultTokenProvider(\n get_old_ClassDeclaration_DefaultTokenProvider());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"ClassDeclaration_DefaultTokenProvider\": {\"backCompat\": false}\n*/\ndeclare function get_current_ClassDeclaration_DefaultTokenProvider():\n TypeOnly<current.DefaultTokenProvider>;\ndeclare function use_old_ClassDeclaration_DefaultTokenProvider(\n use: TypeOnly<old.DefaultTokenProvider>): void;\nuse_old_ClassDeclaration_DefaultTokenProvider(\n get_current_ClassDeclaration_DefaultTokenProvider());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"ClassDeclaration_DocumentPostCreateError\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_ClassDeclaration_DocumentPostCreateError():\n TypeOnly<old.DocumentPostCreateError>;\ndeclare function use_current_ClassDeclaration_DocumentPostCreateError(\n use: TypeOnly<current.DocumentPostCreateError>): void;\nuse_current_ClassDeclaration_DocumentPostCreateError(\n get_old_ClassDeclaration_DocumentPostCreateError());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"ClassDeclaration_DocumentPostCreateError\": {\"backCompat\": false}\n*/\ndeclare function get_current_ClassDeclaration_DocumentPostCreateError():\n TypeOnly<current.DocumentPostCreateError>;\ndeclare function use_old_ClassDeclaration_DocumentPostCreateError(\n use: TypeOnly<old.DocumentPostCreateError>): void;\nuse_old_ClassDeclaration_DocumentPostCreateError(\n get_current_ClassDeclaration_DocumentPostCreateError());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_IRouterliciousDriverPolicies\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_InterfaceDeclaration_IRouterliciousDriverPolicies():\n TypeOnly<old.IRouterliciousDriverPolicies>;\ndeclare function use_current_InterfaceDeclaration_IRouterliciousDriverPolicies(\n use: TypeOnly<current.IRouterliciousDriverPolicies>): void;\nuse_current_InterfaceDeclaration_IRouterliciousDriverPolicies(\n get_old_InterfaceDeclaration_IRouterliciousDriverPolicies());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_IRouterliciousDriverPolicies\": {\"backCompat\": false}\n*/\ndeclare function get_current_InterfaceDeclaration_IRouterliciousDriverPolicies():\n TypeOnly<current.IRouterliciousDriverPolicies>;\ndeclare function use_old_InterfaceDeclaration_IRouterliciousDriverPolicies(\n use: TypeOnly<old.IRouterliciousDriverPolicies>): void;\nuse_old_InterfaceDeclaration_IRouterliciousDriverPolicies(\n // @ts-expect-error compatibility expected to be broken\n get_current_InterfaceDeclaration_IRouterliciousDriverPolicies());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_ITokenProvider\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_InterfaceDeclaration_ITokenProvider():\n TypeOnly<old.ITokenProvider>;\ndeclare function use_current_InterfaceDeclaration_ITokenProvider(\n use: TypeOnly<current.ITokenProvider>): void;\nuse_current_InterfaceDeclaration_ITokenProvider(\n get_old_InterfaceDeclaration_ITokenProvider());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_ITokenProvider\": {\"backCompat\": false}\n*/\ndeclare function get_current_InterfaceDeclaration_ITokenProvider():\n TypeOnly<current.ITokenProvider>;\ndeclare function use_old_InterfaceDeclaration_ITokenProvider(\n use: TypeOnly<old.ITokenProvider>): void;\nuse_old_InterfaceDeclaration_ITokenProvider(\n get_current_InterfaceDeclaration_ITokenProvider());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_ITokenResponse\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_InterfaceDeclaration_ITokenResponse():\n TypeOnly<old.ITokenResponse>;\ndeclare function use_current_InterfaceDeclaration_ITokenResponse(\n use: TypeOnly<current.ITokenResponse>): void;\nuse_current_InterfaceDeclaration_ITokenResponse(\n get_old_InterfaceDeclaration_ITokenResponse());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_ITokenResponse\": {\"backCompat\": false}\n*/\ndeclare function get_current_InterfaceDeclaration_ITokenResponse():\n TypeOnly<current.ITokenResponse>;\ndeclare function use_old_InterfaceDeclaration_ITokenResponse(\n use: TypeOnly<old.ITokenResponse>): void;\nuse_old_InterfaceDeclaration_ITokenResponse(\n get_current_InterfaceDeclaration_ITokenResponse());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_ITokenService\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_InterfaceDeclaration_ITokenService():\n TypeOnly<old.ITokenService>;\ndeclare function use_current_InterfaceDeclaration_ITokenService(\n use: TypeOnly<current.ITokenService>): void;\nuse_current_InterfaceDeclaration_ITokenService(\n get_old_InterfaceDeclaration_ITokenService());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_ITokenService\": {\"backCompat\": false}\n*/\ndeclare function get_current_InterfaceDeclaration_ITokenService():\n TypeOnly<current.ITokenService>;\ndeclare function use_old_InterfaceDeclaration_ITokenService(\n use: TypeOnly<old.ITokenService>): void;\nuse_old_InterfaceDeclaration_ITokenService(\n get_current_InterfaceDeclaration_ITokenService());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"ClassDeclaration_RouterliciousDocumentServiceFactory\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_ClassDeclaration_RouterliciousDocumentServiceFactory():\n TypeOnly<old.RouterliciousDocumentServiceFactory>;\ndeclare function use_current_ClassDeclaration_RouterliciousDocumentServiceFactory(\n use: TypeOnly<current.RouterliciousDocumentServiceFactory>): void;\nuse_current_ClassDeclaration_RouterliciousDocumentServiceFactory(\n get_old_ClassDeclaration_RouterliciousDocumentServiceFactory());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"ClassDeclaration_RouterliciousDocumentServiceFactory\": {\"backCompat\": false}\n*/\ndeclare function get_current_ClassDeclaration_RouterliciousDocumentServiceFactory():\n TypeOnly<current.RouterliciousDocumentServiceFactory>;\ndeclare function use_old_ClassDeclaration_RouterliciousDocumentServiceFactory(\n use: TypeOnly<old.RouterliciousDocumentServiceFactory>): void;\nuse_old_ClassDeclaration_RouterliciousDocumentServiceFactory(\n get_current_ClassDeclaration_RouterliciousDocumentServiceFactory());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"RemovedEnumDeclaration_RouterliciousErrorType\": {\"forwardCompat\": false}\n*/\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"RemovedEnumDeclaration_RouterliciousErrorType\": {\"backCompat\": false}\n*/\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"VariableDeclaration_RouterliciousErrorTypes\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_VariableDeclaration_RouterliciousErrorTypes():\n TypeOnly<typeof old.RouterliciousErrorTypes>;\ndeclare function use_current_VariableDeclaration_RouterliciousErrorTypes(\n use: TypeOnly<typeof current.RouterliciousErrorTypes>): void;\nuse_current_VariableDeclaration_RouterliciousErrorTypes(\n get_old_VariableDeclaration_RouterliciousErrorTypes());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"VariableDeclaration_RouterliciousErrorTypes\": {\"backCompat\": false}\n*/\ndeclare function get_current_VariableDeclaration_RouterliciousErrorTypes():\n TypeOnly<typeof current.RouterliciousErrorTypes>;\ndeclare function use_old_VariableDeclaration_RouterliciousErrorTypes(\n use: TypeOnly<typeof old.RouterliciousErrorTypes>): void;\nuse_old_VariableDeclaration_RouterliciousErrorTypes(\n get_current_VariableDeclaration_RouterliciousErrorTypes());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"TypeAliasDeclaration_RouterliciousErrorTypes\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_TypeAliasDeclaration_RouterliciousErrorTypes():\n TypeOnly<old.RouterliciousErrorTypes>;\ndeclare function use_current_TypeAliasDeclaration_RouterliciousErrorTypes(\n use: TypeOnly<current.RouterliciousErrorTypes>): void;\nuse_current_TypeAliasDeclaration_RouterliciousErrorTypes(\n get_old_TypeAliasDeclaration_RouterliciousErrorTypes());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"TypeAliasDeclaration_RouterliciousErrorTypes\": {\"backCompat\": false}\n*/\ndeclare function get_current_TypeAliasDeclaration_RouterliciousErrorTypes():\n TypeOnly<current.RouterliciousErrorTypes>;\ndeclare function use_old_TypeAliasDeclaration_RouterliciousErrorTypes(\n use: TypeOnly<old.RouterliciousErrorTypes>): void;\nuse_old_TypeAliasDeclaration_RouterliciousErrorTypes(\n get_current_TypeAliasDeclaration_RouterliciousErrorTypes());\n"]}
@@ -1,62 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import assert from "assert";
6
- import { getDiscoveredFluidResolvedUrl, replaceDocumentIdInPath } from "../urlUtils.js";
7
- describe("UrlUtils", () => {
8
- const exampleFluidUrl1 = "https://orderer.examplehost.com/example-tenant/some-document?param1=value1";
9
- const exampleFluidUrl2 = "https://examplehost.com/other-tenant/";
10
- describe("replaceDocumentIdInPath()", () => {
11
- it("returns pathname with replacement", () => {
12
- const parsedUrl = new URL(exampleFluidUrl1);
13
- assert.strictEqual(replaceDocumentIdInPath(parsedUrl.pathname, "otherdoc"), "/example-tenant/otherdoc");
14
- });
15
- it("returns pathname with replacement of blank documentId", () => {
16
- const parsedUrl = new URL(exampleFluidUrl2);
17
- assert.strictEqual(replaceDocumentIdInPath(parsedUrl.pathname, "otherdoc"), "/other-tenant/otherdoc");
18
- });
19
- it("replaced pathname is altered in full URL", () => {
20
- const parsedUrl = new URL(exampleFluidUrl1);
21
- parsedUrl.pathname = replaceDocumentIdInPath(parsedUrl.pathname, "otherdoc");
22
- assert.strictEqual(parsedUrl.toString(), exampleFluidUrl1.replace("some-document", "otherdoc"));
23
- });
24
- });
25
- describe("getDiscoveredFluidResolvedUrl()", () => {
26
- let testResolvedURL;
27
- let testSession;
28
- before(() => {
29
- testResolvedURL = {
30
- type: "fluid",
31
- id: "id",
32
- // Routerlicious resolved urls are expected to always have a valid URL.
33
- url: "https://examplehost.com",
34
- tokens: {
35
- testKey: "testValue",
36
- },
37
- endpoints: {
38
- // Routerlicious resolved urls are expected to always have these three endpoints with valid URLs,
39
- // though their exact values are not important for this test.
40
- storageUrl: "https://examplehost.com",
41
- deltaStorageUrl: "https://examplehost.com",
42
- ordererUrl: "https://examplehost.com",
43
- },
44
- };
45
- testSession = {
46
- ordererUrl: "http://ordererUrl.test",
47
- deltaStreamUrl: "http://deltaStreamUrl.test",
48
- historianUrl: "http://historianUrl.test",
49
- isSessionActive: false,
50
- isSessionAlive: false,
51
- };
52
- });
53
- it("overrides resolvedURL endpoints with session endpoints", () => {
54
- const result = getDiscoveredFluidResolvedUrl(testResolvedURL, testSession);
55
- assert.strictEqual("https://ordererurl.test/", result.endpoints.deltaStorageUrl);
56
- assert.strictEqual("https://historianurl.test/", result.endpoints.storageUrl);
57
- assert.strictEqual(testSession.ordererUrl, result.endpoints.ordererUrl);
58
- assert.strictEqual(testSession.deltaStreamUrl, result.endpoints.deltaStreamUrl);
59
- });
60
- });
61
- });
62
- //# sourceMappingURL=urlUtils.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"urlUtils.spec.js","sourceRoot":"","sources":["../../src/test/urlUtils.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,OAAO,EAAE,6BAA6B,EAAE,u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EAAE,EAAE,IAAI;gBACR,uEAAuE;gBACvE,GAAG,EAAE,yBAAyB;gBAC9B,MAAM,EAAE;oBACP,OAAO,EAAE,WAAW;iBACpB;gBACD,SAAS,EAAE;oBACV,iGAAiG;oBACjG,6DAA6D;oBAC7D,UAAU,EAAE,yBAAyB;oBACrC,eAAe,EAAE,yBAAyB;oBAC1C,UAAU,EAAE,yBAAyB;iBACrC;aACD,CAAC;YAEF,WAAW,GAAG;gBACb,UAAU,EAAE,wBAAwB;gBACpC,cAAc,EAAE,4BAA4B;gBAC5C,YAAY,EAAE,0BAA0B;gBACxC,eAAe,EAAE,KAAK;gBACtB,cAAc,EAAE,KAAK;aACrB,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;YACjE,MAAM,MAAM,GAAG,6BAA6B,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;YAE3E,MAAM,CAAC,WAAW,CAAC,0BAA0B,EAAE,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;YACjF,MAAM,CAAC,WAAW,CAAC,4BAA4B,EAAE,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;YAC9E,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,UAAU,EAAE,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;YACxE,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,cAAc,EAAE,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QACjF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport assert from \"assert\";\nimport { IResolvedUrl } from \"@fluidframework/driver-definitions\";\nimport { ISession } from \"@fluidframework/server-services-client\";\nimport { getDiscoveredFluidResolvedUrl, replaceDocumentIdInPath } from \"../urlUtils.js\";\n\ndescribe(\"UrlUtils\", () => {\n\tconst exampleFluidUrl1 =\n\t\t\"https://orderer.examplehost.com/example-tenant/some-document?param1=value1\";\n\tconst exampleFluidUrl2 = \"https://examplehost.com/other-tenant/\";\n\n\tdescribe(\"replaceDocumentIdInPath()\", () => {\n\t\tit(\"returns pathname with replacement\", () => {\n\t\t\tconst parsedUrl = new URL(exampleFluidUrl1);\n\t\t\tassert.strictEqual(\n\t\t\t\treplaceDocumentIdInPath(parsedUrl.pathname, \"otherdoc\"),\n\t\t\t\t\"/example-tenant/otherdoc\",\n\t\t\t);\n\t\t});\n\t\tit(\"returns pathname with replacement of blank documentId\", () => {\n\t\t\tconst parsedUrl = new URL(exampleFluidUrl2);\n\t\t\tassert.strictEqual(\n\t\t\t\treplaceDocumentIdInPath(parsedUrl.pathname, \"otherdoc\"),\n\t\t\t\t\"/other-tenant/otherdoc\",\n\t\t\t);\n\t\t});\n\t\tit(\"replaced pathname is altered in full URL\", () => {\n\t\t\tconst parsedUrl = new URL(exampleFluidUrl1);\n\t\t\tparsedUrl.pathname = replaceDocumentIdInPath(parsedUrl.pathname, \"otherdoc\");\n\t\t\tassert.strictEqual(\n\t\t\t\tparsedUrl.toString(),\n\t\t\t\texampleFluidUrl1.replace(\"some-document\", \"otherdoc\"),\n\t\t\t);\n\t\t});\n\t});\n\n\tdescribe(\"getDiscoveredFluidResolvedUrl()\", () => {\n\t\tlet testResolvedURL: IResolvedUrl;\n\t\tlet testSession: ISession;\n\n\t\tbefore(() => {\n\t\t\ttestResolvedURL = {\n\t\t\t\ttype: \"fluid\",\n\t\t\t\tid: \"id\",\n\t\t\t\t// Routerlicious resolved urls are expected to always have a valid URL.\n\t\t\t\turl: \"https://examplehost.com\",\n\t\t\t\ttokens: {\n\t\t\t\t\ttestKey: \"testValue\",\n\t\t\t\t},\n\t\t\t\tendpoints: {\n\t\t\t\t\t// Routerlicious resolved urls are expected to always have these three endpoints with valid URLs,\n\t\t\t\t\t// though their exact values are not important for this test.\n\t\t\t\t\tstorageUrl: \"https://examplehost.com\",\n\t\t\t\t\tdeltaStorageUrl: \"https://examplehost.com\",\n\t\t\t\t\tordererUrl: \"https://examplehost.com\",\n\t\t\t\t},\n\t\t\t};\n\n\t\t\ttestSession = {\n\t\t\t\tordererUrl: \"http://ordererUrl.test\",\n\t\t\t\tdeltaStreamUrl: \"http://deltaStreamUrl.test\",\n\t\t\t\thistorianUrl: \"http://historianUrl.test\",\n\t\t\t\tisSessionActive: false,\n\t\t\t\tisSessionAlive: false,\n\t\t\t};\n\t\t});\n\n\t\tit(\"overrides resolvedURL endpoints with session endpoints\", () => {\n\t\t\tconst result = getDiscoveredFluidResolvedUrl(testResolvedURL, testSession);\n\n\t\t\tassert.strictEqual(\"https://ordererurl.test/\", result.endpoints.deltaStorageUrl);\n\t\t\tassert.strictEqual(\"https://historianurl.test/\", result.endpoints.storageUrl);\n\t\t\tassert.strictEqual(testSession.ordererUrl, result.endpoints.ordererUrl);\n\t\t\tassert.strictEqual(testSession.deltaStreamUrl, result.endpoints.deltaStreamUrl);\n\t\t});\n\t});\n});\n"]}
@@ -1,144 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import assert from "assert";
6
- import { SummaryType } from "@fluidframework/protocol-definitions";
7
- import { createChildLogger } from "@fluidframework/telemetry-utils";
8
- import { WholeSummaryDocumentStorageService } from "../wholeSummaryDocumentStorageService.js";
9
- /* Blobs contained within source snapshot tree returned by git manager */
10
- const summaryBlobs = [
11
- {
12
- id: "bARCTBK4PQiMLVK2gR5hPRkId",
13
- content: "[]",
14
- encoding: "utf-8",
15
- size: 2,
16
- },
17
- {
18
- id: "bARCfbIYtOyFwf1+nY75C4UFc",
19
- content: '{"createContainerRuntimeVersion":"0.59.1000","createContainerTimestamp":1651351060440,"summaryFormatVersion":1,"gcFeature":0}',
20
- encoding: "utf-8",
21
- size: 125,
22
- },
23
- {
24
- id: "bARAL2CXvHYOch_aQtJAJOker",
25
- content: '[["code",{"key":"code","value":{"package":"no-dynamic-package","config":{}},"approvalSequenceNumber":0,"commitSequenceNumber":0,"sequenceNumber":0}]]',
26
- encoding: "utf-8",
27
- size: 149,
28
- },
29
- ];
30
- /* Tree entries contained within source snapshot tree returned by git manager */
31
- const treeEntries = [
32
- {
33
- path: ".protocol",
34
- type: "tree",
35
- },
36
- {
37
- id: "bARCTBK4PQiMLVK2gR5hPRkId",
38
- path: ".protocol/attributes",
39
- type: "blob",
40
- },
41
- {
42
- id: "bARAL2CXvHYOch_aQtJAJOker",
43
- path: ".protocol/quorumValues",
44
- type: "blob",
45
- },
46
- {
47
- path: ".app",
48
- type: "tree",
49
- },
50
- {
51
- path: ".app/.channels",
52
- type: "tree",
53
- },
54
- {
55
- path: ".app/.channels/rootDOId",
56
- type: "tree",
57
- },
58
- {
59
- id: "bARCfbIYtOyFwf1+nY75C4UFc",
60
- path: ".app/.metadata",
61
- type: "blob",
62
- },
63
- ];
64
- /* Source snapshot returned by git manager */
65
- const flatSnapshot = {
66
- id: "bBwAAAAAHAAAA",
67
- trees: [
68
- {
69
- id: "bBwAAAAAHAAAA",
70
- sequenceNumber: 0,
71
- entries: treeEntries,
72
- },
73
- ],
74
- blobs: summaryBlobs,
75
- };
76
- /* Expoected summary to be returned by downloadSummary */
77
- const expectedSummary = {
78
- tree: {
79
- ".app": {
80
- tree: {
81
- ".channels": {
82
- tree: {
83
- rootDOId: {
84
- tree: {},
85
- type: 1,
86
- unreferenced: undefined,
87
- groupId: undefined,
88
- },
89
- },
90
- type: 1,
91
- unreferenced: undefined,
92
- groupId: undefined,
93
- },
94
- ".metadata": {
95
- content: '{"createContainerRuntimeVersion":"0.59.1000","createContainerTimestamp":1651351060440,"summaryFormatVersion":1,"gcFeature":0}',
96
- type: 2,
97
- },
98
- },
99
- type: 1,
100
- unreferenced: undefined,
101
- groupId: undefined,
102
- },
103
- ".protocol": {
104
- tree: {
105
- attributes: {
106
- content: "[]",
107
- type: 2,
108
- },
109
- quorumValues: {
110
- content: '[["code",{"key":"code","value":{"package":"no-dynamic-package","config":{}},"approvalSequenceNumber":0,"commitSequenceNumber":0,"sequenceNumber":0}]]',
111
- type: 2,
112
- },
113
- },
114
- type: 1,
115
- unreferenced: undefined,
116
- groupId: undefined,
117
- },
118
- },
119
- type: 1,
120
- unreferenced: undefined,
121
- groupId: undefined,
122
- };
123
- class MockGitManager {
124
- async getSnapshot(sha) {
125
- return {
126
- content: flatSnapshot,
127
- headers: new Map(),
128
- propsToLog: {},
129
- requestUrl: "",
130
- };
131
- }
132
- }
133
- describe("WholeSummaryDocumentStorageService", () => {
134
- it("downloads summaries in expected format", async () => {
135
- const service = new WholeSummaryDocumentStorageService("id", new MockGitManager(), createChildLogger({ namespace: "fluid:testSummaries" }), {});
136
- const res = await service.downloadSummary({
137
- type: SummaryType.Handle,
138
- handleType: SummaryType.Tree,
139
- handle: "testHandle",
140
- });
141
- assert.deepStrictEqual(res, expectedSummary, "Unexpected summary returned.");
142
- });
143
- });
144
- //# sourceMappingURL=wholeSummaryDocumentStorageService.spec.js.map