@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.
Files changed (61) hide show
  1. package/.mocharc.js +12 -0
  2. package/dist/documentStorageServiceProxy.d.ts +2 -2
  3. package/dist/documentStorageServiceProxy.d.ts.map +1 -1
  4. package/dist/documentStorageServiceProxy.js +2 -2
  5. package/dist/documentStorageServiceProxy.js.map +1 -1
  6. package/dist/messageRecognition.d.ts +38 -22
  7. package/dist/messageRecognition.d.ts.map +1 -1
  8. package/dist/messageRecognition.js +48 -23
  9. package/dist/messageRecognition.js.map +1 -1
  10. package/dist/network.d.ts +7 -1
  11. package/dist/network.d.ts.map +1 -1
  12. package/dist/network.js +11 -1
  13. package/dist/network.js.map +1 -1
  14. package/dist/packageVersion.d.ts +1 -1
  15. package/dist/packageVersion.d.ts.map +1 -1
  16. package/dist/packageVersion.js +1 -1
  17. package/dist/packageVersion.js.map +1 -1
  18. package/dist/parallelRequests.d.ts +1 -1
  19. package/dist/parallelRequests.js +1 -1
  20. package/dist/parallelRequests.js.map +1 -1
  21. package/dist/readAndParse.d.ts +9 -4
  22. package/dist/readAndParse.d.ts.map +1 -1
  23. package/dist/readAndParse.js +9 -4
  24. package/dist/readAndParse.js.map +1 -1
  25. package/dist/runWithRetry.d.ts +9 -5
  26. package/dist/runWithRetry.d.ts.map +1 -1
  27. package/dist/runWithRetry.js.map +1 -1
  28. package/lib/documentStorageServiceProxy.d.ts +2 -2
  29. package/lib/documentStorageServiceProxy.d.ts.map +1 -1
  30. package/lib/documentStorageServiceProxy.js +2 -2
  31. package/lib/documentStorageServiceProxy.js.map +1 -1
  32. package/lib/messageRecognition.d.ts +38 -22
  33. package/lib/messageRecognition.d.ts.map +1 -1
  34. package/lib/messageRecognition.js +46 -22
  35. package/lib/messageRecognition.js.map +1 -1
  36. package/lib/network.d.ts +7 -1
  37. package/lib/network.d.ts.map +1 -1
  38. package/lib/network.js +9 -0
  39. package/lib/network.js.map +1 -1
  40. package/lib/packageVersion.d.ts +1 -1
  41. package/lib/packageVersion.d.ts.map +1 -1
  42. package/lib/packageVersion.js +1 -1
  43. package/lib/packageVersion.js.map +1 -1
  44. package/lib/parallelRequests.d.ts +1 -1
  45. package/lib/parallelRequests.js +1 -1
  46. package/lib/parallelRequests.js.map +1 -1
  47. package/lib/readAndParse.d.ts +9 -4
  48. package/lib/readAndParse.d.ts.map +1 -1
  49. package/lib/readAndParse.js +9 -4
  50. package/lib/readAndParse.js.map +1 -1
  51. package/lib/runWithRetry.d.ts +9 -5
  52. package/lib/runWithRetry.d.ts.map +1 -1
  53. package/lib/runWithRetry.js.map +1 -1
  54. package/package.json +31 -17
  55. package/src/documentStorageServiceProxy.ts +8 -2
  56. package/src/messageRecognition.ts +48 -23
  57. package/src/network.ts +16 -0
  58. package/src/packageVersion.ts +1 -1
  59. package/src/parallelRequests.ts +1 -1
  60. package/src/readAndParse.ts +9 -4
  61. 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
- * @param message-message
10
- * @returns whether or not the message type is one listed below
11
- * "op"
12
- * "summarize"
13
- * "propose"
14
- * "reject"
15
- * "noop"
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
- * @param message-message
34
- * @returns whether or not the message type is one listed below
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: ISequencedDocumentMessage | IDocumentMessage): boolean {
39
- return message.type === MessageType.Operation || message.type === MessageType.Summarize;
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
- * @param message-message
55
- * @returns whether or not the message type is one listed below (legacy)
56
- * "component"
57
- * "attach"
58
- * "chunkedOp"
59
- * "blobAttach"
60
- * "rejoin"
61
- * "alias"
62
- * "op"
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,
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/driver-utils";
9
- export const pkgVersion = "1.3.0";
9
+ export const pkgVersion = "2.0.0-dev.1.4.5.105745";
@@ -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 - ending point of fetching data. exclusive, or undefined if unknown
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
@@ -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 JSON.parse it into object of type T
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 - the IDocumentStorageService to read from
13
- * @param id - the id of the blob to read and parse
14
- * @returns the object that we decoded and JSON.parse
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);
@@ -16,14 +16,18 @@ import { NonRetryableError } from ".";
16
16
  */
17
17
  export interface IProgress {
18
18
  /**
19
- * Abort signal used to cancel operation
20
- * Note that most of the layers do not use this signal yet. We need to change that over time.
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
- * Layers in question are:
25
- * - driver (RateLimiter)
26
- * - runWithRetry
25
+ *
26
+ * The layers in question are:
27
+ *
28
+ * - driver (RateLimiter)
29
+ *
30
+ * - runWithRetry
27
31
  */
28
32
  cancel?: AbortSignal;
29
33