azure-mock 2.8.0 → 2.9.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 +17 -13
- package/dist/index.js +82 -42
- package/package.json +3 -3
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
|
|
@@ -867,6 +862,15 @@ declare const getBlobItemXml: ({
|
|
|
867
862
|
//#region src/util/getBlobPrefixXml.d.ts
|
|
868
863
|
declare const getBlobPrefixXml: (name: string) => string;
|
|
869
864
|
//#endregion
|
|
865
|
+
//#region src/util/getListBlobsXml.d.ts
|
|
866
|
+
/**
|
|
867
|
+
* Generates a standard Azure Storage list blobs XML response body.
|
|
868
|
+
* @param containerName The container name.
|
|
869
|
+
* @param blobsXml The blobs xml data.
|
|
870
|
+
* @returns A formatted XML string.
|
|
871
|
+
*/
|
|
872
|
+
declare const getListBlobsXml: (containerName: string, blobsXml: string) => string;
|
|
873
|
+
//#endregion
|
|
870
874
|
//#region src/util/isReadableStream.d.ts
|
|
871
875
|
declare const isReadableStream: (value: unknown) => value is NodeJS.ReadableStream;
|
|
872
876
|
//#endregion
|
|
@@ -896,7 +900,7 @@ declare global {
|
|
|
896
900
|
interface Event {}
|
|
897
901
|
}
|
|
898
902
|
//#endregion
|
|
899
|
-
//#region ../../node_modules/.pnpm/@azure+core-util@1.
|
|
903
|
+
//#region ../../node_modules/.pnpm/@azure+core-util@1.13.0/node_modules/@azure/core-util/dist/esm/index.d.ts
|
|
900
904
|
/**
|
|
901
905
|
* Supported HTTP methods to use when making requests.
|
|
902
906
|
*
|
|
@@ -908,7 +912,7 @@ type HttpMethods = "GET" | "PUT" | "POST" | "DELETE" | "PATCH" | "HEAD" | "OPTIO
|
|
|
908
912
|
*/
|
|
909
913
|
|
|
910
914
|
//#endregion
|
|
911
|
-
//#region ../../node_modules/.pnpm/@azure+core-tracing@1.
|
|
915
|
+
//#region ../../node_modules/.pnpm/@azure+core-tracing@1.3.0/node_modules/@azure/core-tracing/dist/esm/interfaces.d.ts
|
|
912
916
|
/** An immutable context bag of tracing values for the current operation. */
|
|
913
917
|
interface TracingContext {
|
|
914
918
|
/**
|
|
@@ -944,7 +948,7 @@ interface OperationTracingOptions {
|
|
|
944
948
|
* as part of an operation's options.
|
|
945
949
|
*/
|
|
946
950
|
//#endregion
|
|
947
|
-
//#region ../../node_modules/.pnpm/@azure+core-rest-pipeline@1.
|
|
951
|
+
//#region ../../node_modules/.pnpm/@azure+core-rest-pipeline@1.22.0/node_modules/@azure/core-rest-pipeline/dist/esm/interfaces.d.ts
|
|
948
952
|
/**
|
|
949
953
|
* A HttpHeaders collection represented as a simple JSON object.
|
|
950
954
|
*/
|
|
@@ -1282,7 +1286,7 @@ interface PxfObject {
|
|
|
1282
1286
|
}
|
|
1283
1287
|
//# sourceMappingURL=interfaces.d.ts.map
|
|
1284
1288
|
//#endregion
|
|
1285
|
-
//#region ../../node_modules/.pnpm/@azure+core-rest-pipeline@1.
|
|
1289
|
+
//#region ../../node_modules/.pnpm/@azure+core-rest-pipeline@1.22.0/node_modules/@azure/core-rest-pipeline/dist/esm/index.d.ts
|
|
1286
1290
|
declare global {
|
|
1287
1291
|
interface FormData {}
|
|
1288
1292
|
interface Blob {}
|
|
@@ -1521,4 +1525,4 @@ type TransferProgressEvent = {
|
|
|
1521
1525
|
//#region src/util/toWebResourceLike.d.ts
|
|
1522
1526
|
declare const toWebResourceLike: (request: PipelineRequest) => WebResourceLike;
|
|
1523
1527
|
//#endregion
|
|
1524
|
-
export { BlobHierarchyItem, MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerClient, MockContainerDatabase, MockRestError, MockTableClient, MockTableDatabase, PageSettings, PagedAsyncIterableIterator, bodyToBuffer, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, isReadableStream, toWebResourceLike };
|
|
1528
|
+
export { BlobHierarchyItem, MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerClient, MockContainerDatabase, MockRestError, MockTableClient, MockTableDatabase, PageSettings, PagedAsyncIterableIterator, bodyToBuffer, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, getListBlobsXml, isReadableStream, toWebResourceLike };
|
package/dist/index.js
CHANGED
|
@@ -47,7 +47,7 @@ const getAzureErrorXml = (errorCode, errorMessage) => html`<?xml version="1.0" e
|
|
|
47
47
|
</Error>`;
|
|
48
48
|
|
|
49
49
|
//#endregion
|
|
50
|
-
//#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.
|
|
50
|
+
//#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.0/node_modules/@typespec/ts-http-runtime/dist/browser/httpHeaders.js
|
|
51
51
|
function normalizeName(name) {
|
|
52
52
|
return name.toLowerCase();
|
|
53
53
|
}
|
|
@@ -125,7 +125,7 @@ function createHttpHeaders$1(rawHeaders) {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
//#endregion
|
|
128
|
-
//#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.
|
|
128
|
+
//#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.0/node_modules/@typespec/ts-http-runtime/dist/browser/util/uuidUtils.common.js
|
|
129
129
|
/**
|
|
130
130
|
* Generated Universally Unique Identifier
|
|
131
131
|
*
|
|
@@ -144,7 +144,7 @@ function generateUUID() {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
//#endregion
|
|
147
|
-
//#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.
|
|
147
|
+
//#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.0/node_modules/@typespec/ts-http-runtime/dist/browser/util/uuidUtils.js
|
|
148
148
|
var _a;
|
|
149
149
|
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
150
|
/**
|
|
@@ -157,7 +157,7 @@ function randomUUID() {
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
//#endregion
|
|
160
|
-
//#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.
|
|
160
|
+
//#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.0/node_modules/@typespec/ts-http-runtime/dist/browser/pipelineRequest.js
|
|
161
161
|
var PipelineRequestImpl = class {
|
|
162
162
|
constructor(options) {
|
|
163
163
|
var _a$1, _b, _c, _d, _e, _f, _g;
|
|
@@ -192,7 +192,7 @@ function createPipelineRequest$1(options) {
|
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
//#endregion
|
|
195
|
-
//#region ../../node_modules/.pnpm/@azure+core-rest-pipeline@1.
|
|
195
|
+
//#region ../../node_modules/.pnpm/@azure+core-rest-pipeline@1.22.0/node_modules/@azure/core-rest-pipeline/dist/browser/httpHeaders.js
|
|
196
196
|
/**
|
|
197
197
|
* Creates an object that satisfies the `HttpHeaders` interface.
|
|
198
198
|
* @param rawHeaders - A simple object representing initial headers
|
|
@@ -202,7 +202,7 @@ function createHttpHeaders(rawHeaders) {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
//#endregion
|
|
205
|
-
//#region ../../node_modules/.pnpm/@azure+core-rest-pipeline@1.
|
|
205
|
+
//#region ../../node_modules/.pnpm/@azure+core-rest-pipeline@1.22.0/node_modules/@azure/core-rest-pipeline/dist/browser/pipelineRequest.js
|
|
206
206
|
/**
|
|
207
207
|
* Creates a new pipeline request with the given options.
|
|
208
208
|
* This method is to allow for the easy setting of default values and not required.
|
|
@@ -612,8 +612,37 @@ var MockBlobClient = class {
|
|
|
612
612
|
abortCopyFromURL() {
|
|
613
613
|
throw new Error("Method not implemented.");
|
|
614
614
|
}
|
|
615
|
-
beginCopyFromURL() {
|
|
616
|
-
|
|
615
|
+
beginCopyFromURL(copySource) {
|
|
616
|
+
const url = new URL(copySource);
|
|
617
|
+
const pathSegments = url.pathname.split("/").filter(Boolean);
|
|
618
|
+
if (pathSegments.length < 2) throw new MockRestError("Invalid copy source URL format", 400);
|
|
619
|
+
const sourceContainerName = pathSegments[0];
|
|
620
|
+
const sourceBlobName = pathSegments.slice(1).join("/");
|
|
621
|
+
const sourceContainer = MockContainerDatabase.get(sourceContainerName);
|
|
622
|
+
if (!sourceContainer) throw new MockRestError("Source container not found", 404);
|
|
623
|
+
const sourceData = sourceContainer.get(sourceBlobName);
|
|
624
|
+
if (!sourceData) throw new MockRestError("Source blob not found", 404);
|
|
625
|
+
this.container.set(this.name, Buffer.from(sourceData));
|
|
626
|
+
const response = { _response: {
|
|
627
|
+
headers: toHttpHeadersLike(createHttpHeaders()),
|
|
628
|
+
parsedHeaders: {},
|
|
629
|
+
request: toWebResourceLike(createPipelineRequest({ url: `${this.url}?comp=copy` })),
|
|
630
|
+
status: 202
|
|
631
|
+
} };
|
|
632
|
+
return Promise.resolve({
|
|
633
|
+
cancelOperation: () => Promise.resolve(),
|
|
634
|
+
getOperationState: () => ({
|
|
635
|
+
isCompleted: true,
|
|
636
|
+
result: response
|
|
637
|
+
}),
|
|
638
|
+
getResult: () => response,
|
|
639
|
+
isDone: () => true,
|
|
640
|
+
isStopped: () => false,
|
|
641
|
+
onProgress: () => () => {},
|
|
642
|
+
poll: () => Promise.resolve(),
|
|
643
|
+
pollUntilDone: () => Promise.resolve(response),
|
|
644
|
+
stopPolling: () => {}
|
|
645
|
+
});
|
|
617
646
|
}
|
|
618
647
|
createSnapshot() {
|
|
619
648
|
throw new Error("Method not implemented.");
|
|
@@ -661,7 +690,7 @@ var MockBlobClient = class {
|
|
|
661
690
|
throw new Error("Method not implemented.");
|
|
662
691
|
}
|
|
663
692
|
generateSasUrl() {
|
|
664
|
-
|
|
693
|
+
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
694
|
}
|
|
666
695
|
generateUserDelegationSasStringToSign() {
|
|
667
696
|
throw new Error("Method not implemented.");
|
|
@@ -816,6 +845,20 @@ const getBlobItemXml = ({ name, properties }) => html`<Blob>
|
|
|
816
845
|
//#region src/util/getBlobPrefixXml.ts
|
|
817
846
|
const getBlobPrefixXml = (name) => html`<BlobPrefix><Name>${name}</Name></BlobPrefix>`;
|
|
818
847
|
|
|
848
|
+
//#endregion
|
|
849
|
+
//#region src/util/getListBlobsXml.ts
|
|
850
|
+
/**
|
|
851
|
+
* Generates a standard Azure Storage list blobs XML response body.
|
|
852
|
+
* @param containerName The container name.
|
|
853
|
+
* @param blobsXml The blobs xml data.
|
|
854
|
+
* @returns A formatted XML string.
|
|
855
|
+
*/
|
|
856
|
+
const getListBlobsXml = (containerName, blobsXml) => html`<?xml version="1.0" encoding="utf8"?>
|
|
857
|
+
<EnumerationResults ServiceEndpoint="" ContainerName="${containerName}">
|
|
858
|
+
<Blobs>${blobsXml}</Blobs>
|
|
859
|
+
<NextMarker />
|
|
860
|
+
</EnumerationResults>`;
|
|
861
|
+
|
|
819
862
|
//#endregion
|
|
820
863
|
//#region src/models/MockContainerClient.ts
|
|
821
864
|
/**
|
|
@@ -855,8 +898,15 @@ var MockContainerClient = class {
|
|
|
855
898
|
delete() {
|
|
856
899
|
throw new Error("Method not implemented.");
|
|
857
900
|
}
|
|
858
|
-
deleteBlob() {
|
|
859
|
-
throw new
|
|
901
|
+
deleteBlob(blobName) {
|
|
902
|
+
if (!this.container.has(blobName)) throw new MockRestError("The specified blob does not exist.", 404);
|
|
903
|
+
this.container.delete(blobName);
|
|
904
|
+
return Promise.resolve({ _response: {
|
|
905
|
+
headers: toHttpHeadersLike(createHttpHeaders()),
|
|
906
|
+
parsedHeaders: {},
|
|
907
|
+
request: toWebResourceLike(createPipelineRequest({ url: `${this.url}/${blobName}` })),
|
|
908
|
+
status: 200
|
|
909
|
+
} });
|
|
860
910
|
}
|
|
861
911
|
deleteIfExists() {
|
|
862
912
|
throw new Error("Method not implemented.");
|
|
@@ -871,7 +921,7 @@ var MockContainerClient = class {
|
|
|
871
921
|
throw new Error("Method not implemented.");
|
|
872
922
|
}
|
|
873
923
|
generateSasUrl() {
|
|
874
|
-
|
|
924
|
+
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`);
|
|
875
925
|
}
|
|
876
926
|
generateUserDelegationSasStringToSign() {
|
|
877
927
|
throw new Error("Method not implemented.");
|
|
@@ -923,11 +973,7 @@ var MockContainerClient = class {
|
|
|
923
973
|
}
|
|
924
974
|
if (allBlobItems.length > 0 || allBlobPrefixes.length > 0) yield await Promise.resolve({
|
|
925
975
|
_response: {
|
|
926
|
-
bodyAsText:
|
|
927
|
-
<EnumerationResults ServiceEndpoint="" ContainerName="${this.containerName}">
|
|
928
|
-
<Blobs>${allBlobItemXml.join("")}${allBlobPrefixXml.join("")}</Blobs>
|
|
929
|
-
<NextMarker />
|
|
930
|
-
</EnumerationResults>`,
|
|
976
|
+
bodyAsText: getListBlobsXml(this.containerName, `${allBlobItemXml.join("")}${allBlobPrefixXml.join("")}`),
|
|
931
977
|
headers: toHttpHeadersLike(createHttpHeaders()),
|
|
932
978
|
parsedBody: {
|
|
933
979
|
containerName: this.containerName,
|
|
@@ -965,11 +1011,7 @@ var MockContainerClient = class {
|
|
|
965
1011
|
}
|
|
966
1012
|
if (allBlobItems.length > 0) yield await Promise.resolve({
|
|
967
1013
|
_response: {
|
|
968
|
-
bodyAsText:
|
|
969
|
-
<EnumerationResults ServiceEndpoint="" ContainerName="${this.containerName}">
|
|
970
|
-
<Blobs>${allBlobItemXml.join("")}</Blobs>
|
|
971
|
-
<NextMarker />
|
|
972
|
-
</EnumerationResults>`,
|
|
1014
|
+
bodyAsText: getListBlobsXml(this.containerName, allBlobItemXml.join("")),
|
|
973
1015
|
headers: toHttpHeadersLike(createHttpHeaders()),
|
|
974
1016
|
parsedBody: {
|
|
975
1017
|
containerName: this.containerName,
|
|
@@ -1095,11 +1137,10 @@ var MockTableClient = class {
|
|
|
1095
1137
|
createEntity(entity) {
|
|
1096
1138
|
const key = this.getCompositeKey(entity.partitionKey, entity.rowKey);
|
|
1097
1139
|
if (this.table.has(key)) throw new MockRestError("The specified entity already exists.", 409);
|
|
1098
|
-
|
|
1099
|
-
this.table.set(key, storedEntity);
|
|
1140
|
+
this.table.set(key, entity);
|
|
1100
1141
|
return Promise.resolve({
|
|
1101
1142
|
date: /* @__PURE__ */ new Date(),
|
|
1102
|
-
etag:
|
|
1143
|
+
etag: this.getEtag()
|
|
1103
1144
|
});
|
|
1104
1145
|
}
|
|
1105
1146
|
createTable() {
|
|
@@ -1121,8 +1162,10 @@ var MockTableClient = class {
|
|
|
1121
1162
|
const key = this.getCompositeKey(partitionKey, rowKey);
|
|
1122
1163
|
const entity = this.table.get(key);
|
|
1123
1164
|
if (!entity) throw new MockRestError("The specified resource does not exist.", 404);
|
|
1124
|
-
|
|
1125
|
-
|
|
1165
|
+
return Promise.resolve({
|
|
1166
|
+
...entity,
|
|
1167
|
+
etag: this.getEtag()
|
|
1168
|
+
});
|
|
1126
1169
|
}
|
|
1127
1170
|
listEntities() {
|
|
1128
1171
|
const withMetadata = this.withMetadata.bind(this);
|
|
@@ -1132,10 +1175,7 @@ var MockTableClient = class {
|
|
|
1132
1175
|
if (allEntitiesWithMetadata.length > 0) yield await Promise.resolve(allEntitiesWithMetadata);
|
|
1133
1176
|
}(this.table),
|
|
1134
1177
|
next: () => async function* (entities) {
|
|
1135
|
-
for (const entity of entities.values())
|
|
1136
|
-
const entityWithMetadata = withMetadata(entity);
|
|
1137
|
-
yield await Promise.resolve(entityWithMetadata);
|
|
1138
|
-
}
|
|
1178
|
+
for (const entity of entities.values()) yield await Promise.resolve(withMetadata(entity));
|
|
1139
1179
|
}(this.table).next(),
|
|
1140
1180
|
[Symbol.asyncIterator]() {
|
|
1141
1181
|
return this;
|
|
@@ -1153,45 +1193,45 @@ var MockTableClient = class {
|
|
|
1153
1193
|
const existingEntity = this.table.get(key);
|
|
1154
1194
|
if (!existingEntity) throw new MockRestError("The specified resource does not exist.", 404);
|
|
1155
1195
|
else if (mode === "Merge") return this.mergeEntity(key, existingEntity, entity);
|
|
1156
|
-
|
|
1157
|
-
this.table.set(key, newEntityWithMetadata);
|
|
1196
|
+
this.table.set(key, entity);
|
|
1158
1197
|
return Promise.resolve({
|
|
1159
1198
|
date: /* @__PURE__ */ new Date(),
|
|
1160
|
-
etag:
|
|
1199
|
+
etag: this.getEtag()
|
|
1161
1200
|
});
|
|
1162
1201
|
}
|
|
1163
1202
|
upsertEntity(entity, mode = "Merge") {
|
|
1164
1203
|
const key = this.getCompositeKey(entity.partitionKey, entity.rowKey);
|
|
1165
1204
|
const existingEntity = this.table.get(key);
|
|
1166
1205
|
if (existingEntity && mode === "Merge") return this.mergeEntity(key, existingEntity, entity);
|
|
1167
|
-
|
|
1168
|
-
this.table.set(key, newEntity);
|
|
1206
|
+
this.table.set(key, entity);
|
|
1169
1207
|
return Promise.resolve({
|
|
1170
1208
|
date: /* @__PURE__ */ new Date(),
|
|
1171
|
-
etag:
|
|
1209
|
+
etag: this.getEtag()
|
|
1172
1210
|
});
|
|
1173
1211
|
}
|
|
1174
1212
|
getCompositeKey(partitionKey, rowKey) {
|
|
1175
1213
|
return `${partitionKey}${ID_SEPARATOR}${rowKey}`;
|
|
1176
1214
|
}
|
|
1215
|
+
getEtag() {
|
|
1216
|
+
return `W/"datetime'${(/* @__PURE__ */ new Date()).toISOString()}'"`;
|
|
1217
|
+
}
|
|
1177
1218
|
mergeEntity(key, entity, entityToMerge) {
|
|
1178
|
-
|
|
1219
|
+
this.table.set(key, {
|
|
1179
1220
|
...entity,
|
|
1180
1221
|
...entityToMerge
|
|
1181
1222
|
});
|
|
1182
|
-
this.table.set(key, mergedEntityWithMetadata);
|
|
1183
1223
|
return Promise.resolve({
|
|
1184
1224
|
date: /* @__PURE__ */ new Date(),
|
|
1185
|
-
etag:
|
|
1225
|
+
etag: this.getEtag()
|
|
1186
1226
|
});
|
|
1187
1227
|
}
|
|
1188
1228
|
withMetadata(entity) {
|
|
1189
1229
|
return {
|
|
1190
1230
|
...entity,
|
|
1191
|
-
etag:
|
|
1231
|
+
etag: this.getEtag()
|
|
1192
1232
|
};
|
|
1193
1233
|
}
|
|
1194
1234
|
};
|
|
1195
1235
|
|
|
1196
1236
|
//#endregion
|
|
1197
|
-
export { MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerClient, MockContainerDatabase, MockRestError, MockTableClient, MockTableDatabase, bodyToBuffer, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, isReadableStream, toWebResourceLike };
|
|
1237
|
+
export { MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerClient, MockContainerDatabase, MockRestError, MockTableClient, MockTableDatabase, bodyToBuffer, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, getListBlobsXml, isReadableStream, toWebResourceLike };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "azure-mock",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.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
35
|
"@azure/storage-blob": "^12.27.0"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "9fc7b20cf4085cca521b09f7f49259b3dc488b68"
|
|
38
38
|
}
|