@fluidframework/driver-utils 2.0.0-dev-rc.5.0.0.267932 → 2.0.0-dev-rc.5.0.0.270401
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/api-report/driver-utils.alpha.api.md +78 -0
- package/api-report/driver-utils.beta.api.md +65 -0
- package/api-report/driver-utils.public.api.md +65 -0
- package/dist/adapters/compression/documentServiceCompressionAdapter.js +1 -0
- package/dist/adapters/compression/documentServiceCompressionAdapter.js.map +1 -1
- package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.js +1 -0
- package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.js.map +1 -1
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js +44 -43
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js.map +1 -1
- package/dist/blob.js +13 -6
- package/dist/blob.js.map +1 -1
- package/dist/buildSnapshotTree.d.ts.map +1 -1
- package/dist/buildSnapshotTree.js +2 -2
- package/dist/buildSnapshotTree.js.map +1 -1
- package/dist/documentServiceFactoryProxy.js +1 -0
- package/dist/documentServiceFactoryProxy.js.map +1 -1
- package/dist/documentServiceProxy.js +1 -0
- package/dist/documentServiceProxy.js.map +1 -1
- package/dist/documentStorageServiceProxy.js +2 -0
- package/dist/documentStorageServiceProxy.js.map +1 -1
- package/dist/error.js +2 -2
- package/dist/error.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/insecureUrlResolver.js +8 -1
- package/dist/insecureUrlResolver.js.map +1 -1
- package/dist/messageRecognition.d.ts +1 -2
- package/dist/messageRecognition.d.ts.map +1 -1
- package/dist/messageRecognition.js.map +1 -1
- package/dist/network.js +25 -15
- package/dist/network.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/parallelRequests.d.ts +1 -2
- package/dist/parallelRequests.d.ts.map +1 -1
- package/dist/parallelRequests.js +16 -9
- package/dist/parallelRequests.js.map +1 -1
- package/dist/prefetchDocumentStorageService.js +3 -6
- package/dist/prefetchDocumentStorageService.js.map +1 -1
- package/dist/protocol/gitHelper.d.ts +33 -0
- package/dist/protocol/gitHelper.d.ts.map +1 -0
- package/dist/protocol/gitHelper.js +88 -0
- package/dist/protocol/gitHelper.js.map +1 -0
- package/dist/protocol/index.d.ts +6 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/index.js +12 -0
- package/dist/protocol/index.js.map +1 -0
- package/dist/rateLimiter.js +11 -10
- package/dist/rateLimiter.js.map +1 -1
- package/lib/adapters/compression/documentServiceCompressionAdapter.js +1 -0
- package/lib/adapters/compression/documentServiceCompressionAdapter.js.map +1 -1
- package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.js +1 -0
- package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.js.map +1 -1
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js +44 -43
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js.map +1 -1
- package/lib/blob.js +13 -6
- package/lib/blob.js.map +1 -1
- package/lib/buildSnapshotTree.d.ts.map +1 -1
- package/lib/buildSnapshotTree.js +1 -1
- package/lib/buildSnapshotTree.js.map +1 -1
- package/lib/documentServiceFactoryProxy.js +1 -0
- package/lib/documentServiceFactoryProxy.js.map +1 -1
- package/lib/documentServiceProxy.js +1 -0
- package/lib/documentServiceProxy.js.map +1 -1
- package/lib/documentStorageServiceProxy.js +2 -0
- package/lib/documentStorageServiceProxy.js.map +1 -1
- package/lib/error.js +2 -2
- package/lib/error.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/insecureUrlResolver.js +8 -1
- package/lib/insecureUrlResolver.js.map +1 -1
- package/lib/messageRecognition.d.ts +1 -2
- package/lib/messageRecognition.d.ts.map +1 -1
- package/lib/messageRecognition.js +1 -1
- package/lib/messageRecognition.js.map +1 -1
- package/lib/network.js +25 -15
- package/lib/network.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/parallelRequests.d.ts +1 -2
- package/lib/parallelRequests.d.ts.map +1 -1
- package/lib/parallelRequests.js +16 -9
- package/lib/parallelRequests.js.map +1 -1
- package/lib/prefetchDocumentStorageService.js +3 -6
- package/lib/prefetchDocumentStorageService.js.map +1 -1
- package/lib/protocol/gitHelper.d.ts +33 -0
- package/lib/protocol/gitHelper.d.ts.map +1 -0
- package/lib/protocol/gitHelper.js +82 -0
- package/lib/protocol/gitHelper.js.map +1 -0
- package/lib/protocol/index.d.ts +6 -0
- package/lib/protocol/index.d.ts.map +1 -0
- package/lib/protocol/index.js +6 -0
- package/lib/protocol/index.js.map +1 -0
- package/lib/rateLimiter.js +11 -10
- package/lib/rateLimiter.js.map +1 -1
- package/package.json +9 -10
- package/src/buildSnapshotTree.ts +4 -2
- package/src/index.ts +1 -0
- package/src/messageRecognition.ts +5 -2
- package/src/packageVersion.ts +1 -1
- package/src/parallelRequests.ts +1 -1
- package/src/protocol/README.md +11 -0
- package/src/protocol/gitHelper.ts +98 -0
- package/src/protocol/index.ts +6 -0
- package/tsconfig.json +2 -0
- package/api-report/driver-utils.api.md +0 -408
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitHelper.js","sourceRoot":"","sources":["../../src/protocol/gitHelper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EACN,QAAQ,EAGR,WAAW,GAEX,MAAM,6CAA6C,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,KAAoB;IAC9C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ED,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tFileMode,\n\tIGitTree,\n\tISnapshotTreeEx,\n\tSummaryType,\n\tSummaryObject,\n} from \"@fluidframework/driver-definitions/internal\";\n\n/**\n * Take a summary object and returns its git mode.\n *\n * @param value - summary object\n * @returns the git mode of summary object\n * @internal\n */\nexport function getGitMode(value: SummaryObject): string {\n\tconst type = value.type === SummaryType.Handle ? value.handleType : value.type;\n\tswitch (type) {\n\t\tcase SummaryType.Blob:\n\t\tcase SummaryType.Attachment:\n\t\t\treturn FileMode.File;\n\t\tcase SummaryType.Tree:\n\t\t\treturn FileMode.Directory;\n\t\tdefault:\n\t\t\tunreachableCase(type, `Unknown type: ${type}`);\n\t}\n}\n\n/**\n * Take a summary object and returns its type.\n *\n * @param value - summary object\n * @returns the type of summary object\n * @internal\n */\nexport function getGitType(value: SummaryObject): \"blob\" | \"tree\" {\n\tconst type = value.type === SummaryType.Handle ? value.handleType : value.type;\n\n\tswitch (type) {\n\t\tcase SummaryType.Blob:\n\t\tcase SummaryType.Attachment:\n\t\t\treturn \"blob\";\n\t\tcase SummaryType.Tree:\n\t\t\treturn \"tree\";\n\t\tdefault:\n\t\t\tunreachableCase(type, `Unknown type: ${type}`);\n\t}\n}\n\n/**\n * NOTE: Renamed from `buildHierarchy` to `buildGitTreeHierarchy`. There is usage of this function in loader and driver layer.\n * Build a tree hierarchy base on a flat tree\n *\n * @param flatTree - a flat tree\n * @param blobsShaToPathCache - Map with blobs sha as keys and values as path of the blob.\n * @param removeAppTreePrefix - Remove `.app/` from beginning of paths when present\n * @returns the hierarchical tree\n * @internal\n */\nexport function buildGitTreeHierarchy(\n\tflatTree: IGitTree,\n\tblobsShaToPathCache: Map<string, string> = new Map<string, string>(),\n\tremoveAppTreePrefix = false,\n): ISnapshotTreeEx {\n\tconst lookup: { [path: string]: ISnapshotTreeEx } = {};\n\tconst root: ISnapshotTreeEx = { id: flatTree.sha, blobs: {}, trees: {} };\n\tlookup[\"\"] = root;\n\n\tfor (const entry of flatTree.tree) {\n\t\tconst entryPath = removeAppTreePrefix ? entry.path.replace(/^\\.app\\//, \"\") : entry.path;\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 = { id: entry.sha, blobs: {}, commits: {}, trees: {} };\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.sha;\n\t\t\tblobsShaToPathCache.set(entry.sha, `/${entryPath}`);\n\t\t} else {\n\t\t\tthrow new Error(\"Unknown entry type!!\");\n\t\t}\n\t}\n\n\treturn root;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { buildGitTreeHierarchy, getGitMode, getGitType } from \"./gitHelper.js\";\n"]}
|
package/lib/rateLimiter.js
CHANGED
|
@@ -7,23 +7,24 @@ import { assert } from "@fluidframework/core-utils/internal";
|
|
|
7
7
|
* @alpha
|
|
8
8
|
*/
|
|
9
9
|
export class RateLimiter {
|
|
10
|
+
maxRequests;
|
|
11
|
+
tasks = [];
|
|
10
12
|
constructor(maxRequests) {
|
|
11
13
|
this.maxRequests = maxRequests;
|
|
12
|
-
this.tasks = [];
|
|
13
|
-
// Run when one of the tasks finished running.
|
|
14
|
-
// Release next task if we have one, or allow more tasks to run in future.
|
|
15
|
-
this.release = () => {
|
|
16
|
-
const task = this.tasks.shift();
|
|
17
|
-
if (task !== undefined) {
|
|
18
|
-
return task();
|
|
19
|
-
}
|
|
20
|
-
this.maxRequests++;
|
|
21
|
-
};
|
|
22
14
|
assert(maxRequests > 0, 0x0ae /* "Tried to create rate limiter with 0 max requests!" */);
|
|
23
15
|
}
|
|
24
16
|
get waitQueueLength() {
|
|
25
17
|
return this.tasks.length;
|
|
26
18
|
}
|
|
19
|
+
// Run when one of the tasks finished running.
|
|
20
|
+
// Release next task if we have one, or allow more tasks to run in future.
|
|
21
|
+
release = () => {
|
|
22
|
+
const task = this.tasks.shift();
|
|
23
|
+
if (task !== undefined) {
|
|
24
|
+
return task();
|
|
25
|
+
}
|
|
26
|
+
this.maxRequests++;
|
|
27
|
+
};
|
|
27
28
|
async acquire() {
|
|
28
29
|
if (this.maxRequests > 0) {
|
|
29
30
|
this.maxRequests--;
|
package/lib/rateLimiter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rateLimiter.js","sourceRoot":"","sources":["../src/rateLimiter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D;;GAEG;AACH,MAAM,OAAO,WAAW;
|
|
1
|
+
{"version":3,"file":"rateLimiter.js","sourceRoot":"","sources":["../src/rateLimiter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D;;GAEG;AACH,MAAM,OAAO,WAAW;IAEH;IADH,KAAK,GAAmB,EAAE,CAAC;IAC5C,YAAoB,WAAmB;QAAnB,gBAAW,GAAX,WAAW,CAAQ;QACtC,MAAM,CAAC,WAAW,GAAG,CAAC,EAAE,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC1F,CAAC;IAED,IAAW,eAAe;QACzB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC1B,CAAC;IAED,8CAA8C;IAC9C,0EAA0E;IACvD,OAAO,GAAG,GAAG,EAAE;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QAChC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,IAAI,EAAE,CAAC;QACf,CAAC;QACD,IAAI,CAAC,WAAW,EAAE,CAAC;IACpB,CAAC,CAAC;IAEQ,KAAK,CAAC,OAAO;QACtB,IAAI,IAAI,CAAC,WAAW,GAAG,CAAC,EAAE,CAAC;YAC1B,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,OAAO;QACR,CAAC;QAED,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YACpC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAI,IAAsB;QAC9C,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\n/**\n * @alpha\n */\nexport class RateLimiter {\n\tprivate readonly tasks: (() => void)[] = [];\n\tconstructor(private maxRequests: number) {\n\t\tassert(maxRequests > 0, 0x0ae /* \"Tried to create rate limiter with 0 max requests!\" */);\n\t}\n\n\tpublic get waitQueueLength(): number {\n\t\treturn this.tasks.length;\n\t}\n\n\t// Run when one of the tasks finished running.\n\t// Release next task if we have one, or allow more tasks to run in future.\n\tprotected readonly release = () => {\n\t\tconst task = this.tasks.shift();\n\t\tif (task !== undefined) {\n\t\t\treturn task();\n\t\t}\n\t\tthis.maxRequests++;\n\t};\n\n\tprotected async acquire() {\n\t\tif (this.maxRequests > 0) {\n\t\t\tthis.maxRequests--;\n\t\t\treturn;\n\t\t}\n\n\t\treturn new Promise<void>((resolve) => {\n\t\t\tthis.tasks.push(resolve);\n\t\t});\n\t}\n\n\tpublic async schedule<T>(work: () => Promise<T>) {\n\t\tawait this.acquire();\n\t\treturn work().finally(this.release);\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/driver-utils",
|
|
3
|
-
"version": "2.0.0-dev-rc.5.0.0.
|
|
3
|
+
"version": "2.0.0-dev-rc.5.0.0.270401",
|
|
4
4
|
"description": "Collection of utility functions for Fluid drivers",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -67,25 +67,24 @@
|
|
|
67
67
|
"temp-directory": "nyc/.nyc_output"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@fluid-internal/client-utils": "2.0.0-dev-rc.5.0.0.
|
|
71
|
-
"@fluidframework/core-interfaces": "2.0.0-dev-rc.5.0.0.
|
|
72
|
-
"@fluidframework/core-utils": "2.0.0-dev-rc.5.0.0.
|
|
73
|
-
"@fluidframework/driver-definitions": "2.0.0-dev-rc.5.0.0.
|
|
74
|
-
"@fluidframework/
|
|
75
|
-
"@fluidframework/telemetry-utils": "2.0.0-dev-rc.5.0.0.267932",
|
|
70
|
+
"@fluid-internal/client-utils": "2.0.0-dev-rc.5.0.0.270401",
|
|
71
|
+
"@fluidframework/core-interfaces": "2.0.0-dev-rc.5.0.0.270401",
|
|
72
|
+
"@fluidframework/core-utils": "2.0.0-dev-rc.5.0.0.270401",
|
|
73
|
+
"@fluidframework/driver-definitions": "2.0.0-dev-rc.5.0.0.270401",
|
|
74
|
+
"@fluidframework/telemetry-utils": "2.0.0-dev-rc.5.0.0.270401",
|
|
76
75
|
"axios": "^1.6.2",
|
|
77
76
|
"lz4js": "^0.2.0",
|
|
78
77
|
"uuid": "^9.0.0"
|
|
79
78
|
},
|
|
80
79
|
"devDependencies": {
|
|
81
80
|
"@arethetypeswrong/cli": "^0.15.2",
|
|
82
|
-
"@biomejs/biome": "^1.
|
|
83
|
-
"@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.5.0.0.
|
|
81
|
+
"@biomejs/biome": "^1.7.3",
|
|
82
|
+
"@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.5.0.0.270401",
|
|
84
83
|
"@fluid-tools/build-cli": "^0.39.0-264124",
|
|
85
84
|
"@fluidframework/build-common": "^2.0.3",
|
|
86
85
|
"@fluidframework/build-tools": "^0.39.0-264124",
|
|
87
86
|
"@fluidframework/driver-utils-previous": "npm:@fluidframework/driver-utils@2.0.0-rc.4.0.0",
|
|
88
|
-
"@fluidframework/eslint-config-fluid": "^5.
|
|
87
|
+
"@fluidframework/eslint-config-fluid": "^5.3.0",
|
|
89
88
|
"@microsoft/api-extractor": "^7.45.1",
|
|
90
89
|
"@types/mocha": "^9.1.1",
|
|
91
90
|
"@types/node": "^18.19.0",
|
package/src/buildSnapshotTree.ts
CHANGED
|
@@ -5,16 +5,18 @@
|
|
|
5
5
|
|
|
6
6
|
import { stringToBuffer } from "@fluid-internal/client-utils";
|
|
7
7
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
8
|
-
import type { IGitTree, IGitTreeEntry } from "@fluidframework/driver-definitions/internal";
|
|
9
8
|
import {
|
|
10
9
|
FileMode,
|
|
10
|
+
IGitTree,
|
|
11
|
+
IGitTreeEntry,
|
|
11
12
|
ISnapshotTree,
|
|
12
13
|
ITreeEntry,
|
|
13
14
|
TreeEntry,
|
|
14
15
|
} from "@fluidframework/driver-definitions/internal";
|
|
15
|
-
import { buildGitTreeHierarchy } from "@fluidframework/protocol-base";
|
|
16
16
|
import { v4 as uuid } from "uuid";
|
|
17
17
|
|
|
18
|
+
import { buildGitTreeHierarchy } from "./protocol/index.js";
|
|
19
|
+
|
|
18
20
|
function flattenCore(
|
|
19
21
|
path: string,
|
|
20
22
|
treeEntries: ITreeEntry[],
|
package/src/index.ts
CHANGED
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import {
|
|
7
|
+
ISequencedDocumentMessage,
|
|
8
|
+
IDocumentMessage,
|
|
9
|
+
MessageType,
|
|
10
|
+
} from "@fluidframework/driver-definitions/internal";
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* Tells if message was sent by container runtime
|
package/src/packageVersion.ts
CHANGED
package/src/parallelRequests.ts
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
import { performance } from "@fluid-internal/client-utils";
|
|
7
7
|
import { ITelemetryBaseProperties } from "@fluidframework/core-interfaces";
|
|
8
8
|
import { assert, Deferred } from "@fluidframework/core-utils/internal";
|
|
9
|
-
import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions";
|
|
10
9
|
import {
|
|
11
10
|
IDeltasFetchResult,
|
|
12
11
|
IStream,
|
|
13
12
|
IStreamResult,
|
|
13
|
+
ISequencedDocumentMessage,
|
|
14
14
|
} from "@fluidframework/driver-definitions/internal";
|
|
15
15
|
import { ITelemetryLoggerExt, PerformanceEvent } from "@fluidframework/telemetry-utils/internal";
|
|
16
16
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @fluidframework/driver-utils/src/protocol
|
|
2
|
+
|
|
3
|
+
These files should not be changed unless the Fluid service itself is changed, and
|
|
4
|
+
should be aligned with the service side definitions contained here:
|
|
5
|
+
|
|
6
|
+
server/routerlicious/packages/protocol-base
|
|
7
|
+
|
|
8
|
+
## Notes
|
|
9
|
+
|
|
10
|
+
The file names in this directory align with those in server/protocol-base to facilitate
|
|
11
|
+
copying/synchronization in the future, if desireable.
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { unreachableCase } from "@fluidframework/core-utils/internal";
|
|
7
|
+
import {
|
|
8
|
+
FileMode,
|
|
9
|
+
IGitTree,
|
|
10
|
+
ISnapshotTreeEx,
|
|
11
|
+
SummaryType,
|
|
12
|
+
SummaryObject,
|
|
13
|
+
} from "@fluidframework/driver-definitions/internal";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Take a summary object and returns its git mode.
|
|
17
|
+
*
|
|
18
|
+
* @param value - summary object
|
|
19
|
+
* @returns the git mode of summary object
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export function getGitMode(value: SummaryObject): string {
|
|
23
|
+
const type = value.type === SummaryType.Handle ? value.handleType : value.type;
|
|
24
|
+
switch (type) {
|
|
25
|
+
case SummaryType.Blob:
|
|
26
|
+
case SummaryType.Attachment:
|
|
27
|
+
return FileMode.File;
|
|
28
|
+
case SummaryType.Tree:
|
|
29
|
+
return FileMode.Directory;
|
|
30
|
+
default:
|
|
31
|
+
unreachableCase(type, `Unknown type: ${type}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Take a summary object and returns its type.
|
|
37
|
+
*
|
|
38
|
+
* @param value - summary object
|
|
39
|
+
* @returns the type of summary object
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
export function getGitType(value: SummaryObject): "blob" | "tree" {
|
|
43
|
+
const type = value.type === SummaryType.Handle ? value.handleType : value.type;
|
|
44
|
+
|
|
45
|
+
switch (type) {
|
|
46
|
+
case SummaryType.Blob:
|
|
47
|
+
case SummaryType.Attachment:
|
|
48
|
+
return "blob";
|
|
49
|
+
case SummaryType.Tree:
|
|
50
|
+
return "tree";
|
|
51
|
+
default:
|
|
52
|
+
unreachableCase(type, `Unknown type: ${type}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* NOTE: Renamed from `buildHierarchy` to `buildGitTreeHierarchy`. There is usage of this function in loader and driver layer.
|
|
58
|
+
* Build a tree hierarchy base on a flat tree
|
|
59
|
+
*
|
|
60
|
+
* @param flatTree - a flat tree
|
|
61
|
+
* @param blobsShaToPathCache - Map with blobs sha as keys and values as path of the blob.
|
|
62
|
+
* @param removeAppTreePrefix - Remove `.app/` from beginning of paths when present
|
|
63
|
+
* @returns the hierarchical tree
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
export function buildGitTreeHierarchy(
|
|
67
|
+
flatTree: IGitTree,
|
|
68
|
+
blobsShaToPathCache: Map<string, string> = new Map<string, string>(),
|
|
69
|
+
removeAppTreePrefix = false,
|
|
70
|
+
): ISnapshotTreeEx {
|
|
71
|
+
const lookup: { [path: string]: ISnapshotTreeEx } = {};
|
|
72
|
+
const root: ISnapshotTreeEx = { id: flatTree.sha, blobs: {}, trees: {} };
|
|
73
|
+
lookup[""] = root;
|
|
74
|
+
|
|
75
|
+
for (const entry of flatTree.tree) {
|
|
76
|
+
const entryPath = removeAppTreePrefix ? entry.path.replace(/^\.app\//, "") : entry.path;
|
|
77
|
+
const lastIndex = entryPath.lastIndexOf("/");
|
|
78
|
+
const entryPathDir = entryPath.slice(0, Math.max(0, lastIndex));
|
|
79
|
+
const entryPathBase = entryPath.slice(lastIndex + 1);
|
|
80
|
+
|
|
81
|
+
// The flat output is breadth-first so we can assume we see tree nodes prior to their contents
|
|
82
|
+
const node = lookup[entryPathDir];
|
|
83
|
+
|
|
84
|
+
// Add in either the blob or tree
|
|
85
|
+
if (entry.type === "tree") {
|
|
86
|
+
const newTree = { id: entry.sha, blobs: {}, commits: {}, trees: {} };
|
|
87
|
+
node.trees[decodeURIComponent(entryPathBase)] = newTree;
|
|
88
|
+
lookup[entryPath] = newTree;
|
|
89
|
+
} else if (entry.type === "blob") {
|
|
90
|
+
node.blobs[decodeURIComponent(entryPathBase)] = entry.sha;
|
|
91
|
+
blobsShaToPathCache.set(entry.sha, `/${entryPath}`);
|
|
92
|
+
} else {
|
|
93
|
+
throw new Error("Unknown entry type!!");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return root;
|
|
98
|
+
}
|