@fluidframework/routerlicious-driver 2.0.0-dev.4.1.0.148229 → 2.0.0-dev.4.3.0.157531
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/CHANGELOG.md +5 -0
- package/README.md +38 -0
- package/dist/contracts.d.ts +15 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +7 -0
- package/dist/contracts.js.map +1 -0
- package/dist/deltaStorageService.d.ts +1 -1
- package/dist/deltaStorageService.d.ts.map +1 -1
- package/dist/deltaStorageService.js +7 -4
- package/dist/deltaStorageService.js.map +1 -1
- package/dist/documentService.d.ts +4 -2
- package/dist/documentService.d.ts.map +1 -1
- package/dist/documentService.js +11 -9
- package/dist/documentService.js.map +1 -1
- package/dist/documentServiceFactory.d.ts +2 -1
- package/dist/documentServiceFactory.d.ts.map +1 -1
- package/dist/documentServiceFactory.js +18 -8
- package/dist/documentServiceFactory.js.map +1 -1
- package/dist/documentStorageService.d.ts +3 -2
- package/dist/documentStorageService.d.ts.map +1 -1
- package/dist/documentStorageService.js +4 -4
- package/dist/documentStorageService.js.map +1 -1
- package/dist/gitManager.d.ts +30 -0
- package/dist/gitManager.d.ts.map +1 -0
- package/dist/gitManager.js +89 -0
- package/dist/gitManager.js.map +1 -0
- package/dist/historian.d.ts +33 -0
- package/dist/historian.d.ts.map +1 -0
- package/dist/historian.js +65 -0
- package/dist/historian.js.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/r11sSnapshotParser.d.ts +15 -0
- package/dist/r11sSnapshotParser.d.ts.map +1 -0
- package/dist/r11sSnapshotParser.js +75 -0
- package/dist/r11sSnapshotParser.js.map +1 -0
- package/dist/restWrapper.d.ts +21 -8
- package/dist/restWrapper.d.ts.map +1 -1
- package/dist/restWrapper.js +93 -25
- package/dist/restWrapper.js.map +1 -1
- package/dist/restWrapperBase.d.ts +26 -0
- package/dist/restWrapperBase.d.ts.map +1 -0
- package/dist/restWrapperBase.js +55 -0
- package/dist/restWrapperBase.js.map +1 -0
- package/dist/retriableGitManager.d.ts +10 -21
- package/dist/retriableGitManager.d.ts.map +1 -1
- package/dist/retriableGitManager.js +0 -36
- 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 +6 -6
- package/dist/shreddedSummaryDocumentStorageService.js.map +1 -1
- package/dist/storageContracts.d.ts +44 -0
- package/dist/storageContracts.d.ts.map +1 -0
- package/dist/storageContracts.js +7 -0
- package/dist/storageContracts.js.map +1 -0
- package/dist/summaryTreeUploadManager.d.ts +23 -0
- package/dist/summaryTreeUploadManager.d.ts.map +1 -0
- package/dist/summaryTreeUploadManager.js +110 -0
- package/dist/summaryTreeUploadManager.js.map +1 -0
- package/dist/treeUtils.d.ts +7 -0
- package/dist/treeUtils.d.ts.map +1 -1
- package/dist/treeUtils.js +23 -1
- package/dist/treeUtils.js.map +1 -1
- package/dist/wholeSummaryDocumentStorageService.d.ts +5 -4
- package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -1
- package/dist/wholeSummaryDocumentStorageService.js +74 -42
- package/dist/wholeSummaryDocumentStorageService.js.map +1 -1
- package/dist/wholeSummaryUploadManager.d.ts +16 -0
- package/dist/wholeSummaryUploadManager.d.ts.map +1 -0
- package/dist/wholeSummaryUploadManager.js +38 -0
- package/dist/wholeSummaryUploadManager.js.map +1 -0
- package/lib/contracts.d.ts +15 -0
- package/lib/contracts.d.ts.map +1 -0
- package/lib/contracts.js +6 -0
- package/lib/contracts.js.map +1 -0
- package/lib/deltaStorageService.d.ts +1 -1
- package/lib/deltaStorageService.d.ts.map +1 -1
- package/lib/deltaStorageService.js +7 -4
- package/lib/deltaStorageService.js.map +1 -1
- package/lib/documentService.d.ts +4 -2
- package/lib/documentService.d.ts.map +1 -1
- package/lib/documentService.js +9 -7
- package/lib/documentService.js.map +1 -1
- package/lib/documentServiceFactory.d.ts +2 -1
- package/lib/documentServiceFactory.d.ts.map +1 -1
- package/lib/documentServiceFactory.js +18 -8
- package/lib/documentServiceFactory.js.map +1 -1
- package/lib/documentStorageService.d.ts +3 -2
- package/lib/documentStorageService.d.ts.map +1 -1
- package/lib/documentStorageService.js +4 -4
- package/lib/documentStorageService.js.map +1 -1
- package/lib/gitManager.d.ts +30 -0
- package/lib/gitManager.d.ts.map +1 -0
- package/lib/gitManager.js +85 -0
- package/lib/gitManager.js.map +1 -0
- package/lib/historian.d.ts +33 -0
- package/lib/historian.d.ts.map +1 -0
- package/lib/historian.js +60 -0
- package/lib/historian.js.map +1 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/r11sSnapshotParser.d.ts +15 -0
- package/lib/r11sSnapshotParser.d.ts.map +1 -0
- package/lib/r11sSnapshotParser.js +71 -0
- package/lib/r11sSnapshotParser.js.map +1 -0
- package/lib/restWrapper.d.ts +21 -8
- package/lib/restWrapper.d.ts.map +1 -1
- package/lib/restWrapper.js +92 -26
- package/lib/restWrapper.js.map +1 -1
- package/lib/restWrapperBase.d.ts +26 -0
- package/lib/restWrapperBase.d.ts.map +1 -0
- package/lib/restWrapperBase.js +50 -0
- package/lib/restWrapperBase.js.map +1 -0
- package/lib/retriableGitManager.d.ts +10 -21
- package/lib/retriableGitManager.d.ts.map +1 -1
- package/lib/retriableGitManager.js +0 -36
- 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 +5 -5
- package/lib/shreddedSummaryDocumentStorageService.js.map +1 -1
- package/lib/storageContracts.d.ts +44 -0
- package/lib/storageContracts.d.ts.map +1 -0
- package/lib/storageContracts.js +6 -0
- package/lib/storageContracts.js.map +1 -0
- package/lib/summaryTreeUploadManager.d.ts +23 -0
- package/lib/summaryTreeUploadManager.d.ts.map +1 -0
- package/lib/summaryTreeUploadManager.js +106 -0
- package/lib/summaryTreeUploadManager.js.map +1 -0
- package/lib/treeUtils.d.ts +7 -0
- package/lib/treeUtils.d.ts.map +1 -1
- package/lib/treeUtils.js +20 -0
- package/lib/treeUtils.js.map +1 -1
- package/lib/wholeSummaryDocumentStorageService.d.ts +5 -4
- package/lib/wholeSummaryDocumentStorageService.d.ts.map +1 -1
- package/lib/wholeSummaryDocumentStorageService.js +74 -42
- package/lib/wholeSummaryDocumentStorageService.js.map +1 -1
- package/lib/wholeSummaryUploadManager.d.ts +16 -0
- package/lib/wholeSummaryUploadManager.d.ts.map +1 -0
- package/lib/wholeSummaryUploadManager.js +34 -0
- package/lib/wholeSummaryUploadManager.js.map +1 -0
- package/package.json +9 -10
- package/src/contracts.ts +16 -0
- package/src/deltaStorageService.ts +11 -3
- package/src/documentService.ts +11 -11
- package/src/documentServiceFactory.ts +35 -16
- package/src/documentStorageService.ts +8 -4
- package/src/gitManager.ts +116 -0
- package/src/historian.ts +121 -0
- package/src/packageVersion.ts +1 -1
- package/src/r11sSnapshotParser.ts +83 -0
- package/src/restWrapper.ts +114 -38
- package/src/restWrapperBase.ts +146 -0
- package/src/retriableGitManager.ts +17 -95
- package/src/shreddedSummaryDocumentStorageService.ts +7 -9
- package/src/storageContracts.ts +63 -0
- package/src/summaryTreeUploadManager.ts +160 -0
- package/src/treeUtils.ts +30 -0
- package/src/wholeSummaryDocumentStorageService.ts +117 -58
- package/src/wholeSummaryUploadManager.ts +64 -0
|
@@ -10,8 +10,8 @@ const driver_utils_1 = require("@fluidframework/driver-utils");
|
|
|
10
10
|
const wholeSummaryDocumentStorageService_1 = require("./wholeSummaryDocumentStorageService");
|
|
11
11
|
const shreddedSummaryDocumentStorageService_1 = require("./shreddedSummaryDocumentStorageService");
|
|
12
12
|
class DocumentStorageService extends driver_utils_1.DocumentStorageServiceProxy {
|
|
13
|
-
constructor(id, manager, logger, policies, driverPolicies, blobCache, snapshotTreeCache, noCacheGitManager, getStorageManager) {
|
|
14
|
-
super(DocumentStorageService.loadInternalDocumentStorageService(id, manager, logger, policies, driverPolicies, blobCache, snapshotTreeCache, noCacheGitManager, getStorageManager));
|
|
13
|
+
constructor(id, manager, logger, policies, driverPolicies, blobCache, snapshotTreeCache, shreddedSummaryTreeCache, noCacheGitManager, getStorageManager) {
|
|
14
|
+
super(DocumentStorageService.loadInternalDocumentStorageService(id, manager, logger, policies, driverPolicies, blobCache, snapshotTreeCache, shreddedSummaryTreeCache, noCacheGitManager, getStorageManager));
|
|
15
15
|
this.id = id;
|
|
16
16
|
this.manager = manager;
|
|
17
17
|
this.noCacheGitManager = noCacheGitManager;
|
|
@@ -20,10 +20,10 @@ class DocumentStorageService extends driver_utils_1.DocumentStorageServiceProxy
|
|
|
20
20
|
get logTailSha() {
|
|
21
21
|
return this._logTailSha;
|
|
22
22
|
}
|
|
23
|
-
static loadInternalDocumentStorageService(id, manager, logger, policies, driverPolicies, blobCache, snapshotTreeCache, noCacheGitManager, getStorageManager) {
|
|
23
|
+
static loadInternalDocumentStorageService(id, manager, logger, policies, driverPolicies, blobCache, snapshotTreeCache, shreddedSummaryTreeCache, noCacheGitManager, getStorageManager) {
|
|
24
24
|
const storageService = (driverPolicies === null || driverPolicies === void 0 ? void 0 : driverPolicies.enableWholeSummaryUpload)
|
|
25
25
|
? new wholeSummaryDocumentStorageService_1.WholeSummaryDocumentStorageService(id, manager, logger, policies, driverPolicies, blobCache, snapshotTreeCache, noCacheGitManager, getStorageManager)
|
|
26
|
-
: new shreddedSummaryDocumentStorageService_1.ShreddedSummaryDocumentStorageService(id, manager, logger, policies, driverPolicies, blobCache,
|
|
26
|
+
: new shreddedSummaryDocumentStorageService_1.ShreddedSummaryDocumentStorageService(id, manager, logger, policies, driverPolicies, blobCache, shreddedSummaryTreeCache, getStorageManager);
|
|
27
27
|
// TODO: worth prefetching latest summary making version + snapshot call with WholeSummary storage?
|
|
28
28
|
if (!(driverPolicies === null || driverPolicies === void 0 ? void 0 : driverPolicies.enableWholeSummaryUpload) &&
|
|
29
29
|
policies.caching === driver_definitions_1.LoaderCachingPolicy.Prefetch) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentStorageService.js","sourceRoot":"","sources":["../src/documentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2EAI4C;
|
|
1
|
+
{"version":3,"file":"documentStorageService.js","sourceRoot":"","sources":["../src/documentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2EAI4C;AAE5C,+DAGsC;AAGtC,6FAA0F;AAC1F,mGAAgG;AAKhG,MAAa,sBAAuB,SAAQ,0CAA2B;IAmDtE,YACiB,EAAU,EACnB,OAAmB,EAC1B,MAAwB,EACxB,QAAyC,EACzC,cAA6C,EAC7C,SAAmC,EACnC,iBAAmD,EACnD,wBAAuD,EAChD,iBAA8B,EACrC,iBAAmE;QAEnE,KAAK,CACJ,sBAAsB,CAAC,kCAAkC,CACxD,EAAE,EACF,OAAO,EACP,MAAM,EACN,QAAQ,EACR,cAAc,EACd,SAAS,EACT,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,CACjB,CACD,CAAC;QAxBc,OAAE,GAAF,EAAE,CAAQ;QACnB,YAAO,GAAP,OAAO,CAAY;QAOnB,sBAAiB,GAAjB,iBAAiB,CAAa;QA3D9B,gBAAW,GAAuB,SAAS,CAAC;IA4EpD,CAAC;IA1ED,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;IAEO,MAAM,CAAC,kCAAkC,CAChD,EAAU,EACV,OAAmB,EACnB,MAAwB,EACxB,QAAyC,EACzC,cAA6C,EAC7C,SAAmC,EACnC,iBAAmD,EACnD,wBAAuD,EACvD,iBAA8B,EAC9B,iBAAmE;QAEnE,MAAM,cAAc,GAAG,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,wBAAwB;YAC9D,CAAC,CAAC,IAAI,uEAAkC,CACtC,EAAE,EACF,OAAO,EACP,MAAM,EACN,QAAQ,EACR,cAAc,EACd,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,CAChB;YACH,CAAC,CAAC,IAAI,6EAAqC,CACzC,EAAE,EACF,OAAO,EACP,MAAM,EACN,QAAQ,EACR,cAAc,EACd,SAAS,EACT,wBAAwB,EACxB,iBAAiB,CAChB,CAAC;QACL,mGAAmG;QACnG,IACC,CAAC,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,wBAAwB,CAAA;YACzC,QAAQ,CAAC,OAAO,KAAK,wCAAmB,CAAC,QAAQ,EAChD;YACD,OAAO,IAAI,6CAA8B,CAAC,cAAc,CAAC,CAAC;SAC1D;QACD,OAAO,cAAc,CAAC;IACvB,CAAC;IA8BM,KAAK,CAAC,eAAe,CAAC,OAAkB;QAC9C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACxE,IAAI,IAAI,KAAK,IAAI,EAAE;YAClB,IAAI,CAAC,WAAW;gBACf,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;SAC7E;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAvFD,wDAuFC","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\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tLoaderCachingPolicy,\n} from \"@fluidframework/driver-definitions\";\nimport { ISnapshotTree, IVersion } from \"@fluidframework/protocol-definitions\";\nimport {\n\tDocumentStorageServiceProxy,\n\tPrefetchDocumentStorageService,\n} from \"@fluidframework/driver-utils\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport { ICache } from \"./cache\";\nimport { WholeSummaryDocumentStorageService } from \"./wholeSummaryDocumentStorageService\";\nimport { ShreddedSummaryDocumentStorageService } from \"./shreddedSummaryDocumentStorageService\";\nimport { GitManager } from \"./gitManager\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { INormalizedWholeSummary } from \"./contracts\";\n\nexport class DocumentStorageService extends DocumentStorageServiceProxy {\n\tprivate _logTailSha: string | undefined = undefined;\n\n\tpublic get logTailSha(): string | undefined {\n\t\treturn this._logTailSha;\n\t}\n\n\tprivate static loadInternalDocumentStorageService(\n\t\tid: string,\n\t\tmanager: GitManager,\n\t\tlogger: ITelemetryLogger,\n\t\tpolicies: IDocumentStorageServicePolicies,\n\t\tdriverPolicies?: IRouterliciousDriverPolicies,\n\t\tblobCache?: ICache<ArrayBufferLike>,\n\t\tsnapshotTreeCache?: ICache<INormalizedWholeSummary>,\n\t\tshreddedSummaryTreeCache?: ICache<ISnapshotTreeVersion>,\n\t\tnoCacheGitManager?: GitManager,\n\t\tgetStorageManager?: (disableCache?: boolean) => Promise<GitManager>,\n\t): IDocumentStorageService {\n\t\tconst storageService = driverPolicies?.enableWholeSummaryUpload\n\t\t\t? new WholeSummaryDocumentStorageService(\n\t\t\t\t\tid,\n\t\t\t\t\tmanager,\n\t\t\t\t\tlogger,\n\t\t\t\t\tpolicies,\n\t\t\t\t\tdriverPolicies,\n\t\t\t\t\tblobCache,\n\t\t\t\t\tsnapshotTreeCache,\n\t\t\t\t\tnoCacheGitManager,\n\t\t\t\t\tgetStorageManager,\n\t\t\t )\n\t\t\t: new ShreddedSummaryDocumentStorageService(\n\t\t\t\t\tid,\n\t\t\t\t\tmanager,\n\t\t\t\t\tlogger,\n\t\t\t\t\tpolicies,\n\t\t\t\t\tdriverPolicies,\n\t\t\t\t\tblobCache,\n\t\t\t\t\tshreddedSummaryTreeCache,\n\t\t\t\t\tgetStorageManager,\n\t\t\t );\n\t\t// TODO: worth prefetching latest summary making version + snapshot call with WholeSummary storage?\n\t\tif (\n\t\t\t!driverPolicies?.enableWholeSummaryUpload &&\n\t\t\tpolicies.caching === LoaderCachingPolicy.Prefetch\n\t\t) {\n\t\t\treturn new PrefetchDocumentStorageService(storageService);\n\t\t}\n\t\treturn storageService;\n\t}\n\n\tconstructor(\n\t\tpublic readonly id: string,\n\t\tpublic manager: GitManager,\n\t\tlogger: ITelemetryLogger,\n\t\tpolicies: IDocumentStorageServicePolicies,\n\t\tdriverPolicies?: IRouterliciousDriverPolicies,\n\t\tblobCache?: ICache<ArrayBufferLike>,\n\t\tsnapshotTreeCache?: ICache<INormalizedWholeSummary>,\n\t\tshreddedSummaryTreeCache?: ICache<ISnapshotTreeVersion>,\n\t\tpublic noCacheGitManager?: GitManager,\n\t\tgetStorageManager?: (disableCache?: boolean) => Promise<GitManager>,\n\t) {\n\t\tsuper(\n\t\t\tDocumentStorageService.loadInternalDocumentStorageService(\n\t\t\t\tid,\n\t\t\t\tmanager,\n\t\t\t\tlogger,\n\t\t\t\tpolicies,\n\t\t\t\tdriverPolicies,\n\t\t\t\tblobCache,\n\t\t\t\tsnapshotTreeCache,\n\t\t\t\tshreddedSummaryTreeCache,\n\t\t\t\tnoCacheGitManager,\n\t\t\t\tgetStorageManager,\n\t\t\t),\n\t\t);\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n\t\tconst tree = await this.internalStorageService.getSnapshotTree(version);\n\t\tif (tree !== null) {\n\t\t\tthis._logTailSha =\n\t\t\t\t\".logTail\" in tree.trees ? tree.trees[\".logTail\"].blobs.logTail : undefined;\n\t\t}\n\t\treturn tree;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import * as resources from "@fluidframework/gitresources";
|
|
6
|
+
import { IWholeFlatSummary, IWholeSummaryPayload, IWriteSummaryResponse } from "@fluidframework/server-services-client";
|
|
7
|
+
import { IGitManager, IHistorian } from "./storageContracts";
|
|
8
|
+
import { IR11sResponse } from "./restWrapper";
|
|
9
|
+
export declare class GitManager implements IGitManager {
|
|
10
|
+
private readonly historian;
|
|
11
|
+
private readonly blobCache;
|
|
12
|
+
private readonly commitCache;
|
|
13
|
+
private readonly treeCache;
|
|
14
|
+
private readonly refCache;
|
|
15
|
+
constructor(historian: IHistorian);
|
|
16
|
+
/**
|
|
17
|
+
* Reads the object with the given ID. We defer to the client implementation to do the actual read.
|
|
18
|
+
*/
|
|
19
|
+
getCommits(shaOrRef: string, count: number): Promise<IR11sResponse<resources.ICommitDetails[]>>;
|
|
20
|
+
/**
|
|
21
|
+
* Reads the object with the given ID. We defer to the client implementation to do the actual read.
|
|
22
|
+
*/
|
|
23
|
+
getTree(root: string, recursive?: boolean): Promise<IR11sResponse<resources.ITree>>;
|
|
24
|
+
getBlob(sha: string): Promise<IR11sResponse<resources.IBlob>>;
|
|
25
|
+
createBlob(content: string, encoding: "utf-8" | "base64"): Promise<IR11sResponse<resources.ICreateBlobResponse>>;
|
|
26
|
+
createGitTree(params: resources.ICreateTreeParams): Promise<IR11sResponse<resources.ITree>>;
|
|
27
|
+
createSummary(summary: IWholeSummaryPayload, initial?: boolean): Promise<IR11sResponse<IWriteSummaryResponse>>;
|
|
28
|
+
getSummary(sha: string): Promise<IR11sResponse<IWholeFlatSummary>>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=gitManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitManager.d.ts","sourceRoot":"","sources":["../src/gitManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,SAAS,MAAM,8BAA8B,CAAC;AAC1D,OAAO,E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AAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;CAG/E"}
|
|
@@ -0,0 +1,89 @@
|
|
|
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.GitManager = void 0;
|
|
8
|
+
const restWrapper_1 = require("./restWrapper");
|
|
9
|
+
class GitManager {
|
|
10
|
+
constructor(historian) {
|
|
11
|
+
this.historian = historian;
|
|
12
|
+
this.blobCache = new Map();
|
|
13
|
+
this.commitCache = new Map();
|
|
14
|
+
this.treeCache = new Map();
|
|
15
|
+
this.refCache = new Map();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Reads the object with the given ID. We defer to the client implementation to do the actual read.
|
|
19
|
+
*/
|
|
20
|
+
async getCommits(shaOrRef, count) {
|
|
21
|
+
let sha = shaOrRef;
|
|
22
|
+
// See if the sha is really a ref and convert
|
|
23
|
+
if (this.refCache.has(shaOrRef)) {
|
|
24
|
+
sha = this.refCache.get(shaOrRef);
|
|
25
|
+
// Delete refcache after first use
|
|
26
|
+
this.refCache.delete(shaOrRef);
|
|
27
|
+
// If null is stored for the ref then there are no commits - return an empty array
|
|
28
|
+
if (!sha) {
|
|
29
|
+
return (0, restWrapper_1.createR11sResponseFromContent)([]);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// See if the commit sha is hashed and return it if so
|
|
33
|
+
const commit = this.commitCache.get(sha);
|
|
34
|
+
if (commit !== undefined) {
|
|
35
|
+
return (0, restWrapper_1.createR11sResponseFromContent)([
|
|
36
|
+
{
|
|
37
|
+
commit: {
|
|
38
|
+
author: commit.author,
|
|
39
|
+
committer: commit.committer,
|
|
40
|
+
message: commit.message,
|
|
41
|
+
tree: commit.tree,
|
|
42
|
+
url: commit.url,
|
|
43
|
+
},
|
|
44
|
+
parents: commit.parents,
|
|
45
|
+
sha: commit.sha,
|
|
46
|
+
url: commit.url,
|
|
47
|
+
},
|
|
48
|
+
]);
|
|
49
|
+
}
|
|
50
|
+
// Otherwise fall back to the historian
|
|
51
|
+
return this.historian.getCommits(sha, count);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Reads the object with the given ID. We defer to the client implementation to do the actual read.
|
|
55
|
+
*/
|
|
56
|
+
async getTree(root, recursive = true) {
|
|
57
|
+
const tree = this.treeCache.get(root);
|
|
58
|
+
if (tree !== undefined) {
|
|
59
|
+
return (0, restWrapper_1.createR11sResponseFromContent)(tree);
|
|
60
|
+
}
|
|
61
|
+
return this.historian.getTree(root, recursive);
|
|
62
|
+
}
|
|
63
|
+
async getBlob(sha) {
|
|
64
|
+
const blob = this.blobCache.get(sha);
|
|
65
|
+
if (blob !== undefined) {
|
|
66
|
+
return (0, restWrapper_1.createR11sResponseFromContent)(blob);
|
|
67
|
+
}
|
|
68
|
+
return this.historian.getBlob(sha);
|
|
69
|
+
}
|
|
70
|
+
async createBlob(content, encoding) {
|
|
71
|
+
const blob = {
|
|
72
|
+
content,
|
|
73
|
+
encoding,
|
|
74
|
+
};
|
|
75
|
+
return this.historian.createBlob(blob);
|
|
76
|
+
}
|
|
77
|
+
async createGitTree(params) {
|
|
78
|
+
const treeP = this.historian.createTree(params);
|
|
79
|
+
return treeP;
|
|
80
|
+
}
|
|
81
|
+
async createSummary(summary, initial = false) {
|
|
82
|
+
return this.historian.createSummary(summary, initial);
|
|
83
|
+
}
|
|
84
|
+
async getSummary(sha) {
|
|
85
|
+
return this.historian.getSummary(sha);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.GitManager = GitManager;
|
|
89
|
+
//# sourceMappingURL=gitManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitManager.js","sourceRoot":"","sources":["../src/gitManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,+C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,GAAW;QAClC,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;CACD;AArGD,gCAqGC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as resources from \"@fluidframework/gitresources\";\nimport {\n\tIWholeFlatSummary,\n\tIWholeSummaryPayload,\n\tIWriteSummaryResponse,\n} from \"@fluidframework/server-services-client\";\nimport { IGitManager, IHistorian } from \"./storageContracts\";\nimport { IR11sResponse, createR11sResponseFromContent } from \"./restWrapper\";\n\nexport class GitManager implements IGitManager {\n\tprivate readonly blobCache = new Map<string, resources.IBlob>();\n\tprivate readonly commitCache = new Map<string, resources.ICommit>();\n\tprivate readonly treeCache = new Map<string, resources.ITree>();\n\tprivate readonly refCache = new Map<string, string>();\n\n\tconstructor(private readonly historian: IHistorian) {}\n\n\t/**\n\t * Reads the object with the given ID. We defer to the client implementation to do the actual read.\n\t */\n\tpublic async getCommits(\n\t\tshaOrRef: string,\n\t\tcount: number,\n\t): Promise<IR11sResponse<resources.ICommitDetails[]>> {\n\t\tlet sha: string | undefined = shaOrRef;\n\n\t\t// See if the sha is really a ref and convert\n\t\tif (this.refCache.has(shaOrRef)) {\n\t\t\tsha = this.refCache.get(shaOrRef);\n\n\t\t\t// Delete refcache after first use\n\t\t\tthis.refCache.delete(shaOrRef);\n\n\t\t\t// If null is stored for the ref then there are no commits - return an empty array\n\t\t\tif (!sha) {\n\t\t\t\treturn createR11sResponseFromContent([]);\n\t\t\t}\n\t\t}\n\n\t\t// See if the commit sha is hashed and return it if so\n\t\tconst commit = this.commitCache.get(sha);\n\t\tif (commit !== undefined) {\n\t\t\treturn createR11sResponseFromContent([\n\t\t\t\t{\n\t\t\t\t\tcommit: {\n\t\t\t\t\t\tauthor: commit.author,\n\t\t\t\t\t\tcommitter: commit.committer,\n\t\t\t\t\t\tmessage: commit.message,\n\t\t\t\t\t\ttree: commit.tree,\n\t\t\t\t\t\turl: commit.url,\n\t\t\t\t\t},\n\t\t\t\t\tparents: commit.parents,\n\t\t\t\t\tsha: commit.sha,\n\t\t\t\t\turl: commit.url,\n\t\t\t\t},\n\t\t\t]);\n\t\t}\n\n\t\t// Otherwise fall back to the historian\n\t\treturn this.historian.getCommits(sha, count);\n\t}\n\n\t/**\n\t * Reads the object with the given ID. We defer to the client implementation to do the actual read.\n\t */\n\tpublic async getTree(root: string, recursive = true): Promise<IR11sResponse<resources.ITree>> {\n\t\tconst tree = this.treeCache.get(root);\n\t\tif (tree !== undefined) {\n\t\t\treturn createR11sResponseFromContent(tree);\n\t\t}\n\n\t\treturn this.historian.getTree(root, recursive);\n\t}\n\n\tpublic async getBlob(sha: string): Promise<IR11sResponse<resources.IBlob>> {\n\t\tconst blob = this.blobCache.get(sha);\n\t\tif (blob !== undefined) {\n\t\t\treturn createR11sResponseFromContent(blob);\n\t\t}\n\t\treturn this.historian.getBlob(sha);\n\t}\n\n\tpublic async createBlob(\n\t\tcontent: string,\n\t\tencoding: \"utf-8\" | \"base64\",\n\t): Promise<IR11sResponse<resources.ICreateBlobResponse>> {\n\t\tconst blob: resources.ICreateBlobParams = {\n\t\t\tcontent,\n\t\t\tencoding,\n\t\t};\n\t\treturn this.historian.createBlob(blob);\n\t}\n\n\tpublic async createGitTree(\n\t\tparams: resources.ICreateTreeParams,\n\t): Promise<IR11sResponse<resources.ITree>> {\n\t\tconst treeP = this.historian.createTree(params);\n\t\treturn treeP;\n\t}\n\n\tpublic async createSummary(\n\t\tsummary: IWholeSummaryPayload,\n\t\tinitial: boolean = false,\n\t): Promise<IR11sResponse<IWriteSummaryResponse>> {\n\t\treturn this.historian.createSummary(summary, initial);\n\t}\n\n\tpublic async getSummary(sha: string): Promise<IR11sResponse<IWholeFlatSummary>> {\n\t\treturn this.historian.getSummary(sha);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import * as git from "@fluidframework/gitresources";
|
|
6
|
+
import { IWholeFlatSummary, IWholeSummaryPayload, IWriteSummaryResponse } from "@fluidframework/server-services-client";
|
|
7
|
+
import { RestWrapper } from "./restWrapperBase";
|
|
8
|
+
import { IR11sResponse } from "./restWrapper";
|
|
9
|
+
import { IHistorian } from "./storageContracts";
|
|
10
|
+
export interface ICredentials {
|
|
11
|
+
user: string;
|
|
12
|
+
password: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const getAuthorizationTokenFromCredentials: (credentials: ICredentials) => string;
|
|
15
|
+
/**
|
|
16
|
+
* Implementation of the IHistorian interface that calls out to a REST interface
|
|
17
|
+
*/
|
|
18
|
+
export declare class Historian implements IHistorian {
|
|
19
|
+
private readonly historianApi;
|
|
20
|
+
private readonly restWrapper;
|
|
21
|
+
private readonly defaultQueryString;
|
|
22
|
+
private readonly cacheBust;
|
|
23
|
+
constructor(historianApi: boolean, disableCache: boolean, restWrapper: RestWrapper);
|
|
24
|
+
getBlob(sha: string): Promise<IR11sResponse<git.IBlob>>;
|
|
25
|
+
createBlob(blob: git.ICreateBlobParams): Promise<IR11sResponse<git.ICreateBlobResponse>>;
|
|
26
|
+
getCommits(sha: string, count: number): Promise<IR11sResponse<git.ICommitDetails[]>>;
|
|
27
|
+
createTree(tree: git.ICreateTreeParams): Promise<IR11sResponse<git.ITree>>;
|
|
28
|
+
getTree(sha: string, recursive: boolean): Promise<IR11sResponse<git.ITree>>;
|
|
29
|
+
createSummary(summary: IWholeSummaryPayload, initial?: boolean): Promise<IR11sResponse<IWriteSummaryResponse>>;
|
|
30
|
+
getSummary(sha: string): Promise<IR11sResponse<IWholeFlatSummary>>;
|
|
31
|
+
private getQueryString;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=historian.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"historian.d.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,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAM3E,aAAa,CACzB,OAAO,EAAE,oBAAoB,EAC7B,OAAO,CAAC,EAAE,OAAO,GACf,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;IAQnC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAO/E,OAAO,CAAC,cAAc;CAatB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
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.Historian = exports.getAuthorizationTokenFromCredentials = void 0;
|
|
8
|
+
const common_utils_1 = require("@fluidframework/common-utils");
|
|
9
|
+
const getAuthorizationTokenFromCredentials = (credentials) => `Basic ${(0, common_utils_1.fromUtf8ToBase64)(`${credentials.user}:${credentials.password}`)}`;
|
|
10
|
+
exports.getAuthorizationTokenFromCredentials = getAuthorizationTokenFromCredentials;
|
|
11
|
+
/**
|
|
12
|
+
* Implementation of the IHistorian interface that calls out to a REST interface
|
|
13
|
+
*/
|
|
14
|
+
class Historian {
|
|
15
|
+
constructor(historianApi, disableCache, restWrapper) {
|
|
16
|
+
this.historianApi = historianApi;
|
|
17
|
+
this.restWrapper = restWrapper;
|
|
18
|
+
this.defaultQueryString = {};
|
|
19
|
+
if (disableCache && this.historianApi) {
|
|
20
|
+
this.defaultQueryString.disableCache = disableCache;
|
|
21
|
+
this.cacheBust = false;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
this.cacheBust = disableCache;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async getBlob(sha) {
|
|
28
|
+
return this.restWrapper.get(`/git/blobs/${encodeURIComponent(sha)}`, this.getQueryString());
|
|
29
|
+
}
|
|
30
|
+
async createBlob(blob) {
|
|
31
|
+
return this.restWrapper.post(`/git/blobs`, blob, this.getQueryString());
|
|
32
|
+
}
|
|
33
|
+
async getCommits(sha, count) {
|
|
34
|
+
return this.restWrapper
|
|
35
|
+
.get(`/commits`, this.getQueryString({ count, sha }))
|
|
36
|
+
.catch((error) => error.statusCode === 400 || error.statusCode === 404
|
|
37
|
+
? {
|
|
38
|
+
content: [],
|
|
39
|
+
headers: new Map(),
|
|
40
|
+
propsToLog: {},
|
|
41
|
+
requestUrl: "",
|
|
42
|
+
}
|
|
43
|
+
: Promise.reject(error));
|
|
44
|
+
}
|
|
45
|
+
async createTree(tree) {
|
|
46
|
+
return this.restWrapper.post(`/git/trees`, tree, this.getQueryString());
|
|
47
|
+
}
|
|
48
|
+
async getTree(sha, recursive) {
|
|
49
|
+
return this.restWrapper.get(`/git/trees/${encodeURIComponent(sha)}`, this.getQueryString({ recursive: recursive ? 1 : 0 }));
|
|
50
|
+
}
|
|
51
|
+
async createSummary(summary, initial) {
|
|
52
|
+
return this.restWrapper.post(`/git/summaries`, summary, this.getQueryString(initial !== undefined ? { initial } : undefined));
|
|
53
|
+
}
|
|
54
|
+
async getSummary(sha) {
|
|
55
|
+
return this.restWrapper.get(`/git/summaries/${sha}`, this.getQueryString());
|
|
56
|
+
}
|
|
57
|
+
getQueryString(queryString) {
|
|
58
|
+
if (this.cacheBust) {
|
|
59
|
+
return Object.assign(Object.assign({ cacheBust: Date.now() }, this.defaultQueryString), queryString);
|
|
60
|
+
}
|
|
61
|
+
return Object.assign(Object.assign({}, this.defaultQueryString), queryString);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.Historian = Historian;
|
|
65
|
+
//# sourceMappingURL=historian.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"historian.js","sourceRoot":"","sources":["../src/historian.ts"],"names":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b;SACF;QACD,uCACI,IAAI,CAAC,kBAAkB,GACvB,WAAW,EACb;IACH,CAAC;CACD;AA7FD,8BA6FC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fromUtf8ToBase64 } from \"@fluidframework/common-utils\";\nimport * as git from \"@fluidframework/gitresources\";\nimport {\n\tIWholeFlatSummary,\n\tIWholeSummaryPayload,\n\tIWriteSummaryResponse,\n} from \"@fluidframework/server-services-client\";\nimport { QueryStringType, RestWrapper } from \"./restWrapperBase\";\nimport { IR11sResponse } from \"./restWrapper\";\nimport { IHistorian } from \"./storageContracts\";\n\nexport interface ICredentials {\n\tuser: string;\n\tpassword: string;\n}\n\nexport const getAuthorizationTokenFromCredentials = (credentials: ICredentials): string =>\n\t`Basic ${fromUtf8ToBase64(`${credentials.user}:${credentials.password}`)}`;\n\n/**\n * Implementation of the IHistorian interface that calls out to a REST interface\n */\nexport class Historian implements IHistorian {\n\tprivate readonly defaultQueryString: QueryStringType = {};\n\tprivate readonly cacheBust: boolean;\n\n\tconstructor(\n\t\tprivate readonly historianApi: boolean,\n\t\tdisableCache: boolean,\n\t\tprivate readonly restWrapper: RestWrapper,\n\t) {\n\t\tif (disableCache && this.historianApi) {\n\t\t\tthis.defaultQueryString.disableCache = disableCache;\n\t\t\tthis.cacheBust = false;\n\t\t} else {\n\t\t\tthis.cacheBust = disableCache;\n\t\t}\n\t}\n\n\tpublic async getBlob(sha: string): Promise<IR11sResponse<git.IBlob>> {\n\t\treturn this.restWrapper.get<git.IBlob>(\n\t\t\t`/git/blobs/${encodeURIComponent(sha)}`,\n\t\t\tthis.getQueryString(),\n\t\t);\n\t}\n\n\tpublic async createBlob(\n\t\tblob: git.ICreateBlobParams,\n\t): Promise<IR11sResponse<git.ICreateBlobResponse>> {\n\t\treturn this.restWrapper.post<git.ICreateBlobResponse>(\n\t\t\t`/git/blobs`,\n\t\t\tblob,\n\t\t\tthis.getQueryString(),\n\t\t);\n\t}\n\n\tpublic async getCommits(\n\t\tsha: string,\n\t\tcount: number,\n\t): Promise<IR11sResponse<git.ICommitDetails[]>> {\n\t\treturn this.restWrapper\n\t\t\t.get<git.ICommitDetails[]>(`/commits`, this.getQueryString({ count, sha }))\n\t\t\t.catch((error) =>\n\t\t\t\terror.statusCode === 400 || error.statusCode === 404\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tcontent: [],\n\t\t\t\t\t\t\theaders: new Map(),\n\t\t\t\t\t\t\tpropsToLog: {},\n\t\t\t\t\t\t\trequestUrl: \"\",\n\t\t\t\t\t }\n\t\t\t\t\t: Promise.reject<IR11sResponse<git.ICommitDetails[]>>(error),\n\t\t\t);\n\t}\n\n\tpublic async createTree(tree: git.ICreateTreeParams): Promise<IR11sResponse<git.ITree>> {\n\t\treturn this.restWrapper.post<git.ITree>(`/git/trees`, tree, this.getQueryString());\n\t}\n\n\tpublic async getTree(sha: string, recursive: boolean): Promise<IR11sResponse<git.ITree>> {\n\t\treturn this.restWrapper.get<git.ITree>(\n\t\t\t`/git/trees/${encodeURIComponent(sha)}`,\n\t\t\tthis.getQueryString({ recursive: recursive ? 1 : 0 }),\n\t\t);\n\t}\n\tpublic async createSummary(\n\t\tsummary: IWholeSummaryPayload,\n\t\tinitial?: boolean,\n\t): Promise<IR11sResponse<IWriteSummaryResponse>> {\n\t\treturn this.restWrapper.post<IWriteSummaryResponse>(\n\t\t\t`/git/summaries`,\n\t\t\tsummary,\n\t\t\tthis.getQueryString(initial !== undefined ? { initial } : undefined),\n\t\t);\n\t}\n\n\tpublic async getSummary(sha: string): Promise<IR11sResponse<IWholeFlatSummary>> {\n\t\treturn this.restWrapper.get<IWholeFlatSummary>(\n\t\t\t`/git/summaries/${sha}`,\n\t\t\tthis.getQueryString(),\n\t\t);\n\t}\n\n\tprivate getQueryString(queryString?: QueryStringType): QueryStringType {\n\t\tif (this.cacheBust) {\n\t\t\treturn {\n\t\t\t\tcacheBust: Date.now(),\n\t\t\t\t...this.defaultQueryString,\n\t\t\t\t...queryString,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...this.defaultQueryString,\n\t\t\t...queryString,\n\t\t};\n\t}\n}\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/routerlicious-driver";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-dev.4.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-dev.4.3.0.157531";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/routerlicious-driver";
|
|
11
|
-
exports.pkgVersion = "2.0.0-dev.4.
|
|
11
|
+
exports.pkgVersion = "2.0.0-dev.4.3.0.157531";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,sCAAsC,CAAC;AACjD,QAAA,UAAU,GAAG,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/routerlicious-driver\";\nexport const pkgVersion = \"2.0.0-dev.4.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,sCAAsC,CAAC;AACjD,QAAA,UAAU,GAAG,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/routerlicious-driver\";\nexport const pkgVersion = \"2.0.0-dev.4.3.0.157531\";\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { IWholeFlatSummary } from "@fluidframework/server-services-client";
|
|
6
|
+
import { INormalizedWholeSummary } from "./contracts";
|
|
7
|
+
/**
|
|
8
|
+
* Converts existing IWholeFlatSummary to snapshot tree, blob array, and sequence number.
|
|
9
|
+
*
|
|
10
|
+
* @param flatSummary - flat summary
|
|
11
|
+
* @param treePrefixToRemove - tree prefix to strip. By default we are stripping ".app" prefix
|
|
12
|
+
* @returns snapshot tree, blob array, and sequence number
|
|
13
|
+
*/
|
|
14
|
+
export declare function convertWholeFlatSummaryToSnapshotTreeAndBlobs(flatSummary: IWholeFlatSummary, treePrefixToRemove?: string): INormalizedWholeSummary;
|
|
15
|
+
//# sourceMappingURL=r11sSnapshotParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"r11sSnapshotParser.d.ts","sourceRoot":"","sources":["../src/r11sSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAyB,MAAM,wCAAwC,CAAC;AAElG,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AA+CtD;;;;;;GAMG;AACH,wBAAgB,6CAA6C,CAC5D,WAAW,EAAE,iBAAiB,EAC9B,kBAAkB,GAAE,MAAe,GACjC,uBAAuB,CAiBzB"}
|
|
@@ -0,0 +1,75 @@
|
|
|
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.convertWholeFlatSummaryToSnapshotTreeAndBlobs = void 0;
|
|
8
|
+
const common_utils_1 = require("@fluidframework/common-utils");
|
|
9
|
+
/**
|
|
10
|
+
* Build a tree heirarchy from a flat tree.
|
|
11
|
+
*
|
|
12
|
+
* @param flatTree - a flat tree
|
|
13
|
+
* @param treePrefixToRemove - tree prefix to strip
|
|
14
|
+
* @returns the heirarchical tree
|
|
15
|
+
*/
|
|
16
|
+
function buildHierarchy(flatTree, treePrefixToRemove) {
|
|
17
|
+
const lookup = {};
|
|
18
|
+
// Root tree id will be used to determine which version was downloaded.
|
|
19
|
+
const root = { id: flatTree.id, blobs: {}, trees: {} };
|
|
20
|
+
lookup[""] = root;
|
|
21
|
+
for (const entry of flatTree.entries) {
|
|
22
|
+
// Strip the `treePrefixToRemove` path from tree entries such that they are stored under root.
|
|
23
|
+
const entryPath = entry.path.replace(new RegExp(`^${treePrefixToRemove}/`), "");
|
|
24
|
+
const lastIndex = entryPath.lastIndexOf("/");
|
|
25
|
+
const entryPathDir = entryPath.slice(0, Math.max(0, lastIndex));
|
|
26
|
+
const entryPathBase = entryPath.slice(lastIndex + 1);
|
|
27
|
+
// The flat output is breadth-first so we can assume we see tree nodes prior to their contents
|
|
28
|
+
const node = lookup[entryPathDir];
|
|
29
|
+
// Add in either the blob or tree
|
|
30
|
+
if (entry.type === "tree") {
|
|
31
|
+
const newTree = {
|
|
32
|
+
blobs: {},
|
|
33
|
+
trees: {},
|
|
34
|
+
unreferenced: entry.unreferenced,
|
|
35
|
+
};
|
|
36
|
+
node.trees[decodeURIComponent(entryPathBase)] = newTree;
|
|
37
|
+
lookup[entryPath] = newTree;
|
|
38
|
+
}
|
|
39
|
+
else if (entry.type === "blob") {
|
|
40
|
+
node.blobs[decodeURIComponent(entryPathBase)] = entry.id;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
throw new Error(`Unknown entry type!!`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return root;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Converts existing IWholeFlatSummary to snapshot tree, blob array, and sequence number.
|
|
50
|
+
*
|
|
51
|
+
* @param flatSummary - flat summary
|
|
52
|
+
* @param treePrefixToRemove - tree prefix to strip. By default we are stripping ".app" prefix
|
|
53
|
+
* @returns snapshot tree, blob array, and sequence number
|
|
54
|
+
*/
|
|
55
|
+
function convertWholeFlatSummaryToSnapshotTreeAndBlobs(flatSummary, treePrefixToRemove = ".app") {
|
|
56
|
+
var _a;
|
|
57
|
+
const blobs = new Map();
|
|
58
|
+
if (flatSummary.blobs) {
|
|
59
|
+
flatSummary.blobs.forEach((blob) => {
|
|
60
|
+
var _a;
|
|
61
|
+
blobs.set(blob.id, (0, common_utils_1.stringToBuffer)(blob.content, (_a = blob.encoding) !== null && _a !== void 0 ? _a : "utf-8"));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const flatSummaryTree = (_a = flatSummary.trees) === null || _a === void 0 ? void 0 : _a[0];
|
|
65
|
+
const sequenceNumber = flatSummaryTree === null || flatSummaryTree === void 0 ? void 0 : flatSummaryTree.sequenceNumber;
|
|
66
|
+
const snapshotTree = buildHierarchy(flatSummaryTree, treePrefixToRemove);
|
|
67
|
+
return {
|
|
68
|
+
blobs,
|
|
69
|
+
snapshotTree,
|
|
70
|
+
sequenceNumber,
|
|
71
|
+
id: flatSummary.id,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
exports.convertWholeFlatSummaryToSnapshotTreeAndBlobs = convertWholeFlatSummaryToSnapshotTreeAndBlobs;
|
|
75
|
+
//# sourceMappingURL=r11sSnapshotParser.js.map
|
|
@@ -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,MAAM,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC;SAC5B;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE;YACjC,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC;SACzD;aAAM;YACN,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;SACxC;KACD;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,6CAA6C,CAC5D,WAA8B,EAC9B,qBAA6B,MAAM;;IAEnC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC7C,IAAI,WAAW,CAAC,KAAK,EAAE;QACtB,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;;YAClC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAA,6BAAc,EAAC,IAAI,CAAC,OAAO,EAAE,MAAA,IAAI,CAAC,QAAQ,mCAAI,OAAO,CAAC,CAAC,CAAC;QAC5E,CAAC,CAAC,CAAC;KACH;IACD,MAAM,eAAe,GAAG,MAAA,WAAW,CAAC,KAAK,0CAAG,CAAC,CAAC,CAAC;IAC/C,MAAM,cAAc,GAAG,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,cAAc,CAAC;IACvD,MAAM,YAAY,GAAG,cAAc,CAAC,eAAe,EAAE,kBAAkB,CAAC,CAAC;IAEzE,OAAO;QACN,KAAK;QACL,YAAY;QACZ,cAAc;QACd,EAAE,EAAE,WAAW,CAAC,EAAE;KAClB,CAAC;AACH,CAAC;AApBD,sGAoBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { IWholeFlatSummary, IWholeFlatSummaryTree } from \"@fluidframework/server-services-client\";\nimport { stringToBuffer } from \"@fluidframework/common-utils\";\nimport { INormalizedWholeSummary } from \"./contracts\";\n\n/**\n * Build a tree heirarchy from a flat tree.\n *\n * @param flatTree - a flat tree\n * @param treePrefixToRemove - tree prefix to strip\n * @returns the heirarchical tree\n */\nfunction buildHierarchy(\n\tflatTree: IWholeFlatSummaryTree,\n\ttreePrefixToRemove: string,\n): ISnapshotTree {\n\tconst lookup: { [path: string]: ISnapshotTree } = {};\n\t// Root tree id will be used to determine which version was downloaded.\n\tconst root: ISnapshotTree = { id: flatTree.id, blobs: {}, trees: {} };\n\tlookup[\"\"] = root;\n\n\tfor (const entry of flatTree.entries) {\n\t\t// Strip the `treePrefixToRemove` path from tree entries such that they are stored under root.\n\t\tconst entryPath = entry.path.replace(new RegExp(`^${treePrefixToRemove}/`), \"\");\n\t\tconst lastIndex = entryPath.lastIndexOf(\"/\");\n\t\tconst entryPathDir = entryPath.slice(0, Math.max(0, lastIndex));\n\t\tconst entryPathBase = entryPath.slice(lastIndex + 1);\n\n\t\t// The flat output is breadth-first so we can assume we see tree nodes prior to their contents\n\t\tconst node = lookup[entryPathDir];\n\n\t\t// Add in either the blob or tree\n\t\tif (entry.type === \"tree\") {\n\t\t\tconst newTree: ISnapshotTree = {\n\t\t\t\tblobs: {},\n\t\t\t\ttrees: {},\n\t\t\t\tunreferenced: entry.unreferenced,\n\t\t\t};\n\t\t\tnode.trees[decodeURIComponent(entryPathBase)] = newTree;\n\t\t\tlookup[entryPath] = newTree;\n\t\t} else if (entry.type === \"blob\") {\n\t\t\tnode.blobs[decodeURIComponent(entryPathBase)] = entry.id;\n\t\t} else {\n\t\t\tthrow new Error(`Unknown entry type!!`);\n\t\t}\n\t}\n\n\treturn root;\n}\n\n/**\n * Converts existing IWholeFlatSummary to snapshot tree, blob array, and sequence number.\n *\n * @param flatSummary - flat summary\n * @param treePrefixToRemove - tree prefix to strip. By default we are stripping \".app\" prefix\n * @returns snapshot tree, blob array, and sequence number\n */\nexport function convertWholeFlatSummaryToSnapshotTreeAndBlobs(\n\tflatSummary: IWholeFlatSummary,\n\ttreePrefixToRemove: string = \".app\",\n): INormalizedWholeSummary {\n\tconst blobs = new Map<string, ArrayBuffer>();\n\tif (flatSummary.blobs) {\n\t\tflatSummary.blobs.forEach((blob) => {\n\t\t\tblobs.set(blob.id, stringToBuffer(blob.content, blob.encoding ?? \"utf-8\"));\n\t\t});\n\t}\n\tconst flatSummaryTree = flatSummary.trees?.[0];\n\tconst sequenceNumber = flatSummaryTree?.sequenceNumber;\n\tconst snapshotTree = buildHierarchy(flatSummaryTree, treePrefixToRemove);\n\n\treturn {\n\t\tblobs,\n\t\tsnapshotTree,\n\t\tsequenceNumber,\n\t\tid: flatSummary.id,\n\t};\n}\n"]}
|
package/dist/restWrapper.d.ts
CHANGED
|
@@ -2,26 +2,39 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
import type { ParsedUrlQueryInput } from "querystring";
|
|
7
|
-
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
5
|
+
import { ITelemetryLogger, ITelemetryProperties } from "@fluidframework/common-definitions";
|
|
8
6
|
import { RateLimiter } from "@fluidframework/driver-utils";
|
|
9
|
-
import { RestWrapper } from "@fluidframework/server-services-client";
|
|
10
7
|
import type { AxiosRequestConfig } from "axios";
|
|
11
8
|
import { ITokenProvider, ITokenResponse } from "./tokens";
|
|
9
|
+
import { QueryStringType, RestWrapper } from "./restWrapperBase";
|
|
12
10
|
declare type AuthorizationHeaderGetter = (token: ITokenResponse) => string;
|
|
13
11
|
declare type TokenFetcher = (refresh?: boolean) => Promise<ITokenResponse>;
|
|
12
|
+
export interface IR11sResponse<T> {
|
|
13
|
+
content: T;
|
|
14
|
+
headers: Map<string, string>;
|
|
15
|
+
propsToLog: ITelemetryProperties;
|
|
16
|
+
requestUrl: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A utility function to create a r11s response without any additional props as we might not have them always.
|
|
20
|
+
* @param content - response which is equivalent to content.
|
|
21
|
+
* @returns - a r11s response without any extra props.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createR11sResponseFromContent<T>(content: T): IR11sResponse<T>;
|
|
24
|
+
export declare function getPropsToLogFromResponse(headers: {
|
|
25
|
+
get: (id: string) => string | undefined | null;
|
|
26
|
+
}): ITelemetryProperties;
|
|
14
27
|
export declare class RouterliciousRestWrapper extends RestWrapper {
|
|
15
28
|
private readonly rateLimiter;
|
|
16
|
-
private token;
|
|
17
29
|
private readonly fetchRefreshedToken;
|
|
18
30
|
private readonly getAuthorizationHeader;
|
|
19
31
|
private readonly useRestLess;
|
|
20
32
|
private readonly restLess;
|
|
21
|
-
|
|
22
|
-
|
|
33
|
+
private token;
|
|
34
|
+
constructor(logger: ITelemetryLogger, rateLimiter: RateLimiter, fetchRefreshedToken: TokenFetcher, getAuthorizationHeader: AuthorizationHeaderGetter, useRestLess: boolean, baseurl?: string, defaultQueryString?: QueryStringType);
|
|
35
|
+
protected request<T>(requestConfig: AxiosRequestConfig, statusCode: number, canRetry?: boolean): Promise<IR11sResponse<T>>;
|
|
23
36
|
private generateHeaders;
|
|
24
|
-
getToken(): ITokenResponse
|
|
37
|
+
getToken(): Promise<ITokenResponse>;
|
|
25
38
|
setToken(token: ITokenResponse): void;
|
|
26
39
|
}
|
|
27
40
|
export declare class RouterliciousStorageRestWrapper extends RouterliciousRestWrapper {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restWrapper.d.ts","sourceRoot":"","sources":["../src/restWrapper.ts"],"names":[],"mappings":"AAAA;;;GAGG
|
|
1
|
+
{"version":3,"file":"restWrapper.d.ts","sourceRoot":"","sources":["../src/restWrapper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE5F,OAAO,EAAE,WAAW,EAAE,MAA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