@fluidframework/routerlicious-driver 2.0.0-internal.6.4.0 → 2.0.0-internal.7.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 (76) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/api-extractor.json +9 -1
  3. package/api-report/routerlicious-driver.api.md +108 -0
  4. package/dist/contracts.d.ts +1 -1
  5. package/dist/contracts.d.ts.map +1 -1
  6. package/dist/documentService.js +3 -3
  7. package/dist/documentService.js.map +1 -1
  8. package/dist/documentServiceFactory.d.ts.map +1 -1
  9. package/dist/documentServiceFactory.js +0 -2
  10. package/dist/documentServiceFactory.js.map +1 -1
  11. package/dist/documentStorageService.js +7 -7
  12. package/dist/documentStorageService.js.map +1 -1
  13. package/dist/errorUtils.d.ts +3 -2
  14. package/dist/errorUtils.d.ts.map +1 -1
  15. package/dist/errorUtils.js +1 -1
  16. package/dist/errorUtils.js.map +1 -1
  17. package/dist/packageVersion.d.ts +1 -1
  18. package/dist/packageVersion.js +1 -1
  19. package/dist/packageVersion.js.map +1 -1
  20. package/dist/policies.d.ts +0 -8
  21. package/dist/policies.d.ts.map +1 -1
  22. package/dist/policies.js.map +1 -1
  23. package/dist/restWrapper.d.ts +2 -2
  24. package/dist/restWrapper.d.ts.map +1 -1
  25. package/dist/restWrapperBase.d.ts +1 -1
  26. package/dist/restWrapperBase.d.ts.map +1 -1
  27. package/dist/routerlicious-driver-alpha.d.ts +245 -0
  28. package/dist/routerlicious-driver-beta.d.ts +245 -0
  29. package/dist/routerlicious-driver-public.d.ts +245 -0
  30. package/dist/routerlicious-driver.d.ts +245 -0
  31. package/dist/shreddedSummaryDocumentStorageService.d.ts +1 -0
  32. package/dist/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
  33. package/dist/shreddedSummaryDocumentStorageService.js +10 -5
  34. package/dist/shreddedSummaryDocumentStorageService.js.map +1 -1
  35. package/dist/tsdoc-metadata.json +1 -1
  36. package/dist/wholeSummaryDocumentStorageService.d.ts +1 -0
  37. package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -1
  38. package/dist/wholeSummaryDocumentStorageService.js +10 -5
  39. package/dist/wholeSummaryDocumentStorageService.js.map +1 -1
  40. package/lib/contracts.d.ts +1 -1
  41. package/lib/contracts.d.ts.map +1 -1
  42. package/lib/documentService.js +3 -3
  43. package/lib/documentService.js.map +1 -1
  44. package/lib/documentServiceFactory.d.ts.map +1 -1
  45. package/lib/documentServiceFactory.js +0 -2
  46. package/lib/documentServiceFactory.js.map +1 -1
  47. package/lib/documentStorageService.js +7 -7
  48. package/lib/documentStorageService.js.map +1 -1
  49. package/lib/errorUtils.d.ts +3 -2
  50. package/lib/errorUtils.d.ts.map +1 -1
  51. package/lib/errorUtils.js.map +1 -1
  52. package/lib/packageVersion.d.ts +1 -1
  53. package/lib/packageVersion.js +1 -1
  54. package/lib/packageVersion.js.map +1 -1
  55. package/lib/policies.d.ts +0 -8
  56. package/lib/policies.d.ts.map +1 -1
  57. package/lib/policies.js.map +1 -1
  58. package/lib/restWrapper.d.ts +2 -2
  59. package/lib/restWrapper.d.ts.map +1 -1
  60. package/lib/restWrapperBase.d.ts +1 -1
  61. package/lib/restWrapperBase.d.ts.map +1 -1
  62. package/lib/shreddedSummaryDocumentStorageService.d.ts +1 -0
  63. package/lib/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
  64. package/lib/shreddedSummaryDocumentStorageService.js +11 -6
  65. package/lib/shreddedSummaryDocumentStorageService.js.map +1 -1
  66. package/lib/wholeSummaryDocumentStorageService.d.ts +1 -0
  67. package/lib/wholeSummaryDocumentStorageService.d.ts.map +1 -1
  68. package/lib/wholeSummaryDocumentStorageService.js +11 -6
  69. package/lib/wholeSummaryDocumentStorageService.js.map +1 -1
  70. package/package.json +24 -24
  71. package/src/documentServiceFactory.ts +0 -2
  72. package/src/errorUtils.ts +1 -1
  73. package/src/packageVersion.ts +1 -1
  74. package/src/policies.ts +0 -8
  75. package/src/shreddedSummaryDocumentStorageService.ts +14 -1
  76. package/src/wholeSummaryDocumentStorageService.ts +17 -5
@@ -0,0 +1,245 @@
1
+ import { IDocumentService } from '@fluidframework/driver-definitions';
2
+ import { IDocumentServiceFactory } from '@fluidframework/driver-definitions';
3
+ import { IResolvedUrl } from '@fluidframework/driver-definitions';
4
+ import { ISession } from '@fluidframework/server-services-client';
5
+ import { ISummaryTree } from '@fluidframework/protocol-definitions';
6
+ import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
7
+ import { ITokenClaims } from '@fluidframework/protocol-definitions';
8
+
9
+ /**
10
+ * Default token provider in case the host does not provide one. It simply caches the provided jwt and returns it back.
11
+ */
12
+ export declare class DefaultTokenProvider implements ITokenProvider {
13
+ private readonly jwt;
14
+ constructor(jwt: string);
15
+ fetchOrdererToken(): Promise<ITokenResponse>;
16
+ fetchStorageToken(): Promise<ITokenResponse>;
17
+ }
18
+
19
+ /**
20
+ * Error returned by {@link RouterliciousDocumentServiceFactory.createContainer} when an error is thrown
21
+ * in {@link ITokenProvider.documentPostCreateCallback}.
22
+ * It is the consumer's responsibility to ensure that any state related to container creation is appropriately
23
+ * cleaned up in the event of failure.
24
+ * This includes the document itself, which will have been created by the time this error was thrown.
25
+ *
26
+ * @remarks TODO: examples of suggested actions for recovery.
27
+ * - How would a user delete the created document?
28
+ * - What would a retry pattern look like here?
29
+ */
30
+ export declare class DocumentPostCreateError extends Error {
31
+ /**
32
+ * Inner error being wrapped.
33
+ */
34
+ private readonly innerError;
35
+ constructor(
36
+ /**
37
+ * Inner error being wrapped.
38
+ */
39
+ innerError: Error);
40
+ readonly name = "DocumentPostCreateError";
41
+ get stack(): string | undefined;
42
+ }
43
+
44
+ export declare interface IRouterliciousDriverPolicies {
45
+ /**
46
+ * Enable prefetching entire snapshot tree into memory before it is loaded by the runtime.
47
+ * Default: true
48
+ */
49
+ enablePrefetch: boolean;
50
+ /**
51
+ * Rate limit concurrent storage requests.
52
+ * Default: 100
53
+ */
54
+ maxConcurrentStorageRequests: number;
55
+ /**
56
+ * Rate limit concurrent orderer requests.
57
+ * Default: 100
58
+ */
59
+ maxConcurrentOrdererRequests: number;
60
+ /**
61
+ * Enable uploading entire summary tree as a IWholeSummaryPayload to storage.
62
+ * Default: false
63
+ */
64
+ enableWholeSummaryUpload: boolean;
65
+ /**
66
+ * Enable service endpoint discovery when creating or joining a session.
67
+ * Default: false
68
+ */
69
+ enableDiscovery: boolean;
70
+ /**
71
+ * Enable using RestLess which avoids CORS preflight requests.
72
+ * Default: true
73
+ */
74
+ enableRestLess: boolean;
75
+ /**
76
+ * Enable internal cache of summaries/snapshots.
77
+ * Reduces Summarizer boot time and reduces server load in E2E tests.
78
+ * Default: true
79
+ */
80
+ enableInternalSummaryCaching: boolean;
81
+ /**
82
+ * Enable downgrading socket connection to long-polling
83
+ * when websocket connection cannot be established.
84
+ * Default: true
85
+ */
86
+ enableLongPollingDowngrade: boolean;
87
+ /**
88
+ * Indicates that the container is ephemeral.
89
+ * Artifacts relates to the container are limited to container lifetime.
90
+ * Default: false
91
+ */
92
+ isEphemeralContainer: boolean;
93
+ }
94
+
95
+ /**
96
+ * Abstracts the token fetching mechanism for a hosting application.
97
+ * The hosting application is responsible for providing an implementation.
98
+ */
99
+ export declare interface ITokenProvider {
100
+ /**
101
+ * Fetches the orderer token from host.
102
+ *
103
+ * @param tenantId - Tenant ID.
104
+ * @param documentId - Optional. Document ID is only required for document-scoped requests.
105
+ * @param refresh - Optional flag indicating whether token fetch must bypass local cache.
106
+ * This likely indicates that some previous request failed authorization due to an expired token,
107
+ * and so a fresh token is required.
108
+ *
109
+ * Default: `false`.
110
+ *
111
+ * NOTE: This parameter will be made required in the future.
112
+ */
113
+ fetchOrdererToken(tenantId: string, documentId?: string, refresh?: boolean): Promise<ITokenResponse>;
114
+ /**
115
+ * Fetches the storage token from host.
116
+ *
117
+ * @param tenantId - Tenant ID.
118
+ * @param documentId - Document ID.
119
+ * @param refresh - Optional flag indicating whether token fetch must bypass local cache.
120
+ * This likely indicates that some previous request failed authorization due to an expired token,
121
+ * and so a fresh token is required.
122
+ *
123
+ * Default: `false`.
124
+ *
125
+ * NOTE: This parameter will be made required in the future.
126
+ */
127
+ fetchStorageToken(tenantId: string, documentId: string, refresh?: boolean): Promise<ITokenResponse>;
128
+ /**
129
+ * A callback triggered directly after creating the document. In this callback the client has the opportunity, to
130
+ * verify against an authorization service, if the user who claims to create the document is the same user who
131
+ * created it.
132
+ *
133
+ * @remarks Notes:
134
+ *
135
+ * * Using the callback may have performance impact on the document creation process.
136
+ *
137
+ * * Any exceptions thrown in the callback would fail the creation workflow
138
+ * (see {@link RouterliciousDocumentServiceFactory.createContainer} for more details).
139
+ *
140
+ * @param documentId - Document ID.
141
+ * @param creationToken - A special token that doesn't provide any kind of access, but it has the user's payload
142
+ * and document id. It can be used to validate the identity of the document creator.
143
+ */
144
+ documentPostCreateCallback?(documentId: string, creationToken: string): Promise<void>;
145
+ }
146
+
147
+ export declare interface ITokenResponse {
148
+ /**
149
+ * {@link https://jwt.io/introduction/ | JSON Web Token (JWT)} value.
150
+ */
151
+ jwt: string;
152
+ /**
153
+ * A flag indicating whether token was obtained from local cache.
154
+ *
155
+ * @remarks `undefined` indicates that the source of the token could not be determined.
156
+ */
157
+ fromCache?: boolean;
158
+ }
159
+
160
+ /**
161
+ * Abstracts the discovery of claims contained within a token.
162
+ */
163
+ export declare interface ITokenService {
164
+ /**
165
+ * Extracts the {@link @fluidframework/protocol-definitions#ITokenClaims | token claims} from the provided
166
+ * {@link https://jwt.io/introduction/ | JSON Web Token (JWT)} string representation.
167
+ */
168
+ extractClaims(token: string): ITokenClaims;
169
+ }
170
+
171
+ /**
172
+ * Factory for creating the routerlicious document service. Use this if you want to
173
+ * use the routerlicious implementation.
174
+ */
175
+ export declare class RouterliciousDocumentServiceFactory implements IDocumentServiceFactory {
176
+ private readonly tokenProvider;
177
+ private readonly driverPolicies;
178
+ private readonly blobCache;
179
+ private readonly wholeSnapshotTreeCache;
180
+ private readonly shreddedSummaryTreeCache;
181
+ constructor(tokenProvider: ITokenProvider, driverPolicies?: Partial<IRouterliciousDriverPolicies>);
182
+ /**
183
+ * {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createContainer}
184
+ *
185
+ * @throws {@link DocumentPostCreateError}
186
+ * If an exception is thrown while invoking the provided {@link ITokenProvider.documentPostCreateCallback}.
187
+ */
188
+ createContainer(createNewSummary: ISummaryTree | undefined, resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
189
+ /**
190
+ * {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createDocumentService}
191
+ *
192
+ * @returns Routerlicious document service.
193
+ */
194
+ createDocumentService(resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean, session?: ISession): Promise<IDocumentService>;
195
+ }
196
+
197
+ /**
198
+ * Routerlicious Error types
199
+ * Different error types that may be thrown by the routerlicious driver
200
+ *
201
+ * @deprecated Use {@link (RouterliciousErrorTypes:variable)} instead.
202
+ */
203
+ export declare enum RouterliciousErrorType {
204
+ /**
205
+ * File not found, or file deleted during session
206
+ */
207
+ fileNotFoundOrAccessDeniedError = "fileNotFoundOrAccessDeniedError",
208
+ /**
209
+ * SSL Certificate Error.
210
+ */
211
+ sslCertError = "sslCertError"
212
+ }
213
+
214
+ /**
215
+ * Routerlicious Error types
216
+ * Different error types that may be thrown by the routerlicious driver
217
+ */
218
+ export declare const RouterliciousErrorTypes: {
219
+ /**
220
+ * SSL Certificate Error.
221
+ */
222
+ readonly sslCertError: "sslCertError";
223
+ readonly genericNetworkError: "genericNetworkError";
224
+ readonly authorizationError: "authorizationError";
225
+ readonly fileNotFoundOrAccessDeniedError: "fileNotFoundOrAccessDeniedError";
226
+ readonly offlineError: "offlineError";
227
+ readonly unsupportedClientProtocolVersion: "unsupportedClientProtocolVersion";
228
+ readonly writeError: "writeError";
229
+ readonly fetchFailure: "fetchFailure";
230
+ readonly fetchTokenError: "fetchTokenError";
231
+ readonly incorrectServerResponse: "incorrectServerResponse";
232
+ readonly fileOverwrittenInStorage: "fileOverwrittenInStorage";
233
+ readonly deltaStreamConnectionForbidden: "deltaStreamConnectionForbidden";
234
+ readonly locationRedirection: "locationRedirection";
235
+ readonly fluidInvalidSchema: "fluidInvalidSchema";
236
+ readonly fileIsLocked: "fileIsLocked";
237
+ readonly outOfStorageError: "outOfStorageError";
238
+ readonly genericError: "genericError";
239
+ readonly throttlingError: "throttlingError";
240
+ readonly usageError: "usageError";
241
+ };
242
+
243
+ export declare type RouterliciousErrorTypes = (typeof RouterliciousErrorTypes)[keyof typeof RouterliciousErrorTypes];
244
+
245
+ export { }
@@ -0,0 +1,245 @@
1
+ import { IDocumentService } from '@fluidframework/driver-definitions';
2
+ import { IDocumentServiceFactory } from '@fluidframework/driver-definitions';
3
+ import { IResolvedUrl } from '@fluidframework/driver-definitions';
4
+ import { ISession } from '@fluidframework/server-services-client';
5
+ import { ISummaryTree } from '@fluidframework/protocol-definitions';
6
+ import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
7
+ import { ITokenClaims } from '@fluidframework/protocol-definitions';
8
+
9
+ /**
10
+ * Default token provider in case the host does not provide one. It simply caches the provided jwt and returns it back.
11
+ */
12
+ export declare class DefaultTokenProvider implements ITokenProvider {
13
+ private readonly jwt;
14
+ constructor(jwt: string);
15
+ fetchOrdererToken(): Promise<ITokenResponse>;
16
+ fetchStorageToken(): Promise<ITokenResponse>;
17
+ }
18
+
19
+ /**
20
+ * Error returned by {@link RouterliciousDocumentServiceFactory.createContainer} when an error is thrown
21
+ * in {@link ITokenProvider.documentPostCreateCallback}.
22
+ * It is the consumer's responsibility to ensure that any state related to container creation is appropriately
23
+ * cleaned up in the event of failure.
24
+ * This includes the document itself, which will have been created by the time this error was thrown.
25
+ *
26
+ * @remarks TODO: examples of suggested actions for recovery.
27
+ * - How would a user delete the created document?
28
+ * - What would a retry pattern look like here?
29
+ */
30
+ export declare class DocumentPostCreateError extends Error {
31
+ /**
32
+ * Inner error being wrapped.
33
+ */
34
+ private readonly innerError;
35
+ constructor(
36
+ /**
37
+ * Inner error being wrapped.
38
+ */
39
+ innerError: Error);
40
+ readonly name = "DocumentPostCreateError";
41
+ get stack(): string | undefined;
42
+ }
43
+
44
+ export declare interface IRouterliciousDriverPolicies {
45
+ /**
46
+ * Enable prefetching entire snapshot tree into memory before it is loaded by the runtime.
47
+ * Default: true
48
+ */
49
+ enablePrefetch: boolean;
50
+ /**
51
+ * Rate limit concurrent storage requests.
52
+ * Default: 100
53
+ */
54
+ maxConcurrentStorageRequests: number;
55
+ /**
56
+ * Rate limit concurrent orderer requests.
57
+ * Default: 100
58
+ */
59
+ maxConcurrentOrdererRequests: number;
60
+ /**
61
+ * Enable uploading entire summary tree as a IWholeSummaryPayload to storage.
62
+ * Default: false
63
+ */
64
+ enableWholeSummaryUpload: boolean;
65
+ /**
66
+ * Enable service endpoint discovery when creating or joining a session.
67
+ * Default: false
68
+ */
69
+ enableDiscovery: boolean;
70
+ /**
71
+ * Enable using RestLess which avoids CORS preflight requests.
72
+ * Default: true
73
+ */
74
+ enableRestLess: boolean;
75
+ /**
76
+ * Enable internal cache of summaries/snapshots.
77
+ * Reduces Summarizer boot time and reduces server load in E2E tests.
78
+ * Default: true
79
+ */
80
+ enableInternalSummaryCaching: boolean;
81
+ /**
82
+ * Enable downgrading socket connection to long-polling
83
+ * when websocket connection cannot be established.
84
+ * Default: true
85
+ */
86
+ enableLongPollingDowngrade: boolean;
87
+ /**
88
+ * Indicates that the container is ephemeral.
89
+ * Artifacts relates to the container are limited to container lifetime.
90
+ * Default: false
91
+ */
92
+ isEphemeralContainer: boolean;
93
+ }
94
+
95
+ /**
96
+ * Abstracts the token fetching mechanism for a hosting application.
97
+ * The hosting application is responsible for providing an implementation.
98
+ */
99
+ export declare interface ITokenProvider {
100
+ /**
101
+ * Fetches the orderer token from host.
102
+ *
103
+ * @param tenantId - Tenant ID.
104
+ * @param documentId - Optional. Document ID is only required for document-scoped requests.
105
+ * @param refresh - Optional flag indicating whether token fetch must bypass local cache.
106
+ * This likely indicates that some previous request failed authorization due to an expired token,
107
+ * and so a fresh token is required.
108
+ *
109
+ * Default: `false`.
110
+ *
111
+ * NOTE: This parameter will be made required in the future.
112
+ */
113
+ fetchOrdererToken(tenantId: string, documentId?: string, refresh?: boolean): Promise<ITokenResponse>;
114
+ /**
115
+ * Fetches the storage token from host.
116
+ *
117
+ * @param tenantId - Tenant ID.
118
+ * @param documentId - Document ID.
119
+ * @param refresh - Optional flag indicating whether token fetch must bypass local cache.
120
+ * This likely indicates that some previous request failed authorization due to an expired token,
121
+ * and so a fresh token is required.
122
+ *
123
+ * Default: `false`.
124
+ *
125
+ * NOTE: This parameter will be made required in the future.
126
+ */
127
+ fetchStorageToken(tenantId: string, documentId: string, refresh?: boolean): Promise<ITokenResponse>;
128
+ /**
129
+ * A callback triggered directly after creating the document. In this callback the client has the opportunity, to
130
+ * verify against an authorization service, if the user who claims to create the document is the same user who
131
+ * created it.
132
+ *
133
+ * @remarks Notes:
134
+ *
135
+ * * Using the callback may have performance impact on the document creation process.
136
+ *
137
+ * * Any exceptions thrown in the callback would fail the creation workflow
138
+ * (see {@link RouterliciousDocumentServiceFactory.createContainer} for more details).
139
+ *
140
+ * @param documentId - Document ID.
141
+ * @param creationToken - A special token that doesn't provide any kind of access, but it has the user's payload
142
+ * and document id. It can be used to validate the identity of the document creator.
143
+ */
144
+ documentPostCreateCallback?(documentId: string, creationToken: string): Promise<void>;
145
+ }
146
+
147
+ export declare interface ITokenResponse {
148
+ /**
149
+ * {@link https://jwt.io/introduction/ | JSON Web Token (JWT)} value.
150
+ */
151
+ jwt: string;
152
+ /**
153
+ * A flag indicating whether token was obtained from local cache.
154
+ *
155
+ * @remarks `undefined` indicates that the source of the token could not be determined.
156
+ */
157
+ fromCache?: boolean;
158
+ }
159
+
160
+ /**
161
+ * Abstracts the discovery of claims contained within a token.
162
+ */
163
+ export declare interface ITokenService {
164
+ /**
165
+ * Extracts the {@link @fluidframework/protocol-definitions#ITokenClaims | token claims} from the provided
166
+ * {@link https://jwt.io/introduction/ | JSON Web Token (JWT)} string representation.
167
+ */
168
+ extractClaims(token: string): ITokenClaims;
169
+ }
170
+
171
+ /**
172
+ * Factory for creating the routerlicious document service. Use this if you want to
173
+ * use the routerlicious implementation.
174
+ */
175
+ export declare class RouterliciousDocumentServiceFactory implements IDocumentServiceFactory {
176
+ private readonly tokenProvider;
177
+ private readonly driverPolicies;
178
+ private readonly blobCache;
179
+ private readonly wholeSnapshotTreeCache;
180
+ private readonly shreddedSummaryTreeCache;
181
+ constructor(tokenProvider: ITokenProvider, driverPolicies?: Partial<IRouterliciousDriverPolicies>);
182
+ /**
183
+ * {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createContainer}
184
+ *
185
+ * @throws {@link DocumentPostCreateError}
186
+ * If an exception is thrown while invoking the provided {@link ITokenProvider.documentPostCreateCallback}.
187
+ */
188
+ createContainer(createNewSummary: ISummaryTree | undefined, resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
189
+ /**
190
+ * {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createDocumentService}
191
+ *
192
+ * @returns Routerlicious document service.
193
+ */
194
+ createDocumentService(resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean, session?: ISession): Promise<IDocumentService>;
195
+ }
196
+
197
+ /**
198
+ * Routerlicious Error types
199
+ * Different error types that may be thrown by the routerlicious driver
200
+ *
201
+ * @deprecated Use {@link (RouterliciousErrorTypes:variable)} instead.
202
+ */
203
+ export declare enum RouterliciousErrorType {
204
+ /**
205
+ * File not found, or file deleted during session
206
+ */
207
+ fileNotFoundOrAccessDeniedError = "fileNotFoundOrAccessDeniedError",
208
+ /**
209
+ * SSL Certificate Error.
210
+ */
211
+ sslCertError = "sslCertError"
212
+ }
213
+
214
+ /**
215
+ * Routerlicious Error types
216
+ * Different error types that may be thrown by the routerlicious driver
217
+ */
218
+ export declare const RouterliciousErrorTypes: {
219
+ /**
220
+ * SSL Certificate Error.
221
+ */
222
+ readonly sslCertError: "sslCertError";
223
+ readonly genericNetworkError: "genericNetworkError";
224
+ readonly authorizationError: "authorizationError";
225
+ readonly fileNotFoundOrAccessDeniedError: "fileNotFoundOrAccessDeniedError";
226
+ readonly offlineError: "offlineError";
227
+ readonly unsupportedClientProtocolVersion: "unsupportedClientProtocolVersion";
228
+ readonly writeError: "writeError";
229
+ readonly fetchFailure: "fetchFailure";
230
+ readonly fetchTokenError: "fetchTokenError";
231
+ readonly incorrectServerResponse: "incorrectServerResponse";
232
+ readonly fileOverwrittenInStorage: "fileOverwrittenInStorage";
233
+ readonly deltaStreamConnectionForbidden: "deltaStreamConnectionForbidden";
234
+ readonly locationRedirection: "locationRedirection";
235
+ readonly fluidInvalidSchema: "fluidInvalidSchema";
236
+ readonly fileIsLocked: "fileIsLocked";
237
+ readonly outOfStorageError: "outOfStorageError";
238
+ readonly genericError: "genericError";
239
+ readonly throttlingError: "throttlingError";
240
+ readonly usageError: "usageError";
241
+ };
242
+
243
+ export declare type RouterliciousErrorTypes = (typeof RouterliciousErrorTypes)[keyof typeof RouterliciousErrorTypes];
244
+
245
+ export { }
@@ -20,6 +20,7 @@ export declare class ShreddedSummaryDocumentStorageService implements IDocumentS
20
20
  protected readonly logger: ITelemetryLoggerExt;
21
21
  readonly policies: IDocumentStorageServicePolicies;
22
22
  private readonly getStorageManager;
23
+ private readonly mc;
23
24
  protected readonly blobsShaCache: Map<string, string>;
24
25
  private readonly blobCache;
25
26
  private readonly snapshotTreeCache;
@@ -1 +1 @@
1
- {"version":3,"file":"shreddedSummaryDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/shreddedSummaryDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAoB,MAAM,iCAAiC,CAA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by-piece on-demand, or up-front when prefetch is enabled.
19
19
  */
20
20
  class ShreddedSummaryDocumentStorageService {
21
+ async getSummaryUploadManager() {
22
+ const manager = await this.getStorageManager();
23
+ return new summaryTreeUploadManager_1.SummaryTreeUploadManager(new retriableGitManager_1.RetriableGitManager(manager, this.logger), this.blobsShaCache, this.getPreviousFullSnapshot.bind(this));
24
+ }
21
25
  constructor(id, manager, logger, policies, driverPolicies, blobCache, snapshotTreeCache, getStorageManager = async () => this.manager) {
22
26
  this.id = id;
23
27
  this.manager = manager;
@@ -32,10 +36,9 @@ class ShreddedSummaryDocumentStorageService {
32
36
  this.blobCache = blobCache ?? new cache_1.InMemoryCache();
33
37
  this.snapshotTreeCache = snapshotTreeCache ?? new cache_1.InMemoryCache();
34
38
  }
35
- }
36
- async getSummaryUploadManager() {
37
- const manager = await this.getStorageManager();
38
- return new summaryTreeUploadManager_1.SummaryTreeUploadManager(new retriableGitManager_1.RetriableGitManager(manager, this.logger), this.blobsShaCache, this.getPreviousFullSnapshot.bind(this));
39
+ this.mc = (0, telemetry_utils_1.createChildMonitoringContext)({
40
+ logger,
41
+ });
39
42
  }
40
43
  async getVersions(versionId, count) {
41
44
  const id = versionId ? versionId : this.id;
@@ -99,7 +102,9 @@ class ShreddedSummaryDocumentStorageService {
99
102
  size: response.size,
100
103
  });
101
104
  return response;
102
- });
105
+ }, undefined, // workers
106
+ undefined, // recordHeapSize
107
+ this.mc.config.getNumber("Fluid.Driver.ReadBlobTelemetrySampling"));
103
108
  this.blobsShaCache.set(value.sha, "");
104
109
  const bufferContent = (0, client_utils_1.stringToBuffer)(value.content, value.encoding);
105
110
  await this.blobCache?.put(this.getCacheKey(value.sha), bufferContent);
@@ -1 +1 @@
1
- {"version":3,"file":"shreddedSummaryDocumentStorageService.js","sourceRoot":"","sources":["../src/shreddedSummaryDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAAwF;AACxF,+DAAkF;AAMlF,iEAAsE;AAStE,mCAAg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ACrC,IAAI,CAAC,MAAM,EACX;YACC,SAAS,EAAE,YAAY;YACvB,IAAI,EAAE,cAAc,CAAC,MAAM;SAC3B,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;YACf,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC/C,MAAM,QAAQ,GAAG,MAAM,OAAO;iBAC5B,UAAU,CAAC,IAAA,iCAAkB,EAAC,cAAc,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC;iBAClE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAC3D,KAAK,CAAC,GAAG,CAAC;gBACT,MAAM,EAAE,QAAQ,CAAC,EAAE;aACnB,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC;QACjB,CAAC,CACD,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,uBAAuB,CACpC,YAAoB;QAEpB,OAAO,YAAY;YAClB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;gBAC1D,mEAAmE;gBACnE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;gBAC3B,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YACzC,CAAC,CAAC;YACJ,CAAC,CAAC,SAAS,CAAC;IACd,CAAC;IAEO,WAAW,CAAC,MAAc;QACjC,OAAO,GAAG,IAAI,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;IAC/B,CAAC;CACD;AA7LD,sFA6LC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { stringToBuffer, Uint8ArrayToString } from \"@fluid-internal/client-utils\";\nimport {\n\tIDocumentStorageService,\n\tISummaryContext,\n\tIDocumentStorageServicePolicies,\n} from \"@fluidframework/driver-definitions\";\nimport { buildGitTreeHierarchy } from \"@fluidframework/protocol-base\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTreeEx,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport { ICache, InMemoryCache } from \"./cache\";\nimport { RetriableGitManager } from \"./retriableGitManager\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { GitManager } from \"./gitManager\";\nimport { ISummaryUploadManager } from \"./storageContracts\";\nimport { SummaryTreeUploadManager } from \"./summaryTreeUploadManager\";\n\nconst isNode = typeof window === \"undefined\";\n\n/**\n * Document access to underlying storage for routerlicious driver.\n * Uploads summaries piece-by-piece traversing the tree recursively.\n * Downloads summaries piece-by-piece on-demand, or up-front when prefetch is enabled.\n */\nexport class ShreddedSummaryDocumentStorageService implements IDocumentStorageService {\n\t// The values of this cache is useless. We only need the keys. So we are always putting\n\t// empty strings as values.\n\tprotected readonly blobsShaCache = new Map<string, string>();\n\tprivate readonly blobCache: ICache<ArrayBufferLike> | undefined;\n\tprivate readonly snapshotTreeCache: ICache<ISnapshotTreeVersion> | undefined;\n\n\tpublic readonly repositoryUrl = \"\";\n\n\tprivate async getSummaryUploadManager(): Promise<ISummaryUploadManager> {\n\t\tconst manager = await this.getStorageManager();\n\t\treturn new SummaryTreeUploadManager(\n\t\t\tnew RetriableGitManager(manager, this.logger),\n\t\t\tthis.blobsShaCache,\n\t\t\tthis.getPreviousFullSnapshot.bind(this),\n\t\t);\n\t}\n\n\tconstructor(\n\t\tprotected readonly id: string,\n\t\tprotected readonly manager: GitManager,\n\t\tprotected readonly logger: ITelemetryLoggerExt,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tdriverPolicies?: IRouterliciousDriverPolicies,\n\t\tblobCache?: ICache<ArrayBufferLike>,\n\t\tsnapshotTreeCache?: ICache<ISnapshotTreeVersion>,\n\t\tprivate readonly getStorageManager: (\n\t\t\tdisableCache?: boolean,\n\t\t) => Promise<GitManager> = async () => this.manager,\n\t) {\n\t\tif (driverPolicies?.enableRestLess === true || isNode) {\n\t\t\tthis.blobCache = blobCache ?? new InMemoryCache();\n\t\t\tthis.snapshotTreeCache = snapshotTreeCache ?? new InMemoryCache();\n\t\t}\n\t}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getVersions\",\n\t\t\t\tversionId: id,\n\t\t\t\tcount,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\treturn (await manager.getCommits(id, count)).content;\n\t\t\t},\n\t\t);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTreeEx | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\trequestVersion = versions[0];\n\t\t}\n\n\t\tconst cachedSnapshotTree = await this.snapshotTreeCache?.get(\n\t\t\tthis.getCacheKey(requestVersion.treeId),\n\t\t);\n\t\tif (cachedSnapshotTree) {\n\t\t\treturn cachedSnapshotTree.snapshotTree as ISnapshotTreeEx;\n\t\t}\n\n\t\tconst rawTree = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getSnapshotTree\",\n\t\t\t\ttreeId: requestVersion.treeId,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = (await manager.getTree(requestVersion!.treeId)).content;\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.tree.length,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t\tconst tree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tawait this.snapshotTreeCache?.put(this.getCacheKey(tree.id), {\n\t\t\tid: requestVersion.id,\n\t\t\tsnapshotTree: tree,\n\t\t});\n\t\treturn tree;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst cachedBlob = await this.blobCache?.get(this.getCacheKey(blobId));\n\t\tif (cachedBlob) {\n\t\t\treturn cachedBlob;\n\t\t}\n\n\t\tconst value = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"readBlob\",\n\t\t\t\tblobId,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = (await manager.getBlob(blobId)).content;\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.size,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t\tthis.blobsShaCache.set(value.sha, \"\");\n\t\tconst bufferContent = stringToBuffer(value.content, value.encoding);\n\t\tawait this.blobCache?.put(this.getCacheKey(value.sha), bufferContent);\n\t\treturn bufferContent;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tconst summaryHandle = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"uploadSummaryWithContext\",\n\t\t\t\tproposalHandle: context.proposalHandle,\n\t\t\t\tackHandle: context.ackHandle,\n\t\t\t\treferenceSequenceNumber: context.referenceSequenceNumber,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst summaryUploadManager = await this.getSummaryUploadManager();\n\t\t\t\treturn summaryUploadManager.writeSummaryTree(\n\t\t\t\t\tsummary,\n\t\t\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\t\t\"channel\",\n\t\t\t\t);\n\t\t\t},\n\t\t);\n\t\treturn summaryHandle;\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tthrow new Error(\"NOT IMPLEMENTED!\");\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"createBlob\",\n\t\t\t\tsize: uint8ArrayFile.length,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = await manager\n\t\t\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t\t\t.then((r) => ({ id: r.content.sha, url: r.content.url }));\n\t\t\t\tevent.end({\n\t\t\t\t\tblobId: response.id,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate async getPreviousFullSnapshot(\n\t\tparentHandle: string,\n\t): Promise<ISnapshotTreeEx | null | undefined> {\n\t\treturn parentHandle\n\t\t\t? this.getVersions(parentHandle, 1).then(async (versions) => {\n\t\t\t\t\t// Clear the cache as the getSnapshotTree call will fill the cache.\n\t\t\t\t\tthis.blobsShaCache.clear();\n\t\t\t\t\treturn this.getSnapshotTree(versions[0]);\n\t\t\t })\n\t\t\t: undefined;\n\t}\n\n\tprivate getCacheKey(blobId: string): string {\n\t\treturn `${this.id}:${blobId}`;\n\t}\n}\n"]}
1
+ {"version":3,"file":"shreddedSummaryDocumentStorage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eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YACzC,CAAC,CAAC;YACJ,CAAC,CAAC,SAAS,CAAC;IACd,CAAC;IAEO,WAAW,CAAC,MAAc;QACjC,OAAO,GAAG,IAAI,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;IAC/B,CAAC;CACD;AArMD,sFAqMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tITelemetryLoggerExt,\n\tMonitoringContext,\n\tPerformanceEvent,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport { stringToBuffer, Uint8ArrayToString } from \"@fluid-internal/client-utils\";\nimport {\n\tIDocumentStorageService,\n\tISummaryContext,\n\tIDocumentStorageServicePolicies,\n} from \"@fluidframework/driver-definitions\";\nimport { buildGitTreeHierarchy } from \"@fluidframework/protocol-base\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTreeEx,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport { ICache, InMemoryCache } from \"./cache\";\nimport { RetriableGitManager } from \"./retriableGitManager\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { GitManager } from \"./gitManager\";\nimport { ISummaryUploadManager } from \"./storageContracts\";\nimport { SummaryTreeUploadManager } from \"./summaryTreeUploadManager\";\n\nconst isNode = typeof window === \"undefined\";\n\n/**\n * Document access to underlying storage for routerlicious driver.\n * Uploads summaries piece-by-piece traversing the tree recursively.\n * Downloads summaries piece-by-piece on-demand, or up-front when prefetch is enabled.\n */\nexport class ShreddedSummaryDocumentStorageService implements IDocumentStorageService {\n\tprivate readonly mc: MonitoringContext;\n\t// The values of this cache is useless. We only need the keys. So we are always putting\n\t// empty strings as values.\n\tprotected readonly blobsShaCache = new Map<string, string>();\n\tprivate readonly blobCache: ICache<ArrayBufferLike> | undefined;\n\tprivate readonly snapshotTreeCache: ICache<ISnapshotTreeVersion> | undefined;\n\n\tpublic readonly repositoryUrl = \"\";\n\n\tprivate async getSummaryUploadManager(): Promise<ISummaryUploadManager> {\n\t\tconst manager = await this.getStorageManager();\n\t\treturn new SummaryTreeUploadManager(\n\t\t\tnew RetriableGitManager(manager, this.logger),\n\t\t\tthis.blobsShaCache,\n\t\t\tthis.getPreviousFullSnapshot.bind(this),\n\t\t);\n\t}\n\n\tconstructor(\n\t\tprotected readonly id: string,\n\t\tprotected readonly manager: GitManager,\n\t\tprotected readonly logger: ITelemetryLoggerExt,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tdriverPolicies?: IRouterliciousDriverPolicies,\n\t\tblobCache?: ICache<ArrayBufferLike>,\n\t\tsnapshotTreeCache?: ICache<ISnapshotTreeVersion>,\n\t\tprivate readonly getStorageManager: (\n\t\t\tdisableCache?: boolean,\n\t\t) => Promise<GitManager> = async () => this.manager,\n\t) {\n\t\tif (driverPolicies?.enableRestLess === true || isNode) {\n\t\t\tthis.blobCache = blobCache ?? new InMemoryCache();\n\t\t\tthis.snapshotTreeCache = snapshotTreeCache ?? new InMemoryCache();\n\t\t}\n\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger,\n\t\t});\n\t}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getVersions\",\n\t\t\t\tversionId: id,\n\t\t\t\tcount,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\treturn (await manager.getCommits(id, count)).content;\n\t\t\t},\n\t\t);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTreeEx | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\trequestVersion = versions[0];\n\t\t}\n\n\t\tconst cachedSnapshotTree = await this.snapshotTreeCache?.get(\n\t\t\tthis.getCacheKey(requestVersion.treeId),\n\t\t);\n\t\tif (cachedSnapshotTree) {\n\t\t\treturn cachedSnapshotTree.snapshotTree as ISnapshotTreeEx;\n\t\t}\n\n\t\tconst rawTree = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getSnapshotTree\",\n\t\t\t\ttreeId: requestVersion.treeId,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = (await manager.getTree(requestVersion!.treeId)).content;\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.tree.length,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t\tconst tree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tawait this.snapshotTreeCache?.put(this.getCacheKey(tree.id), {\n\t\t\tid: requestVersion.id,\n\t\t\tsnapshotTree: tree,\n\t\t});\n\t\treturn tree;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst cachedBlob = await this.blobCache?.get(this.getCacheKey(blobId));\n\t\tif (cachedBlob) {\n\t\t\treturn cachedBlob;\n\t\t}\n\n\t\tconst value = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"readBlob\",\n\t\t\t\tblobId,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = (await manager.getBlob(blobId)).content;\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.size,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t\tundefined, // workers\n\t\t\tundefined, // recordHeapSize\n\t\t\tthis.mc.config.getNumber(\"Fluid.Driver.ReadBlobTelemetrySampling\"),\n\t\t);\n\t\tthis.blobsShaCache.set(value.sha, \"\");\n\t\tconst bufferContent = stringToBuffer(value.content, value.encoding);\n\t\tawait this.blobCache?.put(this.getCacheKey(value.sha), bufferContent);\n\t\treturn bufferContent;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tconst summaryHandle = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"uploadSummaryWithContext\",\n\t\t\t\tproposalHandle: context.proposalHandle,\n\t\t\t\tackHandle: context.ackHandle,\n\t\t\t\treferenceSequenceNumber: context.referenceSequenceNumber,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst summaryUploadManager = await this.getSummaryUploadManager();\n\t\t\t\treturn summaryUploadManager.writeSummaryTree(\n\t\t\t\t\tsummary,\n\t\t\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\t\t\"channel\",\n\t\t\t\t);\n\t\t\t},\n\t\t);\n\t\treturn summaryHandle;\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tthrow new Error(\"NOT IMPLEMENTED!\");\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"createBlob\",\n\t\t\t\tsize: uint8ArrayFile.length,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = await manager\n\t\t\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t\t\t.then((r) => ({ id: r.content.sha, url: r.content.url }));\n\t\t\t\tevent.end({\n\t\t\t\t\tblobId: response.id,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate async getPreviousFullSnapshot(\n\t\tparentHandle: string,\n\t): Promise<ISnapshotTreeEx | null | undefined> {\n\t\treturn parentHandle\n\t\t\t? this.getVersions(parentHandle, 1).then(async (versions) => {\n\t\t\t\t\t// Clear the cache as the getSnapshotTree call will fill the cache.\n\t\t\t\t\tthis.blobsShaCache.clear();\n\t\t\t\t\treturn this.getSnapshotTree(versions[0]);\n\t\t\t })\n\t\t\t: undefined;\n\t}\n\n\tprivate getCacheKey(blobId: string): string {\n\t\treturn `${this.id}:${blobId}`;\n\t}\n}\n"]}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.34.9"
8
+ "packageVersion": "7.38.0"
9
9
  }
10
10
  ]
11
11
  }
@@ -19,6 +19,7 @@ export declare class WholeSummaryDocumentStorageService implements IDocumentStor
19
19
  private readonly snapshotTreeCache;
20
20
  private readonly noCacheGitManager?;
21
21
  private readonly getStorageManager;
22
+ private readonly mc;
22
23
  private firstVersionsCall;
23
24
  readonly repositoryUrl = "";
24
25
  private getSummaryUploadManager;
@@ -1 +1 @@
1
- {"version":3,"file":"wholeSummaryDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAoB,MAAM,iCAAiC,CAAC;AAIxF,OAAO,EACN,uBAAuB,EACvB,eAAe,EACf,+BAA+B,EAC/B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,MAAM,sCAAsC,CAAC;AAC9C,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