@fluidframework/container-loader 2.0.0-internal.6.4.0 → 2.0.0-internal.7.1.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.
Files changed (126) hide show
  1. package/CHANGELOG.md +118 -0
  2. package/api-extractor.json +9 -1
  3. package/api-report/container-loader.api.md +142 -0
  4. package/dist/catchUpMonitor.d.ts +2 -2
  5. package/dist/catchUpMonitor.d.ts.map +1 -1
  6. package/dist/connectionManager.d.ts +1 -0
  7. package/dist/connectionManager.d.ts.map +1 -1
  8. package/dist/connectionManager.js +109 -83
  9. package/dist/connectionManager.js.map +1 -1
  10. package/dist/connectionState.js +1 -1
  11. package/dist/connectionState.js.map +1 -1
  12. package/dist/connectionStateHandler.js +9 -9
  13. package/dist/connectionStateHandler.js.map +1 -1
  14. package/dist/container-loader-alpha.d.ts +297 -0
  15. package/dist/container-loader-beta.d.ts +297 -0
  16. package/dist/container-loader-public.d.ts +297 -0
  17. package/dist/container-loader.d.ts +297 -0
  18. package/dist/container.d.ts +6 -1
  19. package/dist/container.d.ts.map +1 -1
  20. package/dist/container.js +215 -215
  21. package/dist/container.js.map +1 -1
  22. package/dist/containerContext.js +16 -16
  23. package/dist/containerContext.js.map +1 -1
  24. package/dist/containerStorageAdapter.d.ts.map +1 -1
  25. package/dist/containerStorageAdapter.js +6 -8
  26. package/dist/containerStorageAdapter.js.map +1 -1
  27. package/dist/contracts.d.ts +5 -4
  28. package/dist/contracts.d.ts.map +1 -1
  29. package/dist/contracts.js +1 -1
  30. package/dist/contracts.js.map +1 -1
  31. package/dist/debugLogger.d.ts.map +1 -1
  32. package/dist/debugLogger.js +4 -4
  33. package/dist/debugLogger.js.map +1 -1
  34. package/dist/deltaManager.d.ts.map +1 -1
  35. package/dist/deltaManager.js +90 -89
  36. package/dist/deltaManager.js.map +1 -1
  37. package/dist/deltaQueue.js +14 -14
  38. package/dist/deltaQueue.js.map +1 -1
  39. package/dist/index.d.ts +1 -0
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +4 -1
  42. package/dist/index.js.map +1 -1
  43. package/dist/loader.d.ts +3 -6
  44. package/dist/loader.d.ts.map +1 -1
  45. package/dist/loader.js +20 -85
  46. package/dist/loader.js.map +1 -1
  47. package/dist/location-redirection-utilities/index.d.ts +6 -0
  48. package/dist/location-redirection-utilities/index.d.ts.map +1 -0
  49. package/dist/location-redirection-utilities/index.js +11 -0
  50. package/dist/location-redirection-utilities/index.js.map +1 -0
  51. package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts +22 -0
  52. package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -0
  53. package/dist/location-redirection-utilities/resolveWithLocationRedirection.js +51 -0
  54. package/dist/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -0
  55. package/dist/packageVersion.d.ts +1 -1
  56. package/dist/packageVersion.js +1 -1
  57. package/dist/packageVersion.js.map +1 -1
  58. package/dist/protocol.d.ts +1 -2
  59. package/dist/protocol.d.ts.map +1 -1
  60. package/dist/protocol.js +3 -5
  61. package/dist/protocol.js.map +1 -1
  62. package/dist/tsdoc-metadata.json +1 -1
  63. package/lib/catchUpMonitor.d.ts +2 -2
  64. package/lib/catchUpMonitor.d.ts.map +1 -1
  65. package/lib/connectionManager.d.ts +1 -0
  66. package/lib/connectionManager.d.ts.map +1 -1
  67. package/lib/connectionManager.js +112 -84
  68. package/lib/connectionManager.js.map +1 -1
  69. package/lib/connectionStateHandler.js +9 -9
  70. package/lib/connectionStateHandler.js.map +1 -1
  71. package/lib/container.d.ts +6 -1
  72. package/lib/container.d.ts.map +1 -1
  73. package/lib/container.js +216 -216
  74. package/lib/container.js.map +1 -1
  75. package/lib/containerContext.js +16 -16
  76. package/lib/containerContext.js.map +1 -1
  77. package/lib/containerStorageAdapter.d.ts.map +1 -1
  78. package/lib/containerStorageAdapter.js +6 -8
  79. package/lib/containerStorageAdapter.js.map +1 -1
  80. package/lib/contracts.d.ts +5 -4
  81. package/lib/contracts.d.ts.map +1 -1
  82. package/lib/contracts.js.map +1 -1
  83. package/lib/debugLogger.d.ts.map +1 -1
  84. package/lib/debugLogger.js +4 -4
  85. package/lib/debugLogger.js.map +1 -1
  86. package/lib/deltaManager.d.ts.map +1 -1
  87. package/lib/deltaManager.js +90 -89
  88. package/lib/deltaManager.js.map +1 -1
  89. package/lib/deltaQueue.js +14 -14
  90. package/lib/deltaQueue.js.map +1 -1
  91. package/lib/index.d.ts +1 -0
  92. package/lib/index.d.ts.map +1 -1
  93. package/lib/index.js +1 -0
  94. package/lib/index.js.map +1 -1
  95. package/lib/loader.d.ts +3 -6
  96. package/lib/loader.d.ts.map +1 -1
  97. package/lib/loader.js +20 -85
  98. package/lib/loader.js.map +1 -1
  99. package/lib/location-redirection-utilities/index.d.ts +6 -0
  100. package/lib/location-redirection-utilities/index.d.ts.map +1 -0
  101. package/lib/location-redirection-utilities/index.js +6 -0
  102. package/lib/location-redirection-utilities/index.js.map +1 -0
  103. package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts +22 -0
  104. package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -0
  105. package/lib/location-redirection-utilities/resolveWithLocationRedirection.js +46 -0
  106. package/lib/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -0
  107. package/lib/packageVersion.d.ts +1 -1
  108. package/lib/packageVersion.js +1 -1
  109. package/lib/packageVersion.js.map +1 -1
  110. package/lib/protocol.d.ts +1 -2
  111. package/lib/protocol.d.ts.map +1 -1
  112. package/lib/protocol.js +1 -3
  113. package/lib/protocol.js.map +1 -1
  114. package/package.json +23 -24
  115. package/src/connectionManager.ts +57 -16
  116. package/src/container.ts +15 -15
  117. package/src/containerStorageAdapter.ts +0 -6
  118. package/src/contracts.ts +8 -4
  119. package/src/debugLogger.ts +4 -1
  120. package/src/deltaManager.ts +11 -9
  121. package/src/index.ts +4 -0
  122. package/src/loader.ts +24 -92
  123. package/src/location-redirection-utilities/index.ts +9 -0
  124. package/src/location-redirection-utilities/resolveWithLocationRedirection.ts +59 -0
  125. package/src/packageVersion.ts +1 -1
  126. package/src/protocol.ts +2 -6
@@ -0,0 +1,9 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ export {
7
+ isLocationRedirectionError,
8
+ resolveWithLocationRedirectionHandling,
9
+ } from "./resolveWithLocationRedirection";
@@ -0,0 +1,59 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { ITelemetryBaseLogger, IRequest } from "@fluidframework/core-interfaces";
7
+ import {
8
+ DriverErrorTypes,
9
+ ILocationRedirectionError,
10
+ IUrlResolver,
11
+ } from "@fluidframework/driver-definitions";
12
+ import { createChildLogger } from "@fluidframework/telemetry-utils";
13
+
14
+ /**
15
+ * Checks if the error is location redirection error.
16
+ * @param error - error whose type is to be determined.
17
+ * @returns `true` is the error is location redirection error, otherwise `false`.
18
+ */
19
+ export function isLocationRedirectionError(error: any): error is ILocationRedirectionError {
20
+ return (
21
+ typeof error === "object" &&
22
+ error !== null &&
23
+ error.errorType === DriverErrorTypes.locationRedirection
24
+ );
25
+ }
26
+
27
+ /**
28
+ * Handles location redirection while fulfilling the loader request.
29
+ * @param api - Callback in which user can wrap the loader.resolve or loader.request call.
30
+ * @param request - request to be resolved.
31
+ * @param urlResolver - resolver used to resolve the url.
32
+ * @param logger - logger to send events.
33
+ * @returns Response from the API call.
34
+ */
35
+ export async function resolveWithLocationRedirectionHandling<T>(
36
+ api: (request: IRequest) => Promise<T>,
37
+ request: IRequest,
38
+ urlResolver: IUrlResolver,
39
+ logger?: ITelemetryBaseLogger,
40
+ ): Promise<T> {
41
+ let req: IRequest = request;
42
+ const childLogger = createChildLogger({ logger, namespace: "LocationRedirection" });
43
+ for (;;) {
44
+ try {
45
+ return await api(req);
46
+ } catch (error: any) {
47
+ if (!isLocationRedirectionError(error)) {
48
+ throw error;
49
+ }
50
+ childLogger.sendTelemetryEvent({ eventName: "LocationRedirectionError" });
51
+ const resolvedUrl = error.redirectUrl;
52
+ // Generate the new request with new location details from the resolved url. For datastore/relative path,
53
+ // we don't need to pass "/" as host could have asked for a specific data store. So driver need to
54
+ // extract it from the resolved url.
55
+ const absoluteUrl = await urlResolver.getAbsoluteUrl(resolvedUrl, "", undefined);
56
+ req = { url: absoluteUrl, headers: req.headers };
57
+ }
58
+ }
59
+ }
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/container-loader";
9
- export const pkgVersion = "2.0.0-internal.6.4.0";
9
+ export const pkgVersion = "2.0.0-internal.7.1.0";
package/src/protocol.ts CHANGED
@@ -13,16 +13,12 @@ import {
13
13
  import {
14
14
  IDocumentAttributes,
15
15
  IProcessMessageResult,
16
- ISequencedClient,
17
16
  ISequencedDocumentMessage,
18
17
  ISignalClient,
19
18
  ISignalMessage,
20
19
  MessageType,
21
20
  } from "@fluidframework/protocol-definitions";
22
21
 
23
- // "term" was an experimental feature that is being removed. The only safe value to use is 1.
24
- export const OnlyValidTermValue = 1 as const;
25
-
26
22
  // ADO: #1986: Start using enum from protocol-base.
27
23
  export enum SignalType {
28
24
  ClientJoin = "join", // same value as MessageType.ClientJoin,
@@ -75,11 +71,11 @@ export class ProtocolHandler extends ProtocolOpHandler implements IProtocolHandl
75
71
  message: ISequencedDocumentMessage,
76
72
  local: boolean,
77
73
  ): IProcessMessageResult {
78
- const client: ISequencedClient | undefined = this.quorum.getMember(message.clientId);
79
-
80
74
  // Check and report if we're getting messages from a clientId that we previously
81
75
  // flagged as shouldHaveLeft, or from a client that's not in the quorum but should be
82
76
  if (message.clientId != null) {
77
+ const client = this.quorum.getMember(message.clientId);
78
+
83
79
  if (client === undefined && message.type !== MessageType.ClientJoin) {
84
80
  // pre-0.58 error message: messageClientIdMissingFromQuorum
85
81
  throw new Error("Remote message's clientId is missing from the quorum");