azure-mock 2.7.0 → 2.8.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.
package/dist/index.js CHANGED
@@ -1,18 +1,7 @@
1
1
  import { Readable } from "node:stream";
2
2
 
3
- //#region src/models/MockRestError.ts
4
- var MockRestError = class extends Error {
5
- statusCode;
6
- constructor(message, statusCode) {
7
- super(message);
8
- this.name = "MockRestError";
9
- this.statusCode = statusCode;
10
- }
11
- };
12
-
13
- //#endregion
14
- //#region src/util/isReadableStream.ts
15
- const isReadableStream = (value) => value instanceof Readable;
3
+ //#region src/store/MockContainerDatabase.ts
4
+ const MockContainerDatabase = /* @__PURE__ */ new Map();
16
5
 
17
6
  //#endregion
18
7
  //#region ../shared/dist/index.js
@@ -44,31 +33,18 @@ const exhaustiveGuard = (value) => {
44
33
  };
45
34
 
46
35
  //#endregion
47
- //#region src/util/bodyToBuffer.ts
48
- const bodyToBuffer = async (body) => {
49
- if (body === null) return Buffer.alloc(0);
50
- else if (typeof body === "string") return Buffer.from(body);
51
- else if (body instanceof ArrayBuffer) return Buffer.from(body);
52
- else if (ArrayBuffer.isView(body)) return Buffer.from(body.buffer, body.byteOffset, body.byteLength);
53
- else if (typeof body === "function") {
54
- const streamOrBlob = body();
55
- return bodyToBuffer(streamOrBlob);
56
- } else if (body instanceof Blob) {
57
- const arrayBuffer = await body.arrayBuffer();
58
- return Buffer.from(arrayBuffer);
59
- } else if (isReadableStream(body)) return Buffer.from(await streamToText(body));
60
- else if (body instanceof ReadableStream) {
61
- const reader = body.getReader();
62
- const chunks = [];
63
- while (true) {
64
- const { done, value } = await reader.read();
65
- if (done) break;
66
- else chunks.push(value);
67
- }
68
- return Buffer.concat(chunks);
69
- } else if (body instanceof FormData) throw new Error("FormData is not supported in this mock implementation.");
70
- else exhaustiveGuard(body);
71
- };
36
+ //#region src/util/getAzureErrorXml.ts
37
+ /**
38
+ * Generates a standard Azure Storage error XML response body.
39
+ * @param errorCode The official Azure error code (e.g., "BlobNotFound").
40
+ * @param errorMessage The user-friendly error message.
41
+ * @returns A formatted XML string.
42
+ */
43
+ const getAzureErrorXml = (errorCode, errorMessage) => html`<?xml version="1.0" encoding="utf-8"?>
44
+ <Error>
45
+ <code>${errorCode}</code>
46
+ <Message>${errorMessage}</Message>
47
+ </Error>`;
72
48
 
73
49
  //#endregion
74
50
  //#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.2.3/node_modules/@typespec/ts-http-runtime/dist/browser/httpHeaders.js
@@ -394,6 +370,110 @@ const toWebResourceLike = (request) => ({
394
370
  withCredentials: request.withCredentials
395
371
  });
396
372
 
373
+ //#endregion
374
+ //#region src/models/MockBlobBatchClient.ts
375
+ var MockBlobBatchClient = class {
376
+ url;
377
+ constructor(url) {
378
+ this.url = url;
379
+ }
380
+ /**
381
+ * Simulates the deletion of multiple blobs in a single batch request.
382
+ * It iterates through the requested deletions, removes existing blobs from the
383
+ * underlying MockContainerDatabase, and builds a response object that reports
384
+ * which deletions succeeded and which failed (e.g. for blobs that didn't exist).
385
+ */
386
+ deleteBlobs(urls, credential, _options) {
387
+ const subResponses = [];
388
+ let subResponsesSucceededCount = 0;
389
+ let subResponsesFailedCount = 0;
390
+ for (const url of urls) {
391
+ const urlParts = new URL(url);
392
+ const pathSegments = urlParts.pathname.split("/").filter(Boolean);
393
+ if (pathSegments.length < 2) {
394
+ const errorCode = "InvalidUri";
395
+ const statusMessage = "Invalid blob URL format.";
396
+ subResponses.push({
397
+ _request: {
398
+ credential,
399
+ url: this.url
400
+ },
401
+ bodyAsText: getAzureErrorXml(errorCode, statusMessage),
402
+ errorCode,
403
+ headers: toHttpHeadersLike(createHttpHeaders()),
404
+ status: 400,
405
+ statusMessage
406
+ });
407
+ subResponsesFailedCount++;
408
+ }
409
+ const containerName = pathSegments[0];
410
+ const blobName = pathSegments.slice(1).join("/");
411
+ const container = this.getContainer(containerName);
412
+ if (container.has(blobName)) {
413
+ container.delete(blobName);
414
+ subResponses.push({
415
+ _request: {
416
+ credential,
417
+ url: this.url
418
+ },
419
+ headers: toHttpHeadersLike(createHttpHeaders()),
420
+ status: 202,
421
+ statusMessage: "Accepted"
422
+ });
423
+ subResponsesSucceededCount++;
424
+ } else {
425
+ const errorCode = "BlobNotFound";
426
+ const statusMessage = "The specified blob does not exist.";
427
+ subResponses.push({
428
+ _request: {
429
+ credential,
430
+ url: this.url
431
+ },
432
+ bodyAsText: getAzureErrorXml(errorCode, statusMessage),
433
+ errorCode,
434
+ headers: toHttpHeadersLike(createHttpHeaders()),
435
+ status: 404,
436
+ statusMessage
437
+ });
438
+ subResponsesFailedCount++;
439
+ }
440
+ }
441
+ return Promise.resolve({
442
+ _response: {
443
+ headers: toHttpHeadersLike(createHttpHeaders({
444
+ "content-type": "multipart/mixed",
445
+ "x-ms-request-id": crypto.randomUUID()
446
+ })),
447
+ parsedHeaders: {},
448
+ request: toWebResourceLike(createPipelineRequest({ url: this.url })),
449
+ status: 202
450
+ },
451
+ subResponses,
452
+ subResponsesFailedCount,
453
+ subResponsesSucceededCount
454
+ });
455
+ }
456
+ getContainer(containerName) {
457
+ let container = MockContainerDatabase.get(containerName);
458
+ if (!container) {
459
+ container = /* @__PURE__ */ new Map();
460
+ MockContainerDatabase.set(containerName, container);
461
+ }
462
+ return container;
463
+ }
464
+ };
465
+
466
+ //#endregion
467
+ //#region src/models/MockRestError.ts
468
+ var MockRestError = class extends Error {
469
+ statusCode;
470
+ constructor(message, statusCode) {
471
+ super(message);
472
+ this.name = "MockRestError";
473
+ this.statusCode = statusCode;
474
+ }
475
+ };
476
+
397
477
  //#endregion
398
478
  //#region ../../node_modules/.pnpm/@azure+storage-blob@12.27.0/node_modules/@azure/storage-blob/dist-esm/storage-blob/src/policies/RequestPolicy.js
399
479
  /**
@@ -508,17 +588,24 @@ var AnonymousCredential = class extends Credential {
508
588
  };
509
589
 
510
590
  //#endregion
511
- //#region src/models/MockBlockBlobClient.ts
512
- var MockBlockBlobClient = class {
513
- containerClient;
591
+ //#region src/models/MockBlobClient.ts
592
+ var MockBlobClient = class {
593
+ connectionString;
594
+ containerName;
514
595
  credential = new AnonymousCredential();
515
596
  name;
516
597
  url;
517
- get containerName() {
518
- return this.containerClient.containerName;
598
+ get container() {
599
+ let container = MockContainerDatabase.get(this.containerName);
600
+ if (!container) {
601
+ container = /* @__PURE__ */ new Map();
602
+ MockContainerDatabase.set(this.containerName, container);
603
+ }
604
+ return container;
519
605
  }
520
- constructor(_connectionString, containerClient, blobName) {
521
- this.containerClient = containerClient;
606
+ constructor(connectionString, containerName, blobName) {
607
+ this.connectionString = connectionString;
608
+ this.containerName = containerName;
522
609
  this.name = blobName;
523
610
  this.url = `https://mockaccount.blob.core.windows.net/${this.containerName}/${this.name}`;
524
611
  }
@@ -528,21 +615,18 @@ var MockBlockBlobClient = class {
528
615
  beginCopyFromURL() {
529
616
  throw new Error("Method not implemented.");
530
617
  }
531
- commitBlockList() {
532
- throw new Error("Method not implemented.");
533
- }
534
618
  createSnapshot() {
535
619
  throw new Error("Method not implemented.");
536
620
  }
537
621
  delete() {
538
- if (!this.containerClient.blobs.has(this.name)) throw new MockRestError("The specified blob does not exist.", 404);
539
- this.containerClient.blobs.delete(this.name);
540
- return new Promise((resolve) => resolve({ _response: {
622
+ if (!this.container.has(this.name)) throw new MockRestError("The specified blob does not exist.", 404);
623
+ this.container.delete(this.name);
624
+ return Promise.resolve({ _response: {
541
625
  headers: toHttpHeadersLike(createHttpHeaders()),
542
626
  parsedHeaders: {},
543
627
  request: toWebResourceLike(createPipelineRequest({ url: "" })),
544
628
  status: 200
545
- } }));
629
+ } });
546
630
  }
547
631
  deleteIfExists() {
548
632
  throw new Error("Method not implemented.");
@@ -551,8 +635,8 @@ var MockBlockBlobClient = class {
551
635
  throw new Error("Method not implemented.");
552
636
  }
553
637
  download() {
554
- const buffer = this.containerClient.blobs.get(this.name);
555
- return new Promise((resolve) => resolve({
638
+ const buffer = this.container.get(this.name);
639
+ return Promise.resolve({
556
640
  _response: {
557
641
  headers: toHttpHeadersLike(createHttpHeaders()),
558
642
  parsedHeaders: {},
@@ -560,12 +644,12 @@ var MockBlockBlobClient = class {
560
644
  status: buffer ? 200 : 404
561
645
  },
562
646
  readableStreamBody: buffer ? Readable.from(buffer) : void 0
563
- }));
647
+ });
564
648
  }
565
649
  downloadToBuffer() {
566
- const data = this.containerClient.blobs.get(this.name);
650
+ const data = this.container.get(this.name);
567
651
  if (!data) throw new MockRestError("The specified blob does not exist.", 404);
568
- return new Promise((resolve) => resolve(Buffer.from(data)));
652
+ return Promise.resolve(Buffer.from(data));
569
653
  }
570
654
  downloadToFile() {
571
655
  throw new Error("Method not implemented.");
@@ -597,9 +681,6 @@ var MockBlockBlobClient = class {
597
681
  getBlockBlobClient() {
598
682
  throw new Error("Method not implemented.");
599
683
  }
600
- getBlockList() {
601
- throw new Error("Method not implemented.");
602
- }
603
684
  getPageBlobClient() {
604
685
  throw new Error("Method not implemented.");
605
686
  }
@@ -609,9 +690,6 @@ var MockBlockBlobClient = class {
609
690
  getTags() {
610
691
  throw new Error("Method not implemented.");
611
692
  }
612
- query() {
613
- throw new Error("Method not implemented.");
614
- }
615
693
  setAccessTier() {
616
694
  throw new Error("Method not implemented.");
617
695
  }
@@ -630,23 +708,74 @@ var MockBlockBlobClient = class {
630
708
  setTags() {
631
709
  throw new Error("Method not implemented.");
632
710
  }
633
- stageBlock() {
711
+ syncCopyFromURL() {
634
712
  throw new Error("Method not implemented.");
635
713
  }
636
- stageBlockFromURL() {
714
+ undelete() {
637
715
  throw new Error("Method not implemented.");
638
716
  }
639
- syncCopyFromURL() {
717
+ withSnapshot() {
640
718
  throw new Error("Method not implemented.");
641
719
  }
642
- syncUploadFromURL() {
720
+ withVersion() {
643
721
  throw new Error("Method not implemented.");
644
722
  }
645
- undelete() {
723
+ };
724
+
725
+ //#endregion
726
+ //#region src/util/isReadableStream.ts
727
+ const isReadableStream = (value) => value instanceof Readable;
728
+
729
+ //#endregion
730
+ //#region src/util/bodyToBuffer.ts
731
+ const bodyToBuffer = async (body) => {
732
+ if (body === null) return Buffer.alloc(0);
733
+ else if (typeof body === "string") return Buffer.from(body);
734
+ else if (body instanceof ArrayBuffer) return Buffer.from(body);
735
+ else if (ArrayBuffer.isView(body)) return Buffer.from(body.buffer, body.byteOffset, body.byteLength);
736
+ else if (typeof body === "function") {
737
+ const streamOrBlob = body();
738
+ return bodyToBuffer(streamOrBlob);
739
+ } else if (body instanceof Blob) {
740
+ const arrayBuffer = await body.arrayBuffer();
741
+ return Buffer.from(arrayBuffer);
742
+ } else if (isReadableStream(body)) return Buffer.from(await streamToText(body));
743
+ else if (body instanceof ReadableStream) {
744
+ const reader = body.getReader();
745
+ const chunks = [];
746
+ while (true) {
747
+ const { done, value } = await reader.read();
748
+ if (done) break;
749
+ else chunks.push(value);
750
+ }
751
+ return Buffer.concat(chunks);
752
+ } else if (body instanceof FormData) throw new Error("FormData is not supported in this mock implementation.");
753
+ else exhaustiveGuard(body);
754
+ };
755
+
756
+ //#endregion
757
+ //#region src/models/MockBlockBlobClient.ts
758
+ var MockBlockBlobClient = class extends MockBlobClient {
759
+ commitBlockList() {
760
+ throw new Error("Method not implemented.");
761
+ }
762
+ getBlockList() {
763
+ throw new Error("Method not implemented.");
764
+ }
765
+ query() {
766
+ throw new Error("Method not implemented.");
767
+ }
768
+ stageBlock() {
769
+ throw new Error("Method not implemented.");
770
+ }
771
+ stageBlockFromURL() {
772
+ throw new Error("Method not implemented.");
773
+ }
774
+ syncUploadFromURL() {
646
775
  throw new Error("Method not implemented.");
647
776
  }
648
777
  async upload(body, _contentLength) {
649
- this.containerClient.blobs.set(this.name, await bodyToBuffer(body));
778
+ this.container.set(this.name, await bodyToBuffer(body));
650
779
  return { _response: {
651
780
  headers: toHttpHeadersLike(createHttpHeaders()),
652
781
  parsedHeaders: {},
@@ -666,12 +795,6 @@ var MockBlockBlobClient = class {
666
795
  uploadStream() {
667
796
  throw new Error("Method not implemented.");
668
797
  }
669
- withSnapshot() {
670
- throw new Error("Method not implemented.");
671
- }
672
- withVersion() {
673
- throw new Error("Method not implemented.");
674
- }
675
798
  };
676
799
 
677
800
  //#endregion
@@ -706,11 +829,20 @@ const getBlobPrefixXml = (name) => html`<BlobPrefix><Name>${name}</Name></BlobPr
706
829
  * const content = await blockBlobClient.downloadToBuffer();
707
830
  */
708
831
  var MockContainerClient = class {
709
- blobs = /* @__PURE__ */ new Map();
832
+ connectionString;
710
833
  containerName;
711
834
  credential = new AnonymousCredential();
712
835
  url;
713
- constructor(_connectionString, containerName) {
836
+ get container() {
837
+ let container = MockContainerDatabase.get(this.containerName);
838
+ if (!container) {
839
+ container = /* @__PURE__ */ new Map();
840
+ MockContainerDatabase.set(this.containerName, container);
841
+ }
842
+ return container;
843
+ }
844
+ constructor(connectionString, containerName) {
845
+ this.connectionString = connectionString;
714
846
  this.containerName = containerName;
715
847
  this.url = `https://mockaccount.blob.core.windows.net/${this.containerName}`;
716
848
  }
@@ -757,16 +889,16 @@ var MockContainerClient = class {
757
889
  throw new Error("Method not implemented.");
758
890
  }
759
891
  getBlobBatchClient() {
760
- throw new Error("Method not implemented.");
892
+ return new MockBlobBatchClient(this.url);
761
893
  }
762
- getBlobClient() {
763
- throw new Error("Method not implemented.");
894
+ getBlobClient(blobName) {
895
+ return new MockBlockBlobClient(this.connectionString, this.containerName, blobName);
764
896
  }
765
897
  getBlobLeaseClient() {
766
898
  throw new Error("Method not implemented.");
767
899
  }
768
900
  getBlockBlobClient(blobName) {
769
- return new MockBlockBlobClient("", this, blobName);
901
+ return new MockBlockBlobClient(this.connectionString, this.containerName, blobName);
770
902
  }
771
903
  getPageBlobClient() {
772
904
  throw new Error("Method not implemented.");
@@ -789,13 +921,13 @@ var MockContainerClient = class {
789
921
  allBlobPrefixes.push({ name: blobHierarchyItem.name });
790
922
  allBlobPrefixXml.push(getBlobPrefixXml(blobHierarchyItem.name));
791
923
  }
792
- if (allBlobItems.length > 0 || allBlobPrefixes.length > 0) yield await new Promise((resolve) => resolve({
924
+ if (allBlobItems.length > 0 || allBlobPrefixes.length > 0) yield await Promise.resolve({
793
925
  _response: {
794
926
  bodyAsText: html`<?xml version="1.0" encoding="utf8"?>
795
- <EnumerationResults ServiceEndpoint="" ContainerName="${this.containerName}">
796
- <Blobs>${allBlobItemXml.join("")}${allBlobPrefixXml.join("")}</Blobs>
797
- <NextMarker />
798
- </EnumerationResults>`,
927
+ <EnumerationResults ServiceEndpoint="" ContainerName="${this.containerName}">
928
+ <Blobs>${allBlobItemXml.join("")}${allBlobPrefixXml.join("")}</Blobs>
929
+ <NextMarker />
930
+ </EnumerationResults>`,
799
931
  headers: toHttpHeadersLike(createHttpHeaders()),
800
932
  parsedBody: {
801
933
  containerName: this.containerName,
@@ -813,7 +945,7 @@ var MockContainerClient = class {
813
945
  prefix: options?.prefix ?? "",
814
946
  segment: { blobItems: allBlobItems },
815
947
  serviceEndpoint: ""
816
- }));
948
+ });
817
949
  }.bind(this)(),
818
950
  next: blobHierarchyItemIterator.next.bind(blobHierarchyItemIterator),
819
951
  [Symbol.asyncIterator]() {
@@ -831,13 +963,13 @@ var MockContainerClient = class {
831
963
  allBlobItems.push(blobItem);
832
964
  allBlobItemXml.push(getBlobItemXml(blobItem));
833
965
  }
834
- if (allBlobItems.length > 0) yield await new Promise((resolve) => resolve({
966
+ if (allBlobItems.length > 0) yield await Promise.resolve({
835
967
  _response: {
836
968
  bodyAsText: html`<?xml version="1.0" encoding="utf8"?>
837
- <EnumerationResults ServiceEndpoint="" ContainerName="${this.containerName}">
838
- <Blobs>${allBlobItemXml.join("")}</Blobs>
839
- <NextMarker />
840
- </EnumerationResults>`,
969
+ <EnumerationResults ServiceEndpoint="" ContainerName="${this.containerName}">
970
+ <Blobs>${allBlobItemXml.join("")}</Blobs>
971
+ <NextMarker />
972
+ </EnumerationResults>`,
841
973
  headers: toHttpHeadersLike(createHttpHeaders()),
842
974
  parsedBody: {
843
975
  containerName: this.containerName,
@@ -855,7 +987,7 @@ var MockContainerClient = class {
855
987
  prefix: "",
856
988
  segment: { blobItems: allBlobItems },
857
989
  serviceEndpoint: ""
858
- }));
990
+ });
859
991
  }.bind(this)(),
860
992
  next: blobItemIterator.next.bind(blobItemIterator),
861
993
  [Symbol.asyncIterator]() {
@@ -880,7 +1012,7 @@ var MockContainerClient = class {
880
1012
  const prefix = options?.prefix ?? "";
881
1013
  const uniqueSubprefixes = /* @__PURE__ */ new Set();
882
1014
  const blobsInCurrentLevel = [];
883
- for (const [name, buffer] of this.blobs.entries()) {
1015
+ for (const [name, buffer] of this.container.entries()) {
884
1016
  if (!name.startsWith(prefix)) continue;
885
1017
  const nameAfterPrefix = name.slice(prefix.length);
886
1018
  const delimiterIndex = nameAfterPrefix.indexOf(delimiter);
@@ -903,17 +1035,17 @@ var MockContainerClient = class {
903
1035
  uniqueSubprefixes.add(subprefix);
904
1036
  }
905
1037
  }
906
- for (const prefixName of [...uniqueSubprefixes].sort()) yield await new Promise((resolve) => resolve({
1038
+ for (const prefixName of [...uniqueSubprefixes].sort()) yield await Promise.resolve({
907
1039
  kind: "prefix",
908
1040
  name: prefixName
909
- }));
910
- for (const blobItem of blobsInCurrentLevel) yield await new Promise((resolve) => resolve({
1041
+ });
1042
+ for (const blobItem of blobsInCurrentLevel) yield await Promise.resolve({
911
1043
  kind: "blob",
912
1044
  ...blobItem
913
- }));
1045
+ });
914
1046
  }
915
1047
  async *getBlobItemIterator() {
916
- for (const [name, buffer] of this.blobs.entries()) yield await new Promise((resolve) => resolve({
1048
+ for (const [name, buffer] of this.container.entries()) yield await Promise.resolve({
917
1049
  deleted: false,
918
1050
  name,
919
1051
  properties: {
@@ -926,10 +1058,14 @@ var MockContainerClient = class {
926
1058
  leaseStatus: "unlocked"
927
1059
  },
928
1060
  snapshot: ""
929
- }));
1061
+ });
930
1062
  }
931
1063
  };
932
1064
 
1065
+ //#endregion
1066
+ //#region src/store/MockTableDatabase.ts
1067
+ const MockTableDatabase = /* @__PURE__ */ new Map();
1068
+
933
1069
  //#endregion
934
1070
  //#region src/models/MockTableClient.ts
935
1071
  /**
@@ -942,31 +1078,38 @@ var MockContainerClient = class {
942
1078
  * const entity = await mockTableClient.getEntity("partitionKey", "rowKey");
943
1079
  */
944
1080
  var MockTableClient = class {
945
- entities = /* @__PURE__ */ new Map();
946
1081
  tableName;
947
1082
  url;
1083
+ get table() {
1084
+ let table = MockTableDatabase.get(this.tableName);
1085
+ if (!table) {
1086
+ table = /* @__PURE__ */ new Map();
1087
+ MockTableDatabase.set(this.tableName, table);
1088
+ }
1089
+ return table;
1090
+ }
948
1091
  constructor(_url, tableName) {
949
1092
  this.tableName = tableName;
950
1093
  this.url = `https://mockaccount.table.core.windows.net/${this.tableName}`;
951
1094
  }
952
1095
  createEntity(entity) {
953
1096
  const key = this.getCompositeKey(entity.partitionKey, entity.rowKey);
954
- if (this.entities.has(key)) throw new MockRestError("The specified entity already exists.", 409);
1097
+ if (this.table.has(key)) throw new MockRestError("The specified entity already exists.", 409);
955
1098
  const storedEntity = this.withMetadata(entity);
956
- this.entities.set(key, storedEntity);
957
- return new Promise((resolve) => resolve({
1099
+ this.table.set(key, storedEntity);
1100
+ return Promise.resolve({
958
1101
  date: /* @__PURE__ */ new Date(),
959
1102
  etag: storedEntity.etag
960
- }));
1103
+ });
961
1104
  }
962
1105
  createTable() {
963
1106
  throw new Error("Method not implemented.");
964
1107
  }
965
1108
  deleteEntity(partitionKey, rowKey) {
966
1109
  const key = this.getCompositeKey(partitionKey, rowKey);
967
- if (!this.entities.has(key)) throw new MockRestError("The specified resource does not exist.", 404);
968
- this.entities.delete(key);
969
- return new Promise((resolve) => resolve({}));
1110
+ if (!this.table.has(key)) throw new MockRestError("The specified resource does not exist.", 404);
1111
+ this.table.delete(key);
1112
+ return Promise.resolve({});
970
1113
  }
971
1114
  deleteTable() {
972
1115
  throw new Error("Method not implemented.");
@@ -976,24 +1119,24 @@ var MockTableClient = class {
976
1119
  }
977
1120
  getEntity(partitionKey, rowKey) {
978
1121
  const key = this.getCompositeKey(partitionKey, rowKey);
979
- const entity = this.entities.get(key);
1122
+ const entity = this.table.get(key);
980
1123
  if (!entity) throw new MockRestError("The specified resource does not exist.", 404);
981
1124
  const entityWithMetadata = this.withMetadata(entity);
982
- return new Promise((resolve) => resolve(entityWithMetadata));
1125
+ return Promise.resolve(entityWithMetadata);
983
1126
  }
984
1127
  listEntities() {
985
1128
  const withMetadata = this.withMetadata.bind(this);
986
1129
  return {
987
1130
  byPage: () => async function* (entities) {
988
1131
  const allEntitiesWithMetadata = [...entities.values()].map(withMetadata);
989
- if (allEntitiesWithMetadata.length > 0) yield await new Promise((resolve) => resolve(allEntitiesWithMetadata));
990
- }(this.entities),
1132
+ if (allEntitiesWithMetadata.length > 0) yield await Promise.resolve(allEntitiesWithMetadata);
1133
+ }(this.table),
991
1134
  next: () => async function* (entities) {
992
1135
  for (const entity of entities.values()) {
993
1136
  const entityWithMetadata = withMetadata(entity);
994
- yield await new Promise((resolve) => resolve(entityWithMetadata));
1137
+ yield await Promise.resolve(entityWithMetadata);
995
1138
  }
996
- }(this.entities).next(),
1139
+ }(this.table).next(),
997
1140
  [Symbol.asyncIterator]() {
998
1141
  return this;
999
1142
  }
@@ -1007,26 +1150,26 @@ var MockTableClient = class {
1007
1150
  }
1008
1151
  updateEntity(entity, mode = "Merge") {
1009
1152
  const key = this.getCompositeKey(entity.partitionKey, entity.rowKey);
1010
- const existingEntity = this.entities.get(key);
1153
+ const existingEntity = this.table.get(key);
1011
1154
  if (!existingEntity) throw new MockRestError("The specified resource does not exist.", 404);
1012
1155
  else if (mode === "Merge") return this.mergeEntity(key, existingEntity, entity);
1013
1156
  const newEntityWithMetadata = this.withMetadata(entity);
1014
- this.entities.set(key, newEntityWithMetadata);
1015
- return new Promise((resolve) => resolve({
1157
+ this.table.set(key, newEntityWithMetadata);
1158
+ return Promise.resolve({
1016
1159
  date: /* @__PURE__ */ new Date(),
1017
1160
  etag: newEntityWithMetadata.etag
1018
- }));
1161
+ });
1019
1162
  }
1020
1163
  upsertEntity(entity, mode = "Merge") {
1021
1164
  const key = this.getCompositeKey(entity.partitionKey, entity.rowKey);
1022
- const existingEntity = this.entities.get(key);
1165
+ const existingEntity = this.table.get(key);
1023
1166
  if (existingEntity && mode === "Merge") return this.mergeEntity(key, existingEntity, entity);
1024
1167
  const newEntity = this.withMetadata(entity);
1025
- this.entities.set(key, newEntity);
1026
- return new Promise((resolve) => resolve({
1168
+ this.table.set(key, newEntity);
1169
+ return Promise.resolve({
1027
1170
  date: /* @__PURE__ */ new Date(),
1028
1171
  etag: newEntity.etag
1029
- }));
1172
+ });
1030
1173
  }
1031
1174
  getCompositeKey(partitionKey, rowKey) {
1032
1175
  return `${partitionKey}${ID_SEPARATOR}${rowKey}`;
@@ -1036,11 +1179,11 @@ var MockTableClient = class {
1036
1179
  ...entity,
1037
1180
  ...entityToMerge
1038
1181
  });
1039
- this.entities.set(key, mergedEntityWithMetadata);
1040
- return new Promise((resolve) => resolve({
1182
+ this.table.set(key, mergedEntityWithMetadata);
1183
+ return Promise.resolve({
1041
1184
  date: /* @__PURE__ */ new Date(),
1042
1185
  etag: mergedEntityWithMetadata.etag
1043
- }));
1186
+ });
1044
1187
  }
1045
1188
  withMetadata(entity) {
1046
1189
  return {
@@ -1051,4 +1194,4 @@ var MockTableClient = class {
1051
1194
  };
1052
1195
 
1053
1196
  //#endregion
1054
- export { MockBlockBlobClient, MockContainerClient, MockRestError, MockTableClient, bodyToBuffer, getBlobItemXml, getBlobPrefixXml, isReadableStream, toWebResourceLike };
1197
+ export { MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerClient, MockContainerDatabase, MockRestError, MockTableClient, MockTableDatabase, bodyToBuffer, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, isReadableStream, toWebResourceLike };