@fluidframework/container-loader 0.59.2000 → 0.59.3000-67119

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 (94) hide show
  1. package/.eslintrc.js +0 -1
  2. package/README.md +4 -4
  3. package/dist/collabWindowTracker.js +5 -5
  4. package/dist/collabWindowTracker.js.map +1 -1
  5. package/dist/connectionManager.d.ts.map +1 -1
  6. package/dist/connectionManager.js +32 -32
  7. package/dist/connectionManager.js.map +1 -1
  8. package/dist/connectionStateHandler.d.ts.map +1 -1
  9. package/dist/connectionStateHandler.js +10 -10
  10. package/dist/connectionStateHandler.js.map +1 -1
  11. package/dist/container.d.ts +2 -1
  12. package/dist/container.d.ts.map +1 -1
  13. package/dist/container.js +76 -71
  14. package/dist/container.js.map +1 -1
  15. package/dist/containerContext.js +2 -2
  16. package/dist/containerContext.js.map +1 -1
  17. package/dist/containerStorageAdapter.d.ts.map +1 -1
  18. package/dist/containerStorageAdapter.js.map +1 -1
  19. package/dist/contracts.js +1 -1
  20. package/dist/contracts.js.map +1 -1
  21. package/dist/deltaManager.d.ts.map +1 -1
  22. package/dist/deltaManager.js +27 -27
  23. package/dist/deltaManager.js.map +1 -1
  24. package/dist/deltaQueue.d.ts.map +1 -1
  25. package/dist/deltaQueue.js +1 -1
  26. package/dist/deltaQueue.js.map +1 -1
  27. package/dist/loader.d.ts +2 -0
  28. package/dist/loader.d.ts.map +1 -1
  29. package/dist/loader.js +9 -9
  30. package/dist/loader.js.map +1 -1
  31. package/dist/packageVersion.d.ts +1 -1
  32. package/dist/packageVersion.d.ts.map +1 -1
  33. package/dist/packageVersion.js +1 -1
  34. package/dist/packageVersion.js.map +1 -1
  35. package/dist/protocolTreeDocumentStorageService.d.ts +2 -2
  36. package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
  37. package/dist/protocolTreeDocumentStorageService.js +1 -1
  38. package/dist/protocolTreeDocumentStorageService.js.map +1 -1
  39. package/dist/quorum.d.ts +4 -1
  40. package/dist/quorum.d.ts.map +1 -1
  41. package/dist/quorum.js +25 -6
  42. package/dist/quorum.js.map +1 -1
  43. package/dist/retriableDocumentStorageService.js +2 -2
  44. package/dist/retriableDocumentStorageService.js.map +1 -1
  45. package/dist/utils.d.ts +1 -0
  46. package/dist/utils.d.ts.map +1 -1
  47. package/dist/utils.js +11 -7
  48. package/dist/utils.js.map +1 -1
  49. package/lib/connectionManager.d.ts.map +1 -1
  50. package/lib/connectionManager.js.map +1 -1
  51. package/lib/connectionStateHandler.d.ts.map +1 -1
  52. package/lib/connectionStateHandler.js +3 -3
  53. package/lib/connectionStateHandler.js.map +1 -1
  54. package/lib/container.d.ts +2 -1
  55. package/lib/container.d.ts.map +1 -1
  56. package/lib/container.js +28 -23
  57. package/lib/container.js.map +1 -1
  58. package/lib/containerContext.js.map +1 -1
  59. package/lib/containerStorageAdapter.d.ts.map +1 -1
  60. package/lib/containerStorageAdapter.js.map +1 -1
  61. package/lib/contracts.js.map +1 -1
  62. package/lib/deltaManager.d.ts.map +1 -1
  63. package/lib/deltaManager.js.map +1 -1
  64. package/lib/deltaQueue.d.ts.map +1 -1
  65. package/lib/deltaQueue.js.map +1 -1
  66. package/lib/loader.d.ts +2 -0
  67. package/lib/loader.d.ts.map +1 -1
  68. package/lib/loader.js.map +1 -1
  69. package/lib/packageVersion.d.ts +1 -1
  70. package/lib/packageVersion.d.ts.map +1 -1
  71. package/lib/packageVersion.js +1 -1
  72. package/lib/packageVersion.js.map +1 -1
  73. package/lib/protocolTreeDocumentStorageService.d.ts +2 -2
  74. package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
  75. package/lib/quorum.d.ts +4 -1
  76. package/lib/quorum.d.ts.map +1 -1
  77. package/lib/quorum.js +18 -1
  78. package/lib/quorum.js.map +1 -1
  79. package/lib/utils.d.ts +1 -0
  80. package/lib/utils.d.ts.map +1 -1
  81. package/lib/utils.js +3 -0
  82. package/lib/utils.js.map +1 -1
  83. package/package.json +12 -11
  84. package/src/connectionManager.ts +2 -3
  85. package/src/connectionStateHandler.ts +11 -8
  86. package/src/container.ts +55 -49
  87. package/src/containerStorageAdapter.ts +4 -4
  88. package/src/contracts.ts +8 -8
  89. package/src/deltaManager.ts +5 -8
  90. package/src/deltaQueue.ts +2 -4
  91. package/src/loader.ts +5 -3
  92. package/src/packageVersion.ts +1 -1
  93. package/src/quorum.ts +26 -1
  94. package/src/utils.ts +6 -2
package/dist/container.js CHANGED
@@ -60,26 +60,36 @@ var ConnectionState;
60
60
  * @returns true: container is up to date, it processed all the ops that were know at the time of first connection
61
61
  * false: storage does not provide indication of how far the client is. Container processed
62
62
  * all the ops known to it, but it maybe still behind.
63
+ * @throws an error beginning with `"Container closed"` if the container is closed before it catches up.
63
64
  */
64
65
  async function waitContainerToCatchUp(container) {
65
66
  // Make sure we stop waiting if container is closed.
66
67
  if (container.closed) {
67
- throw new Error("Container is closed");
68
+ throw new container_utils_1.UsageError("waitContainerToCatchUp: Container closed");
68
69
  }
69
70
  return new Promise((resolve, reject) => {
70
71
  const deltaManager = container.deltaManager;
71
- container.on("closed", reject);
72
+ const closedCallback = (err) => {
73
+ container.off("closed", closedCallback);
74
+ const baseMessage = "Container closed while waiting to catch up";
75
+ reject(err !== undefined
76
+ ? (0, telemetry_utils_1.wrapError)(err, (innerMessage) => new container_utils_1.GenericError(`${baseMessage}: ${innerMessage}`))
77
+ : new container_utils_1.GenericError(baseMessage));
78
+ };
79
+ container.on("closed", closedCallback);
72
80
  const waitForOps = () => {
73
- common_utils_1.assert(container.connectionState !== ConnectionState.Disconnected, 0x0cd /* "Container disconnected while waiting for ops!" */);
81
+ (0, common_utils_1.assert)(container.connectionState !== ConnectionState.Disconnected, 0x0cd /* "Container disconnected while waiting for ops!" */);
74
82
  const hasCheckpointSequenceNumber = deltaManager.hasCheckpointSequenceNumber;
75
83
  const connectionOpSeqNumber = deltaManager.lastKnownSeqNumber;
76
- common_utils_1.assert(deltaManager.lastSequenceNumber <= connectionOpSeqNumber, 0x266 /* "lastKnownSeqNumber should never be below last processed sequence number" */);
84
+ (0, common_utils_1.assert)(deltaManager.lastSequenceNumber <= connectionOpSeqNumber, 0x266 /* "lastKnownSeqNumber should never be below last processed sequence number" */);
77
85
  if (deltaManager.lastSequenceNumber === connectionOpSeqNumber) {
86
+ container.off("closed", closedCallback);
78
87
  resolve(hasCheckpointSequenceNumber);
79
88
  return;
80
89
  }
81
90
  const callbackOps = (message) => {
82
91
  if (connectionOpSeqNumber <= message.sequenceNumber) {
92
+ container.off("closed", closedCallback);
83
93
  resolve(hasCheckpointSequenceNumber);
84
94
  deltaManager.off("op", callbackOps);
85
95
  }
@@ -147,7 +157,7 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
147
157
  this.subLogger = telemetry_utils_1.ChildLogger.create(loader.services.subLogger, undefined, {
148
158
  all: {
149
159
  clientType,
150
- containerId: uuid_1.v4(),
160
+ containerId: (0, uuid_1.v4)(),
151
161
  docId: () => { var _a, _b; return (_b = (_a = this._resolvedUrl) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : undefined; },
152
162
  containerAttachState: () => this._attachState,
153
163
  containerLifecycleState: () => this._lifecycleState,
@@ -171,7 +181,7 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
171
181
  },
172
182
  });
173
183
  // Prefix all events in this file with container-loader
174
- this.mc = telemetry_utils_1.loggerToMonitoringContext(telemetry_utils_1.ChildLogger.create(this.subLogger, "Container"));
184
+ this.mc = (0, telemetry_utils_1.loggerToMonitoringContext)(telemetry_utils_1.ChildLogger.create(this.subLogger, "Container"));
175
185
  const summarizeProtocolTree = (_c = this.mc.config.getBoolean("Fluid.Container.summarizeProtocolTree")) !== null && _c !== void 0 ? _c : this.loader.services.options.summarizeProtocolTree;
176
186
  this.options = Object.assign(Object.assign({}, this.loader.services.options), { summarizeProtocolTree });
177
187
  this.connectionStateHandler = new connectionStateHandler_1.ConnectionStateHandler({
@@ -278,7 +288,7 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
278
288
  // always load unpaused with pending ops!
279
289
  // It is also default mode in general.
280
290
  const defaultMode = { opsBeforeReturn: "cached" };
281
- common_utils_1.assert(pendingLocalState === undefined || loadOptions.loadMode === undefined, 0x1e1 /* "pending state requires immediate connection!" */);
291
+ (0, common_utils_1.assert)(pendingLocalState === undefined || loadOptions.loadMode === undefined, 0x1e1 /* "pending state requires immediate connection!" */);
282
292
  const mode = (_a = loadOptions.loadMode) !== null && _a !== void 0 ? _a : defaultMode;
283
293
  const onClosed = (err) => {
284
294
  // pre-0.58 error message: containerClosedWithoutErrorDuringLoad
@@ -293,7 +303,7 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
293
303
  event.end(Object.assign(Object.assign({}, props), loadOptions.loadMode));
294
304
  resolve(container);
295
305
  }, (error) => {
296
- const err = telemetry_utils_1.normalizeError(error);
306
+ const err = (0, telemetry_utils_1.normalizeError)(error);
297
307
  // Depending where error happens, we can be attempting to connect to web socket
298
308
  // and continuously retrying (consider offline mode)
299
309
  // Host has no container to close, so it's prudent to do it here
@@ -330,8 +340,8 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
330
340
  return (this._lifecycleState !== "created" && this._lifecycleState !== "loading");
331
341
  }
332
342
  set loaded(t) {
333
- common_utils_1.assert(t, 0x27d /* "Setting loaded state to false is not supported" */);
334
- common_utils_1.assert(this._lifecycleState !== "created", 0x27e /* "Must go through loading state before loaded" */);
343
+ (0, common_utils_1.assert)(t, 0x27d /* "Setting loaded state to false is not supported" */);
344
+ (0, common_utils_1.assert)(this._lifecycleState !== "created", 0x27e /* "Must go through loading state before loaded" */);
335
345
  // It's conceivable the container could be closed when this is called
336
346
  // Only transition states if currently loading
337
347
  if (this._lifecycleState === "loading") {
@@ -468,7 +478,7 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
468
478
  (_a = this._protocolHandler) === null || _a === void 0 ? void 0 : _a.close();
469
479
  this.connectionStateHandler.dispose();
470
480
  (_b = this._context) === null || _b === void 0 ? void 0 : _b.dispose(error !== undefined ? new Error(error.message) : undefined);
471
- common_utils_1.assert(this.connectionState === ConnectionState.Disconnected, 0x0cf /* "disconnect event was not raised!" */);
481
+ (0, common_utils_1.assert)(this.connectionState === ConnectionState.Disconnected, 0x0cf /* "disconnect event was not raised!" */);
472
482
  (_c = this._storageService) === null || _c === void 0 ? void 0 : _c.dispose();
473
483
  // Notify storage about critical errors. They may be due to disconnect between client & server knowledge
474
484
  // about file, like file being overwritten in storage, but client having stale local cache.
@@ -496,8 +506,8 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
496
506
  // runtime matches pending ops to successful ones by clientId and client seq num, so we need to close the
497
507
  // container at the same time we get pending state, otherwise this container could reconnect and resubmit with
498
508
  // a new clientId and a future container using stale pending state without the new clientId would resubmit them
499
- common_utils_1.assert(this.attachState === container_definitions_1.AttachState.Attached, 0x0d1 /* "Container should be attached before close" */);
500
- common_utils_1.assert(this.resolvedUrl !== undefined && this.resolvedUrl.type === "fluid", 0x0d2 /* "resolved url should be valid Fluid url" */);
509
+ (0, common_utils_1.assert)(this.attachState === container_definitions_1.AttachState.Attached, 0x0d1 /* "Container should be attached before close" */);
510
+ (0, common_utils_1.assert)(this.resolvedUrl !== undefined && this.resolvedUrl.type === "fluid", 0x0d2 /* "resolved url should be valid Fluid url" */);
501
511
  const pendingState = {
502
512
  pendingRuntimeState: this.context.getPendingLocalState(),
503
513
  url: this.resolvedUrl.url,
@@ -509,10 +519,10 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
509
519
  return this._attachState;
510
520
  }
511
521
  serialize() {
512
- common_utils_1.assert(this.attachState === container_definitions_1.AttachState.Detached, 0x0d3 /* "Should only be called in detached container" */);
522
+ (0, common_utils_1.assert)(this.attachState === container_definitions_1.AttachState.Detached, 0x0d3 /* "Should only be called in detached container" */);
513
523
  const appSummary = this.context.createSummary();
514
524
  const protocolSummary = this.captureProtocolSummary();
515
- const combinedSummary = driver_utils_1.combineAppAndProtocolSummary(appSummary, protocolSummary);
525
+ const combinedSummary = (0, driver_utils_1.combineAppAndProtocolSummary)(appSummary, protocolSummary);
516
526
  if (this.loader.services.detachedBlobStorage && this.loader.services.detachedBlobStorage.size > 0) {
517
527
  combinedSummary.tree[".hasAttachmentBlobs"] = { type: protocol_definitions_1.SummaryType.Blob, content: "true" };
518
528
  }
@@ -525,20 +535,20 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
525
535
  throw new container_utils_1.UsageError(`The Container is not in a valid state for attach [${this._lifecycleState}]`);
526
536
  }
527
537
  // If container is already attached or attach is in progress, throw an error.
528
- common_utils_1.assert(this._attachState === container_definitions_1.AttachState.Detached && !this.attachStarted, 0x205 /* "attach() called more than once" */);
538
+ (0, common_utils_1.assert)(this._attachState === container_definitions_1.AttachState.Detached && !this.attachStarted, 0x205 /* "attach() called more than once" */);
529
539
  this.attachStarted = true;
530
540
  // If attachment blobs were uploaded in detached state we will go through a different attach flow
531
541
  const hasAttachmentBlobs = this.loader.services.detachedBlobStorage !== undefined
532
542
  && this.loader.services.detachedBlobStorage.size > 0;
533
543
  try {
534
- common_utils_1.assert(this.deltaManager.inbound.length === 0, 0x0d6 /* "Inbound queue should be empty when attaching" */);
544
+ (0, common_utils_1.assert)(this.deltaManager.inbound.length === 0, 0x0d6 /* "Inbound queue should be empty when attaching" */);
535
545
  let summary;
536
546
  if (!hasAttachmentBlobs) {
537
547
  // Get the document state post attach - possibly can just call attach but we need to change the
538
548
  // semantics around what the attach means as far as async code goes.
539
549
  const appSummary = this.context.createSummary();
540
550
  const protocolSummary = this.captureProtocolSummary();
541
- summary = driver_utils_1.combineAppAndProtocolSummary(appSummary, protocolSummary);
551
+ summary = (0, driver_utils_1.combineAppAndProtocolSummary)(appSummary, protocolSummary);
542
552
  // Set the state as attaching as we are starting the process of attaching container.
543
553
  // This should be fired after taking the summary because it is the place where we are
544
554
  // starting to attach the container to storage.
@@ -548,20 +558,20 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
548
558
  }
549
559
  // Actually go and create the resolved document
550
560
  const createNewResolvedUrl = await this.urlResolver.resolve(request);
551
- driver_utils_1.ensureFluidResolvedUrl(createNewResolvedUrl);
561
+ (0, driver_utils_1.ensureFluidResolvedUrl)(createNewResolvedUrl);
552
562
  if (this.service === undefined) {
553
- common_utils_1.assert(this.client.details.type !== summarizerClientType, 0x2c4 /* "client should not be summarizer before container is created" */);
554
- this.service = await driver_utils_1.runWithRetry(async () => this.serviceFactory.createContainer(summary, createNewResolvedUrl, this.subLogger, false), "containerAttach", this.mc.logger, {
563
+ (0, common_utils_1.assert)(this.client.details.type !== summarizerClientType, 0x2c4 /* "client should not be summarizer before container is created" */);
564
+ this.service = await (0, driver_utils_1.runWithRetry)(async () => this.serviceFactory.createContainer(summary, createNewResolvedUrl, this.subLogger, false), "containerAttach", this.mc.logger, {
555
565
  cancel: this.closeSignal,
556
566
  });
557
567
  }
558
568
  const resolvedUrl = this.service.resolvedUrl;
559
- driver_utils_1.ensureFluidResolvedUrl(resolvedUrl);
569
+ (0, driver_utils_1.ensureFluidResolvedUrl)(resolvedUrl);
560
570
  this._resolvedUrl = resolvedUrl;
561
571
  await this.connectStorageService();
562
572
  if (hasAttachmentBlobs) {
563
573
  // upload blobs to storage
564
- common_utils_1.assert(!!this.loader.services.detachedBlobStorage, 0x24e /* "assertion for type narrowing" */);
574
+ (0, common_utils_1.assert)(!!this.loader.services.detachedBlobStorage, 0x24e /* "assertion for type narrowing" */);
565
575
  // build a table mapping IDs assigned locally to IDs assigned by storage and pass it to runtime to
566
576
  // support blob handles that only know about the local IDs
567
577
  const redirectTable = new Map();
@@ -577,7 +587,7 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
577
587
  // take summary and upload
578
588
  const appSummary = this.context.createSummary(redirectTable);
579
589
  const protocolSummary = this.captureProtocolSummary();
580
- summary = driver_utils_1.combineAppAndProtocolSummary(appSummary, protocolSummary);
590
+ summary = (0, driver_utils_1.combineAppAndProtocolSummary)(appSummary, protocolSummary);
581
591
  this._attachState = container_definitions_1.AttachState.Attaching;
582
592
  this.context.notifyAttaching();
583
593
  await this.storageService.uploadSummaryWithContext(summary, {
@@ -596,9 +606,9 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
596
606
  }
597
607
  catch (error) {
598
608
  // add resolved URL on error object so that host has the ability to find this document and delete it
599
- const newError = telemetry_utils_1.normalizeError(error);
609
+ const newError = (0, telemetry_utils_1.normalizeError)(error);
600
610
  const resolvedUrl = this.resolvedUrl;
601
- if (driver_utils_1.isFluidResolvedUrl(resolvedUrl)) {
611
+ if ((0, driver_utils_1.isFluidResolvedUrl)(resolvedUrl)) {
602
612
  newError.addTelemetryProperties({ resolvedUrl: resolvedUrl.url });
603
613
  }
604
614
  this.close(newError);
@@ -661,8 +671,8 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
661
671
  }
662
672
  }
663
673
  connectInternal(args) {
664
- common_utils_1.assert(!this.closed, 0x2c5 /* "Attempting to connect() a closed Container" */);
665
- common_utils_1.assert(this._attachState === container_definitions_1.AttachState.Attached, 0x2c6 /* "Attempting to connect() a container that is not attached" */);
674
+ (0, common_utils_1.assert)(!this.closed, 0x2c5 /* "Attempting to connect() a closed Container" */);
675
+ (0, common_utils_1.assert)(this._attachState === container_definitions_1.AttachState.Attached, 0x2c6 /* "Attempting to connect() a container that is not attached" */);
666
676
  // Resume processing ops and connect to delta stream
667
677
  this.resumeInternal(args);
668
678
  // Set Auto Reconnect Mode
@@ -678,7 +688,7 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
678
688
  }
679
689
  }
680
690
  disconnectInternal() {
681
- common_utils_1.assert(!this.closed, 0x2c7 /* "Attempting to disconnect() a closed Container" */);
691
+ (0, common_utils_1.assert)(!this.closed, 0x2c7 /* "Attempting to disconnect() a closed Container" */);
682
692
  // Set Auto Reconnect Mode
683
693
  const mode = contracts_1.ReconnectMode.Disabled;
684
694
  this.setAutoReconnectInternal(mode);
@@ -698,7 +708,7 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
698
708
  }
699
709
  }
700
710
  resumeInternal(args) {
701
- common_utils_1.assert(!this.closed, 0x0d9 /* "Attempting to setAutoReconnect() a closed DeltaManager" */);
711
+ (0, common_utils_1.assert)(!this.closed, 0x0d9 /* "Attempting to setAutoReconnect() a closed DeltaManager" */);
702
712
  // Resume processing ops
703
713
  if (!this.resumedOpProcessingAfterLoad) {
704
714
  this.resumedOpProcessingAfterLoad = true;
@@ -713,10 +723,10 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
713
723
  if (this.resolvedUrl === undefined) {
714
724
  return undefined;
715
725
  }
716
- return this.urlResolver.getAbsoluteUrl(this.resolvedUrl, relativeUrl, contracts_1.getPackageName((_a = this._context) === null || _a === void 0 ? void 0 : _a.codeDetails));
726
+ return this.urlResolver.getAbsoluteUrl(this.resolvedUrl, relativeUrl, (0, contracts_1.getPackageName)((_a = this._context) === null || _a === void 0 ? void 0 : _a.codeDetails));
717
727
  }
718
728
  async proposeCodeDetails(codeDetails) {
719
- if (!container_definitions_1.isFluidCodeDetails(codeDetails)) {
729
+ if (!(0, container_definitions_1.isFluidCodeDetails)(codeDetails)) {
720
730
  throw new Error("Provided codeDetails are not IFluidCodeDetails");
721
731
  }
722
732
  if (this.codeLoader.IFluidCodeDetailsComparer) {
@@ -791,7 +801,7 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
791
801
  this._attachState = container_definitions_1.AttachState.Attached;
792
802
  // Fetch specified snapshot.
793
803
  const { snapshot, versionId } = await this.fetchSnapshotTree(specifiedVersion);
794
- common_utils_1.assert(snapshot !== undefined, 0x237 /* "Snapshot should exist" */);
804
+ (0, common_utils_1.assert)(snapshot !== undefined, 0x237 /* "Snapshot should exist" */);
795
805
  const attributes = await this.getDocumentAttributes(this.storageService, snapshot);
796
806
  let opsBeforeReturnP;
797
807
  // Attach op handlers to finish initialization and be able to start processing ops
@@ -809,12 +819,12 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
809
819
  opsBeforeReturnP = this.attachDeltaManagerOpHandler(attributes, "all");
810
820
  break;
811
821
  default:
812
- common_utils_1.unreachableCase(loadMode.opsBeforeReturn);
822
+ (0, common_utils_1.unreachableCase)(loadMode.opsBeforeReturn);
813
823
  }
814
824
  // ...load in the existing quorum
815
825
  // Initialize the protocol handler
816
826
  this._protocolHandler =
817
- await this.loadAndInitializeProtocolState(attributes, this.storageService, snapshot);
827
+ await this.initializeProtocolStateFromSnapshot(attributes, this.storageService, snapshot);
818
828
  const codeDetails = this.getCodeDetailsFromQuorum();
819
829
  await this.instantiateContext(true, // existing
820
830
  codeDetails, snapshot, pendingLocalState);
@@ -844,7 +854,7 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
844
854
  case "none":
845
855
  break;
846
856
  default:
847
- common_utils_1.unreachableCase(loadMode.deltaConnection);
857
+ (0, common_utils_1.unreachableCase)(loadMode.deltaConnection);
848
858
  }
849
859
  }
850
860
  // Safety net: static version of Container.load() should have learned about it through "closed" handler.
@@ -866,20 +876,12 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
866
876
  term: 1,
867
877
  minimumSequenceNumber: 0,
868
878
  };
869
- // Seed the base quorum to be an empty list with a code quorum set
870
- const committedCodeProposal = {
871
- key: "code",
872
- value: source,
873
- approvalSequenceNumber: 0,
874
- commitSequenceNumber: 0,
875
- sequenceNumber: 0,
876
- };
877
- const members = [];
878
- const proposals = [];
879
- const values = [["code", committedCodeProposal]];
880
879
  await this.attachDeltaManagerOpHandler(attributes);
881
880
  // Need to just seed the source data in the code quorum. Quorum itself is empty
882
- this._protocolHandler = await this.initializeProtocolState(attributes, members, proposals, values);
881
+ const qValues = (0, quorum_1.initQuorumValuesFromCodeDetails)(source);
882
+ this._protocolHandler = await this.initializeProtocolState(attributes, [], // members
883
+ [], // proposals
884
+ qValues);
883
885
  // The load context - given we seeded the quorum - will be great
884
886
  await this.instantiateContextDetached(false);
885
887
  this.propagateConnectionState();
@@ -887,18 +889,21 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
887
889
  }
888
890
  async rehydrateDetachedFromSnapshot(detachedContainerSnapshot) {
889
891
  if (detachedContainerSnapshot.tree[".hasAttachmentBlobs"] !== undefined) {
890
- common_utils_1.assert(!!this.loader.services.detachedBlobStorage && this.loader.services.detachedBlobStorage.size > 0, 0x250 /* "serialized container with attachment blobs must be rehydrated with detached blob storage" */);
892
+ (0, common_utils_1.assert)(!!this.loader.services.detachedBlobStorage && this.loader.services.detachedBlobStorage.size > 0, 0x250 /* "serialized container with attachment blobs must be rehydrated with detached blob storage" */);
891
893
  delete detachedContainerSnapshot.tree[".hasAttachmentBlobs"];
892
894
  }
893
- const snapshotTree = utils_1.getSnapshotTreeFromSerializedContainer(detachedContainerSnapshot);
895
+ const snapshotTree = (0, utils_1.getSnapshotTreeFromSerializedContainer)(detachedContainerSnapshot);
894
896
  this._storage.loadSnapshotForRehydratingContainer(snapshotTree);
895
897
  const attributes = await this.getDocumentAttributes(this._storage, snapshotTree);
896
- common_utils_1.assert(attributes.sequenceNumber === 0, 0x0db /* "Seq number in detached container should be 0!!" */);
897
898
  await this.attachDeltaManagerOpHandler(attributes);
898
- // ...load in the existing quorum
899
899
  // Initialize the protocol handler
900
+ const baseTree = (0, utils_1.getProtocolSnapshotTree)(snapshotTree);
901
+ const qValues = await (0, driver_utils_1.readAndParse)(this._storage, baseTree.blobs.quorumValues);
902
+ const codeDetails = (0, quorum_1.getCodeDetailsFromQuorumValues)(qValues);
900
903
  this._protocolHandler =
901
- await this.loadAndInitializeProtocolState(attributes, this._storage, snapshotTree);
904
+ await this.initializeProtocolState(attributes, [], // members
905
+ [], // proposals
906
+ codeDetails !== undefined ? (0, quorum_1.initQuorumValuesFromCodeDetails)(codeDetails) : []);
902
907
  await this.instantiateContextDetached(true, // existing
903
908
  snapshotTree);
904
909
  this.loaded = true;
@@ -909,7 +914,7 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
909
914
  if (this._storageService !== undefined) {
910
915
  return;
911
916
  }
912
- common_utils_1.assert(this.service !== undefined, 0x1ef /* "services must be defined" */);
917
+ (0, common_utils_1.assert)(this.service !== undefined, 0x1ef /* "services must be defined" */);
913
918
  const storageService = await this.service.connectToStorage();
914
919
  this._storageService =
915
920
  new retriableDocumentStorageService_1.RetriableDocumentStorageService(storageService, this.mc.logger);
@@ -919,7 +924,7 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
919
924
  new protocolTreeDocumentStorageService_1.ProtocolTreeStorageService(this._storageService, () => this.captureProtocolSummary());
920
925
  }
921
926
  // ensure we did not lose that policy in the process of wrapping
922
- common_utils_1.assert(((_a = storageService.policies) === null || _a === void 0 ? void 0 : _a.minBlobSize) === ((_b = this.storageService.policies) === null || _b === void 0 ? void 0 : _b.minBlobSize), 0x0e0 /* "lost minBlobSize policy" */);
927
+ (0, common_utils_1.assert)(((_a = storageService.policies) === null || _a === void 0 ? void 0 : _a.minBlobSize) === ((_b = this.storageService.policies) === null || _b === void 0 ? void 0 : _b.minBlobSize), 0x0e0 /* "lost minBlobSize policy" */);
923
928
  }
924
929
  async getDocumentAttributes(storage, tree) {
925
930
  if (tree === undefined) {
@@ -933,23 +938,23 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
933
938
  const attributesHash = ".protocol" in tree.trees
934
939
  ? tree.trees[".protocol"].blobs.attributes
935
940
  : tree.blobs[".attributes"];
936
- const attributes = await driver_utils_1.readAndParse(storage, attributesHash);
941
+ const attributes = await (0, driver_utils_1.readAndParse)(storage, attributesHash);
937
942
  // Backward compatibility for older summaries with no term
938
943
  if (attributes.term === undefined) {
939
944
  attributes.term = 1;
940
945
  }
941
946
  return attributes;
942
947
  }
943
- async loadAndInitializeProtocolState(attributes, storage, snapshot) {
948
+ async initializeProtocolStateFromSnapshot(attributes, storage, snapshot) {
944
949
  let members = [];
945
950
  let proposals = [];
946
951
  let values = [];
947
952
  if (snapshot !== undefined) {
948
- const baseTree = ".protocol" in snapshot.trees ? snapshot.trees[".protocol"] : snapshot;
953
+ const baseTree = (0, utils_1.getProtocolSnapshotTree)(snapshot);
949
954
  [members, proposals, values] = await Promise.all([
950
- driver_utils_1.readAndParse(storage, baseTree.blobs.quorumMembers),
951
- driver_utils_1.readAndParse(storage, baseTree.blobs.quorumProposals),
952
- driver_utils_1.readAndParse(storage, baseTree.blobs.quorumValues),
955
+ (0, driver_utils_1.readAndParse)(storage, baseTree.blobs.quorumMembers),
956
+ (0, driver_utils_1.readAndParse)(storage, baseTree.blobs.quorumProposals),
957
+ (0, driver_utils_1.readAndParse)(storage, baseTree.blobs.quorumValues),
953
958
  ]);
954
959
  }
955
960
  const protocolHandler = await this.initializeProtocolState(attributes, members, proposals, values);
@@ -975,13 +980,13 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
975
980
  });
976
981
  protocol.quorum.on("approveProposal", (sequenceNumber, key, value) => {
977
982
  if (key === "code" || key === "code2") {
978
- if (!container_definitions_1.isFluidCodeDetails(value)) {
983
+ if (!(0, container_definitions_1.isFluidCodeDetails)(value)) {
979
984
  this.mc.logger.sendErrorEvent({
980
985
  eventName: "CodeProposalNotIFluidCodeDetails",
981
986
  });
982
987
  }
983
988
  this.processCodeProposal().catch((error) => {
984
- this.close(telemetry_utils_1.normalizeError(error));
989
+ this.close((0, telemetry_utils_1.normalizeError)(error));
985
990
  throw error;
986
991
  });
987
992
  }
@@ -1038,7 +1043,7 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
1038
1043
  user: { id: "" },
1039
1044
  };
1040
1045
  if (this.clientDetailsOverride !== undefined) {
1041
- merge_1.default(client.details, this.clientDetailsOverride);
1046
+ (0, merge_1.default)(client.details, this.clientDetailsOverride);
1042
1047
  }
1043
1048
  client.details.environment = [client.details.environment, ` loaderVersion:${packageVersion_1.pkgVersion}`].join(";");
1044
1049
  return client;
@@ -1136,7 +1141,7 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
1136
1141
  durationFromDisconnected,
1137
1142
  reason,
1138
1143
  connectionInitiationReason, pendingClientId: this.connectionStateHandler.pendingClientId, clientId: this.clientId, autoReconnect,
1139
- opsBehind, online: driver_utils_1.OnlineStatus[driver_utils_1.isOnline()], lastVisible: this.lastVisible !== undefined ? common_utils_1.performance.now() - this.lastVisible : undefined, checkpointSequenceNumber }, this._deltaManager.connectionProps));
1144
+ opsBehind, online: driver_utils_1.OnlineStatus[(0, driver_utils_1.isOnline)()], lastVisible: this.lastVisible !== undefined ? common_utils_1.performance.now() - this.lastVisible : undefined, checkpointSequenceNumber }, this._deltaManager.connectionProps));
1140
1145
  if (value === ConnectionState.Connected) {
1141
1146
  this.firstConnection = false;
1142
1147
  }
@@ -1152,9 +1157,9 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
1152
1157
  if (!this.context.disposed) {
1153
1158
  this.context.setConnectionState(state, this.clientId);
1154
1159
  }
1155
- common_utils_1.assert(this.protocolHandler !== undefined, 0x0dc /* "Protocol handler should be set here" */);
1160
+ (0, common_utils_1.assert)(this.protocolHandler !== undefined, 0x0dc /* "Protocol handler should be set here" */);
1156
1161
  this.protocolHandler.quorum.setConnectionState(state, this.clientId);
1157
- telemetry_utils_1.raiseConnectedEvent(this.mc.logger, this, state, this.clientId);
1162
+ (0, telemetry_utils_1.raiseConnectedEvent)(this.mc.logger, this, state, this.clientId);
1158
1163
  if (logOpsOnReconnect) {
1159
1164
  this.mc.logger.sendTelemetryEvent({ eventName: "OpsSentOnReconnect", count: this.messageCountAfterDisconnection });
1160
1165
  }
@@ -1208,13 +1213,13 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
1208
1213
  errorMsg = "Remote message's clientId already should have left";
1209
1214
  }
1210
1215
  if (errorMsg !== undefined) {
1211
- const error = new container_utils_1.DataCorruptionError(errorMsg, container_utils_1.extractSafePropertiesFromMessage(message));
1212
- this.close(telemetry_utils_1.normalizeError(error));
1216
+ const error = new container_utils_1.DataCorruptionError(errorMsg, (0, container_utils_1.extractSafePropertiesFromMessage)(message));
1217
+ this.close((0, telemetry_utils_1.normalizeError)(error));
1213
1218
  }
1214
1219
  }
1215
1220
  const local = this.clientId === message.clientId;
1216
1221
  // Forward non system messages to the loaded runtime for processing
1217
- if (!protocol_base_1.isSystemMessage(message)) {
1222
+ if (!(0, protocol_base_1.isSystemMessage)(message)) {
1218
1223
  this.context.process(message, local, undefined);
1219
1224
  }
1220
1225
  // Allow the protocol handler to process the message
@@ -1272,7 +1277,7 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
1272
1277
  }
1273
1278
  async instantiateContext(existing, codeDetails, snapshot, pendingLocalState) {
1274
1279
  var _a;
1275
- common_utils_1.assert(((_a = this._context) === null || _a === void 0 ? void 0 : _a.disposed) !== false, 0x0dd /* "Existing context not disposed" */);
1280
+ (0, common_utils_1.assert)(((_a = this._context) === null || _a === void 0 ? void 0 : _a.disposed) !== false, 0x0dd /* "Existing context not disposed" */);
1276
1281
  // The relative loader will proxy requests to '/' to the loader itself assuming no non-cache flags
1277
1282
  // are set. Global requests will still go directly to the loader
1278
1283
  const loader = new loader_1.RelativeLoader(this, this.loader);