@fluidframework/test-runtime-utils 2.74.0-370705 → 2.80.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 (53) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/api-report/test-runtime-utils.legacy.beta.api.md +3 -3
  3. package/assertTagging.config.mjs +1 -1
  4. package/dist/assertionShortCodesMap.d.ts +12 -21
  5. package/dist/assertionShortCodesMap.d.ts.map +1 -1
  6. package/dist/assertionShortCodesMap.js +13 -22
  7. package/dist/assertionShortCodesMap.js.map +1 -1
  8. package/dist/deepFreeze.js.map +1 -1
  9. package/dist/mockDeltas.d.ts.map +1 -1
  10. package/dist/mockDeltas.js.map +1 -1
  11. package/dist/mockStorage.d.ts.map +1 -1
  12. package/dist/mockStorage.js.map +1 -1
  13. package/dist/mocks.d.ts +3 -2
  14. package/dist/mocks.d.ts.map +1 -1
  15. package/dist/mocks.js +2 -1
  16. package/dist/mocks.js.map +1 -1
  17. package/dist/mocksDataStoreContext.d.ts.map +1 -1
  18. package/dist/mocksDataStoreContext.js.map +1 -1
  19. package/dist/mocksForReconnection.d.ts.map +1 -1
  20. package/dist/mocksForReconnection.js.map +1 -1
  21. package/dist/validateAssertionError.d.ts.map +1 -1
  22. package/dist/validateAssertionError.js +4 -4
  23. package/dist/validateAssertionError.js.map +1 -1
  24. package/eslint.config.mts +30 -0
  25. package/lib/assertionShortCodesMap.d.ts +12 -21
  26. package/lib/assertionShortCodesMap.d.ts.map +1 -1
  27. package/lib/assertionShortCodesMap.js +13 -22
  28. package/lib/assertionShortCodesMap.js.map +1 -1
  29. package/lib/deepFreeze.js.map +1 -1
  30. package/lib/mockDeltas.d.ts.map +1 -1
  31. package/lib/mockDeltas.js.map +1 -1
  32. package/lib/mockStorage.d.ts.map +1 -1
  33. package/lib/mockStorage.js.map +1 -1
  34. package/lib/mocks.d.ts +3 -2
  35. package/lib/mocks.d.ts.map +1 -1
  36. package/lib/mocks.js +2 -1
  37. package/lib/mocks.js.map +1 -1
  38. package/lib/mocksDataStoreContext.d.ts.map +1 -1
  39. package/lib/mocksDataStoreContext.js.map +1 -1
  40. package/lib/mocksForReconnection.d.ts.map +1 -1
  41. package/lib/mocksForReconnection.js.map +1 -1
  42. package/lib/validateAssertionError.d.ts.map +1 -1
  43. package/lib/validateAssertionError.js +1 -1
  44. package/lib/validateAssertionError.js.map +1 -1
  45. package/package.json +25 -24
  46. package/src/assertionShortCodesMap.ts +13 -22
  47. package/src/deepFreeze.ts +1 -1
  48. package/src/mockDeltas.ts +9 -9
  49. package/src/mockStorage.ts +1 -1
  50. package/src/mocks.ts +45 -37
  51. package/src/mocksDataStoreContext.ts +5 -1
  52. package/src/mocksForReconnection.ts +7 -7
  53. package/src/validateAssertionError.ts +2 -1
package/src/mocks.ts CHANGED
@@ -106,16 +106,16 @@ export class MockDeltaConnection implements IDeltaConnection {
106
106
  this.dirtyFn();
107
107
  }
108
108
 
109
- public setConnectionState(connected: boolean) {
109
+ public setConnectionState(connected: boolean): void {
110
110
  this._connected = connected;
111
111
  this.handler?.setConnectionState(connected);
112
112
  }
113
113
 
114
- public processMessages(messageCollection: IRuntimeMessageCollection) {
114
+ public processMessages(messageCollection: IRuntimeMessageCollection): void {
115
115
  this.handler?.processMessages?.(messageCollection);
116
116
  }
117
117
 
118
- public reSubmit(content: any, localOpMetadata: unknown, squash?: boolean) {
118
+ public reSubmit(content: any, localOpMetadata: unknown, squash: boolean): void {
119
119
  this.handler?.reSubmit(content, localOpMetadata, squash);
120
120
  }
121
121
 
@@ -249,7 +249,7 @@ export class MockContainerRuntime extends TypedEventEmitter<IContainerRuntimeEve
249
249
  return deltaConnection;
250
250
  }
251
251
 
252
- public finalizeIdRange(range: IdCreationRange) {
252
+ public finalizeIdRange(range: IdCreationRange): void {
253
253
  assert(
254
254
  this.dataStoreRuntime.idCompressor !== undefined,
255
255
  "Shouldn't try to finalize IdRanges without an IdCompressor",
@@ -260,7 +260,7 @@ export class MockContainerRuntime extends TypedEventEmitter<IContainerRuntimeEve
260
260
  // This enables manual control over flush mode, allowing operations like rollback to be executed in a controlled environment.
261
261
  #manualFlushCalls: number = 0;
262
262
 
263
- public async runWithManualFlush(act: () => void | Promise<void>) {
263
+ public async runWithManualFlush(act: () => void | Promise<void>): Promise<void> {
264
264
  this.#manualFlushCalls++;
265
265
  try {
266
266
  await act();
@@ -333,7 +333,7 @@ export class MockContainerRuntime extends TypedEventEmitter<IContainerRuntimeEve
333
333
  }
334
334
 
335
335
  public dirty(): void {}
336
- public get isDirty() {
336
+ public get isDirty(): boolean {
337
337
  return this.pendingMessages.length > 0;
338
338
  }
339
339
 
@@ -341,7 +341,7 @@ export class MockContainerRuntime extends TypedEventEmitter<IContainerRuntimeEve
341
341
  * If flush mode is set to FlushMode.TurnBased, it will send all messages queued since the last time
342
342
  * this method (or `flushSomeMessages`) was called. Otherwise, calling the method does nothing.
343
343
  */
344
- public flush() {
344
+ public flush(): void {
345
345
  this.flushSomeMessages(this.outbox.length);
346
346
  }
347
347
 
@@ -393,7 +393,7 @@ export class MockContainerRuntime extends TypedEventEmitter<IContainerRuntimeEve
393
393
  *
394
394
  * The method requires `runtimeOptions.enableGroupedBatching` to be enabled.
395
395
  */
396
- public rebase() {
396
+ public rebase(): void {
397
397
  if (this.runtimeOptions.flushMode !== FlushMode.TurnBased) {
398
398
  return;
399
399
  }
@@ -426,7 +426,11 @@ export class MockContainerRuntime extends TypedEventEmitter<IContainerRuntimeEve
426
426
  if (pendingMessage.content.type === "idAllocation") {
427
427
  this.submit(pendingMessage.content, pendingMessage.localOpMetadata);
428
428
  } else {
429
- this.dataStoreRuntime.reSubmit(pendingMessage.content, pendingMessage.localOpMetadata);
429
+ this.dataStoreRuntime.reSubmit(
430
+ pendingMessage.content,
431
+ pendingMessage.localOpMetadata,
432
+ false,
433
+ );
430
434
  }
431
435
  });
432
436
  }
@@ -461,7 +465,10 @@ export class MockContainerRuntime extends TypedEventEmitter<IContainerRuntimeEve
461
465
  return undefined;
462
466
  }
463
467
 
464
- private submitInternal(message: IInternalMockRuntimeMessage, clientSequenceNumber: number) {
468
+ private submitInternal(
469
+ message: IInternalMockRuntimeMessage,
470
+ clientSequenceNumber: number,
471
+ ): void {
465
472
  // Here, we should instead push to the DeltaManager. And the DeltaManager will push things into the factory's messages
466
473
  this.deltaManager.outbound.push([
467
474
  {
@@ -475,7 +482,7 @@ export class MockContainerRuntime extends TypedEventEmitter<IContainerRuntimeEve
475
482
  this.addPendingMessage(message.content, message.localOpMetadata, clientSequenceNumber);
476
483
  }
477
484
 
478
- public process(message: ISequencedDocumentMessage) {
485
+ public process(message: ISequencedDocumentMessage): void {
479
486
  this.deltaManager.process(message);
480
487
  const [local, localOpMetadata] = this.processInternal(message);
481
488
 
@@ -497,7 +504,7 @@ export class MockContainerRuntime extends TypedEventEmitter<IContainerRuntimeEve
497
504
  content: any,
498
505
  localOpMetadata: unknown,
499
506
  clientSequenceNumber: number,
500
- ) {
507
+ ): void {
501
508
  const pendingMessage: IMockContainerRuntimePendingMessage = {
502
509
  referenceSequenceNumber: this.deltaManager.lastSequenceNumber,
503
510
  content,
@@ -521,7 +528,7 @@ export class MockContainerRuntime extends TypedEventEmitter<IContainerRuntimeEve
521
528
  return [local, localOpMetadata];
522
529
  }
523
530
 
524
- public async resolveHandle(handle: IFluidHandle) {
531
+ public async resolveHandle(handle: IFluidHandle): Promise<IResponse> {
525
532
  return this.dataStoreRuntime.resolveHandle({
526
533
  url: toFluidHandleInternal(handle).absolutePath,
527
534
  });
@@ -563,7 +570,7 @@ export class MockContainerRuntimeFactory {
563
570
  this.runtimeOptions = makeContainerRuntimeOptions(mockContainerRuntimeOptions);
564
571
  }
565
572
 
566
- public get outstandingMessageCount() {
573
+ public get outstandingMessageCount(): number {
567
574
  return this.messages.length;
568
575
  }
569
576
 
@@ -601,11 +608,11 @@ export class MockContainerRuntimeFactory {
601
608
  return containerRuntime;
602
609
  }
603
610
 
604
- public removeContainerRuntime(containerRuntime: MockContainerRuntime) {
611
+ public removeContainerRuntime(containerRuntime: MockContainerRuntime): void {
605
612
  this.runtimes.delete(containerRuntime);
606
613
  }
607
614
 
608
- public pushMessage(msg: Partial<ISequencedDocumentMessage>) {
615
+ public pushMessage(msg: Partial<ISequencedDocumentMessage>): void {
609
616
  deepFreeze(msg);
610
617
  if (
611
618
  msg.clientId &&
@@ -618,7 +625,7 @@ export class MockContainerRuntimeFactory {
618
625
  }
619
626
 
620
627
  protected lastProcessedMessage: ISequencedDocumentMessage | undefined;
621
- protected getFirstMessageToProcess() {
628
+ protected getFirstMessageToProcess(): ISequencedDocumentMessage {
622
629
  assert(this.messages.length > 0, "The message queue should not be empty");
623
630
 
624
631
  // Explicitly JSON clone the value to match the behavior of going thru the wire.
@@ -640,7 +647,7 @@ export class MockContainerRuntimeFactory {
640
647
  return message;
641
648
  }
642
649
 
643
- private processFirstMessage() {
650
+ private processFirstMessage(): void {
644
651
  const message = this.getFirstMessageToProcess();
645
652
  for (const runtime of this.runtimes) {
646
653
  runtime.process(message);
@@ -650,7 +657,7 @@ export class MockContainerRuntimeFactory {
650
657
  /**
651
658
  * Process one of the queued messages. Throws if no messages are queued.
652
659
  */
653
- public processOneMessage() {
660
+ public processOneMessage(): void {
654
661
  if (this.messages.length === 0) {
655
662
  throw new Error("Tried to process a message that did not exist");
656
663
  }
@@ -663,7 +670,7 @@ export class MockContainerRuntimeFactory {
663
670
  * Process a given number of queued messages. Throws if there are fewer messages queued than requested.
664
671
  * @param count - the number of messages to process
665
672
  */
666
- public processSomeMessages(count: number) {
673
+ public processSomeMessages(count: number): void {
667
674
  if (count > this.messages.length) {
668
675
  throw new Error("Tried to process more messages than exist");
669
676
  }
@@ -678,7 +685,7 @@ export class MockContainerRuntimeFactory {
678
685
  /**
679
686
  * Process all remaining messages in the queue.
680
687
  */
681
- public processAllMessages() {
688
+ public processAllMessages(): void {
682
689
  this.lastProcessedMessage = undefined;
683
690
  while (this.messages.length > 0) {
684
691
  this.processFirstMessage();
@@ -697,12 +704,12 @@ export class MockQuorumClients implements IQuorumClients, EventEmitter {
697
704
  this.members = new Map((members as [string, ISequencedClient][]) ?? []);
698
705
  }
699
706
 
700
- addMember(id: string, client: Partial<ISequencedClient>) {
707
+ addMember(id: string, client: Partial<ISequencedClient>): void {
701
708
  this.members.set(id, client as ISequencedClient);
702
709
  this.eventEmitter.emit("addMember", id, client);
703
710
  }
704
711
 
705
- removeMember(id: string) {
712
+ removeMember(id: string): void {
706
713
  if (this.members.delete(id)) {
707
714
  this.eventEmitter.emit("removeMember", id);
708
715
  }
@@ -848,6 +855,7 @@ const attachStatesToComparableNumbers = {
848
855
  /**
849
856
  * Mock implementation of IRuntime for testing that does nothing
850
857
  * @legacy @beta
858
+ * @sealed
851
859
  */
852
860
  export class MockFluidDataStoreRuntime
853
861
  extends EventEmitter
@@ -889,7 +897,7 @@ export class MockFluidDataStoreRuntime
889
897
  }
890
898
 
891
899
  private readonly: boolean = false;
892
- public readonly isReadOnly = () => this.readonly;
900
+ public readonly isReadOnly = (): boolean => this.readonly;
893
901
 
894
902
  public readonly entryPoint: IFluidHandleInternal<FluidObject>;
895
903
 
@@ -933,15 +941,15 @@ export class MockFluidDataStoreRuntime
933
941
 
934
942
  public createDeltaConnection(): MockDeltaConnection {
935
943
  const deltaConnection = new MockDeltaConnection(
936
- (messageContent: any, localOpMetadata: unknown) =>
944
+ (messageContent: any, localOpMetadata: unknown): number =>
937
945
  this.submitMessageInternal(messageContent, localOpMetadata),
938
- () => this.setChannelDirty(),
946
+ (): void => this.setChannelDirty(),
939
947
  );
940
948
  this.deltaConnections.push(deltaConnection);
941
949
  return deltaConnection;
942
950
  }
943
951
 
944
- public get absolutePath() {
952
+ public get absolutePath(): string {
945
953
  return `/${this.id}`;
946
954
  }
947
955
 
@@ -962,7 +970,7 @@ export class MockFluidDataStoreRuntime
962
970
 
963
971
  private _disposed = false;
964
972
 
965
- public get disposed() {
973
+ public get disposed(): boolean {
966
974
  return this._disposed;
967
975
  }
968
976
 
@@ -1028,7 +1036,7 @@ export class MockFluidDataStoreRuntime
1028
1036
  return this.audience;
1029
1037
  }
1030
1038
 
1031
- public save(message: string) {
1039
+ public save(message: string): void {
1032
1040
  return;
1033
1041
  }
1034
1042
 
@@ -1062,7 +1070,7 @@ export class MockFluidDataStoreRuntime
1062
1070
 
1063
1071
  public submitSignal: IFluidDataStoreRuntime["submitSignal"] = () => null;
1064
1072
 
1065
- public processMessages(messageCollection: IRuntimeMessageCollection) {
1073
+ public processMessages(messageCollection: IRuntimeMessageCollection): void {
1066
1074
  if (this.disposed) {
1067
1075
  return;
1068
1076
  }
@@ -1071,7 +1079,7 @@ export class MockFluidDataStoreRuntime
1071
1079
  });
1072
1080
  }
1073
1081
 
1074
- public processSignal(message: any, local: boolean) {
1082
+ public processSignal(message: any, local: boolean): void {
1075
1083
  return;
1076
1084
  }
1077
1085
 
@@ -1079,7 +1087,7 @@ export class MockFluidDataStoreRuntime
1079
1087
  return;
1080
1088
  }
1081
1089
 
1082
- public setConnectionState(connected: boolean, clientId?: string) {
1090
+ public setConnectionState(connected: boolean, clientId?: string): void {
1083
1091
  if (connected && clientId !== undefined) {
1084
1092
  this.clientId = clientId;
1085
1093
  }
@@ -1127,7 +1135,7 @@ export class MockFluidDataStoreRuntime
1127
1135
  };
1128
1136
  }
1129
1137
 
1130
- public updateUsedRoutes(usedRoutes: string[]) {}
1138
+ public updateUsedRoutes(usedRoutes: string[]): void {}
1131
1139
 
1132
1140
  public getAttachSnapshot(): ITreeEntry[] {
1133
1141
  return [];
@@ -1188,13 +1196,13 @@ export class MockFluidDataStoreRuntime
1188
1196
  return null as any as IResponse;
1189
1197
  }
1190
1198
 
1191
- public reSubmit(content: any, localOpMetadata: unknown, squash?: boolean) {
1199
+ public reSubmit(content: any, localOpMetadata: unknown, squash: boolean): void {
1192
1200
  this.deltaConnections.forEach((dc) => {
1193
1201
  dc.reSubmit(content, localOpMetadata, squash);
1194
1202
  });
1195
1203
  }
1196
1204
 
1197
- public async applyStashedOp(content: any) {
1205
+ public async applyStashedOp(content: any): Promise<unknown> {
1198
1206
  return this.deltaConnections.map((dc) => dc.applyStashedOp(content))[0];
1199
1207
  }
1200
1208
 
@@ -1212,7 +1220,7 @@ export class MockFluidDataStoreRuntime
1212
1220
  export class MockEmptyDeltaConnection implements IDeltaConnection {
1213
1221
  public connected = false;
1214
1222
 
1215
- public attach(handler) {}
1223
+ public attach(handler): void {}
1216
1224
 
1217
1225
  public submit(messageContent: any): number {
1218
1226
  assert(false, "Throw submit error on mock empty delta connection");
@@ -1263,7 +1271,7 @@ export class MockObjectStorageService implements IChannelStorageService {
1263
1271
  * @legacy @beta
1264
1272
  */
1265
1273
  export class MockSharedObjectServices implements IChannelServices {
1266
- public static createFromSummary(summaryTree: ISummaryTree) {
1274
+ public static createFromSummary(summaryTree: ISummaryTree): MockSharedObjectServices {
1267
1275
  const contents: { [key: string]: string } = {};
1268
1276
  setContentsFromSummaryTree(summaryTree, "", contents);
1269
1277
  return new MockSharedObjectServices(contents);
@@ -160,7 +160,11 @@ export class MockFluidDataStoreContext implements IFluidDataStoreContext {
160
160
  throw new Error("Method not implemented.");
161
161
  }
162
162
 
163
- public addedGCOutboundRoute(fromPath: string, toPath: string, messageTimestampMs?: number) {
163
+ public addedGCOutboundRoute(
164
+ fromPath: string,
165
+ toPath: string,
166
+ messageTimestampMs?: number,
167
+ ): void {
164
168
  throw new Error("Method not implemented.");
165
169
  }
166
170
  }
@@ -42,7 +42,7 @@ export class MockContainerRuntimeForReconnection extends MockContainerRuntime {
42
42
  this.setConnectedState(connected);
43
43
  }
44
44
 
45
- protected processPendingMessages(pendingMessages: ISequencedDocumentMessage[]) {
45
+ protected processPendingMessages(pendingMessages: ISequencedDocumentMessage[]): void {
46
46
  for (const remoteMessage of pendingMessages) {
47
47
  this.process(remoteMessage);
48
48
  }
@@ -101,7 +101,7 @@ export class MockContainerRuntimeForReconnection extends MockContainerRuntime {
101
101
  }
102
102
  }
103
103
 
104
- override process(message: ISequencedDocumentMessage) {
104
+ override process(message: ISequencedDocumentMessage): void {
105
105
  if (this.connected) {
106
106
  this.processedOps?.push(message);
107
107
  super.process(message);
@@ -110,7 +110,7 @@ export class MockContainerRuntimeForReconnection extends MockContainerRuntime {
110
110
  }
111
111
  }
112
112
 
113
- override submit(messageContent: any, localOpMetadata: unknown) {
113
+ override submit(messageContent: any, localOpMetadata: unknown): number {
114
114
  // Submit messages only if we are connection, otherwise, just add it to the pending queue.
115
115
  if (this.connected) {
116
116
  return super.submit(messageContent, localOpMetadata);
@@ -120,7 +120,7 @@ export class MockContainerRuntimeForReconnection extends MockContainerRuntime {
120
120
  return -1;
121
121
  }
122
122
 
123
- override flush() {
123
+ override flush(): void {
124
124
  // Flush messages only if we are connected, otherwise, just ignore it.
125
125
  if (this.connected) {
126
126
  super.flush();
@@ -129,7 +129,7 @@ export class MockContainerRuntimeForReconnection extends MockContainerRuntime {
129
129
 
130
130
  public async initializeWithStashedOps(
131
131
  fromContainerRuntime: MockContainerRuntimeForReconnection,
132
- ) {
132
+ ): Promise<void> {
133
133
  if (this.pendingMessages.length !== 0 || this.deltaManager.clientSequenceNumber !== 0) {
134
134
  throw new Error("applyStashedOps must be called first, and once.");
135
135
  }
@@ -189,7 +189,7 @@ export class MockContainerRuntimeForReconnection extends MockContainerRuntime {
189
189
  stashedOps.set(op.referenceSequenceNumber, ops);
190
190
  });
191
191
 
192
- const applyStashedOpsAtSeq = async (seq: number) => {
192
+ const applyStashedOpsAtSeq = async (seq: number): Promise<void> => {
193
193
  const pendingAtSeq = stashedOps.get(seq);
194
194
  for (const message of pendingAtSeq ?? []) {
195
195
  // As in production, do not locally apply any stashed ID allocation messages.
@@ -238,7 +238,7 @@ export class MockContainerRuntimeFactoryForReconnection extends MockContainerRun
238
238
  return containerRuntime;
239
239
  }
240
240
 
241
- public clearOutstandingClientMessages(clientId: string) {
241
+ public clearOutstandingClientMessages(clientId: string): void {
242
242
  // Delete all the messages for client with the given clientId.
243
243
  this.messages = this.messages.filter((message: ISequencedDocumentMessage) => {
244
244
  return message.clientId !== clientId;
@@ -3,8 +3,9 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { UsageError } from "@fluidframework/telemetry-utils/internal";
7
6
  import { assert } from "@fluidframework/core-utils/internal";
7
+ import { UsageError } from "@fluidframework/telemetry-utils/internal";
8
+
8
9
  import { shortCodeMap } from "./assertionShortCodesMap.js";
9
10
 
10
11
  /**