@fluidframework/driver-utils 1.3.0 → 2.0.0-dev.1.4.5.105745
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/.mocharc.js +12 -0
- package/dist/documentStorageServiceProxy.d.ts +2 -2
- package/dist/documentStorageServiceProxy.d.ts.map +1 -1
- package/dist/documentStorageServiceProxy.js +2 -2
- package/dist/documentStorageServiceProxy.js.map +1 -1
- package/dist/messageRecognition.d.ts +38 -22
- package/dist/messageRecognition.d.ts.map +1 -1
- package/dist/messageRecognition.js +48 -23
- package/dist/messageRecognition.js.map +1 -1
- package/dist/network.d.ts +7 -1
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js +11 -1
- package/dist/network.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/parallelRequests.d.ts +1 -1
- package/dist/parallelRequests.js +1 -1
- package/dist/parallelRequests.js.map +1 -1
- package/dist/readAndParse.d.ts +9 -4
- package/dist/readAndParse.d.ts.map +1 -1
- package/dist/readAndParse.js +9 -4
- package/dist/readAndParse.js.map +1 -1
- package/dist/runWithRetry.d.ts +9 -5
- package/dist/runWithRetry.d.ts.map +1 -1
- package/dist/runWithRetry.js.map +1 -1
- package/lib/documentStorageServiceProxy.d.ts +2 -2
- package/lib/documentStorageServiceProxy.d.ts.map +1 -1
- package/lib/documentStorageServiceProxy.js +2 -2
- package/lib/documentStorageServiceProxy.js.map +1 -1
- package/lib/messageRecognition.d.ts +38 -22
- package/lib/messageRecognition.d.ts.map +1 -1
- package/lib/messageRecognition.js +46 -22
- package/lib/messageRecognition.js.map +1 -1
- package/lib/network.d.ts +7 -1
- package/lib/network.d.ts.map +1 -1
- package/lib/network.js +9 -0
- package/lib/network.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/parallelRequests.d.ts +1 -1
- package/lib/parallelRequests.js +1 -1
- package/lib/parallelRequests.js.map +1 -1
- package/lib/readAndParse.d.ts +9 -4
- package/lib/readAndParse.d.ts.map +1 -1
- package/lib/readAndParse.js +9 -4
- package/lib/readAndParse.js.map +1 -1
- package/lib/runWithRetry.d.ts +9 -5
- package/lib/runWithRetry.d.ts.map +1 -1
- package/lib/runWithRetry.js.map +1 -1
- package/package.json +31 -17
- package/src/documentStorageServiceProxy.ts +8 -2
- package/src/messageRecognition.ts +48 -23
- package/src/network.ts +16 -0
- package/src/packageVersion.ts +1 -1
- package/src/parallelRequests.ts +1 -1
- package/src/readAndParse.ts +9 -4
- package/src/runWithRetry.ts +9 -5
|
@@ -5,14 +5,19 @@
|
|
|
5
5
|
import { IDocumentMessage, ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
+
* Determines whether or not the message type is one of the following:
|
|
8
9
|
*
|
|
9
|
-
* @
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
10
|
+
* - {@link @fluidframework/protocol-definitions#MessageType.Operation}
|
|
11
|
+
*
|
|
12
|
+
* - {@link @fluidframework/protocol-definitions#MessageType.Summarize}
|
|
13
|
+
*
|
|
14
|
+
* - {@link @fluidframework/protocol-definitions#MessageType.Propose}
|
|
15
|
+
*
|
|
16
|
+
* - {@link @fluidframework/protocol-definitions#MessageType.Reject}
|
|
17
|
+
*
|
|
18
|
+
* - {@link @fluidframework/protocol-definitions#MessageType2.Accept}
|
|
19
|
+
*
|
|
20
|
+
* - {@link @fluidframework/protocol-definitions#MessageType.NoOp}
|
|
16
21
|
*/
|
|
17
22
|
export function isClientMessage(message: ISequencedDocumentMessage | IDocumentMessage): boolean {
|
|
18
23
|
if (isRuntimeMessage(message)) {
|
|
@@ -22,6 +27,8 @@ export function isClientMessage(message: ISequencedDocumentMessage | IDocumentMe
|
|
|
22
27
|
case MessageType.Propose:
|
|
23
28
|
case MessageType.Reject:
|
|
24
29
|
case MessageType.NoOp:
|
|
30
|
+
case MessageType2.Accept:
|
|
31
|
+
case MessageType.Summarize:
|
|
25
32
|
return true;
|
|
26
33
|
default:
|
|
27
34
|
return false;
|
|
@@ -29,14 +36,12 @@ export function isClientMessage(message: ISequencedDocumentMessage | IDocumentMe
|
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
/**
|
|
32
|
-
*
|
|
33
|
-
* @
|
|
34
|
-
* @returns whether
|
|
35
|
-
* "op"
|
|
36
|
-
* "summarize"
|
|
39
|
+
* Tells if message was sent by container runtime
|
|
40
|
+
* @privateRemarks ADO #1385: To be moved to container-definitions
|
|
41
|
+
* @returns whether the message is a runtime message
|
|
37
42
|
*/
|
|
38
|
-
export function isRuntimeMessage(message:
|
|
39
|
-
return message.type === MessageType.Operation
|
|
43
|
+
export function isRuntimeMessage(message: { type: string; }): boolean {
|
|
44
|
+
return message.type === MessageType.Operation;
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
enum RuntimeMessage {
|
|
@@ -50,16 +55,23 @@ enum RuntimeMessage {
|
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
/**
|
|
58
|
+
* Determines whether or not the message type is one of the following: (legacy)
|
|
59
|
+
*
|
|
60
|
+
* - "component"
|
|
61
|
+
*
|
|
62
|
+
* - "attach"
|
|
63
|
+
*
|
|
64
|
+
* - "chunkedOp"
|
|
53
65
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* "
|
|
57
|
-
*
|
|
58
|
-
* "
|
|
59
|
-
*
|
|
60
|
-
* "
|
|
61
|
-
*
|
|
62
|
-
*
|
|
66
|
+
* - "blobAttach"
|
|
67
|
+
*
|
|
68
|
+
* - "rejoin"
|
|
69
|
+
*
|
|
70
|
+
* - "alias"
|
|
71
|
+
*
|
|
72
|
+
* - "op"
|
|
73
|
+
*
|
|
74
|
+
* @deprecated This API should not be used.
|
|
63
75
|
*/
|
|
64
76
|
export function isUnpackedRuntimeMessage(message: ISequencedDocumentMessage): boolean {
|
|
65
77
|
if ((Object.values(RuntimeMessage) as string[]).includes(message.type)) {
|
|
@@ -67,3 +79,16 @@ export function isUnpackedRuntimeMessage(message: ISequencedDocumentMessage): bo
|
|
|
67
79
|
}
|
|
68
80
|
return false;
|
|
69
81
|
}
|
|
82
|
+
|
|
83
|
+
// ADO #1385: staging code changes across layers.
|
|
84
|
+
// Eventually to be replaced by MessageType.accept
|
|
85
|
+
export enum MessageType2 {
|
|
86
|
+
Accept = "accept",
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ADO #1385: To be moved to packages/protocol-base/src/protocol.ts
|
|
90
|
+
export function canBeCoalescedByService(message: ISequencedDocumentMessage | IDocumentMessage): boolean {
|
|
91
|
+
// This assumes that in the future relay service may implement coalescing of accept messages,
|
|
92
|
+
// same way it was doing coalescing of immediate noops in the past.
|
|
93
|
+
return message.type === MessageType.NoOp || message.type === MessageType2.Accept;
|
|
94
|
+
}
|
package/src/network.ts
CHANGED
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
IDriverErrorBase,
|
|
9
9
|
IAuthorizationError,
|
|
10
10
|
DriverErrorType,
|
|
11
|
+
ILocationRedirectionError,
|
|
12
|
+
IResolvedUrl,
|
|
11
13
|
} from "@fluidframework/driver-definitions";
|
|
12
14
|
import { ITelemetryProperties } from "@fluidframework/common-definitions";
|
|
13
15
|
import { IFluidErrorBase, LoggingError } from "@fluidframework/telemetry-utils";
|
|
@@ -91,6 +93,20 @@ export class AuthorizationError extends LoggingError implements IAuthorizationEr
|
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
|
|
96
|
+
export class LocationRedirectionError extends LoggingError implements ILocationRedirectionError, IFluidErrorBase {
|
|
97
|
+
readonly errorType = DriverErrorType.locationRedirection;
|
|
98
|
+
readonly canRetry = false;
|
|
99
|
+
|
|
100
|
+
constructor(
|
|
101
|
+
message: string,
|
|
102
|
+
readonly redirectUrl: IResolvedUrl,
|
|
103
|
+
props: DriverErrorTelemetryProps,
|
|
104
|
+
) {
|
|
105
|
+
// do not log redirectURL
|
|
106
|
+
super(message, props, new Set(["redirectUrl"]));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
94
110
|
export class NetworkErrorBasic<T extends string> extends LoggingError implements IFluidErrorBase {
|
|
95
111
|
constructor(
|
|
96
112
|
message: string,
|
package/src/packageVersion.ts
CHANGED
package/src/parallelRequests.ts
CHANGED
|
@@ -23,7 +23,7 @@ type WorkingState = "working" | "done" | "canceled";
|
|
|
23
23
|
* data in the right order. Take a look at UT for examples.
|
|
24
24
|
* @param concurrency - level of concurrency
|
|
25
25
|
* @param from - starting point of fetching data (inclusive)
|
|
26
|
-
* @param to
|
|
26
|
+
* @param to - ending point of fetching data. exclusive, or undefined if unknown
|
|
27
27
|
* @param payloadSize - batch size
|
|
28
28
|
* @param logger - logger to use
|
|
29
29
|
* @param requestCallback - callback to request batches
|
package/src/readAndParse.ts
CHANGED
|
@@ -7,11 +7,16 @@ import { bufferToString } from "@fluidframework/common-utils";
|
|
|
7
7
|
import { IDocumentStorageService } from "@fluidframework/driver-definitions";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Read a blob from IDocumentStorageService and
|
|
10
|
+
* Read a blob from {@link @fluidframework/driver-definitions#IDocumentStorageService} and
|
|
11
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}
|
|
12
|
+
* it into object of type `T`.
|
|
11
13
|
*
|
|
12
|
-
* @param storage -
|
|
13
|
-
* @param id -
|
|
14
|
-
*
|
|
14
|
+
* @param storage - The `DocumentStorageService` to read from.
|
|
15
|
+
* @param id - The ID of the blob to read and parse.
|
|
16
|
+
*
|
|
17
|
+
* @typeParam T - Output type matching JSON format of inpyt blob data.
|
|
18
|
+
*
|
|
19
|
+
* @returns The object that we decoded and parsed via `JSON.parse`.
|
|
15
20
|
*/
|
|
16
21
|
export async function readAndParse<T>(storage: Pick<IDocumentStorageService, "readBlob">, id: string): Promise<T> {
|
|
17
22
|
const blob = await storage.readBlob(id);
|
package/src/runWithRetry.ts
CHANGED
|
@@ -16,14 +16,18 @@ import { NonRetryableError } from ".";
|
|
|
16
16
|
*/
|
|
17
17
|
export interface IProgress {
|
|
18
18
|
/**
|
|
19
|
-
* Abort signal used to cancel operation
|
|
20
|
-
*
|
|
19
|
+
* Abort signal used to cancel operation.
|
|
20
|
+
*
|
|
21
|
+
* @remarks Note that most of the layers do not use this signal yet. We need to change that over time.
|
|
21
22
|
* Please consult with API documentation / implementation.
|
|
22
23
|
* Note that number of layers may not check this signal while holding this request in a queue,
|
|
23
24
|
* so it may take a while it takes effect. This can be improved in the future.
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
25
|
+
*
|
|
26
|
+
* The layers in question are:
|
|
27
|
+
*
|
|
28
|
+
* - driver (RateLimiter)
|
|
29
|
+
*
|
|
30
|
+
* - runWithRetry
|
|
27
31
|
*/
|
|
28
32
|
cancel?: AbortSignal;
|
|
29
33
|
|