azure-mock 2.7.0 → 2.8.1

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
@@ -693,6 +816,20 @@ const getBlobItemXml = ({ name, properties }) => html`<Blob>
693
816
  //#region src/util/getBlobPrefixXml.ts
694
817
  const getBlobPrefixXml = (name) => html`<BlobPrefix><Name>${name}</Name></BlobPrefix>`;
695
818
 
819
+ //#endregion
820
+ //#region src/util/getListBlobsXml.ts
821
+ /**
822
+ * Generates a standard Azure Storage list blobs XML response body.
823
+ * @param containerName The container name.
824
+ * @param blobsXml The blobs xml data.
825
+ * @returns A formatted XML string.
826
+ */
827
+ const getListBlobsXml = (containerName, blobsXml) => html`<?xml version="1.0" encoding="utf8"?>
828
+ <EnumerationResults ServiceEndpoint="" ContainerName="${containerName}">
829
+ <Blobs>${blobsXml}</Blobs>
830
+ <NextMarker />
831
+ </EnumerationResults>`;
832
+
696
833
  //#endregion
697
834
  //#region src/models/MockContainerClient.ts
698
835
  /**
@@ -706,11 +843,20 @@ const getBlobPrefixXml = (name) => html`<BlobPrefix><Name>${name}</Name></BlobPr
706
843
  * const content = await blockBlobClient.downloadToBuffer();
707
844
  */
708
845
  var MockContainerClient = class {
709
- blobs = /* @__PURE__ */ new Map();
846
+ connectionString;
710
847
  containerName;
711
848
  credential = new AnonymousCredential();
712
849
  url;
713
- constructor(_connectionString, containerName) {
850
+ get container() {
851
+ let container = MockContainerDatabase.get(this.containerName);
852
+ if (!container) {
853
+ container = /* @__PURE__ */ new Map();
854
+ MockContainerDatabase.set(this.containerName, container);
855
+ }
856
+ return container;
857
+ }
858
+ constructor(connectionString, containerName) {
859
+ this.connectionString = connectionString;
714
860
  this.containerName = containerName;
715
861
  this.url = `https://mockaccount.blob.core.windows.net/${this.containerName}`;
716
862
  }
@@ -757,16 +903,16 @@ var MockContainerClient = class {
757
903
  throw new Error("Method not implemented.");
758
904
  }
759
905
  getBlobBatchClient() {
760
- throw new Error("Method not implemented.");
906
+ return new MockBlobBatchClient(this.url);
761
907
  }
762
- getBlobClient() {
763
- throw new Error("Method not implemented.");
908
+ getBlobClient(blobName) {
909
+ return new MockBlockBlobClient(this.connectionString, this.containerName, blobName);
764
910
  }
765
911
  getBlobLeaseClient() {
766
912
  throw new Error("Method not implemented.");
767
913
  }
768
914
  getBlockBlobClient(blobName) {
769
- return new MockBlockBlobClient("", this, blobName);
915
+ return new MockBlockBlobClient(this.connectionString, this.containerName, blobName);
770
916
  }
771
917
  getPageBlobClient() {
772
918
  throw new Error("Method not implemented.");
@@ -789,13 +935,9 @@ var MockContainerClient = class {
789
935
  allBlobPrefixes.push({ name: blobHierarchyItem.name });
790
936
  allBlobPrefixXml.push(getBlobPrefixXml(blobHierarchyItem.name));
791
937
  }
792
- if (allBlobItems.length > 0 || allBlobPrefixes.length > 0) yield await new Promise((resolve) => resolve({
938
+ if (allBlobItems.length > 0 || allBlobPrefixes.length > 0) yield await Promise.resolve({
793
939
  _response: {
794
- 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>`,
940
+ bodyAsText: getListBlobsXml(this.containerName, `${allBlobItemXml.join("")}${allBlobPrefixXml.join("")}`),
799
941
  headers: toHttpHeadersLike(createHttpHeaders()),
800
942
  parsedBody: {
801
943
  containerName: this.containerName,
@@ -813,7 +955,7 @@ var MockContainerClient = class {
813
955
  prefix: options?.prefix ?? "",
814
956
  segment: { blobItems: allBlobItems },
815
957
  serviceEndpoint: ""
816
- }));
958
+ });
817
959
  }.bind(this)(),
818
960
  next: blobHierarchyItemIterator.next.bind(blobHierarchyItemIterator),
819
961
  [Symbol.asyncIterator]() {
@@ -831,13 +973,9 @@ var MockContainerClient = class {
831
973
  allBlobItems.push(blobItem);
832
974
  allBlobItemXml.push(getBlobItemXml(blobItem));
833
975
  }
834
- if (allBlobItems.length > 0) yield await new Promise((resolve) => resolve({
976
+ if (allBlobItems.length > 0) yield await Promise.resolve({
835
977
  _response: {
836
- bodyAsText: html`<?xml version="1.0" encoding="utf8"?>
837
- <EnumerationResults ServiceEndpoint="" ContainerName="${this.containerName}">
838
- <Blobs>${allBlobItemXml.join("")}</Blobs>
839
- <NextMarker />
840
- </EnumerationResults>`,
978
+ bodyAsText: getListBlobsXml(this.containerName, allBlobItemXml.join("")),
841
979
  headers: toHttpHeadersLike(createHttpHeaders()),
842
980
  parsedBody: {
843
981
  containerName: this.containerName,
@@ -855,7 +993,7 @@ var MockContainerClient = class {
855
993
  prefix: "",
856
994
  segment: { blobItems: allBlobItems },
857
995
  serviceEndpoint: ""
858
- }));
996
+ });
859
997
  }.bind(this)(),
860
998
  next: blobItemIterator.next.bind(blobItemIterator),
861
999
  [Symbol.asyncIterator]() {
@@ -880,7 +1018,7 @@ var MockContainerClient = class {
880
1018
  const prefix = options?.prefix ?? "";
881
1019
  const uniqueSubprefixes = /* @__PURE__ */ new Set();
882
1020
  const blobsInCurrentLevel = [];
883
- for (const [name, buffer] of this.blobs.entries()) {
1021
+ for (const [name, buffer] of this.container.entries()) {
884
1022
  if (!name.startsWith(prefix)) continue;
885
1023
  const nameAfterPrefix = name.slice(prefix.length);
886
1024
  const delimiterIndex = nameAfterPrefix.indexOf(delimiter);
@@ -903,17 +1041,17 @@ var MockContainerClient = class {
903
1041
  uniqueSubprefixes.add(subprefix);
904
1042
  }
905
1043
  }
906
- for (const prefixName of [...uniqueSubprefixes].sort()) yield await new Promise((resolve) => resolve({
1044
+ for (const prefixName of [...uniqueSubprefixes].sort()) yield await Promise.resolve({
907
1045
  kind: "prefix",
908
1046
  name: prefixName
909
- }));
910
- for (const blobItem of blobsInCurrentLevel) yield await new Promise((resolve) => resolve({
1047
+ });
1048
+ for (const blobItem of blobsInCurrentLevel) yield await Promise.resolve({
911
1049
  kind: "blob",
912
1050
  ...blobItem
913
- }));
1051
+ });
914
1052
  }
915
1053
  async *getBlobItemIterator() {
916
- for (const [name, buffer] of this.blobs.entries()) yield await new Promise((resolve) => resolve({
1054
+ for (const [name, buffer] of this.container.entries()) yield await Promise.resolve({
917
1055
  deleted: false,
918
1056
  name,
919
1057
  properties: {
@@ -926,10 +1064,14 @@ var MockContainerClient = class {
926
1064
  leaseStatus: "unlocked"
927
1065
  },
928
1066
  snapshot: ""
929
- }));
1067
+ });
930
1068
  }
931
1069
  };
932
1070
 
1071
+ //#endregion
1072
+ //#region src/store/MockTableDatabase.ts
1073
+ const MockTableDatabase = /* @__PURE__ */ new Map();
1074
+
933
1075
  //#endregion
934
1076
  //#region src/models/MockTableClient.ts
935
1077
  /**
@@ -942,31 +1084,38 @@ var MockContainerClient = class {
942
1084
  * const entity = await mockTableClient.getEntity("partitionKey", "rowKey");
943
1085
  */
944
1086
  var MockTableClient = class {
945
- entities = /* @__PURE__ */ new Map();
946
1087
  tableName;
947
1088
  url;
1089
+ get table() {
1090
+ let table = MockTableDatabase.get(this.tableName);
1091
+ if (!table) {
1092
+ table = /* @__PURE__ */ new Map();
1093
+ MockTableDatabase.set(this.tableName, table);
1094
+ }
1095
+ return table;
1096
+ }
948
1097
  constructor(_url, tableName) {
949
1098
  this.tableName = tableName;
950
1099
  this.url = `https://mockaccount.table.core.windows.net/${this.tableName}`;
951
1100
  }
952
1101
  createEntity(entity) {
953
1102
  const key = this.getCompositeKey(entity.partitionKey, entity.rowKey);
954
- if (this.entities.has(key)) throw new MockRestError("The specified entity already exists.", 409);
1103
+ if (this.table.has(key)) throw new MockRestError("The specified entity already exists.", 409);
955
1104
  const storedEntity = this.withMetadata(entity);
956
- this.entities.set(key, storedEntity);
957
- return new Promise((resolve) => resolve({
1105
+ this.table.set(key, storedEntity);
1106
+ return Promise.resolve({
958
1107
  date: /* @__PURE__ */ new Date(),
959
1108
  etag: storedEntity.etag
960
- }));
1109
+ });
961
1110
  }
962
1111
  createTable() {
963
1112
  throw new Error("Method not implemented.");
964
1113
  }
965
1114
  deleteEntity(partitionKey, rowKey) {
966
1115
  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({}));
1116
+ if (!this.table.has(key)) throw new MockRestError("The specified resource does not exist.", 404);
1117
+ this.table.delete(key);
1118
+ return Promise.resolve({});
970
1119
  }
971
1120
  deleteTable() {
972
1121
  throw new Error("Method not implemented.");
@@ -976,24 +1125,24 @@ var MockTableClient = class {
976
1125
  }
977
1126
  getEntity(partitionKey, rowKey) {
978
1127
  const key = this.getCompositeKey(partitionKey, rowKey);
979
- const entity = this.entities.get(key);
1128
+ const entity = this.table.get(key);
980
1129
  if (!entity) throw new MockRestError("The specified resource does not exist.", 404);
981
1130
  const entityWithMetadata = this.withMetadata(entity);
982
- return new Promise((resolve) => resolve(entityWithMetadata));
1131
+ return Promise.resolve(entityWithMetadata);
983
1132
  }
984
1133
  listEntities() {
985
1134
  const withMetadata = this.withMetadata.bind(this);
986
1135
  return {
987
1136
  byPage: () => async function* (entities) {
988
1137
  const allEntitiesWithMetadata = [...entities.values()].map(withMetadata);
989
- if (allEntitiesWithMetadata.length > 0) yield await new Promise((resolve) => resolve(allEntitiesWithMetadata));
990
- }(this.entities),
1138
+ if (allEntitiesWithMetadata.length > 0) yield await Promise.resolve(allEntitiesWithMetadata);
1139
+ }(this.table),
991
1140
  next: () => async function* (entities) {
992
1141
  for (const entity of entities.values()) {
993
1142
  const entityWithMetadata = withMetadata(entity);
994
- yield await new Promise((resolve) => resolve(entityWithMetadata));
1143
+ yield await Promise.resolve(entityWithMetadata);
995
1144
  }
996
- }(this.entities).next(),
1145
+ }(this.table).next(),
997
1146
  [Symbol.asyncIterator]() {
998
1147
  return this;
999
1148
  }
@@ -1007,26 +1156,26 @@ var MockTableClient = class {
1007
1156
  }
1008
1157
  updateEntity(entity, mode = "Merge") {
1009
1158
  const key = this.getCompositeKey(entity.partitionKey, entity.rowKey);
1010
- const existingEntity = this.entities.get(key);
1159
+ const existingEntity = this.table.get(key);
1011
1160
  if (!existingEntity) throw new MockRestError("The specified resource does not exist.", 404);
1012
1161
  else if (mode === "Merge") return this.mergeEntity(key, existingEntity, entity);
1013
1162
  const newEntityWithMetadata = this.withMetadata(entity);
1014
- this.entities.set(key, newEntityWithMetadata);
1015
- return new Promise((resolve) => resolve({
1163
+ this.table.set(key, newEntityWithMetadata);
1164
+ return Promise.resolve({
1016
1165
  date: /* @__PURE__ */ new Date(),
1017
1166
  etag: newEntityWithMetadata.etag
1018
- }));
1167
+ });
1019
1168
  }
1020
1169
  upsertEntity(entity, mode = "Merge") {
1021
1170
  const key = this.getCompositeKey(entity.partitionKey, entity.rowKey);
1022
- const existingEntity = this.entities.get(key);
1171
+ const existingEntity = this.table.get(key);
1023
1172
  if (existingEntity && mode === "Merge") return this.mergeEntity(key, existingEntity, entity);
1024
1173
  const newEntity = this.withMetadata(entity);
1025
- this.entities.set(key, newEntity);
1026
- return new Promise((resolve) => resolve({
1174
+ this.table.set(key, newEntity);
1175
+ return Promise.resolve({
1027
1176
  date: /* @__PURE__ */ new Date(),
1028
1177
  etag: newEntity.etag
1029
- }));
1178
+ });
1030
1179
  }
1031
1180
  getCompositeKey(partitionKey, rowKey) {
1032
1181
  return `${partitionKey}${ID_SEPARATOR}${rowKey}`;
@@ -1036,11 +1185,11 @@ var MockTableClient = class {
1036
1185
  ...entity,
1037
1186
  ...entityToMerge
1038
1187
  });
1039
- this.entities.set(key, mergedEntityWithMetadata);
1040
- return new Promise((resolve) => resolve({
1188
+ this.table.set(key, mergedEntityWithMetadata);
1189
+ return Promise.resolve({
1041
1190
  date: /* @__PURE__ */ new Date(),
1042
1191
  etag: mergedEntityWithMetadata.etag
1043
- }));
1192
+ });
1044
1193
  }
1045
1194
  withMetadata(entity) {
1046
1195
  return {
@@ -1051,4 +1200,4 @@ var MockTableClient = class {
1051
1200
  };
1052
1201
 
1053
1202
  //#endregion
1054
- export { MockBlockBlobClient, MockContainerClient, MockRestError, MockTableClient, bodyToBuffer, getBlobItemXml, getBlobPrefixXml, isReadableStream, toWebResourceLike };
1203
+ export { MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerClient, MockContainerDatabase, MockRestError, MockTableClient, MockTableDatabase, bodyToBuffer, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, getListBlobsXml, isReadableStream, toWebResourceLike };