@fluidframework/routerlicious-driver 2.0.0-dev.2.3.0.115467 → 2.0.0-dev.4.1.0.148229
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +10 -12
- package/.mocharc.js +2 -2
- package/README.md +1 -1
- package/api-extractor.json +2 -2
- package/dist/cache.d.ts +3 -0
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +6 -4
- package/dist/cache.js.map +1 -1
- package/dist/createNewUtils.d.ts.map +1 -1
- package/dist/createNewUtils.js +4 -2
- package/dist/createNewUtils.js.map +1 -1
- package/dist/defaultTokenProvider.d.ts.map +1 -1
- package/dist/defaultTokenProvider.js.map +1 -1
- package/dist/definitions.d.ts.map +1 -1
- package/dist/definitions.js.map +1 -1
- package/dist/deltaStorageService.d.ts.map +1 -1
- package/dist/deltaStorageService.js +4 -1
- package/dist/deltaStorageService.js.map +1 -1
- package/dist/documentDeltaConnection.d.ts.map +1 -1
- package/dist/documentDeltaConnection.js.map +1 -1
- package/dist/documentService.d.ts +4 -2
- package/dist/documentService.d.ts.map +1 -1
- package/dist/documentService.js +28 -41
- package/dist/documentService.js.map +1 -1
- package/dist/documentServiceFactory.d.ts +0 -1
- package/dist/documentServiceFactory.d.ts.map +1 -1
- package/dist/documentServiceFactory.js +26 -13
- package/dist/documentServiceFactory.js.map +1 -1
- package/dist/documentStorageService.d.ts +1 -1
- package/dist/documentStorageService.d.ts.map +1 -1
- package/dist/documentStorageService.js +8 -6
- package/dist/documentStorageService.js.map +1 -1
- package/dist/errorUtils.d.ts +11 -3
- package/dist/errorUtils.d.ts.map +1 -1
- package/dist/errorUtils.js +19 -6
- package/dist/errorUtils.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/mapWithExpiration.d.ts +34 -0
- package/dist/mapWithExpiration.d.ts.map +1 -0
- package/dist/mapWithExpiration.js +105 -0
- package/dist/mapWithExpiration.js.map +1 -0
- package/dist/nullBlobStorageService.d.ts.map +1 -1
- package/dist/nullBlobStorageService.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/policies.d.ts.map +1 -1
- package/dist/policies.js.map +1 -1
- package/dist/restWrapper.d.ts +8 -5
- package/dist/restWrapper.d.ts.map +1 -1
- package/dist/restWrapper.js +38 -44
- package/dist/restWrapper.js.map +1 -1
- package/dist/retriableGitManager.d.ts.map +1 -1
- package/dist/retriableGitManager.js.map +1 -1
- package/dist/shreddedSummaryDocumentStorageService.d.ts +1 -1
- package/dist/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
- package/dist/shreddedSummaryDocumentStorageService.js +9 -5
- package/dist/shreddedSummaryDocumentStorageService.js.map +1 -1
- package/dist/tokens.d.ts +24 -7
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js.map +1 -1
- package/dist/treeUtils.d.ts +51 -0
- package/dist/treeUtils.d.ts.map +1 -0
- package/dist/treeUtils.js +85 -0
- package/dist/treeUtils.js.map +1 -0
- package/dist/urlUtils.d.ts.map +1 -1
- package/dist/urlUtils.js.map +1 -1
- package/dist/wholeSummaryDocumentStorageService.d.ts +1 -1
- package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -1
- package/dist/wholeSummaryDocumentStorageService.js +30 -17
- package/dist/wholeSummaryDocumentStorageService.js.map +1 -1
- package/lib/cache.d.ts +3 -0
- package/lib/cache.d.ts.map +1 -1
- package/lib/cache.js +6 -4
- package/lib/cache.js.map +1 -1
- package/lib/createNewUtils.d.ts.map +1 -1
- package/lib/createNewUtils.js +4 -2
- package/lib/createNewUtils.js.map +1 -1
- package/lib/defaultTokenProvider.d.ts.map +1 -1
- package/lib/defaultTokenProvider.js.map +1 -1
- package/lib/definitions.d.ts.map +1 -1
- package/lib/definitions.js.map +1 -1
- package/lib/deltaStorageService.d.ts.map +1 -1
- package/lib/deltaStorageService.js +4 -1
- package/lib/deltaStorageService.js.map +1 -1
- package/lib/documentDeltaConnection.d.ts.map +1 -1
- package/lib/documentDeltaConnection.js.map +1 -1
- package/lib/documentService.d.ts +4 -2
- package/lib/documentService.d.ts.map +1 -1
- package/lib/documentService.js +30 -24
- package/lib/documentService.js.map +1 -1
- package/lib/documentServiceFactory.d.ts +0 -1
- package/lib/documentServiceFactory.d.ts.map +1 -1
- package/lib/documentServiceFactory.js +27 -14
- package/lib/documentServiceFactory.js.map +1 -1
- package/lib/documentStorageService.d.ts +1 -1
- package/lib/documentStorageService.d.ts.map +1 -1
- package/lib/documentStorageService.js +9 -7
- package/lib/documentStorageService.js.map +1 -1
- package/lib/errorUtils.d.ts +11 -3
- package/lib/errorUtils.d.ts.map +1 -1
- package/lib/errorUtils.js +18 -5
- package/lib/errorUtils.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/mapWithExpiration.d.ts +34 -0
- package/lib/mapWithExpiration.d.ts.map +1 -0
- package/lib/mapWithExpiration.js +101 -0
- package/lib/mapWithExpiration.js.map +1 -0
- package/lib/nullBlobStorageService.d.ts.map +1 -1
- package/lib/nullBlobStorageService.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/policies.d.ts.map +1 -1
- package/lib/policies.js.map +1 -1
- package/lib/restWrapper.d.ts +8 -5
- package/lib/restWrapper.d.ts.map +1 -1
- package/lib/restWrapper.js +38 -44
- package/lib/restWrapper.js.map +1 -1
- package/lib/retriableGitManager.d.ts.map +1 -1
- package/lib/retriableGitManager.js.map +1 -1
- package/lib/shreddedSummaryDocumentStorageService.d.ts +1 -1
- package/lib/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
- package/lib/shreddedSummaryDocumentStorageService.js +10 -6
- package/lib/shreddedSummaryDocumentStorageService.js.map +1 -1
- package/lib/tokens.d.ts +24 -7
- package/lib/tokens.d.ts.map +1 -1
- package/lib/tokens.js.map +1 -1
- package/lib/treeUtils.d.ts +51 -0
- package/lib/treeUtils.d.ts.map +1 -0
- package/lib/treeUtils.js +80 -0
- package/lib/treeUtils.js.map +1 -0
- package/lib/urlUtils.d.ts.map +1 -1
- package/lib/urlUtils.js.map +1 -1
- package/lib/wholeSummaryDocumentStorageService.d.ts +1 -1
- package/lib/wholeSummaryDocumentStorageService.d.ts.map +1 -1
- package/lib/wholeSummaryDocumentStorageService.js +30 -17
- package/lib/wholeSummaryDocumentStorageService.js.map +1 -1
- package/package.json +55 -52
- package/prettier.config.cjs +1 -1
- package/src/cache.ts +21 -14
- package/src/createNewUtils.ts +24 -22
- package/src/defaultTokenProvider.ts +13 -15
- package/src/definitions.ts +2 -2
- package/src/deltaStorageService.ts +99 -95
- package/src/documentDeltaConnection.ts +53 -47
- package/src/documentService.ts +260 -241
- package/src/documentServiceFactory.ts +268 -237
- package/src/documentStorageService.ts +87 -83
- package/src/errorUtils.ts +91 -76
- package/src/index.ts +7 -1
- package/src/mapWithExpiration.ts +124 -0
- package/src/nullBlobStorageService.ts +24 -21
- package/src/packageVersion.ts +1 -1
- package/src/policies.ts +44 -44
- package/src/restWrapper.ts +270 -208
- package/src/retriableGitManager.ts +152 -151
- package/src/shreddedSummaryDocumentStorageService.ts +202 -194
- package/src/tokens.ts +69 -44
- package/src/treeUtils.ts +107 -0
- package/src/urlUtils.ts +26 -23
- package/src/wholeSummaryDocumentStorageService.ts +248 -228
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +9 -13
package/dist/tokens.d.ts
CHANGED
|
@@ -4,9 +4,13 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { ITokenClaims } from "@fluidframework/protocol-definitions";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Abstracts the discovery of claims contained within a token.
|
|
8
8
|
*/
|
|
9
9
|
export interface ITokenService {
|
|
10
|
+
/**
|
|
11
|
+
* Extracts the {@link @fluidframework/protocol-definitions#ITokenClaims | token claims} from the provided
|
|
12
|
+
* {@link https://jwt.io/introduction/ | JSON Web Token (JWT)} string representation.
|
|
13
|
+
*/
|
|
10
14
|
extractClaims(token: string): ITokenClaims;
|
|
11
15
|
}
|
|
12
16
|
export interface ITokenResponse {
|
|
@@ -15,8 +19,9 @@ export interface ITokenResponse {
|
|
|
15
19
|
*/
|
|
16
20
|
jwt: string;
|
|
17
21
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
22
|
+
* A flag indicating whether token was obtained from local cache.
|
|
23
|
+
*
|
|
24
|
+
* @remarks `undefined` indicates that the source of the token could not be determined.
|
|
20
25
|
*/
|
|
21
26
|
fromCache?: boolean;
|
|
22
27
|
}
|
|
@@ -27,20 +32,30 @@ export interface ITokenResponse {
|
|
|
27
32
|
export interface ITokenProvider {
|
|
28
33
|
/**
|
|
29
34
|
* Fetches the orderer token from host.
|
|
35
|
+
*
|
|
30
36
|
* @param tenantId - Tenant ID.
|
|
31
37
|
* @param documentId - Optional. Document ID is only required for document-scoped requests.
|
|
32
38
|
* @param refresh - Optional flag indicating whether token fetch must bypass local cache.
|
|
33
|
-
*
|
|
34
|
-
*
|
|
39
|
+
* This likely indicates that some previous request failed authorization due to an expired token,
|
|
40
|
+
* and so a fresh token is required.
|
|
41
|
+
*
|
|
42
|
+
* Default: `false`.
|
|
43
|
+
*
|
|
44
|
+
* NOTE: This parameter will be made required in the future.
|
|
35
45
|
*/
|
|
36
46
|
fetchOrdererToken(tenantId: string, documentId?: string, refresh?: boolean): Promise<ITokenResponse>;
|
|
37
47
|
/**
|
|
38
48
|
* Fetches the storage token from host.
|
|
49
|
+
*
|
|
39
50
|
* @param tenantId - Tenant ID.
|
|
40
51
|
* @param documentId - Document ID.
|
|
41
52
|
* @param refresh - Optional flag indicating whether token fetch must bypass local cache.
|
|
42
|
-
*
|
|
43
|
-
*
|
|
53
|
+
* This likely indicates that some previous request failed authorization due to an expired token,
|
|
54
|
+
* and so a fresh token is required.
|
|
55
|
+
*
|
|
56
|
+
* Default: `false`.
|
|
57
|
+
*
|
|
58
|
+
* NOTE: This parameter will be made required in the future.
|
|
44
59
|
*/
|
|
45
60
|
fetchStorageToken(tenantId: string, documentId: string, refresh?: boolean): Promise<ITokenResponse>;
|
|
46
61
|
/**
|
|
@@ -49,7 +64,9 @@ export interface ITokenProvider {
|
|
|
49
64
|
* created it.
|
|
50
65
|
*
|
|
51
66
|
* @remarks Notes:
|
|
67
|
+
*
|
|
52
68
|
* * Using the callback may have performance impact on the document creation process.
|
|
69
|
+
*
|
|
53
70
|
* * Any exceptions thrown in the callback would fail the creation workflow
|
|
54
71
|
* (see {@link RouterliciousDocumentServiceFactory.createContainer} for more details).
|
|
55
72
|
*
|
package/dist/tokens.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,aAAa;
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAAC;CAC3C;AAED,MAAM,WAAW,cAAc;IAC9B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B;;;;;;;;;;;;OAYG;IACH,iBAAiB,CAChB,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,OAAO,GACf,OAAO,CAAC,cAAc,CAAC,CAAC;IAE3B;;;;;;;;;;;;OAYG;IACH,iBAAiB,CAChB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,OAAO,GACf,OAAO,CAAC,cAAc,CAAC,CAAC;IAE3B;;;;;;;;;;;;;;;OAeG;IACH,0BAA0B,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtF"}
|
package/dist/tokens.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITokenClaims } from \"@fluidframework/protocol-definitions\";\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITokenClaims } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Abstracts the discovery of claims contained within a token.\n */\nexport interface ITokenService {\n\t/**\n\t * Extracts the {@link @fluidframework/protocol-definitions#ITokenClaims | token claims} from the provided\n\t * {@link https://jwt.io/introduction/ | JSON Web Token (JWT)} string representation.\n\t */\n\textractClaims(token: string): ITokenClaims;\n}\n\nexport interface ITokenResponse {\n\t/**\n\t * {@link https://jwt.io/introduction/ | JSON Web Token (JWT)} value.\n\t */\n\tjwt: string;\n\n\t/**\n\t * A flag indicating whether token was obtained from local cache.\n\t *\n\t * @remarks `undefined` indicates that the source of the token could not be determined.\n\t */\n\tfromCache?: boolean;\n}\n\n/**\n * Abstracts the token fetching mechanism for a hosting application.\n * The hosting application is responsible for providing an implementation.\n */\nexport interface ITokenProvider {\n\t/**\n\t * Fetches the orderer token from host.\n\t *\n\t * @param tenantId - Tenant ID.\n\t * @param documentId - Optional. Document ID is only required for document-scoped requests.\n\t * @param refresh - Optional flag indicating whether token fetch must bypass local cache.\n\t * This likely indicates that some previous request failed authorization due to an expired token,\n\t * and so a fresh token is required.\n\t *\n\t * Default: `false`.\n\t *\n\t * NOTE: This parameter will be made required in the future.\n\t */\n\tfetchOrdererToken(\n\t\ttenantId: string,\n\t\tdocumentId?: string,\n\t\trefresh?: boolean,\n\t): Promise<ITokenResponse>;\n\n\t/**\n\t * Fetches the storage token from host.\n\t *\n\t * @param tenantId - Tenant ID.\n\t * @param documentId - Document ID.\n\t * @param refresh - Optional flag indicating whether token fetch must bypass local cache.\n\t * This likely indicates that some previous request failed authorization due to an expired token,\n\t * and so a fresh token is required.\n\t *\n\t * Default: `false`.\n\t *\n\t * NOTE: This parameter will be made required in the future.\n\t */\n\tfetchStorageToken(\n\t\ttenantId: string,\n\t\tdocumentId: string,\n\t\trefresh?: boolean,\n\t): Promise<ITokenResponse>;\n\n\t/**\n\t * A callback triggered directly after creating the document. In this callback the client has the opportunity, to\n\t * verify against an authorization service, if the user who claims to create the document is the same user who\n\t * created it.\n\t *\n\t * @remarks Notes:\n\t *\n\t * * Using the callback may have performance impact on the document creation process.\n\t *\n\t * * Any exceptions thrown in the callback would fail the creation workflow\n\t * (see {@link RouterliciousDocumentServiceFactory.createContainer} for more details).\n\t *\n\t * @param documentId - Document ID.\n\t * @param creationToken - A special token that doesn't provide any kind of access, but it has the user's payload\n\t * and document id. It can be used to validate the identity of the document creator.\n\t */\n\tdocumentPostCreateCallback?(documentId: string, creationToken: string): Promise<void>;\n}\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { SummaryType, ISnapshotTree, ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
6
|
+
/**
|
|
7
|
+
* Summary tree assembler props
|
|
8
|
+
*/
|
|
9
|
+
export interface ISummaryTreeAssemblerProps {
|
|
10
|
+
/**
|
|
11
|
+
* Indicates that this tree is unreferenced. If this is not present, the tree is considered referenced.
|
|
12
|
+
*/
|
|
13
|
+
unreferenced?: true;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Summary tree assembler (without stats collection).
|
|
17
|
+
*/
|
|
18
|
+
export declare class SummaryTreeAssembler {
|
|
19
|
+
private readonly props?;
|
|
20
|
+
private attachmentCounter;
|
|
21
|
+
private readonly summaryTree;
|
|
22
|
+
constructor(props?: ISummaryTreeAssemblerProps | undefined);
|
|
23
|
+
/**
|
|
24
|
+
* Get final summary
|
|
25
|
+
*/
|
|
26
|
+
get summary(): ISummaryTree;
|
|
27
|
+
/**
|
|
28
|
+
* Add blob to summary
|
|
29
|
+
*/
|
|
30
|
+
addBlob(key: string, content: string | Uint8Array): void;
|
|
31
|
+
/**
|
|
32
|
+
* Add handle to summary
|
|
33
|
+
*/
|
|
34
|
+
addHandle(key: string, handleType: SummaryType.Tree | SummaryType.Blob | SummaryType.Attachment, handle: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* Add tree to summary
|
|
37
|
+
*/
|
|
38
|
+
addTree(key: string, summary: ISummaryTree): void;
|
|
39
|
+
/**
|
|
40
|
+
* Add attachment to summary
|
|
41
|
+
*/
|
|
42
|
+
addAttachment(id: string): void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Helper function that converts ISnapshotTree and blobs to ISummaryTree
|
|
46
|
+
* @param snapshot - Source snapshot tree
|
|
47
|
+
* @param blobs - Blobs cache
|
|
48
|
+
* @returns Converted snapshot in ISummaryTree format
|
|
49
|
+
*/
|
|
50
|
+
export declare function convertSnapshotAndBlobsToSummaryTree(snapshot: ISnapshotTree, blobs: Map<string, ArrayBuffer>): ISummaryTree;
|
|
51
|
+
//# sourceMappingURL=treeUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"treeUtils.d.ts","sourceRoot":"","sources":["../src/treeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,WAAW,EACX,aAAa,EACb,YAAY,EAEZ,MAAM,sCAAsC,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;OAEG;IACH,YAAY,CAAC,EAAE,IAAI,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,oBAAoB;IAIpB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;IAHnC,OAAO,CAAC,iBAAiB,CAAa;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAyC;gBAExC,KAAK,CAAC,wCAA4B;IAE/D;;OAEG;IACH,IAAW,OAAO,IAAI,YAAY,CAMjC;IAED;;OAEG;IACI,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAO/D;;OAEG;IACI,SAAS,CACf,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,WAAW,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,GAAG,WAAW,CAAC,UAAU,EACxE,MAAM,EAAE,MAAM,GACZ,IAAI;IAQP;;OAEG;IACI,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI;IAIxD;;OAEG;IACI,aAAa,CAAC,EAAE,EAAE,MAAM;CAG/B;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CACnD,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,GAC7B,YAAY,CAcd"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.convertSnapshotAndBlobsToSummaryTree = exports.SummaryTreeAssembler = void 0;
|
|
8
|
+
const common_utils_1 = require("@fluidframework/common-utils");
|
|
9
|
+
const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
|
|
10
|
+
/**
|
|
11
|
+
* Summary tree assembler (without stats collection).
|
|
12
|
+
*/
|
|
13
|
+
class SummaryTreeAssembler {
|
|
14
|
+
constructor(props) {
|
|
15
|
+
this.props = props;
|
|
16
|
+
this.attachmentCounter = 0;
|
|
17
|
+
this.summaryTree = {};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get final summary
|
|
21
|
+
*/
|
|
22
|
+
get summary() {
|
|
23
|
+
var _a;
|
|
24
|
+
return {
|
|
25
|
+
type: protocol_definitions_1.SummaryType.Tree,
|
|
26
|
+
tree: Object.assign({}, this.summaryTree),
|
|
27
|
+
unreferenced: (_a = this.props) === null || _a === void 0 ? void 0 : _a.unreferenced,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Add blob to summary
|
|
32
|
+
*/
|
|
33
|
+
addBlob(key, content) {
|
|
34
|
+
this.summaryTree[key] = {
|
|
35
|
+
type: protocol_definitions_1.SummaryType.Blob,
|
|
36
|
+
content,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Add handle to summary
|
|
41
|
+
*/
|
|
42
|
+
addHandle(key, handleType, handle) {
|
|
43
|
+
this.summaryTree[key] = {
|
|
44
|
+
type: protocol_definitions_1.SummaryType.Handle,
|
|
45
|
+
handleType,
|
|
46
|
+
handle,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Add tree to summary
|
|
51
|
+
*/
|
|
52
|
+
addTree(key, summary) {
|
|
53
|
+
this.summaryTree[key] = summary;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Add attachment to summary
|
|
57
|
+
*/
|
|
58
|
+
addAttachment(id) {
|
|
59
|
+
this.summaryTree[this.attachmentCounter++] = { id, type: protocol_definitions_1.SummaryType.Attachment };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.SummaryTreeAssembler = SummaryTreeAssembler;
|
|
63
|
+
/**
|
|
64
|
+
* Helper function that converts ISnapshotTree and blobs to ISummaryTree
|
|
65
|
+
* @param snapshot - Source snapshot tree
|
|
66
|
+
* @param blobs - Blobs cache
|
|
67
|
+
* @returns Converted snapshot in ISummaryTree format
|
|
68
|
+
*/
|
|
69
|
+
function convertSnapshotAndBlobsToSummaryTree(snapshot, blobs) {
|
|
70
|
+
const assembler = new SummaryTreeAssembler({
|
|
71
|
+
unreferenced: snapshot.unreferenced,
|
|
72
|
+
});
|
|
73
|
+
for (const [path, id] of Object.entries(snapshot.blobs)) {
|
|
74
|
+
const blob = blobs.get(id);
|
|
75
|
+
(0, common_utils_1.assert)(blob !== undefined, 0x2dd /* "Cannot find blob for a given id" */);
|
|
76
|
+
assembler.addBlob(path, common_utils_1.IsoBuffer.from(blob).toString("utf-8"));
|
|
77
|
+
}
|
|
78
|
+
for (const [key, tree] of Object.entries(snapshot.trees)) {
|
|
79
|
+
const subtree = convertSnapshotAndBlobsToSummaryTree(tree, blobs);
|
|
80
|
+
assembler.addTree(key, subtree);
|
|
81
|
+
}
|
|
82
|
+
return assembler.summary;
|
|
83
|
+
}
|
|
84
|
+
exports.convertSnapshotAndBlobsToSummaryTree = convertSnapshotAndBlobsToSummaryTree;
|
|
85
|
+
//# sourceMappingURL=treeUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"treeUtils.js","sourceRoot":"","sources":["../src/treeUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AACjE,+EAK8C;AAY9C;;GAEG;AAC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CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QACxD,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC3B,IAAA,qBAAM,EAAC,IAAI,KAAK,SAAS,EAAE,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC1E,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,wBAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;KAChE;IACD,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QACzD,MAAM,OAAO,GAAG,oCAAoC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAClE,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;KAChC;IACD,OAAO,SAAS,CAAC,OAAO,CAAC;AAC1B,CAAC;AAjBD,oFAiBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, IsoBuffer } from \"@fluidframework/common-utils\";\nimport {\n\tSummaryType,\n\tISnapshotTree,\n\tISummaryTree,\n\tSummaryObject,\n} from \"@fluidframework/protocol-definitions\";\n\n/**\n * Summary tree assembler props\n */\nexport interface ISummaryTreeAssemblerProps {\n\t/**\n\t * Indicates that this tree is unreferenced. If this is not present, the tree is considered referenced.\n\t */\n\tunreferenced?: true;\n}\n\n/**\n * Summary tree assembler (without stats collection).\n */\nexport class SummaryTreeAssembler {\n\tprivate attachmentCounter: number = 0;\n\tprivate readonly summaryTree: { [path: string]: SummaryObject } = {};\n\n\tconstructor(private readonly props?: ISummaryTreeAssemblerProps) {}\n\n\t/**\n\t * Get final summary\n\t */\n\tpublic get summary(): ISummaryTree {\n\t\treturn {\n\t\t\ttype: SummaryType.Tree,\n\t\t\ttree: { ...this.summaryTree },\n\t\t\tunreferenced: this.props?.unreferenced,\n\t\t};\n\t}\n\n\t/**\n\t * Add blob to summary\n\t */\n\tpublic addBlob(key: string, content: string | Uint8Array): void {\n\t\tthis.summaryTree[key] = {\n\t\t\ttype: SummaryType.Blob,\n\t\t\tcontent,\n\t\t};\n\t}\n\n\t/**\n\t * Add handle to summary\n\t */\n\tpublic addHandle(\n\t\tkey: string,\n\t\thandleType: SummaryType.Tree | SummaryType.Blob | SummaryType.Attachment,\n\t\thandle: string,\n\t): void {\n\t\tthis.summaryTree[key] = {\n\t\t\ttype: SummaryType.Handle,\n\t\t\thandleType,\n\t\t\thandle,\n\t\t};\n\t}\n\n\t/**\n\t * Add tree to summary\n\t */\n\tpublic addTree(key: string, summary: ISummaryTree): void {\n\t\tthis.summaryTree[key] = summary;\n\t}\n\n\t/**\n\t * Add attachment to summary\n\t */\n\tpublic addAttachment(id: string) {\n\t\tthis.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };\n\t}\n}\n\n/**\n * Helper function that converts ISnapshotTree and blobs to ISummaryTree\n * @param snapshot - Source snapshot tree\n * @param blobs - Blobs cache\n * @returns Converted snapshot in ISummaryTree format\n */\nexport function convertSnapshotAndBlobsToSummaryTree(\n\tsnapshot: ISnapshotTree,\n\tblobs: Map<string, ArrayBuffer>,\n): ISummaryTree {\n\tconst assembler = new SummaryTreeAssembler({\n\t\tunreferenced: snapshot.unreferenced,\n\t});\n\tfor (const [path, id] of Object.entries(snapshot.blobs)) {\n\t\tconst blob = blobs.get(id);\n\t\tassert(blob !== undefined, 0x2dd /* \"Cannot find blob for a given id\" */);\n\t\tassembler.addBlob(path, IsoBuffer.from(blob).toString(\"utf-8\"));\n\t}\n\tfor (const [key, tree] of Object.entries(snapshot.trees)) {\n\t\tconst subtree = convertSnapshotAndBlobsToSummaryTree(tree, blobs);\n\t\tassembler.addTree(key, subtree);\n\t}\n\treturn assembler.summary;\n}\n"]}
|
package/dist/urlUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlUtils.d.ts","sourceRoot":"","sources":["../src/urlUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAElE,eAAO,MAAM,aAAa,aAAc,MAAM,KAAG,QAEhD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,YAAa,MAAM,cAAc,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"urlUtils.d.ts","sourceRoot":"","sources":["../src/urlUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAElE,eAAO,MAAM,aAAa,aAAc,MAAM,KAAG,QAEhD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,YAAa,MAAM,cAAc,MAAM,KAAG,MACf,CAAC;AAEhE,eAAO,MAAM,6BAA6B,gBAC5B,iBAAiB,WACrB,QAAQ,KACf,iBAuBF,CAAC"}
|
package/dist/urlUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlUtils.js","sourceRoot":"","sources":["../src/urlUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAGH,0DAAiC;AAG1B,MAAM,aAAa,GAAG,CAAC,QAAgB,EAAY,EAAE;
|
|
1
|
+
{"version":3,"file":"urlUtils.js","sourceRoot":"","sources":["../src/urlUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAGH,0DAAiC;AAG1B,MAAM,aAAa,GAAG,CAAC,QAAgB,EAAY,EAAE;I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,WAAW,CAAC,EAAE;QAClB,MAAM,EAAE,WAAW,CAAC,MAAM;QAC1B,IAAI,EAAE,WAAW,CAAC,IAAI;QACtB,GAAG,EAAE,IAAI,mBAAQ,CAAC,WAAW,oBAAoB,CAAC,IAAI,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE;KACzF,CAAC;IACF,OAAO,qBAAqB,CAAC;AAC9B,CAAC,CAAC;AA1BW,QAAA,6BAA6B,iCA0BxC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidResolvedUrl } from \"@fluidframework/driver-definitions\";\nimport URLParse from \"url-parse\";\nimport { ISession } from \"@fluidframework/server-services-client\";\n\nexport const parseFluidUrl = (fluidUrl: string): URLParse => {\n\treturn new URLParse(fluidUrl, true);\n};\n\n/**\n * Assume documentId is at end of url path.\n * This is true for Routerlicious' and Tinylicious' documentUrl and deltaStorageUrl.\n * Routerlicious and Tinylicious do not use documentId in storageUrl nor ordererUrl.\n * TODO: Ideally we would be able to regenerate the resolvedUrl, rather than patching the current one.\n */\nexport const replaceDocumentIdInPath = (urlPath: string, documentId: string): string =>\n\turlPath.split(\"/\").slice(0, -1).concat([documentId]).join(\"/\");\n\nexport const getDiscoveredFluidResolvedUrl = (\n\tresolvedUrl: IFluidResolvedUrl,\n\tsession: ISession,\n): IFluidResolvedUrl => {\n\tconst discoveredOrdererUrl = new URLParse(session.ordererUrl);\n\tconst deltaStorageUrl = new URLParse(resolvedUrl.endpoints.deltaStorageUrl);\n\tdeltaStorageUrl.set(\"host\", discoveredOrdererUrl.host);\n\n\tconst discoveredStorageUrl = new URLParse(session.historianUrl);\n\tconst storageUrl = new URLParse(resolvedUrl.endpoints.storageUrl);\n\tstorageUrl.set(\"host\", discoveredStorageUrl.host);\n\n\tconst parsedUrl = parseFluidUrl(resolvedUrl.url);\n\tconst discoveredResolvedUrl: IFluidResolvedUrl = {\n\t\tendpoints: {\n\t\t\tdeltaStorageUrl: deltaStorageUrl.toString(),\n\t\t\tordererUrl: session.ordererUrl,\n\t\t\tdeltaStreamUrl: session.deltaStreamUrl,\n\t\t\tstorageUrl: storageUrl.toString(),\n\t\t},\n\t\tid: resolvedUrl.id,\n\t\ttokens: resolvedUrl.tokens,\n\t\ttype: resolvedUrl.type,\n\t\turl: new URLParse(`fluid://${discoveredOrdererUrl.host}${parsedUrl.pathname}`).toString(),\n\t};\n\treturn discoveredResolvedUrl;\n};\n"]}
|
|
@@ -22,7 +22,7 @@ export declare class WholeSummaryDocumentStorageService implements IDocumentStor
|
|
|
22
22
|
private firstVersionsCall;
|
|
23
23
|
get repositoryUrl(): string;
|
|
24
24
|
private getSummaryUploadManager;
|
|
25
|
-
constructor(id: string, manager: GitManager, logger: ITelemetryLogger, policies
|
|
25
|
+
constructor(id: string, manager: GitManager, logger: ITelemetryLogger, policies: IDocumentStorageServicePolicies, driverPolicies?: IRouterliciousDriverPolicies | undefined, blobCache?: ICache<ArrayBufferLike>, snapshotTreeCache?: ICache<ISnapshotTreeVersion>, noCacheGitManager?: GitManager | undefined, getStorageManager?: (disableCache?: boolean) => Promise<GitManager>);
|
|
26
26
|
getVersions(versionId: string | null, count: number): Promise<IVersion[]>;
|
|
27
27
|
getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null>;
|
|
28
28
|
readBlob(blobId: string): Promise<ArrayBufferLike>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wholeSummaryDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"wholeSummaryDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,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AO,CAAC,UAAU,CAGP;IAGJ,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IA8CzE,eAAe,CAAC,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAclE,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IA4BlD,wBAAwB,CACpC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;IAqBL,eAAe,CAAC,aAAa,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAwBrE,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;YAqB9D,yBAAyB;YA4DzB,aAAa;IAS3B,OAAO,CAAC,WAAW;CAGnB"}
|
|
@@ -6,13 +6,15 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.WholeSummaryDocumentStorageService = void 0;
|
|
8
8
|
const common_utils_1 = require("@fluidframework/common-utils");
|
|
9
|
-
const driver_utils_1 = require("@fluidframework/driver-utils");
|
|
10
9
|
const server_services_client_1 = require("@fluidframework/server-services-client");
|
|
11
10
|
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
12
11
|
const cache_1 = require("./cache");
|
|
12
|
+
const treeUtils_1 = require("./treeUtils");
|
|
13
13
|
const latestSnapshotId = "latest";
|
|
14
14
|
class WholeSummaryDocumentStorageService {
|
|
15
|
-
constructor(id, manager, logger, policies
|
|
15
|
+
constructor(id, manager, logger, policies, driverPolicies, blobCache = new cache_1.InMemoryCache(), snapshotTreeCache = new cache_1.InMemoryCache(), noCacheGitManager, getStorageManager = async (disableCache) => disableCache && this.noCacheGitManager !== undefined
|
|
16
|
+
? this.noCacheGitManager
|
|
17
|
+
: this.manager) {
|
|
16
18
|
this.id = id;
|
|
17
19
|
this.manager = manager;
|
|
18
20
|
this.logger = logger;
|
|
@@ -35,22 +37,26 @@ class WholeSummaryDocumentStorageService {
|
|
|
35
37
|
var _a;
|
|
36
38
|
if (versionId !== this.id && versionId !== null) {
|
|
37
39
|
// Blobs/Trees in this scenario will never have multiple versions, so return versionId as is
|
|
38
|
-
return [
|
|
40
|
+
return [
|
|
41
|
+
{
|
|
39
42
|
id: versionId,
|
|
40
43
|
treeId: undefined,
|
|
41
|
-
}
|
|
44
|
+
},
|
|
45
|
+
];
|
|
42
46
|
}
|
|
43
47
|
// If this is the first versions call for the document, we know we will want the latest summary.
|
|
44
48
|
// Fetch latest summary, cache it, and return its id.
|
|
45
49
|
if (this.firstVersionsCall && count === 1) {
|
|
46
50
|
this.firstVersionsCall = false;
|
|
47
|
-
const { id: _id, snapshotTree } = !((_a = this.driverPolicies) === null || _a === void 0 ? void 0 : _a.enableDiscovery)
|
|
48
|
-
await this.fetchAndCacheSnapshotTree(latestSnapshotId, false)
|
|
49
|
-
await this.fetchAndCacheSnapshotTree(latestSnapshotId, true);
|
|
50
|
-
return [
|
|
51
|
+
const { id: _id, snapshotTree } = !((_a = this.driverPolicies) === null || _a === void 0 ? void 0 : _a.enableDiscovery)
|
|
52
|
+
? await this.fetchAndCacheSnapshotTree(latestSnapshotId, false)
|
|
53
|
+
: await this.fetchAndCacheSnapshotTree(latestSnapshotId, true);
|
|
54
|
+
return [
|
|
55
|
+
{
|
|
51
56
|
id: _id,
|
|
52
57
|
treeId: snapshotTree.id,
|
|
53
|
-
}
|
|
58
|
+
},
|
|
59
|
+
];
|
|
54
60
|
}
|
|
55
61
|
// Otherwise, get the latest version of the document as normal.
|
|
56
62
|
const id = versionId ? versionId : this.id;
|
|
@@ -126,7 +132,7 @@ class WholeSummaryDocumentStorageService {
|
|
|
126
132
|
return response;
|
|
127
133
|
});
|
|
128
134
|
const { blobs, snapshotTree } = (0, server_services_client_1.convertWholeFlatSummaryToSnapshotTreeAndBlobs)(wholeFlatSummary, "");
|
|
129
|
-
return (0,
|
|
135
|
+
return (0, treeUtils_1.convertSnapshotAndBlobsToSummaryTree)(snapshotTree, blobs);
|
|
130
136
|
}
|
|
131
137
|
async createBlob(file) {
|
|
132
138
|
const uint8ArrayFile = new Uint8Array(file);
|
|
@@ -135,7 +141,9 @@ class WholeSummaryDocumentStorageService {
|
|
|
135
141
|
size: uint8ArrayFile.length,
|
|
136
142
|
}, async (event) => {
|
|
137
143
|
const manager = await this.getStorageManager();
|
|
138
|
-
const response = await manager
|
|
144
|
+
const response = await manager
|
|
145
|
+
.createBlob((0, common_utils_1.Uint8ArrayToString)(uint8ArrayFile, "base64"), "base64")
|
|
146
|
+
.then((r) => ({ id: r.sha, url: r.url }));
|
|
139
147
|
event.end({
|
|
140
148
|
blobId: response.id,
|
|
141
149
|
});
|
|
@@ -145,7 +153,10 @@ class WholeSummaryDocumentStorageService {
|
|
|
145
153
|
async fetchAndCacheSnapshotTree(versionId, disableCache) {
|
|
146
154
|
const cachedSnapshotTreeVersion = await this.snapshotTreeCache.get(this.getCacheKey(versionId));
|
|
147
155
|
if (cachedSnapshotTreeVersion !== undefined) {
|
|
148
|
-
return {
|
|
156
|
+
return {
|
|
157
|
+
id: cachedSnapshotTreeVersion.id,
|
|
158
|
+
snapshotTree: cachedSnapshotTreeVersion.snapshotTree,
|
|
159
|
+
};
|
|
149
160
|
}
|
|
150
161
|
const wholeFlatSummary = await telemetry_utils_1.PerformanceEvent.timedExecAsync(this.logger, {
|
|
151
162
|
eventName: "getWholeFlatSummary",
|
|
@@ -160,15 +171,17 @@ class WholeSummaryDocumentStorageService {
|
|
|
160
171
|
return response;
|
|
161
172
|
});
|
|
162
173
|
const normalizedWholeSummary = (0, server_services_client_1.convertWholeFlatSummaryToSnapshotTreeAndBlobs)(wholeFlatSummary);
|
|
174
|
+
(0, common_utils_1.assert)(normalizedWholeSummary.snapshotTree.id !== undefined, 0x275 /* "Root tree should contain the id" */);
|
|
163
175
|
const wholeFlatSummaryId = wholeFlatSummary.id;
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
176
|
+
const snapshotTreeVersion = {
|
|
177
|
+
id: wholeFlatSummaryId,
|
|
178
|
+
snapshotTree: normalizedWholeSummary.snapshotTree,
|
|
179
|
+
};
|
|
167
180
|
const cachePs = [
|
|
168
|
-
this.snapshotTreeCache.put(this.getCacheKey(
|
|
181
|
+
this.snapshotTreeCache.put(this.getCacheKey(wholeFlatSummaryId), snapshotTreeVersion),
|
|
169
182
|
this.initBlobCache(normalizedWholeSummary.blobs),
|
|
170
183
|
];
|
|
171
|
-
if (
|
|
184
|
+
if (wholeFlatSummaryId !== versionId) {
|
|
172
185
|
// versionId could be "latest". When summarizer checks cache for "latest", we want it to be available.
|
|
173
186
|
// TODO: For in-memory cache, <latest,snapshotTree> will be a shared pointer with <snapshotId,snapshotTree>,
|
|
174
187
|
// However, for something like Redis, this will cache the same value twice. Alternatively, could we simply
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wholeSummaryDocumentStorageService.js","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAIsC;AAMtC,+DAEsC;AAQtC,mFAKgD;AAChD,qEAAmE;AACnE,mCAAgD;AAIhD,MAAM,gBAAgB,GAAW,QAAQ,CAAC;AAE1C,MAAa,kCAAkC;IAY3C,YACuB,EAAU,EACV,OAAmB,EACnB,MAAwB,EAC3B,WAA4C,EAAE,EAC7C,cAA6C,EAC7C,YAAqC,IAAI,qBAAa,EAAE,EACxD,oBAAkD,IAAI,qBAAa,EAAE,EACrE,iBAA8B,EAC9B,oBAAqE,KAAK,EAAE,YAAY,EAAE,EAAE,CACzG,YAAY,IAAI,IAAI,CAAC,iBAAiB,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO;QAT7E,OAAE,GAAF,EAAE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,CAAC,CAAC;QACH,MAAM,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACtC,CAAC;IAEO,WAAW,CAAC,MAAc;QAC9B,OAAO,GAAG,IAAI,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;IAClC,CAAC;CACJ;AAxOD,gFAwOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n assert,\n stringToBuffer,\n Uint8ArrayToString,\n} from \"@fluidframework/common-utils\";\nimport {\n IDocumentStorageService,\n ISummaryContext,\n IDocumentStorageServicePolicies,\n} from \"@fluidframework/driver-definitions\";\nimport {\n convertSnapshotAndBlobsToSummaryTree,\n} from \"@fluidframework/driver-utils\";\nimport {\n ICreateBlobResponse,\n ISnapshotTree,\n ISummaryHandle,\n ISummaryTree,\n IVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n convertWholeFlatSummaryToSnapshotTreeAndBlobs,\n GitManager,\n ISummaryUploadManager,\n WholeSummaryUploadManager,\n} from \"@fluidframework/server-services-client\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { ICache, InMemoryCache } from \"./cache\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\n\nconst latestSnapshotId: string = \"latest\";\n\nexport class WholeSummaryDocumentStorageService implements IDocumentStorageService {\n private firstVersionsCall: boolean = true;\n\n public get repositoryUrl(): string {\n return \"\";\n }\n\n private async getSummaryUploadManager(): Promise<ISummaryUploadManager> {\n const manager = await this.getStorageManager();\n return new WholeSummaryUploadManager(manager);\n }\n\n constructor(\n protected readonly id: string,\n protected readonly manager: GitManager,\n protected readonly logger: ITelemetryLogger,\n public readonly policies: IDocumentStorageServicePolicies = {},\n private readonly driverPolicies?: IRouterliciousDriverPolicies,\n private readonly blobCache: ICache<ArrayBufferLike> = new InMemoryCache(),\n private readonly snapshotTreeCache: ICache<ISnapshotTreeVersion> = new InMemoryCache(),\n private readonly noCacheGitManager?: GitManager,\n private readonly getStorageManager: (disableCache?: boolean) => Promise<GitManager> = async (disableCache) =>\n disableCache && this.noCacheGitManager !== undefined ? this.noCacheGitManager : this.manager,\n ) {\n }\n\n public async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n if (versionId !== this.id && versionId !== null) {\n // Blobs/Trees in this scenario will never have multiple versions, so return versionId as is\n return [{\n id: versionId,\n treeId: undefined!,\n }];\n }\n // If this is the first versions call for the document, we know we will want the latest summary.\n // Fetch latest summary, cache it, and return its id.\n if (this.firstVersionsCall && count === 1) {\n this.firstVersionsCall = false;\n const { id: _id, snapshotTree } = !this.driverPolicies?.enableDiscovery ?\n await this.fetchAndCacheSnapshotTree(latestSnapshotId, false) :\n await this.fetchAndCacheSnapshotTree(latestSnapshotId, true);\n return [{\n id: _id,\n treeId: snapshotTree.id!,\n }];\n }\n\n // Otherwise, get the latest version of the document as normal.\n const id = versionId ? versionId : this.id;\n const commits = await PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"getVersions\",\n versionId: id,\n count,\n },\n async () => {\n const manager = await this.getStorageManager();\n return manager.getCommits(id, count);\n },\n );\n return commits.map((commit) => ({\n date: commit.commit.author.date,\n id: commit.sha,\n treeId: commit.commit.tree.sha,\n }));\n }\n\n public async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n let requestVersion = version;\n if (!requestVersion) {\n const versions = await this.getVersions(this.id, 1);\n if (versions.length === 0) {\n return null;\n }\n\n requestVersion = versions[0];\n }\n\n return (await this.fetchAndCacheSnapshotTree(requestVersion.id)).snapshotTree;\n }\n\n public async readBlob(blobId: string): Promise<ArrayBufferLike> {\n const cachedBlob = await this.blobCache.get(this.getCacheKey(blobId));\n if (cachedBlob !== undefined) {\n return cachedBlob;\n }\n\n const blob = await PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"readBlob\",\n blobId,\n },\n async (event) => {\n const manager = await this.getStorageManager();\n const response = await manager.getBlob(blobId);\n event.end({\n size: response.size,\n });\n return response;\n },\n );\n const bufferValue = stringToBuffer(blob.content, blob.encoding);\n\n await this.blobCache.put(this.getCacheKey(blob.sha), bufferValue);\n\n return bufferValue;\n }\n\n public async uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string> {\n const summaryHandle = await PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"uploadSummaryWithContext\",\n proposalHandle: context.proposalHandle,\n ackHandle: context.ackHandle,\n referenceSequenceNumber: context.referenceSequenceNumber,\n },\n async () => {\n const summaryUploadManager = await this.getSummaryUploadManager();\n return summaryUploadManager.writeSummaryTree(summary, context.ackHandle ?? \"\", \"channel\");\n },\n );\n return summaryHandle;\n }\n\n public async downloadSummary(summaryHandle: ISummaryHandle): Promise<ISummaryTree> {\n const wholeFlatSummary = await PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"getWholeFlatSummary\",\n treeId: summaryHandle.handle,\n },\n async (event) => {\n const manager = await this.getStorageManager();\n const response = await manager.getSummary(summaryHandle.handle);\n event.end({\n size: response.trees[0]?.entries.length,\n });\n return response;\n },\n );\n\n const { blobs, snapshotTree } = convertWholeFlatSummaryToSnapshotTreeAndBlobs(wholeFlatSummary, \"\");\n return convertSnapshotAndBlobsToSummaryTree(snapshotTree, blobs);\n }\n\n public async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n const uint8ArrayFile = new Uint8Array(file);\n return PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"createBlob\",\n size: uint8ArrayFile.length,\n },\n async (event) => {\n const manager = await this.getStorageManager();\n const response = await manager.createBlob(\n Uint8ArrayToString(\n uint8ArrayFile, \"base64\"),\n \"base64\").then((r) => ({ id: r.sha, url: r.url }));\n event.end({\n blobId: response.id,\n });\n return response;\n },\n );\n }\n\n private async fetchAndCacheSnapshotTree(versionId: string, disableCache?: boolean): Promise<ISnapshotTreeVersion> {\n const cachedSnapshotTreeVersion = await this.snapshotTreeCache.get(this.getCacheKey(versionId));\n if (cachedSnapshotTreeVersion !== undefined) {\n return { id: cachedSnapshotTreeVersion.id, snapshotTree: cachedSnapshotTreeVersion.snapshotTree };\n }\n\n const wholeFlatSummary = await PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"getWholeFlatSummary\",\n treeId: versionId,\n },\n async (event) => {\n const manager = await this.getStorageManager(disableCache);\n const response = await manager.getSummary(versionId);\n event.end({\n size: response.trees[0]?.entries.length,\n });\n return response;\n },\n );\n const normalizedWholeSummary = convertWholeFlatSummaryToSnapshotTreeAndBlobs(wholeFlatSummary);\n const wholeFlatSummaryId: string = wholeFlatSummary.id;\n const snapshotTreeId = normalizedWholeSummary.snapshotTree.id;\n assert(snapshotTreeId !== undefined, 0x275 /* \"Root tree should contain the id\" */);\n const snapshotTreeVersion = { id: wholeFlatSummaryId, snapshotTree: normalizedWholeSummary.snapshotTree };\n\n const cachePs: Promise<any>[] = [\n this.snapshotTreeCache.put(\n this.getCacheKey(snapshotTreeId),\n snapshotTreeVersion,\n ),\n this.initBlobCache(normalizedWholeSummary.blobs),\n ];\n if (snapshotTreeId !== versionId) {\n // versionId could be \"latest\". When summarizer checks cache for \"latest\", we want it to be available.\n // TODO: For in-memory cache, <latest,snapshotTree> will be a shared pointer with <snapshotId,snapshotTree>,\n // However, for something like Redis, this will cache the same value twice. Alternatively, could we simply\n // cache with versionId?\n cachePs.push(this.snapshotTreeCache.put(\n this.getCacheKey(versionId),\n snapshotTreeVersion,\n ));\n }\n\n await Promise.all(cachePs);\n\n return snapshotTreeVersion;\n }\n\n private async initBlobCache(blobs: Map<string, ArrayBuffer>): Promise<void> {\n const blobCachePutPs: Promise<void>[] = [];\n blobs.forEach((value, id) => {\n const cacheKey = this.getCacheKey(id);\n blobCachePutPs.push(this.blobCache.put(cacheKey, value));\n });\n await Promise.all(blobCachePutPs);\n }\n\n private getCacheKey(blobId: string): string {\n return `${this.id}:${blobId}`;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"wholeSummaryDocumentStorageService.js","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAA0F;AAa1F,mFAKgD;AAChD,qEAAmE;AACnE,mCAAgD;AAGhD,2CAAmE;AAEnE,MAAM,gBAAgB,GAAW,QAAQ,CAAC;AAE1C,MAAa,kCAAkC;IAY9C,YACoB,EAAU,EACV,OAAmB,EACnB,MAAwB,EAC3B,QAAyC,EACxC,cAA6C,EAC7C,YAAqC,IAAI,qBAAa,EAAE,EACxD,oBAAkD,IAAI,qBAAa,EAAE,EACrE,iBAA8B,EAC9B,oBAEU,KAAK,EAAE,YAAY,EAAE,EAAE,CACjD,YAAY,IAAI,IAAI,CAAC,iBAAiB,KAAK,SAAS;QACnD,CAAC,CAAC,IAAI,CAAC,iBAAiB;QACxB,CAAC,CAAC,IAAI,CAAC,OAAO;QAbG,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAY;QACnB,WAAM,GAAN,MAAM,CAAkB;QAC3B,aAAQ,GAAR,QAAQ,CAAiC;QACxC,mBAAc,GAAd,cAAc,CAA+B;QAC7C,cAAS,GAAT,SAAS,CAA+C;QACxD,sBAAiB,GAAjB,iBAAiB,CAAoD;QACrE,sBAAiB,GAAjB,iBAAiB,CAAa;QAC9B,sBAAiB,GAAjB,iBAAiB,CAKlB;QAzBT,sBAAiB,GAAY,IAAI,CAAC;IA0BvC,CAAC;IAxBJ,IAAW,aAAa;QACvB,OAAO,EAAE,CAAC;IACX,CAAC;IAEO,KAAK,CAAC,uBAAuB;QACpC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC/C,OAAO,IAAI,kDAAyB,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAmBM,KAAK,CAAC,WAAW,CAAC,SAAwB,EAAE,KAAa;;QAC/D,I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5G,0GAA0G;YAC1G,wBAAwB;YACxB,OAAO,CAAC,IAAI,CACX,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,mBAAmB,CAAC,CAC5E,CAAC;SACF;QAED,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAE3B,OAAO,mBAAmB,CAAC;IAC5B,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,KAA+B;QAC1D,MAAM,cAAc,GAAoB,EAAE,CAAC;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;YAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YACtC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;QACH,MAAM,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACnC,CAAC;IAEO,WAAW,CAAC,MAAc;QACjC,OAAO,GAAG,IAAI,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;IAC/B,CAAC;CACD;AAlQD,gFAkQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, stringToBuffer, Uint8ArrayToString } from \"@fluidframework/common-utils\";\nimport {\n\tIDocumentStorageService,\n\tISummaryContext,\n\tIDocumentStorageServicePolicies,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n\tconvertWholeFlatSummaryToSnapshotTreeAndBlobs,\n\tGitManager,\n\tISummaryUploadManager,\n\tWholeSummaryUploadManager,\n} from \"@fluidframework/server-services-client\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { ICache, InMemoryCache } from \"./cache\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport { convertSnapshotAndBlobsToSummaryTree } from \"./treeUtils\";\n\nconst latestSnapshotId: string = \"latest\";\n\nexport class WholeSummaryDocumentStorageService implements IDocumentStorageService {\n\tprivate firstVersionsCall: boolean = true;\n\n\tpublic get repositoryUrl(): string {\n\t\treturn \"\";\n\t}\n\n\tprivate async getSummaryUploadManager(): Promise<ISummaryUploadManager> {\n\t\tconst manager = await this.getStorageManager();\n\t\treturn new WholeSummaryUploadManager(manager);\n\t}\n\n\tconstructor(\n\t\tprotected readonly id: string,\n\t\tprotected readonly manager: GitManager,\n\t\tprotected readonly logger: ITelemetryLogger,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tprivate readonly driverPolicies?: IRouterliciousDriverPolicies,\n\t\tprivate readonly blobCache: ICache<ArrayBufferLike> = new InMemoryCache(),\n\t\tprivate readonly snapshotTreeCache: ICache<ISnapshotTreeVersion> = new InMemoryCache(),\n\t\tprivate readonly noCacheGitManager?: GitManager,\n\t\tprivate readonly getStorageManager: (\n\t\t\tdisableCache?: boolean,\n\t\t) => Promise<GitManager> = async (disableCache) =>\n\t\t\tdisableCache && this.noCacheGitManager !== undefined\n\t\t\t\t? this.noCacheGitManager\n\t\t\t\t: this.manager,\n\t) {}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\tif (versionId !== this.id && versionId !== null) {\n\t\t\t// Blobs/Trees in this scenario will never have multiple versions, so return versionId as is\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: versionId,\n\t\t\t\t\ttreeId: undefined!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\t// If this is the first versions call for the document, we know we will want the latest summary.\n\t\t// Fetch latest summary, cache it, and return its id.\n\t\tif (this.firstVersionsCall && count === 1) {\n\t\t\tthis.firstVersionsCall = false;\n\t\t\tconst { id: _id, snapshotTree } = !this.driverPolicies?.enableDiscovery\n\t\t\t\t? await this.fetchAndCacheSnapshotTree(latestSnapshotId, false)\n\t\t\t\t: await this.fetchAndCacheSnapshotTree(latestSnapshotId, true);\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: _id,\n\t\t\t\t\ttreeId: snapshotTree.id!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\t// Otherwise, get the latest version of the document as normal.\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 manager.getCommits(id, count);\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<ISnapshotTree | 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\treturn (await this.fetchAndCacheSnapshotTree(requestVersion.id)).snapshotTree;\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 !== undefined) {\n\t\t\treturn cachedBlob;\n\t\t}\n\n\t\tconst blob = 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);\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\tconst bufferValue = stringToBuffer(blob.content, blob.encoding);\n\n\t\tawait this.blobCache.put(this.getCacheKey(blob.sha), bufferValue);\n\n\t\treturn bufferValue;\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(summaryHandle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tconst wholeFlatSummary = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getWholeFlatSummary\",\n\t\t\t\ttreeId: summaryHandle.handle,\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.getSummary(summaryHandle.handle);\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.trees[0]?.entries.length,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\n\t\tconst { blobs, snapshotTree } = convertWholeFlatSummaryToSnapshotTreeAndBlobs(\n\t\t\twholeFlatSummary,\n\t\t\t\"\",\n\t\t);\n\t\treturn convertSnapshotAndBlobsToSummaryTree(snapshotTree, blobs);\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.sha, url: r.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 fetchAndCacheSnapshotTree(\n\t\tversionId: string,\n\t\tdisableCache?: boolean,\n\t): Promise<ISnapshotTreeVersion> {\n\t\tconst cachedSnapshotTreeVersion = await this.snapshotTreeCache.get(\n\t\t\tthis.getCacheKey(versionId),\n\t\t);\n\t\tif (cachedSnapshotTreeVersion !== undefined) {\n\t\t\treturn {\n\t\t\t\tid: cachedSnapshotTreeVersion.id,\n\t\t\t\tsnapshotTree: cachedSnapshotTreeVersion.snapshotTree,\n\t\t\t};\n\t\t}\n\n\t\tconst wholeFlatSummary = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getWholeFlatSummary\",\n\t\t\t\ttreeId: versionId,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager(disableCache);\n\t\t\t\tconst response = await manager.getSummary(versionId);\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.trees[0]?.entries.length,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t\tconst normalizedWholeSummary =\n\t\t\tconvertWholeFlatSummaryToSnapshotTreeAndBlobs(wholeFlatSummary);\n\t\tassert(\n\t\t\tnormalizedWholeSummary.snapshotTree.id !== undefined,\n\t\t\t0x275 /* \"Root tree should contain the id\" */,\n\t\t);\n\t\tconst wholeFlatSummaryId: string = wholeFlatSummary.id;\n\t\tconst snapshotTreeVersion = {\n\t\t\tid: wholeFlatSummaryId,\n\t\t\tsnapshotTree: normalizedWholeSummary.snapshotTree,\n\t\t};\n\n\t\tconst cachePs: Promise<any>[] = [\n\t\t\tthis.snapshotTreeCache.put(this.getCacheKey(wholeFlatSummaryId), snapshotTreeVersion),\n\t\t\tthis.initBlobCache(normalizedWholeSummary.blobs),\n\t\t];\n\t\tif (wholeFlatSummaryId !== versionId) {\n\t\t\t// versionId could be \"latest\". When summarizer checks cache for \"latest\", we want it to be available.\n\t\t\t// TODO: For in-memory cache, <latest,snapshotTree> will be a shared pointer with <snapshotId,snapshotTree>,\n\t\t\t// However, for something like Redis, this will cache the same value twice. Alternatively, could we simply\n\t\t\t// cache with versionId?\n\t\t\tcachePs.push(\n\t\t\t\tthis.snapshotTreeCache.put(this.getCacheKey(versionId), snapshotTreeVersion),\n\t\t\t);\n\t\t}\n\n\t\tawait Promise.all(cachePs);\n\n\t\treturn snapshotTreeVersion;\n\t}\n\n\tprivate async initBlobCache(blobs: Map<string, ArrayBuffer>): Promise<void> {\n\t\tconst blobCachePutPs: Promise<void>[] = [];\n\t\tblobs.forEach((value, id) => {\n\t\t\tconst cacheKey = this.getCacheKey(id);\n\t\t\tblobCachePutPs.push(this.blobCache.put(cacheKey, value));\n\t\t});\n\t\tawait Promise.all(blobCachePutPs);\n\t}\n\n\tprivate getCacheKey(blobId: string): string {\n\t\treturn `${this.id}:${blobId}`;\n\t}\n}\n"]}
|
package/lib/cache.d.ts
CHANGED
|
@@ -6,11 +6,14 @@ export interface ICache<T> {
|
|
|
6
6
|
get(key: string): Promise<T | undefined>;
|
|
7
7
|
put(key: string, value: T): Promise<void>;
|
|
8
8
|
}
|
|
9
|
+
/** A basic in-memory cache that optionally supports expiring entries after a period of inactivity */
|
|
9
10
|
export declare class InMemoryCache<T> implements ICache<T> {
|
|
10
11
|
private readonly cache;
|
|
12
|
+
constructor(expirationMs?: number);
|
|
11
13
|
get(key: string): Promise<T | undefined>;
|
|
12
14
|
put(key: string, value: T): Promise<void>;
|
|
13
15
|
}
|
|
16
|
+
/** This "cache" does nothing on put, and get always returns undefined */
|
|
14
17
|
export declare class NullCache<T> implements ICache<T> {
|
|
15
18
|
get(key: string): Promise<T | undefined>;
|
|
16
19
|
put(key: string, value: T): Promise<void>;
|
package/lib/cache.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,MAAM,CAAC,CAAC;IACxB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IACzC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C;AAED,qGAAqG;AACrG,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,MAAM,CAAC,CAAC,CAAC;IACjD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiB;gBAE3B,YAAY,CAAC,EAAE,MAAM;IAIpB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAIxC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAGtD;AAED,yEAAyE;AACzE,qBAAa,SAAS,CAAC,CAAC,CAAE,YAAW,MAAM,CAAC,CAAC,CAAC;IAChC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAIxC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CACtD"}
|
package/lib/cache.js
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
import { MapWithExpiration } from "./mapWithExpiration";
|
|
6
|
+
/** A basic in-memory cache that optionally supports expiring entries after a period of inactivity */
|
|
5
7
|
export class InMemoryCache {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.cache = new Map();
|
|
8
|
+
constructor(expirationMs) {
|
|
9
|
+
this.cache = expirationMs !== undefined ? new MapWithExpiration(expirationMs) : new Map();
|
|
8
10
|
}
|
|
9
11
|
async get(key) {
|
|
10
12
|
return this.cache.get(key);
|
|
@@ -13,11 +15,11 @@ export class InMemoryCache {
|
|
|
13
15
|
this.cache.set(key, value);
|
|
14
16
|
}
|
|
15
17
|
}
|
|
18
|
+
/** This "cache" does nothing on put, and get always returns undefined */
|
|
16
19
|
export class NullCache {
|
|
17
20
|
async get(key) {
|
|
18
21
|
return undefined;
|
|
19
22
|
}
|
|
20
|
-
async put(key, value) {
|
|
21
|
-
}
|
|
23
|
+
async put(key, value) { }
|
|
22
24
|
}
|
|
23
25
|
//# sourceMappingURL=cache.js.map
|
package/lib/cache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAOxD,qGAAqG;AACrG,MAAM,OAAO,aAAa;IAGzB,YAAY,YAAqB;QAChC,IAAI,CAAC,KAAK,GAAG,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,iBAAiB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;IAC3F,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,GAAW;QAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAQ;QACrC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;CACD;AAED,yEAAyE;AACzE,MAAM,OAAO,SAAS;IACd,KAAK,CAAC,GAAG,CAAC,GAAW;QAC3B,OAAO,SAAS,CAAC;IAClB,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAQ,IAAkB,CAAC;CACzD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { MapWithExpiration } from \"./mapWithExpiration\";\n\nexport interface ICache<T> {\n\tget(key: string): Promise<T | undefined>;\n\tput(key: string, value: T): Promise<void>;\n}\n\n/** A basic in-memory cache that optionally supports expiring entries after a period of inactivity */\nexport class InMemoryCache<T> implements ICache<T> {\n\tprivate readonly cache: Map<string, T>;\n\n\tconstructor(expirationMs?: number) {\n\t\tthis.cache = expirationMs !== undefined ? new MapWithExpiration(expirationMs) : new Map();\n\t}\n\n\tpublic async get(key: string): Promise<T | undefined> {\n\t\treturn this.cache.get(key);\n\t}\n\n\tpublic async put(key: string, value: T): Promise<void> {\n\t\tthis.cache.set(key, value);\n\t}\n}\n\n/** This \"cache\" does nothing on put, and get always returns undefined */\nexport class NullCache<T> implements ICache<T> {\n\tpublic async get(key: string): Promise<T | undefined> {\n\t\treturn undefined;\n\t}\n\n\tpublic async put(key: string, value: T): Promise<void> {}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNewUtils.d.ts","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAe,MAAM,sCAAsC,CAAC;AAEjF;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,YAAY,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"createNewUtils.d.ts","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAe,MAAM,sCAAsC,CAAC;AAEjF;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,YAAY,GAAG,YAAY,CA2BpF"}
|
package/lib/createNewUtils.js
CHANGED
|
@@ -19,8 +19,10 @@ export function convertSummaryToCreateNewSummary(summary) {
|
|
|
19
19
|
break;
|
|
20
20
|
}
|
|
21
21
|
case SummaryType.Blob: {
|
|
22
|
-
summaryObject.content =
|
|
23
|
-
summaryObject.content
|
|
22
|
+
summaryObject.content =
|
|
23
|
+
typeof summaryObject.content === "string"
|
|
24
|
+
? summaryObject.content
|
|
25
|
+
: Uint8ArrayToString(summaryObject.content, "utf8");
|
|
24
26
|
break;
|
|
25
27
|
}
|
|
26
28
|
case SummaryType.Handle: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNewUtils.js","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAgB,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAEjF;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAAC,OAAqB;
|
|
1
|
+
{"version":3,"file":"createNewUtils.js","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAgB,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAEjF;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAAC,OAAqB;IACrE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;QACvB,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAExC,QAAQ,aAAa,CAAC,IAAI,EAAE;YAC3B,KAAK,WAAW,CAAC,IAAI,CAAC,CAAC;gBACtB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,gCAAgC,CAAC,aAAa,CAAC,CAAC;gBACpE,MAAM;aACN;YACD,KAAK,WAAW,CAAC,IAAI,CAAC,CAAC;gBACtB,aAAa,CAAC,OAAO;oBACpB,OAAO,aAAa,CAAC,OAAO,KAAK,QAAQ;wBACxC,CAAC,CAAC,aAAa,CAAC,OAAO;wBACvB,CAAC,CAAC,kBAAkB,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;gBACtD,MAAM;aACN;YACD,KAAK,WAAW,CAAC,MAAM,CAAC,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;aACnE;YACD,OAAO,CAAC,CAAC;gBACR,MAAM,IAAI,KAAK,CAAC,qBAAqB,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;aAC3D;SACD;KACD;IAED,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Uint8ArrayToString } from \"@fluidframework/common-utils\";\nimport { ISummaryTree, SummaryType } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Utility api to convert ISummaryTree to a summary tree where blob contents are only utf8 strings.\n * @param summary - Summary supplied by the runtime to upload.\n * @returns - Modified summary tree where the blob contents could be utf8 string only.\n */\nexport function convertSummaryToCreateNewSummary(summary: ISummaryTree): ISummaryTree {\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tsummary.tree[key] = convertSummaryToCreateNewSummary(summaryObject);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tsummaryObject.content =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? summaryObject.content\n\t\t\t\t\t\t: Uint8ArrayToString(summaryObject.content, \"utf8\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"No handle should be present for first summary!!\");\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Unknown tree type ${summaryObject.type}`);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn summary;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultTokenProvider.d.ts","sourceRoot":"","sources":["../src/defaultTokenProvider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1D;;GAEG;AAEH,qBAAa,oBAAqB,YAAW,cAAc;
|
|
1
|
+
{"version":3,"file":"defaultTokenProvider.d.ts","sourceRoot":"","sources":["../src/defaultTokenProvider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1D;;GAEG;AAEH,qBAAa,oBAAqB,YAAW,cAAc;IAC9C,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,MAAM;IAE3B,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC;IAO5C,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC;CAMzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultTokenProvider.js","sourceRoot":"","sources":["../src/defaultTokenProvider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AAEH,MAAM,OAAO,oBAAoB;
|
|
1
|
+
{"version":3,"file":"defaultTokenProvider.js","sourceRoot":"","sources":["../src/defaultTokenProvider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AAEH,MAAM,OAAO,oBAAoB;IAChC,YAA6B,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAErC,KAAK,CAAC,iBAAiB;QAC7B,OAAO;YACN,SAAS,EAAE,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;SACb,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,iBAAiB;QAC7B,OAAO;YACN,SAAS,EAAE,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;SACb,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITokenProvider, ITokenResponse } from \"./tokens\";\n\n/**\n * Default token provider in case the host does not provide one. It simply caches the provided jwt and returns it back.\n */\n\nexport class DefaultTokenProvider implements ITokenProvider {\n\tconstructor(private readonly jwt: string) {}\n\n\tpublic async fetchOrdererToken(): Promise<ITokenResponse> {\n\t\treturn {\n\t\t\tfromCache: true,\n\t\t\tjwt: this.jwt,\n\t\t};\n\t}\n\n\tpublic async fetchStorageToken(): Promise<ITokenResponse> {\n\t\treturn {\n\t\t\tfromCache: true,\n\t\t\tjwt: this.jwt,\n\t\t};\n\t}\n}\n"]}
|