@fluidframework/driver-utils 2.0.0-internal.7.0.0 → 2.0.0-internal.7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/api-extractor.json +1 -1
- package/api-report/driver-utils.api.md +401 -0
- package/dist/adapters/compression/compressionTypes.d.ts +6 -0
- package/dist/adapters/compression/compressionTypes.d.ts.map +1 -1
- package/dist/adapters/compression/compressionTypes.js +3 -0
- package/dist/adapters/compression/compressionTypes.js.map +1 -1
- package/dist/adapters/compression/documentServiceCompressionAdapter.d.ts.map +1 -1
- package/dist/adapters/compression/documentServiceCompressionAdapter.js.map +1 -1
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts +4 -0
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts.map +1 -1
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js +4 -0
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js.map +1 -1
- package/dist/adapters/predefinedAdapters.d.ts +1 -0
- package/dist/adapters/predefinedAdapters.d.ts.map +1 -1
- package/dist/adapters/predefinedAdapters.js +1 -0
- package/dist/adapters/predefinedAdapters.js.map +1 -1
- package/dist/blob.d.ts +3 -0
- package/dist/blob.d.ts.map +1 -1
- package/dist/blob.js +3 -0
- package/dist/blob.js.map +1 -1
- package/dist/buildSnapshotTree.d.ts +1 -0
- package/dist/buildSnapshotTree.d.ts.map +1 -1
- package/dist/buildSnapshotTree.js +1 -0
- package/dist/buildSnapshotTree.js.map +1 -1
- package/dist/documentStorageServiceProxy.d.ts +3 -0
- package/dist/documentStorageServiceProxy.d.ts.map +1 -1
- package/dist/documentStorageServiceProxy.js +3 -0
- package/dist/documentStorageServiceProxy.js.map +1 -1
- package/dist/error.d.ts +4 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +4 -1
- package/dist/error.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/insecureUrlResolver.d.ts +1 -0
- package/dist/insecureUrlResolver.d.ts.map +1 -1
- package/dist/insecureUrlResolver.js +1 -0
- package/dist/insecureUrlResolver.js.map +1 -1
- package/dist/messageRecognition.d.ts +10 -0
- package/dist/messageRecognition.d.ts.map +1 -1
- package/dist/messageRecognition.js +10 -3
- package/dist/messageRecognition.js.map +1 -1
- package/dist/network.d.ts +49 -3
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js +45 -5
- package/dist/network.js.map +1 -1
- package/dist/networkUtils.d.ts +3 -0
- package/dist/networkUtils.d.ts.map +1 -1
- package/dist/networkUtils.js +3 -0
- package/dist/networkUtils.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 +12 -0
- package/dist/parallelRequests.d.ts.map +1 -1
- package/dist/parallelRequests.js +12 -0
- package/dist/parallelRequests.js.map +1 -1
- package/dist/prefetchDocumentStorageService.d.ts +3 -0
- package/dist/prefetchDocumentStorageService.d.ts.map +1 -1
- package/dist/prefetchDocumentStorageService.js +3 -0
- package/dist/prefetchDocumentStorageService.js.map +1 -1
- package/dist/rateLimiter.d.ts +3 -0
- package/dist/rateLimiter.d.ts.map +1 -1
- package/dist/rateLimiter.js +3 -0
- package/dist/rateLimiter.js.map +1 -1
- package/dist/readAndParse.d.ts +1 -0
- package/dist/readAndParse.d.ts.map +1 -1
- package/dist/readAndParse.js +1 -0
- package/dist/readAndParse.js.map +1 -1
- package/dist/runWithRetry.d.ts +5 -0
- package/dist/runWithRetry.d.ts.map +1 -1
- package/dist/runWithRetry.js +4 -2
- package/dist/runWithRetry.js.map +1 -1
- package/dist/summaryForCreateNew.d.ts +3 -1
- package/dist/summaryForCreateNew.d.ts.map +1 -1
- package/dist/summaryForCreateNew.js +4 -2
- package/dist/summaryForCreateNew.js.map +1 -1
- package/dist/treeConversions.d.ts +1 -0
- package/dist/treeConversions.d.ts.map +1 -1
- package/dist/treeConversions.js +1 -0
- package/dist/treeConversions.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/adapters/compression/compressionTypes.d.ts +6 -0
- package/lib/adapters/compression/compressionTypes.d.ts.map +1 -1
- package/lib/adapters/compression/compressionTypes.js +3 -0
- package/lib/adapters/compression/compressionTypes.js.map +1 -1
- package/lib/adapters/compression/documentServiceCompressionAdapter.d.ts.map +1 -1
- package/lib/adapters/compression/documentServiceCompressionAdapter.js.map +1 -1
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts +4 -0
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts.map +1 -1
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js +4 -0
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js.map +1 -1
- package/lib/adapters/predefinedAdapters.d.ts +1 -0
- package/lib/adapters/predefinedAdapters.d.ts.map +1 -1
- package/lib/adapters/predefinedAdapters.js +1 -0
- package/lib/adapters/predefinedAdapters.js.map +1 -1
- package/lib/blob.d.ts +3 -0
- package/lib/blob.d.ts.map +1 -1
- package/lib/blob.js +3 -0
- package/lib/blob.js.map +1 -1
- package/lib/buildSnapshotTree.d.ts +1 -0
- package/lib/buildSnapshotTree.d.ts.map +1 -1
- package/lib/buildSnapshotTree.js +1 -0
- package/lib/buildSnapshotTree.js.map +1 -1
- package/lib/documentStorageServiceProxy.d.ts +3 -0
- package/lib/documentStorageServiceProxy.d.ts.map +1 -1
- package/lib/documentStorageServiceProxy.js +3 -0
- package/lib/documentStorageServiceProxy.js.map +1 -1
- package/lib/error.d.ts +4 -1
- package/lib/error.d.ts.map +1 -1
- package/lib/error.js +4 -1
- package/lib/error.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/insecureUrlResolver.d.ts +1 -0
- package/lib/insecureUrlResolver.d.ts.map +1 -1
- package/lib/insecureUrlResolver.js +1 -0
- package/lib/insecureUrlResolver.js.map +1 -1
- package/lib/messageRecognition.d.ts +10 -0
- package/lib/messageRecognition.d.ts.map +1 -1
- package/lib/messageRecognition.js +10 -3
- package/lib/messageRecognition.js.map +1 -1
- package/lib/network.d.ts +49 -3
- package/lib/network.d.ts.map +1 -1
- package/lib/network.js +45 -5
- package/lib/network.js.map +1 -1
- package/lib/networkUtils.d.ts +3 -0
- package/lib/networkUtils.d.ts.map +1 -1
- package/lib/networkUtils.js +3 -0
- package/lib/networkUtils.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 +12 -0
- package/lib/parallelRequests.d.ts.map +1 -1
- package/lib/parallelRequests.js +12 -0
- package/lib/parallelRequests.js.map +1 -1
- package/lib/prefetchDocumentStorageService.d.ts +3 -0
- package/lib/prefetchDocumentStorageService.d.ts.map +1 -1
- package/lib/prefetchDocumentStorageService.js +3 -0
- package/lib/prefetchDocumentStorageService.js.map +1 -1
- package/lib/rateLimiter.d.ts +3 -0
- package/lib/rateLimiter.d.ts.map +1 -1
- package/lib/rateLimiter.js +3 -0
- package/lib/rateLimiter.js.map +1 -1
- package/lib/readAndParse.d.ts +1 -0
- package/lib/readAndParse.d.ts.map +1 -1
- package/lib/readAndParse.js +1 -0
- package/lib/readAndParse.js.map +1 -1
- package/lib/runWithRetry.d.ts +5 -0
- package/lib/runWithRetry.d.ts.map +1 -1
- package/lib/runWithRetry.js +4 -2
- package/lib/runWithRetry.js.map +1 -1
- package/lib/summaryForCreateNew.d.ts +3 -1
- package/lib/summaryForCreateNew.d.ts.map +1 -1
- package/lib/summaryForCreateNew.js +4 -2
- package/lib/summaryForCreateNew.js.map +1 -1
- package/lib/treeConversions.d.ts +1 -0
- package/lib/treeConversions.d.ts.map +1 -1
- package/lib/treeConversions.js +1 -0
- package/lib/treeConversions.js.map +1 -1
- package/package.json +17 -18
- package/src/adapters/compression/compressionTypes.ts +6 -0
- package/src/adapters/compression/documentServiceCompressionAdapter.ts +4 -1
- package/src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts +4 -0
- package/src/adapters/predefinedAdapters.ts +1 -0
- package/src/blob.ts +11 -2
- package/src/buildSnapshotTree.ts +1 -0
- package/src/documentStorageServiceProxy.ts +3 -0
- package/src/error.ts +4 -1
- package/src/index.ts +1 -0
- package/src/insecureUrlResolver.ts +1 -0
- package/src/messageRecognition.ts +10 -3
- package/src/network.ts +64 -9
- package/src/networkUtils.ts +3 -0
- package/src/packageVersion.ts +1 -1
- package/src/parallelRequests.ts +12 -0
- package/src/prefetchDocumentStorageService.ts +3 -0
- package/src/rateLimiter.ts +3 -0
- package/src/readAndParse.ts +1 -0
- package/src/runWithRetry.ts +7 -4
- package/src/summaryForCreateNew.ts +4 -1
- package/src/treeConversions.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/driver-utils",
|
|
3
|
-
"version": "2.0.0-internal.7.
|
|
3
|
+
"version": "2.0.0-internal.7.2.0",
|
|
4
4
|
"description": "Collection of utility functions for Fluid drivers",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -35,39 +35,38 @@
|
|
|
35
35
|
"temp-directory": "nyc/.nyc_output"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@fluid-internal/client-utils": ">=2.0.0-internal.7.
|
|
39
|
-
"@fluidframework/core-interfaces": ">=2.0.0-internal.7.
|
|
40
|
-
"@fluidframework/core-utils": ">=2.0.0-internal.7.
|
|
41
|
-
"@fluidframework/driver-definitions": ">=2.0.0-internal.7.
|
|
38
|
+
"@fluid-internal/client-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
39
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
40
|
+
"@fluidframework/core-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
41
|
+
"@fluidframework/driver-definitions": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
42
42
|
"@fluidframework/gitresources": "^2.0.1",
|
|
43
43
|
"@fluidframework/protocol-base": "^2.0.1",
|
|
44
44
|
"@fluidframework/protocol-definitions": "^3.0.0",
|
|
45
|
-
"@fluidframework/telemetry-utils": ">=2.0.0-internal.7.
|
|
45
|
+
"@fluidframework/telemetry-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
46
46
|
"axios": "^0.26.0",
|
|
47
47
|
"lz4js": "^0.2.0",
|
|
48
48
|
"url": "^0.11.0",
|
|
49
49
|
"uuid": "^9.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@fluid-tools/build-cli": "^0.
|
|
53
|
-
"@fluidframework/build-common": "^2.0.
|
|
54
|
-
"@fluidframework/build-tools": "^0.
|
|
55
|
-
"@fluidframework/driver-utils-previous": "npm:@fluidframework/driver-utils@2.0.0-internal.
|
|
56
|
-
"@fluidframework/eslint-config-fluid": "^
|
|
57
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.
|
|
52
|
+
"@fluid-tools/build-cli": "^0.26.1",
|
|
53
|
+
"@fluidframework/build-common": "^2.0.3",
|
|
54
|
+
"@fluidframework/build-tools": "^0.26.1",
|
|
55
|
+
"@fluidframework/driver-utils-previous": "npm:@fluidframework/driver-utils@2.0.0-internal.7.1.0",
|
|
56
|
+
"@fluidframework/eslint-config-fluid": "^3.0.0",
|
|
57
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
58
58
|
"@microsoft/api-extractor": "^7.37.0",
|
|
59
59
|
"@types/mocha": "^9.1.1",
|
|
60
60
|
"@types/node": "^16.18.38",
|
|
61
61
|
"@types/sinon": "^7.0.13",
|
|
62
62
|
"c8": "^7.7.1",
|
|
63
|
-
"copyfiles": "^2.4.1",
|
|
64
63
|
"cross-env": "^7.0.3",
|
|
65
|
-
"eslint": "~8.
|
|
64
|
+
"eslint": "~8.50.0",
|
|
66
65
|
"mocha": "^10.2.0",
|
|
67
66
|
"mocha-json-output-reporter": "^2.0.1",
|
|
68
67
|
"mocha-multi-reporters": "^1.5.1",
|
|
69
68
|
"moment": "^2.21.0",
|
|
70
|
-
"prettier": "~
|
|
69
|
+
"prettier": "~3.0.3",
|
|
71
70
|
"rimraf": "^4.4.0",
|
|
72
71
|
"sinon": "^7.4.2",
|
|
73
72
|
"typescript": "~5.1.6"
|
|
@@ -79,12 +78,12 @@
|
|
|
79
78
|
"build": "fluid-build . --task build",
|
|
80
79
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
81
80
|
"build:compile": "fluid-build . --task compile",
|
|
82
|
-
"build:docs": "api-extractor run --local
|
|
81
|
+
"build:docs": "api-extractor run --local",
|
|
83
82
|
"build:esnext": "tsc --project ./tsconfig.esnext.json",
|
|
84
83
|
"build:genver": "gen-version",
|
|
85
84
|
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
86
|
-
"ci:build:docs": "api-extractor run
|
|
87
|
-
"clean": "rimraf --glob
|
|
85
|
+
"ci:build:docs": "api-extractor run",
|
|
86
|
+
"clean": "rimraf --glob dist lib \"*.tsbuildinfo\" \"*.build.log\" _api-extractor-temp nyc",
|
|
88
87
|
"eslint": "eslint --format stylish src",
|
|
89
88
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
90
89
|
"format": "npm run prettier:fix",
|
|
@@ -3,11 +3,17 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
6
9
|
export enum SummaryCompressionAlgorithm {
|
|
7
10
|
None = 0,
|
|
8
11
|
LZ4 = 1,
|
|
9
12
|
}
|
|
10
13
|
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
11
17
|
export interface ICompressionStorageConfig {
|
|
12
18
|
algorithm: SummaryCompressionAlgorithm;
|
|
13
19
|
minSizeToCompress: number;
|
|
@@ -9,7 +9,10 @@ import { DocumentStorageServiceCompressionAdapter as DocumentStorageServiceSumma
|
|
|
9
9
|
import { ICompressionStorageConfig } from "./compressionTypes";
|
|
10
10
|
|
|
11
11
|
export class DocumentServiceCompressionAdapter extends DocumentServiceProxy {
|
|
12
|
-
constructor(
|
|
12
|
+
constructor(
|
|
13
|
+
service: IDocumentService,
|
|
14
|
+
private readonly _config: ICompressionStorageConfig,
|
|
15
|
+
) {
|
|
13
16
|
super(service);
|
|
14
17
|
}
|
|
15
18
|
|
package/src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts
CHANGED
|
@@ -19,6 +19,9 @@ import { compress, decompress } from "lz4js";
|
|
|
19
19
|
import { DocumentStorageServiceProxy } from "../../../documentStorageServiceProxy";
|
|
20
20
|
import { ICompressionStorageConfig, SummaryCompressionAlgorithm } from "../";
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
22
25
|
export const blobHeadersBlobName = ".metadata.blobHeaders";
|
|
23
26
|
const metadataBlobName = ".metadata";
|
|
24
27
|
|
|
@@ -32,6 +35,7 @@ const metadataBlobName = ".metadata";
|
|
|
32
35
|
* In case, the markup blob is present, it is expected that the first byte of the markup blob
|
|
33
36
|
* will contain the info about the compression. If the first byte is not present, it is assumed
|
|
34
37
|
* that the compression is not enabled and no first prefix byte is present in the blobs.
|
|
38
|
+
* @public
|
|
35
39
|
*/
|
|
36
40
|
export class DocumentStorageServiceCompressionAdapter extends DocumentStorageServiceProxy {
|
|
37
41
|
private _isCompressionEnabled: boolean = false;
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
* @param documentServiceFactory - The document service factory to apply compression to.
|
|
18
18
|
* @param config - The compression configuration.
|
|
19
19
|
* @returns The document service factory possibly with compression applied.
|
|
20
|
+
* @public
|
|
20
21
|
*/
|
|
21
22
|
export function applyStorageCompression(
|
|
22
23
|
documentServiceFactory: IDocumentServiceFactory,
|
package/src/blob.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Basic implementation of a blob ITreeEntry
|
|
16
|
+
* @public
|
|
16
17
|
*/
|
|
17
18
|
export class BlobTreeEntry {
|
|
18
19
|
public readonly mode = FileMode.File;
|
|
@@ -36,6 +37,7 @@ export class BlobTreeEntry {
|
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* Basic implementation of a tree ITreeEntry
|
|
40
|
+
* @public
|
|
39
41
|
*/
|
|
40
42
|
export class TreeTreeEntry {
|
|
41
43
|
public readonly mode = FileMode.Directory;
|
|
@@ -46,11 +48,15 @@ export class TreeTreeEntry {
|
|
|
46
48
|
* @param path - path of entry
|
|
47
49
|
* @param value - subtree
|
|
48
50
|
*/
|
|
49
|
-
constructor(
|
|
51
|
+
constructor(
|
|
52
|
+
public readonly path: string,
|
|
53
|
+
public readonly value: ITree,
|
|
54
|
+
) {}
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
/**
|
|
53
58
|
* Basic implementation of an attachment ITreeEntry
|
|
59
|
+
* @public
|
|
54
60
|
*/
|
|
55
61
|
export class AttachmentTreeEntry {
|
|
56
62
|
public readonly mode = FileMode.File;
|
|
@@ -62,7 +68,10 @@ export class AttachmentTreeEntry {
|
|
|
62
68
|
* @param path - path of entry
|
|
63
69
|
* @param id - id of external blob attachment
|
|
64
70
|
*/
|
|
65
|
-
constructor(
|
|
71
|
+
constructor(
|
|
72
|
+
public readonly path: string,
|
|
73
|
+
public readonly id: string,
|
|
74
|
+
) {
|
|
66
75
|
this.value = { id };
|
|
67
76
|
}
|
|
68
77
|
}
|
package/src/buildSnapshotTree.ts
CHANGED
|
@@ -86,6 +86,7 @@ function flatten(tree: ITreeEntry[], blobMap: Map<string, ArrayBufferLike>): git
|
|
|
86
86
|
* @param blobMap - a map of blob's sha1 to content that gets filled with content from entries
|
|
87
87
|
* NOTE: blobMap's validity is contingent on the returned promise's resolution
|
|
88
88
|
* @returns the hierarchical tree
|
|
89
|
+
* @public
|
|
89
90
|
*/
|
|
90
91
|
export function buildSnapshotTree(
|
|
91
92
|
entries: ITreeEntry[],
|
package/src/error.ts
CHANGED
|
@@ -7,7 +7,10 @@
|
|
|
7
7
|
import { DriverErrorType, IDriverErrorBase } from "@fluidframework/driver-definitions";
|
|
8
8
|
import { IFluidErrorBase, LoggingError } from "@fluidframework/telemetry-utils";
|
|
9
9
|
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Error indicating an API is being used improperly resulting in an invalid operation.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
11
14
|
export class UsageError extends LoggingError implements IDriverErrorBase, IFluidErrorBase {
|
|
12
15
|
// eslint-disable-next-line import/no-deprecated
|
|
13
16
|
readonly errorType = DriverErrorType.usageError;
|
package/src/index.ts
CHANGED
|
@@ -22,6 +22,7 @@ import Axios from "axios";
|
|
|
22
22
|
* The tenantId/documentId pair defines the 'full' document ID the service makes use of. The path is then an optional
|
|
23
23
|
* part of the URL that the document interprets and maps to a data store. It's exactly similar to how a web service
|
|
24
24
|
* works or a router inside of a single page app framework.
|
|
25
|
+
* @public
|
|
25
26
|
*/
|
|
26
27
|
export class InsecureUrlResolver implements IUrlResolver {
|
|
27
28
|
private readonly cache = new Map<string, Promise<IResolvedUrl>>();
|
|
@@ -12,18 +12,25 @@ import {
|
|
|
12
12
|
* Tells if message was sent by container runtime
|
|
13
13
|
* @privateRemarks ADO #1385: To be moved to container-definitions
|
|
14
14
|
* @returns whether the message is a runtime message
|
|
15
|
+
* @public
|
|
15
16
|
*/
|
|
16
17
|
export function isRuntimeMessage(message: { type: string }): boolean {
|
|
17
18
|
return message.type === MessageType.Operation;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* @privateRemarks ADO #1385: staging code changes across layers.
|
|
23
|
+
* Eventually to be replaced by MessageType.accept
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
22
26
|
export enum MessageType2 {
|
|
23
27
|
Accept = "accept",
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
/**
|
|
31
|
+
* @privateRemarks ADO #1385: To be moved to packages/protocol-base/src/protocol.ts
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
27
34
|
export function canBeCoalescedByService(
|
|
28
35
|
message: ISequencedDocumentMessage | IDocumentMessage,
|
|
29
36
|
): boolean {
|
package/src/network.ts
CHANGED
|
@@ -16,15 +16,21 @@ import {
|
|
|
16
16
|
import { ITelemetryProperties } from "@fluidframework/core-interfaces";
|
|
17
17
|
import { IFluidErrorBase, LoggingError } from "@fluidframework/telemetry-utils";
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
19
22
|
export enum OnlineStatus {
|
|
20
23
|
Offline,
|
|
21
24
|
Online,
|
|
22
25
|
Unknown,
|
|
23
26
|
}
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
/**
|
|
29
|
+
* It tells if we have local connection only - we might not have connection to web.
|
|
30
|
+
* No solution for node.js (other than resolve dns names / ping specific sites)
|
|
31
|
+
* Can also use window.addEventListener("online" / "offline")
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
28
34
|
export function isOnline(): OnlineStatus {
|
|
29
35
|
if (
|
|
30
36
|
typeof navigator === "object" &&
|
|
@@ -36,25 +42,34 @@ export function isOnline(): OnlineStatus {
|
|
|
36
42
|
return OnlineStatus.Unknown;
|
|
37
43
|
}
|
|
38
44
|
|
|
39
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Telemetry props with driver-specific required properties
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
40
49
|
export type DriverErrorTelemetryProps = ITelemetryProperties & {
|
|
41
50
|
driverVersion: string | undefined;
|
|
42
51
|
};
|
|
43
52
|
|
|
44
53
|
/**
|
|
45
54
|
* Generic network error class.
|
|
55
|
+
* @public
|
|
46
56
|
*/
|
|
47
57
|
export class GenericNetworkError extends LoggingError implements IDriverErrorBase, IFluidErrorBase {
|
|
48
58
|
// eslint-disable-next-line import/no-deprecated
|
|
49
59
|
readonly errorType = DriverErrorType.genericNetworkError;
|
|
50
60
|
|
|
51
|
-
constructor(
|
|
61
|
+
constructor(
|
|
62
|
+
message: string,
|
|
63
|
+
readonly canRetry: boolean,
|
|
64
|
+
props: DriverErrorTelemetryProps,
|
|
65
|
+
) {
|
|
52
66
|
super(message, props);
|
|
53
67
|
}
|
|
54
68
|
}
|
|
55
69
|
|
|
56
70
|
/**
|
|
57
71
|
* FluidInvalidSchema error class.
|
|
72
|
+
* @public
|
|
58
73
|
*/
|
|
59
74
|
export class FluidInvalidSchemaError
|
|
60
75
|
extends LoggingError
|
|
@@ -69,6 +84,9 @@ export class FluidInvalidSchemaError
|
|
|
69
84
|
}
|
|
70
85
|
}
|
|
71
86
|
|
|
87
|
+
/**
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
72
90
|
export class DeltaStreamConnectionForbiddenError
|
|
73
91
|
extends LoggingError
|
|
74
92
|
implements IDriverErrorBase, IFluidErrorBase
|
|
@@ -85,6 +103,9 @@ export class DeltaStreamConnectionForbiddenError
|
|
|
85
103
|
}
|
|
86
104
|
}
|
|
87
105
|
|
|
106
|
+
/**
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
88
109
|
export class AuthorizationError
|
|
89
110
|
extends LoggingError
|
|
90
111
|
implements IAuthorizationError, IFluidErrorBase
|
|
@@ -104,6 +125,9 @@ export class AuthorizationError
|
|
|
104
125
|
}
|
|
105
126
|
}
|
|
106
127
|
|
|
128
|
+
/**
|
|
129
|
+
* @public
|
|
130
|
+
*/
|
|
107
131
|
export class LocationRedirectionError
|
|
108
132
|
extends LoggingError
|
|
109
133
|
implements ILocationRedirectionError, IFluidErrorBase
|
|
@@ -122,6 +146,9 @@ export class LocationRedirectionError
|
|
|
122
146
|
}
|
|
123
147
|
}
|
|
124
148
|
|
|
149
|
+
/**
|
|
150
|
+
* @public
|
|
151
|
+
*/
|
|
125
152
|
export class NetworkErrorBasic<T extends string> extends LoggingError implements IFluidErrorBase {
|
|
126
153
|
constructor(
|
|
127
154
|
message: string,
|
|
@@ -133,20 +160,35 @@ export class NetworkErrorBasic<T extends string> extends LoggingError implements
|
|
|
133
160
|
}
|
|
134
161
|
}
|
|
135
162
|
|
|
163
|
+
/**
|
|
164
|
+
* @public
|
|
165
|
+
*/
|
|
136
166
|
export class NonRetryableError<T extends string> extends NetworkErrorBasic<T> {
|
|
137
|
-
constructor(
|
|
167
|
+
constructor(
|
|
168
|
+
message: string,
|
|
169
|
+
readonly errorType: T,
|
|
170
|
+
props: DriverErrorTelemetryProps,
|
|
171
|
+
) {
|
|
138
172
|
super(message, errorType, false, props);
|
|
139
173
|
}
|
|
140
174
|
}
|
|
141
175
|
|
|
176
|
+
/**
|
|
177
|
+
* @public
|
|
178
|
+
*/
|
|
142
179
|
export class RetryableError<T extends string> extends NetworkErrorBasic<T> {
|
|
143
|
-
constructor(
|
|
180
|
+
constructor(
|
|
181
|
+
message: string,
|
|
182
|
+
readonly errorType: T,
|
|
183
|
+
props: DriverErrorTelemetryProps,
|
|
184
|
+
) {
|
|
144
185
|
super(message, errorType, true, props);
|
|
145
186
|
}
|
|
146
187
|
}
|
|
147
188
|
|
|
148
189
|
/**
|
|
149
190
|
* Throttling error class - used to communicate all throttling errors
|
|
191
|
+
* @public
|
|
150
192
|
*/
|
|
151
193
|
export class ThrottlingError extends LoggingError implements IThrottlingWarning, IFluidErrorBase {
|
|
152
194
|
// eslint-disable-next-line import/no-deprecated
|
|
@@ -162,9 +204,15 @@ export class ThrottlingError extends LoggingError implements IThrottlingWarning,
|
|
|
162
204
|
}
|
|
163
205
|
}
|
|
164
206
|
|
|
207
|
+
/**
|
|
208
|
+
* @public
|
|
209
|
+
*/
|
|
165
210
|
export const createWriteError = (message: string, props: DriverErrorTelemetryProps) =>
|
|
166
211
|
new NonRetryableError(message, DriverErrorTypes.writeError, props);
|
|
167
212
|
|
|
213
|
+
/**
|
|
214
|
+
* @public
|
|
215
|
+
*/
|
|
168
216
|
export function createGenericNetworkError(
|
|
169
217
|
message: string,
|
|
170
218
|
retryInfo: { canRetry: boolean; retryAfterMs?: number },
|
|
@@ -180,13 +228,20 @@ export function createGenericNetworkError(
|
|
|
180
228
|
* Check if a connection error can be retried. Unless explicitly allowed, retry is disallowed.
|
|
181
229
|
* I.e. asserts or unexpected exceptions in our code result in container failure.
|
|
182
230
|
* @param error - The error to inspect for ability to retry
|
|
231
|
+
* @public
|
|
183
232
|
*/
|
|
184
233
|
export const canRetryOnError = (error: any): boolean => error?.canRetry === true;
|
|
185
234
|
|
|
186
|
-
/**
|
|
235
|
+
/**
|
|
236
|
+
* Check retryAfterSeconds property on error
|
|
237
|
+
* @public
|
|
238
|
+
* */
|
|
187
239
|
export const getRetryDelaySecondsFromError = (error: any): number | undefined =>
|
|
188
240
|
error?.retryAfterSeconds as number | undefined;
|
|
189
241
|
|
|
190
|
-
/**
|
|
242
|
+
/**
|
|
243
|
+
* Check retryAfterSeconds property on error and convert to ms
|
|
244
|
+
* @public
|
|
245
|
+
* */
|
|
191
246
|
export const getRetryDelayFromError = (error: any): number | undefined =>
|
|
192
247
|
error?.retryAfterSeconds !== undefined ? error.retryAfterSeconds * 1000 : undefined;
|
package/src/networkUtils.ts
CHANGED
|
@@ -7,6 +7,9 @@ import { ITelemetryErrorEvent } from "@fluidframework/core-interfaces";
|
|
|
7
7
|
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
8
8
|
import { isOnline, OnlineStatus, canRetryOnError } from "./network";
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
10
13
|
export function logNetworkFailure(
|
|
11
14
|
logger: ITelemetryLoggerExt,
|
|
12
15
|
event: ITelemetryErrorEvent,
|
package/src/packageVersion.ts
CHANGED
package/src/parallelRequests.ts
CHANGED
|
@@ -29,6 +29,7 @@ type WorkingState = "working" | "done" | "canceled";
|
|
|
29
29
|
* @param logger - logger to use
|
|
30
30
|
* @param requestCallback - callback to request batches
|
|
31
31
|
* @returns Queue that can be used to retrieve data
|
|
32
|
+
* @public
|
|
32
33
|
*/
|
|
33
34
|
export class ParallelRequests<T> {
|
|
34
35
|
private latestRequested: number;
|
|
@@ -338,6 +339,7 @@ export class ParallelRequests<T> {
|
|
|
338
339
|
/**
|
|
339
340
|
* Helper queue class to allow async push / pull
|
|
340
341
|
* It's essentially a pipe allowing multiple writers, and single reader
|
|
342
|
+
* @public
|
|
341
343
|
*/
|
|
342
344
|
export class Queue<T> implements IStream<T> {
|
|
343
345
|
private readonly queue: Promise<IStreamResult<T>>[] = [];
|
|
@@ -531,6 +533,7 @@ async function getSingleOpBatch(
|
|
|
531
533
|
* @param signal - Cancelation signal
|
|
532
534
|
* @param scenarioName - Reason for fetching ops
|
|
533
535
|
* @returns Messages fetched
|
|
536
|
+
* @public
|
|
534
537
|
*/
|
|
535
538
|
export function requestOps(
|
|
536
539
|
get: (
|
|
@@ -651,12 +654,18 @@ export function requestOps(
|
|
|
651
654
|
return queue;
|
|
652
655
|
}
|
|
653
656
|
|
|
657
|
+
/**
|
|
658
|
+
* @public
|
|
659
|
+
*/
|
|
654
660
|
export const emptyMessageStream: IStream<ISequencedDocumentMessage[]> = {
|
|
655
661
|
read: async () => {
|
|
656
662
|
return { done: true };
|
|
657
663
|
},
|
|
658
664
|
};
|
|
659
665
|
|
|
666
|
+
/**
|
|
667
|
+
* @public
|
|
668
|
+
*/
|
|
660
669
|
export function streamFromMessages(
|
|
661
670
|
messagesArg: Promise<ISequencedDocumentMessage[]>,
|
|
662
671
|
): IStream<ISequencedDocumentMessage[]> {
|
|
@@ -673,6 +682,9 @@ export function streamFromMessages(
|
|
|
673
682
|
};
|
|
674
683
|
}
|
|
675
684
|
|
|
685
|
+
/**
|
|
686
|
+
* @public
|
|
687
|
+
*/
|
|
676
688
|
export function streamObserver<T>(
|
|
677
689
|
stream: IStream<T>,
|
|
678
690
|
handler: (value: IStreamResult<T>) => void,
|
|
@@ -7,6 +7,9 @@ import { ISnapshotTree, IVersion } from "@fluidframework/protocol-definitions";
|
|
|
7
7
|
import { DocumentStorageServiceProxy } from "./documentStorageServiceProxy";
|
|
8
8
|
import { canRetryOnError } from "./network";
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
10
13
|
export class PrefetchDocumentStorageService extends DocumentStorageServiceProxy {
|
|
11
14
|
// BlobId -> blob prefetchCache cache
|
|
12
15
|
private readonly prefetchCache = new Map<string, Promise<ArrayBufferLike>>();
|
package/src/rateLimiter.ts
CHANGED
package/src/readAndParse.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { IDocumentStorageService } from "@fluidframework/driver-definitions";
|
|
|
17
17
|
* @typeParam T - Output type matching JSON format of inpyt blob data.
|
|
18
18
|
*
|
|
19
19
|
* @returns The object that we decoded and parsed via `JSON.parse`.
|
|
20
|
+
* @public
|
|
20
21
|
*/
|
|
21
22
|
export async function readAndParse<T>(
|
|
22
23
|
storage: Pick<IDocumentStorageService, "readBlob">,
|
package/src/runWithRetry.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { NonRetryableError } from ".";
|
|
|
14
14
|
/**
|
|
15
15
|
* Interface describing an object passed to various network APIs.
|
|
16
16
|
* It allows caller to control cancellation, as well as learn about any delays.
|
|
17
|
+
* @public
|
|
17
18
|
*/
|
|
18
19
|
export interface IProgress {
|
|
19
20
|
/**
|
|
@@ -43,6 +44,9 @@ export interface IProgress {
|
|
|
43
44
|
onRetry?(delayInMs: number, error: any): void;
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
/**
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
46
50
|
export async function runWithRetry<T>(
|
|
47
51
|
api: (cancel?: AbortSignal) => Promise<T>,
|
|
48
52
|
fetchCallName: string,
|
|
@@ -81,8 +85,7 @@ export async function runWithRetry<T>(
|
|
|
81
85
|
retry: numRetries,
|
|
82
86
|
duration: performance.now() - startTime,
|
|
83
87
|
fetchCallName,
|
|
84
|
-
|
|
85
|
-
reason: (progress.cancel as AbortSignal & { reason: any }).reason,
|
|
88
|
+
reason: progress.cancel.reason,
|
|
86
89
|
},
|
|
87
90
|
err,
|
|
88
91
|
);
|
|
@@ -92,8 +95,7 @@ export async function runWithRetry<T>(
|
|
|
92
95
|
{
|
|
93
96
|
driverVersion: pkgVersion,
|
|
94
97
|
fetchCallName,
|
|
95
|
-
|
|
96
|
-
reason: (progress.cancel as AbortSignal & { reason: any }).reason,
|
|
98
|
+
reason: progress.cancel.reason,
|
|
97
99
|
},
|
|
98
100
|
);
|
|
99
101
|
}
|
|
@@ -148,6 +150,7 @@ const MaxReconnectDelayInMsWhenEndpointIsNotReachable = 8000;
|
|
|
148
150
|
* to when endpoint is reachable in which case it is 30s.
|
|
149
151
|
* @param error - error based on which we decide max wait time.
|
|
150
152
|
* @returns Max wait time.
|
|
153
|
+
* @public
|
|
151
154
|
*/
|
|
152
155
|
export function calculateMaxWaitTime(error: unknown): number {
|
|
153
156
|
return isFluidError(error) && error.getTelemetryProperties().endpointReached === true
|
|
@@ -30,6 +30,7 @@ export interface CombinedAppAndProtocolSummary extends ISummaryTree {
|
|
|
30
30
|
*/
|
|
31
31
|
export function isCombinedAppAndProtocolSummary(
|
|
32
32
|
summary: ISummaryTree | undefined,
|
|
33
|
+
...optionalRootTrees: string[]
|
|
33
34
|
): summary is CombinedAppAndProtocolSummary {
|
|
34
35
|
if (
|
|
35
36
|
summary?.tree === undefined ||
|
|
@@ -38,7 +39,7 @@ export function isCombinedAppAndProtocolSummary(
|
|
|
38
39
|
) {
|
|
39
40
|
return false;
|
|
40
41
|
}
|
|
41
|
-
const treeKeys = Object.keys(summary.tree);
|
|
42
|
+
const treeKeys = Object.keys(summary.tree).filter((t) => !optionalRootTrees.includes(t));
|
|
42
43
|
if (treeKeys.length !== 2) {
|
|
43
44
|
return false;
|
|
44
45
|
}
|
|
@@ -48,6 +49,7 @@ export function isCombinedAppAndProtocolSummary(
|
|
|
48
49
|
/**
|
|
49
50
|
* Extract the attributes from the protocol summary.
|
|
50
51
|
* @param protocolSummary - protocol summary from which the values are to be extracted.
|
|
52
|
+
* @public
|
|
51
53
|
*/
|
|
52
54
|
export function getDocAttributesFromProtocolSummary(
|
|
53
55
|
protocolSummary: ISummaryTree,
|
|
@@ -59,6 +61,7 @@ export function getDocAttributesFromProtocolSummary(
|
|
|
59
61
|
/**
|
|
60
62
|
* Extract quorum values from the protocol summary.
|
|
61
63
|
* @param protocolSummary - protocol summary from which the values are to be extracted.
|
|
64
|
+
* @public
|
|
62
65
|
*/
|
|
63
66
|
export function getQuorumValuesFromProtocolSummary(
|
|
64
67
|
protocolSummary: ISummaryTree,
|
package/src/treeConversions.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { isCombinedAppAndProtocolSummary } from "./summaryForCreateNew";
|
|
|
12
12
|
/**
|
|
13
13
|
* Converts ISummaryTree to ITree format.
|
|
14
14
|
* @param summaryTree - summary tree in ISummaryTree format
|
|
15
|
+
* @public
|
|
15
16
|
*/
|
|
16
17
|
export function convertSummaryTreeToSnapshotITree(summaryTree: ISummaryTree): ITree {
|
|
17
18
|
const entries: ITreeEntry[] = [];
|