azure-mock 2.8.1 → 2.10.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.d.ts +7 -15
- package/dist/index.js +77 -40
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ type BlobHierarchyItem = (BlobItem & {
|
|
|
10
10
|
});
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/store/MockContainerDatabase.d.ts
|
|
13
|
-
// Map<container, Map<name, blob>>
|
|
14
13
|
declare const MockContainerDatabase: Map<string, Map<string, Buffer>>;
|
|
15
14
|
//#endregion
|
|
16
15
|
//#region src/models/MockBlobBatchClient.d.ts
|
|
@@ -23,7 +22,6 @@ declare class MockBlobBatchClient implements BlobBatchClient {
|
|
|
23
22
|
* underlying MockContainerDatabase, and builds a response object that reports
|
|
24
23
|
* which deletions succeeded and which failed (e.g. for blobs that didn't exist).
|
|
25
24
|
*/
|
|
26
|
-
// @ts-expect-error We will only implement urls for deleteBlobs and ignore overloads for now
|
|
27
25
|
deleteBlobs(urls: string[], credential: AnonymousCredential | StorageSharedKeyCredential, _options?: BlobDeleteOptions): Promise<BlobBatchDeleteBlobsResponse>;
|
|
28
26
|
getContainer(containerName: string): MapValue<typeof MockContainerDatabase>;
|
|
29
27
|
}
|
|
@@ -671,7 +669,7 @@ declare class MockBlobClient implements Except<BlobClient, "accountName"> {
|
|
|
671
669
|
get container(): MapValue<typeof MockContainerDatabase>;
|
|
672
670
|
constructor(connectionString: string, containerName: string, blobName: string);
|
|
673
671
|
abortCopyFromURL(): Promise<BlobAbortCopyFromURLResponse>;
|
|
674
|
-
beginCopyFromURL(): Promise<PollerLikeWithCancellation<PollOperationState<BlobBeginCopyFromURLResponse>, BlobBeginCopyFromURLResponse>>;
|
|
672
|
+
beginCopyFromURL(copySource: string): Promise<PollerLikeWithCancellation<PollOperationState<BlobBeginCopyFromURLResponse>, BlobBeginCopyFromURLResponse>>;
|
|
675
673
|
createSnapshot(): Promise<BlobCreateSnapshotResponse>;
|
|
676
674
|
delete(): Promise<BlobDeleteResponse>;
|
|
677
675
|
deleteIfExists(): Promise<BlobDeleteIfExistsResponse>;
|
|
@@ -773,7 +771,7 @@ declare class MockContainerClient implements Except<ContainerClient, "accountNam
|
|
|
773
771
|
create(): Promise<ContainerCreateResponse>;
|
|
774
772
|
createIfNotExists(): Promise<ContainerCreateIfNotExistsResponse>;
|
|
775
773
|
delete(): Promise<ContainerDeleteResponse>;
|
|
776
|
-
deleteBlob(): Promise<BlobDeleteResponse>;
|
|
774
|
+
deleteBlob(blobName: string): Promise<BlobDeleteResponse>;
|
|
777
775
|
deleteIfExists(): Promise<ContainerDeleteIfExistsResponse>;
|
|
778
776
|
exists(): Promise<boolean>;
|
|
779
777
|
findBlobsByTags(): PagedAsyncIterableIterator<FilterBlobItem, ContainerFindBlobsByTagsSegmentResponse>;
|
|
@@ -803,15 +801,12 @@ declare class MockContainerClient implements Except<ContainerClient, "accountNam
|
|
|
803
801
|
}
|
|
804
802
|
//#endregion
|
|
805
803
|
//#region src/models/MockRestError.d.ts
|
|
806
|
-
// A mock error class that mimics the structure of Azure's RestError
|
|
807
|
-
// This allows you to test error handling more realistically.
|
|
808
804
|
declare class MockRestError extends Error {
|
|
809
805
|
statusCode: number;
|
|
810
806
|
constructor(message: string, statusCode: number);
|
|
811
807
|
}
|
|
812
808
|
//#endregion
|
|
813
809
|
//#region src/store/MockTableDatabase.d.ts
|
|
814
|
-
// Record<table, Map<compositeKey, entity>>
|
|
815
810
|
declare const MockTableDatabase: Map<string, Map<string, TableEntity>>;
|
|
816
811
|
//#endregion
|
|
817
812
|
//#region src/models/MockTableClient.d.ts
|
|
@@ -841,8 +836,8 @@ declare class MockTableClient implements Except<TableClient, "pipeline"> {
|
|
|
841
836
|
updateEntity<T extends object>(entity: TableEntity<T>, mode?: UpdateMode): Promise<TableMergeEntityHeaders>;
|
|
842
837
|
upsertEntity<T extends object>(entity: TableEntity<T>, mode?: UpdateMode): Promise<TableMergeEntityHeaders>;
|
|
843
838
|
private getCompositeKey;
|
|
839
|
+
private getEtag;
|
|
844
840
|
private mergeEntity;
|
|
845
|
-
// Helper to add mock metadata, similar to the real SDK
|
|
846
841
|
private withMetadata;
|
|
847
842
|
}
|
|
848
843
|
//#endregion
|
|
@@ -898,14 +893,13 @@ interface AbortSignalLike {
|
|
|
898
893
|
*/
|
|
899
894
|
removeEventListener(type: "abort", listener: (this: AbortSignalLike, ev: any) => any, options?: any): void;
|
|
900
895
|
}
|
|
901
|
-
//# sourceMappingURL=AbortSignalLike.d.ts.map
|
|
902
896
|
//#endregion
|
|
903
897
|
//#region ../../node_modules/.pnpm/@azure+abort-controller@2.1.2/node_modules/@azure/abort-controller/dist/esm/index.d.ts
|
|
904
898
|
declare global {
|
|
905
899
|
interface Event {}
|
|
906
900
|
}
|
|
907
901
|
//#endregion
|
|
908
|
-
//#region ../../node_modules/.pnpm/@azure+core-util@1.
|
|
902
|
+
//#region ../../node_modules/.pnpm/@azure+core-util@1.13.0/node_modules/@azure/core-util/dist/esm/index.d.ts
|
|
909
903
|
/**
|
|
910
904
|
* Supported HTTP methods to use when making requests.
|
|
911
905
|
*
|
|
@@ -917,7 +911,7 @@ type HttpMethods = "GET" | "PUT" | "POST" | "DELETE" | "PATCH" | "HEAD" | "OPTIO
|
|
|
917
911
|
*/
|
|
918
912
|
|
|
919
913
|
//#endregion
|
|
920
|
-
//#region ../../node_modules/.pnpm/@azure+core-tracing@1.
|
|
914
|
+
//#region ../../node_modules/.pnpm/@azure+core-tracing@1.3.0/node_modules/@azure/core-tracing/dist/esm/interfaces.d.ts
|
|
921
915
|
/** An immutable context bag of tracing values for the current operation. */
|
|
922
916
|
interface TracingContext {
|
|
923
917
|
/**
|
|
@@ -953,7 +947,7 @@ interface OperationTracingOptions {
|
|
|
953
947
|
* as part of an operation's options.
|
|
954
948
|
*/
|
|
955
949
|
//#endregion
|
|
956
|
-
//#region ../../node_modules/.pnpm/@azure+core-rest-pipeline@1.
|
|
950
|
+
//#region ../../node_modules/.pnpm/@azure+core-rest-pipeline@1.22.0/node_modules/@azure/core-rest-pipeline/dist/esm/interfaces.d.ts
|
|
957
951
|
/**
|
|
958
952
|
* A HttpHeaders collection represented as a simple JSON object.
|
|
959
953
|
*/
|
|
@@ -1289,9 +1283,8 @@ interface PxfObject {
|
|
|
1289
1283
|
*/
|
|
1290
1284
|
passphrase?: string | undefined;
|
|
1291
1285
|
}
|
|
1292
|
-
//# sourceMappingURL=interfaces.d.ts.map
|
|
1293
1286
|
//#endregion
|
|
1294
|
-
//#region ../../node_modules/.pnpm/@azure+core-rest-pipeline@1.
|
|
1287
|
+
//#region ../../node_modules/.pnpm/@azure+core-rest-pipeline@1.22.0/node_modules/@azure/core-rest-pipeline/dist/esm/index.d.ts
|
|
1295
1288
|
declare global {
|
|
1296
1289
|
interface FormData {}
|
|
1297
1290
|
interface Blob {}
|
|
@@ -1525,7 +1518,6 @@ type TransferProgressEvent = {
|
|
|
1525
1518
|
*/
|
|
1526
1519
|
loadedBytes: number;
|
|
1527
1520
|
};
|
|
1528
|
-
//# sourceMappingURL=util.d.ts.map
|
|
1529
1521
|
//#endregion
|
|
1530
1522
|
//#region src/util/toWebResourceLike.d.ts
|
|
1531
1523
|
declare const toWebResourceLike: (request: PipelineRequest) => WebResourceLike;
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ let Operation = /* @__PURE__ */ function(Operation$1) {
|
|
|
16
16
|
Operation$1["Delete"] = "Delete";
|
|
17
17
|
Operation$1["Push"] = "Push";
|
|
18
18
|
Operation$1["Read"] = "Read";
|
|
19
|
+
Operation$1["Unshift"] = "Unshift";
|
|
19
20
|
Operation$1["Update"] = "Update";
|
|
20
21
|
return Operation$1;
|
|
21
22
|
}({});
|
|
@@ -47,7 +48,7 @@ const getAzureErrorXml = (errorCode, errorMessage) => html`<?xml version="1.0" e
|
|
|
47
48
|
</Error>`;
|
|
48
49
|
|
|
49
50
|
//#endregion
|
|
50
|
-
//#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.
|
|
51
|
+
//#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.0/node_modules/@typespec/ts-http-runtime/dist/browser/httpHeaders.js
|
|
51
52
|
function normalizeName(name) {
|
|
52
53
|
return name.toLowerCase();
|
|
53
54
|
}
|
|
@@ -125,7 +126,7 @@ function createHttpHeaders$1(rawHeaders) {
|
|
|
125
126
|
}
|
|
126
127
|
|
|
127
128
|
//#endregion
|
|
128
|
-
//#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.
|
|
129
|
+
//#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.0/node_modules/@typespec/ts-http-runtime/dist/browser/util/uuidUtils.common.js
|
|
129
130
|
/**
|
|
130
131
|
* Generated Universally Unique Identifier
|
|
131
132
|
*
|
|
@@ -144,7 +145,7 @@ function generateUUID() {
|
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
//#endregion
|
|
147
|
-
//#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.
|
|
148
|
+
//#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.0/node_modules/@typespec/ts-http-runtime/dist/browser/util/uuidUtils.js
|
|
148
149
|
var _a;
|
|
149
150
|
const uuidFunction = typeof ((_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.crypto) === null || _a === void 0 ? void 0 : _a.randomUUID) === "function" ? globalThis.crypto.randomUUID.bind(globalThis.crypto) : generateUUID;
|
|
150
151
|
/**
|
|
@@ -157,7 +158,7 @@ function randomUUID() {
|
|
|
157
158
|
}
|
|
158
159
|
|
|
159
160
|
//#endregion
|
|
160
|
-
//#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.
|
|
161
|
+
//#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.0/node_modules/@typespec/ts-http-runtime/dist/browser/pipelineRequest.js
|
|
161
162
|
var PipelineRequestImpl = class {
|
|
162
163
|
constructor(options) {
|
|
163
164
|
var _a$1, _b, _c, _d, _e, _f, _g;
|
|
@@ -192,7 +193,7 @@ function createPipelineRequest$1(options) {
|
|
|
192
193
|
}
|
|
193
194
|
|
|
194
195
|
//#endregion
|
|
195
|
-
//#region ../../node_modules/.pnpm/@azure+core-rest-pipeline@1.
|
|
196
|
+
//#region ../../node_modules/.pnpm/@azure+core-rest-pipeline@1.22.0/node_modules/@azure/core-rest-pipeline/dist/browser/httpHeaders.js
|
|
196
197
|
/**
|
|
197
198
|
* Creates an object that satisfies the `HttpHeaders` interface.
|
|
198
199
|
* @param rawHeaders - A simple object representing initial headers
|
|
@@ -202,7 +203,7 @@ function createHttpHeaders(rawHeaders) {
|
|
|
202
203
|
}
|
|
203
204
|
|
|
204
205
|
//#endregion
|
|
205
|
-
//#region ../../node_modules/.pnpm/@azure+core-rest-pipeline@1.
|
|
206
|
+
//#region ../../node_modules/.pnpm/@azure+core-rest-pipeline@1.22.0/node_modules/@azure/core-rest-pipeline/dist/browser/pipelineRequest.js
|
|
206
207
|
/**
|
|
207
208
|
* Creates a new pipeline request with the given options.
|
|
208
209
|
* This method is to allow for the easy setting of default values and not required.
|
|
@@ -475,11 +476,13 @@ var MockRestError = class extends Error {
|
|
|
475
476
|
};
|
|
476
477
|
|
|
477
478
|
//#endregion
|
|
478
|
-
//#region ../../node_modules/.pnpm/@azure+storage-blob@12.
|
|
479
|
+
//#region ../../node_modules/.pnpm/@azure+storage-blob@12.28.0/node_modules/@azure/storage-blob/dist/browser/policies/RequestPolicy.js
|
|
479
480
|
/**
|
|
480
481
|
* The base class from which all request policies derive.
|
|
481
482
|
*/
|
|
482
483
|
var BaseRequestPolicy = class {
|
|
484
|
+
_nextPolicy;
|
|
485
|
+
_options;
|
|
483
486
|
/**
|
|
484
487
|
* The main method to implement that manipulates a request/response.
|
|
485
488
|
*/
|
|
@@ -507,7 +510,7 @@ var BaseRequestPolicy = class {
|
|
|
507
510
|
};
|
|
508
511
|
|
|
509
512
|
//#endregion
|
|
510
|
-
//#region ../../node_modules/.pnpm/@azure+storage-blob@12.
|
|
513
|
+
//#region ../../node_modules/.pnpm/@azure+storage-blob@12.28.0/node_modules/@azure/storage-blob/dist/browser/policies/CredentialPolicy.js
|
|
511
514
|
/**
|
|
512
515
|
* Credential policy used to sign HTTP(S) requests before sending. This is an
|
|
513
516
|
* abstract class.
|
|
@@ -533,7 +536,7 @@ var CredentialPolicy = class extends BaseRequestPolicy {
|
|
|
533
536
|
};
|
|
534
537
|
|
|
535
538
|
//#endregion
|
|
536
|
-
//#region ../../node_modules/.pnpm/@azure+storage-blob@12.
|
|
539
|
+
//#region ../../node_modules/.pnpm/@azure+storage-blob@12.28.0/node_modules/@azure/storage-blob/dist/browser/policies/AnonymousCredentialPolicy.js
|
|
537
540
|
/**
|
|
538
541
|
* AnonymousCredentialPolicy is used with HTTP(S) requests that read public resources
|
|
539
542
|
* or for use with Shared Access Signatures (SAS).
|
|
@@ -550,7 +553,7 @@ var AnonymousCredentialPolicy = class extends CredentialPolicy {
|
|
|
550
553
|
};
|
|
551
554
|
|
|
552
555
|
//#endregion
|
|
553
|
-
//#region ../../node_modules/.pnpm/@azure+storage-blob@12.
|
|
556
|
+
//#region ../../node_modules/.pnpm/@azure+storage-blob@12.28.0/node_modules/@azure/storage-blob/dist/browser/credentials/Credential.js
|
|
554
557
|
/**
|
|
555
558
|
* Credential is an abstract class for Azure Storage HTTP requests signing. This
|
|
556
559
|
* class will host an credentialPolicyCreator factory which generates CredentialPolicy.
|
|
@@ -568,7 +571,7 @@ var Credential = class {
|
|
|
568
571
|
};
|
|
569
572
|
|
|
570
573
|
//#endregion
|
|
571
|
-
//#region ../../node_modules/.pnpm/@azure+storage-blob@12.
|
|
574
|
+
//#region ../../node_modules/.pnpm/@azure+storage-blob@12.28.0/node_modules/@azure/storage-blob/dist/browser/credentials/AnonymousCredential.js
|
|
572
575
|
/**
|
|
573
576
|
* AnonymousCredential provides a credentialPolicyCreator member used to create
|
|
574
577
|
* AnonymousCredentialPolicy objects. AnonymousCredentialPolicy is used with
|
|
@@ -612,8 +615,37 @@ var MockBlobClient = class {
|
|
|
612
615
|
abortCopyFromURL() {
|
|
613
616
|
throw new Error("Method not implemented.");
|
|
614
617
|
}
|
|
615
|
-
beginCopyFromURL() {
|
|
616
|
-
|
|
618
|
+
beginCopyFromURL(copySource) {
|
|
619
|
+
const url = new URL(copySource);
|
|
620
|
+
const pathSegments = url.pathname.split("/").filter(Boolean);
|
|
621
|
+
if (pathSegments.length < 2) throw new MockRestError("Invalid copy source URL format", 400);
|
|
622
|
+
const sourceContainerName = pathSegments[0];
|
|
623
|
+
const sourceBlobName = pathSegments.slice(1).join("/");
|
|
624
|
+
const sourceContainer = MockContainerDatabase.get(sourceContainerName);
|
|
625
|
+
if (!sourceContainer) throw new MockRestError("Source container not found", 404);
|
|
626
|
+
const sourceData = sourceContainer.get(sourceBlobName);
|
|
627
|
+
if (!sourceData) throw new MockRestError("Source blob not found", 404);
|
|
628
|
+
this.container.set(this.name, Buffer.from(sourceData));
|
|
629
|
+
const response = { _response: {
|
|
630
|
+
headers: toHttpHeadersLike(createHttpHeaders()),
|
|
631
|
+
parsedHeaders: {},
|
|
632
|
+
request: toWebResourceLike(createPipelineRequest({ url: `${this.url}?comp=copy` })),
|
|
633
|
+
status: 202
|
|
634
|
+
} };
|
|
635
|
+
return Promise.resolve({
|
|
636
|
+
cancelOperation: () => Promise.resolve(),
|
|
637
|
+
getOperationState: () => ({
|
|
638
|
+
isCompleted: true,
|
|
639
|
+
result: response
|
|
640
|
+
}),
|
|
641
|
+
getResult: () => response,
|
|
642
|
+
isDone: () => true,
|
|
643
|
+
isStopped: () => false,
|
|
644
|
+
onProgress: () => () => {},
|
|
645
|
+
poll: () => Promise.resolve(),
|
|
646
|
+
pollUntilDone: () => Promise.resolve(response),
|
|
647
|
+
stopPolling: () => {}
|
|
648
|
+
});
|
|
617
649
|
}
|
|
618
650
|
createSnapshot() {
|
|
619
651
|
throw new Error("Method not implemented.");
|
|
@@ -661,7 +693,7 @@ var MockBlobClient = class {
|
|
|
661
693
|
throw new Error("Method not implemented.");
|
|
662
694
|
}
|
|
663
695
|
generateSasUrl() {
|
|
664
|
-
|
|
696
|
+
return Promise.resolve(`https://mockaccount.blob.core.windows.net/${this.containerName}/${this.name}?sv=2025-11-05&sr=b&sig=mock-signature&st=1970-01-01T00:00:00Z&se=2099-12-31T23:59:59Z&sp=r`);
|
|
665
697
|
}
|
|
666
698
|
generateUserDelegationSasStringToSign() {
|
|
667
699
|
throw new Error("Method not implemented.");
|
|
@@ -869,8 +901,15 @@ var MockContainerClient = class {
|
|
|
869
901
|
delete() {
|
|
870
902
|
throw new Error("Method not implemented.");
|
|
871
903
|
}
|
|
872
|
-
deleteBlob() {
|
|
873
|
-
throw new
|
|
904
|
+
deleteBlob(blobName) {
|
|
905
|
+
if (!this.container.has(blobName)) throw new MockRestError("The specified blob does not exist.", 404);
|
|
906
|
+
this.container.delete(blobName);
|
|
907
|
+
return Promise.resolve({ _response: {
|
|
908
|
+
headers: toHttpHeadersLike(createHttpHeaders()),
|
|
909
|
+
parsedHeaders: {},
|
|
910
|
+
request: toWebResourceLike(createPipelineRequest({ url: `${this.url}/${blobName}` })),
|
|
911
|
+
status: 200
|
|
912
|
+
} });
|
|
874
913
|
}
|
|
875
914
|
deleteIfExists() {
|
|
876
915
|
throw new Error("Method not implemented.");
|
|
@@ -885,7 +924,7 @@ var MockContainerClient = class {
|
|
|
885
924
|
throw new Error("Method not implemented.");
|
|
886
925
|
}
|
|
887
926
|
generateSasUrl() {
|
|
888
|
-
|
|
927
|
+
return Promise.resolve(`https://mockaccount.blob.core.windows.net/${this.containerName}?sv=2025-11-05&sr=c&sig=mock-signature&st=1970-01-01T00:00:00Z&se=2099-12-31T23:59:59Z&sp=rw`);
|
|
889
928
|
}
|
|
890
929
|
generateUserDelegationSasStringToSign() {
|
|
891
930
|
throw new Error("Method not implemented.");
|
|
@@ -1101,11 +1140,10 @@ var MockTableClient = class {
|
|
|
1101
1140
|
createEntity(entity) {
|
|
1102
1141
|
const key = this.getCompositeKey(entity.partitionKey, entity.rowKey);
|
|
1103
1142
|
if (this.table.has(key)) throw new MockRestError("The specified entity already exists.", 409);
|
|
1104
|
-
|
|
1105
|
-
this.table.set(key, storedEntity);
|
|
1143
|
+
this.table.set(key, entity);
|
|
1106
1144
|
return Promise.resolve({
|
|
1107
1145
|
date: /* @__PURE__ */ new Date(),
|
|
1108
|
-
etag:
|
|
1146
|
+
etag: this.getEtag()
|
|
1109
1147
|
});
|
|
1110
1148
|
}
|
|
1111
1149
|
createTable() {
|
|
@@ -1127,22 +1165,21 @@ var MockTableClient = class {
|
|
|
1127
1165
|
const key = this.getCompositeKey(partitionKey, rowKey);
|
|
1128
1166
|
const entity = this.table.get(key);
|
|
1129
1167
|
if (!entity) throw new MockRestError("The specified resource does not exist.", 404);
|
|
1130
|
-
|
|
1131
|
-
|
|
1168
|
+
return Promise.resolve({
|
|
1169
|
+
...entity,
|
|
1170
|
+
etag: this.getEtag()
|
|
1171
|
+
});
|
|
1132
1172
|
}
|
|
1133
1173
|
listEntities() {
|
|
1134
1174
|
const withMetadata = this.withMetadata.bind(this);
|
|
1135
1175
|
return {
|
|
1136
|
-
byPage: () => async function* (entities) {
|
|
1176
|
+
byPage: () => (async function* (entities) {
|
|
1137
1177
|
const allEntitiesWithMetadata = [...entities.values()].map(withMetadata);
|
|
1138
1178
|
if (allEntitiesWithMetadata.length > 0) yield await Promise.resolve(allEntitiesWithMetadata);
|
|
1139
|
-
}(this.table),
|
|
1140
|
-
next: () => async function* (entities) {
|
|
1141
|
-
for (const entity of entities.values())
|
|
1142
|
-
|
|
1143
|
-
yield await Promise.resolve(entityWithMetadata);
|
|
1144
|
-
}
|
|
1145
|
-
}(this.table).next(),
|
|
1179
|
+
})(this.table),
|
|
1180
|
+
next: () => (async function* (entities) {
|
|
1181
|
+
for (const entity of entities.values()) yield await Promise.resolve(withMetadata(entity));
|
|
1182
|
+
})(this.table).next(),
|
|
1146
1183
|
[Symbol.asyncIterator]() {
|
|
1147
1184
|
return this;
|
|
1148
1185
|
}
|
|
@@ -1159,42 +1196,42 @@ var MockTableClient = class {
|
|
|
1159
1196
|
const existingEntity = this.table.get(key);
|
|
1160
1197
|
if (!existingEntity) throw new MockRestError("The specified resource does not exist.", 404);
|
|
1161
1198
|
else if (mode === "Merge") return this.mergeEntity(key, existingEntity, entity);
|
|
1162
|
-
|
|
1163
|
-
this.table.set(key, newEntityWithMetadata);
|
|
1199
|
+
this.table.set(key, entity);
|
|
1164
1200
|
return Promise.resolve({
|
|
1165
1201
|
date: /* @__PURE__ */ new Date(),
|
|
1166
|
-
etag:
|
|
1202
|
+
etag: this.getEtag()
|
|
1167
1203
|
});
|
|
1168
1204
|
}
|
|
1169
1205
|
upsertEntity(entity, mode = "Merge") {
|
|
1170
1206
|
const key = this.getCompositeKey(entity.partitionKey, entity.rowKey);
|
|
1171
1207
|
const existingEntity = this.table.get(key);
|
|
1172
1208
|
if (existingEntity && mode === "Merge") return this.mergeEntity(key, existingEntity, entity);
|
|
1173
|
-
|
|
1174
|
-
this.table.set(key, newEntity);
|
|
1209
|
+
this.table.set(key, entity);
|
|
1175
1210
|
return Promise.resolve({
|
|
1176
1211
|
date: /* @__PURE__ */ new Date(),
|
|
1177
|
-
etag:
|
|
1212
|
+
etag: this.getEtag()
|
|
1178
1213
|
});
|
|
1179
1214
|
}
|
|
1180
1215
|
getCompositeKey(partitionKey, rowKey) {
|
|
1181
1216
|
return `${partitionKey}${ID_SEPARATOR}${rowKey}`;
|
|
1182
1217
|
}
|
|
1218
|
+
getEtag() {
|
|
1219
|
+
return `W/"datetime'${(/* @__PURE__ */ new Date()).toISOString()}'"`;
|
|
1220
|
+
}
|
|
1183
1221
|
mergeEntity(key, entity, entityToMerge) {
|
|
1184
|
-
|
|
1222
|
+
this.table.set(key, {
|
|
1185
1223
|
...entity,
|
|
1186
1224
|
...entityToMerge
|
|
1187
1225
|
});
|
|
1188
|
-
this.table.set(key, mergedEntityWithMetadata);
|
|
1189
1226
|
return Promise.resolve({
|
|
1190
1227
|
date: /* @__PURE__ */ new Date(),
|
|
1191
|
-
etag:
|
|
1228
|
+
etag: this.getEtag()
|
|
1192
1229
|
});
|
|
1193
1230
|
}
|
|
1194
1231
|
withMetadata(entity) {
|
|
1195
1232
|
return {
|
|
1196
1233
|
...entity,
|
|
1197
|
-
etag:
|
|
1234
|
+
etag: this.getEtag()
|
|
1198
1235
|
};
|
|
1199
1236
|
}
|
|
1200
1237
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "azure-mock",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"description": "A library that contains azure mock classes.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://github.com/Esposter/Esposter#readme",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@azure/core-http-compat": "^2.3.0",
|
|
33
|
-
"@azure/core-rest-pipeline": "^1.
|
|
33
|
+
"@azure/core-rest-pipeline": "^1.22.0",
|
|
34
34
|
"@azure/data-tables": "^13.3.1",
|
|
35
|
-
"@azure/storage-blob": "^12.
|
|
35
|
+
"@azure/storage-blob": "^12.28.0"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "ccf4ffe4c50cf43881b91045207eb5814ecf1cd3"
|
|
38
38
|
}
|