azure-mock 2.34.0 → 2.34.2
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 +12 -2
- package/dist/index.js +54 -128
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { HttpHeadersLike, WebResourceLike } from "@azure/core-http-compat";
|
|
1
2
|
import { MapValue } from "@esposter/shared";
|
|
2
|
-
import { WebResourceLike } from "@azure/core-http-compat";
|
|
3
3
|
import { PipelineRequest } from "@azure/core-rest-pipeline";
|
|
4
4
|
import { AnonymousCredential, AppendBlobClient, BlobAbortCopyFromURLResponse, BlobBatchClient, BlobBatchDeleteBlobsResponse, BlobBeginCopyFromURLResponse, BlobClient, BlobCopyFromURLResponse, BlobCreateSnapshotResponse, BlobDeleteIfExistsResponse, BlobDeleteImmutabilityPolicyResponse, BlobDeleteOptions, BlobDeleteResponse, BlobDownloadResponseModel, BlobDownloadResponseParsed, BlobGenerateSasUrlOptions, BlobGetAccountInfoResponse, BlobGetPropertiesResponse, BlobGetTagsResponse, BlobItem, BlobLeaseClient, BlobPrefix, BlobSetHTTPHeadersResponse, BlobSetImmutabilityPolicyResponse, BlobSetLegalHoldResponse, BlobSetMetadataResponse, BlobSetTagsResponse, BlobSetTierResponse, BlobUndeleteResponse, BlobUploadCommonResponse, BlockBlobClient, BlockBlobCommitBlockListResponse, BlockBlobGetBlockListResponse, BlockBlobPutBlobFromUrlResponse, BlockBlobStageBlockFromURLResponse, BlockBlobStageBlockResponse, BlockBlobUploadResponse, ContainerClient, ContainerCreateIfNotExistsResponse, ContainerCreateResponse, ContainerDeleteIfExistsResponse, ContainerDeleteResponse, ContainerFindBlobsByTagsSegmentResponse, ContainerGenerateSasUrlOptions, ContainerGetAccessPolicyResponse, ContainerGetAccountInfoResponse, ContainerGetPropertiesResponse, ContainerListBlobFlatSegmentResponse, ContainerListBlobHierarchySegmentResponse, ContainerListBlobsOptions, ContainerSetAccessPolicyResponse, ContainerSetMetadataResponse, FilterBlobItem, HttpRequestBody, PageBlobClient, PollOperationState, PollerLikeWithCancellation, StorageSharedKeyCredential } from "@azure/storage-blob";
|
|
5
5
|
import { BinaryOperator, Clause } from "@esposter/db-schema";
|
|
@@ -11,6 +11,12 @@ declare const MOCK_BLOB_BASE_URL = "https://mockaccount.blob.core.windows.net";
|
|
|
11
11
|
declare const MOCK_QUEUE_BASE_URL = "https://mockaccount.queue.core.windows.net";
|
|
12
12
|
declare const MOCK_SEARCH_BASE_URL = "https://mockaccount.search.windows.net";
|
|
13
13
|
declare const MOCK_TABLE_BASE_URL = "https://mockaccount.table.core.windows.net";
|
|
14
|
+
interface MockResponse {
|
|
15
|
+
headers: HttpHeadersLike;
|
|
16
|
+
parsedHeaders: Record<string, never>;
|
|
17
|
+
request: WebResourceLike;
|
|
18
|
+
status: number;
|
|
19
|
+
}
|
|
14
20
|
declare class MockRestError extends Error {
|
|
15
21
|
statusCode: number;
|
|
16
22
|
constructor(message: string, statusCode: number);
|
|
@@ -45,6 +51,10 @@ interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings
|
|
|
45
51
|
*/
|
|
46
52
|
next: () => Promise<IteratorResult<TElement>>;
|
|
47
53
|
}
|
|
54
|
+
declare const createMockResponse: (status: number, url?: string) => MockResponse;
|
|
55
|
+
declare const getMockSasUrl: (url: string, permissions: undefined | {
|
|
56
|
+
toString: () => string;
|
|
57
|
+
}, resourceType?: string) => string;
|
|
48
58
|
declare const MockContainerDatabase: Map<string, Map<string, Buffer>>;
|
|
49
59
|
declare const MockEventGridDatabase: Map<string, EventGridEvent<unknown>[]>;
|
|
50
60
|
declare const MockQueueDatabase: Map<string, string[]>;
|
|
@@ -1067,4 +1077,4 @@ declare const applyFilter: <T extends Record<string, unknown>>(documents: T[], c
|
|
|
1067
1077
|
declare const compare: <T>(operator: BinaryOperator, leftHandSide: T, rightHandSide: null | T) => boolean;
|
|
1068
1078
|
declare const createFilterPredicate: (filter: string) => ((document: Record<string, unknown>) => boolean);
|
|
1069
1079
|
declare const isNullClause: (clause: Clause<Record<string, unknown>>) => boolean;
|
|
1070
|
-
export { BlobHierarchyItem, MOCK_BLOB_BASE_URL, MOCK_QUEUE_BASE_URL, MOCK_SEARCH_BASE_URL, MOCK_TABLE_BASE_URL, MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerClient, MockContainerDatabase, MockEventGridDatabase, MockEventGridPublisherClient, MockQueueClient, MockQueueDatabase, MockRestError, MockSearchClient, MockSearchDatabase, MockTableClient, MockTableDatabase, MockWebPubSubServiceClient, PageSettings, PagedAsyncIterableIterator, applyFilter, bodyToBuffer, compare, createFilterPredicate, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, getListBlobsXml, isNullClause, isReadableStream, toWebResourceLike };
|
|
1080
|
+
export { BlobHierarchyItem, MOCK_BLOB_BASE_URL, MOCK_QUEUE_BASE_URL, MOCK_SEARCH_BASE_URL, MOCK_TABLE_BASE_URL, MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerClient, MockContainerDatabase, MockEventGridDatabase, MockEventGridPublisherClient, MockQueueClient, MockQueueDatabase, MockResponse, MockRestError, MockSearchClient, MockSearchDatabase, MockTableClient, MockTableDatabase, MockWebPubSubServiceClient, PageSettings, PagedAsyncIterableIterator, applyFilter, bodyToBuffer, compare, createFilterPredicate, createMockResponse, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, getListBlobsXml, getMockSasUrl, isNullClause, isReadableStream, toWebResourceLike };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ID_SEPARATOR, InvalidOperationError, Operation, exhaustiveGuard, getResultAsync, html, noop, streamToText, takeOne } from "@esposter/shared";
|
|
2
1
|
import { toHttpHeadersLike } from "@azure/core-http-compat";
|
|
2
|
+
import { ID_SEPARATOR, InvalidOperationError, Operation, exhaustiveGuard, getOrCreate, getResultAsync, html, noop, streamToText, takeOne } from "@esposter/shared";
|
|
3
3
|
import { createHttpHeaders, createPipelineRequest } from "@azure/core-rest-pipeline";
|
|
4
4
|
import { AnonymousCredential } from "@azure/storage-blob";
|
|
5
5
|
import { Readable } from "node:stream";
|
|
@@ -38,22 +38,6 @@ var MockRestError = class extends Error {
|
|
|
38
38
|
this.statusCode = statusCode;
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
const MockContainerDatabase = /* @__PURE__ */ new Map();
|
|
42
|
-
const MockEventGridDatabase = /* @__PURE__ */ new Map();
|
|
43
|
-
const MockQueueDatabase = /* @__PURE__ */ new Map();
|
|
44
|
-
const MockSearchDatabase = /* @__PURE__ */ new Map();
|
|
45
|
-
const MockTableDatabase = /* @__PURE__ */ new Map();
|
|
46
|
-
/**
|
|
47
|
-
* Generates a standard Azure Storage error XML response body.
|
|
48
|
-
* @param errorCode The official Azure error code (e.g., "BlobNotFound").
|
|
49
|
-
* @param errorMessage The user-friendly error message.
|
|
50
|
-
* @returns A formatted XML string.
|
|
51
|
-
*/
|
|
52
|
-
const getAzureErrorXml = (errorCode, errorMessage) => html`<?xml version="1.0" encoding="utf-8"?>
|
|
53
|
-
<Error>
|
|
54
|
-
<code>${errorCode}</code>
|
|
55
|
-
<Message>${errorMessage}</Message>
|
|
56
|
-
</Error>`;
|
|
57
41
|
const toWebResourceLike = (request) => ({
|
|
58
42
|
abortSignal: request.abortSignal,
|
|
59
43
|
agent: request.agent,
|
|
@@ -79,6 +63,29 @@ const toWebResourceLike = (request) => ({
|
|
|
79
63
|
validateRequestProperties: noop,
|
|
80
64
|
withCredentials: request.withCredentials
|
|
81
65
|
});
|
|
66
|
+
const createMockResponse = (status, url = "") => ({
|
|
67
|
+
headers: toHttpHeadersLike(createHttpHeaders()),
|
|
68
|
+
parsedHeaders: {},
|
|
69
|
+
request: toWebResourceLike(createPipelineRequest({ url })),
|
|
70
|
+
status
|
|
71
|
+
});
|
|
72
|
+
const getMockSasUrl = (url, permissions, resourceType) => `${url}?sv=2025-11-05&${resourceType ? `sr=${resourceType}&` : ""}sig=mock-signature&st=1970-01-01T00:00:00Z&se=2099-12-31T23:59:59Z&sp=${permissions?.toString() ?? "r"}`;
|
|
73
|
+
const MockContainerDatabase = /* @__PURE__ */ new Map();
|
|
74
|
+
const MockEventGridDatabase = /* @__PURE__ */ new Map();
|
|
75
|
+
const MockQueueDatabase = /* @__PURE__ */ new Map();
|
|
76
|
+
const MockSearchDatabase = /* @__PURE__ */ new Map();
|
|
77
|
+
const MockTableDatabase = /* @__PURE__ */ new Map();
|
|
78
|
+
/**
|
|
79
|
+
* Generates a standard Azure Storage error XML response body.
|
|
80
|
+
* @param errorCode The official Azure error code (e.g., "BlobNotFound").
|
|
81
|
+
* @param errorMessage The user-friendly error message.
|
|
82
|
+
* @returns A formatted XML string.
|
|
83
|
+
*/
|
|
84
|
+
const getAzureErrorXml = (errorCode, errorMessage) => html`<?xml version="1.0" encoding="utf-8"?>
|
|
85
|
+
<Error>
|
|
86
|
+
<code>${errorCode}</code>
|
|
87
|
+
<Message>${errorMessage}</Message>
|
|
88
|
+
</Error>`;
|
|
82
89
|
var MockBlobBatchClient = class {
|
|
83
90
|
url;
|
|
84
91
|
constructor(url) {
|
|
@@ -111,6 +118,7 @@ var MockBlobBatchClient = class {
|
|
|
111
118
|
statusMessage
|
|
112
119
|
});
|
|
113
120
|
subResponsesFailedCount++;
|
|
121
|
+
continue;
|
|
114
122
|
}
|
|
115
123
|
const containerName = takeOne(pathSegments);
|
|
116
124
|
const blobName = pathSegments.slice(1).join("/");
|
|
@@ -146,13 +154,11 @@ var MockBlobBatchClient = class {
|
|
|
146
154
|
}
|
|
147
155
|
return Promise.resolve({
|
|
148
156
|
_response: {
|
|
157
|
+
...createMockResponse(202, this.url),
|
|
149
158
|
headers: toHttpHeadersLike(createHttpHeaders({
|
|
150
159
|
"content-type": "multipart/mixed",
|
|
151
160
|
"x-ms-request-id": crypto.randomUUID()
|
|
152
|
-
}))
|
|
153
|
-
parsedHeaders: {},
|
|
154
|
-
request: toWebResourceLike(createPipelineRequest({ url: this.url })),
|
|
155
|
-
status: 202
|
|
161
|
+
}))
|
|
156
162
|
},
|
|
157
163
|
subResponses,
|
|
158
164
|
subResponsesFailedCount,
|
|
@@ -160,12 +166,7 @@ var MockBlobBatchClient = class {
|
|
|
160
166
|
});
|
|
161
167
|
}
|
|
162
168
|
getContainer(containerName) {
|
|
163
|
-
|
|
164
|
-
if (!container) {
|
|
165
|
-
container = /* @__PURE__ */ new Map();
|
|
166
|
-
MockContainerDatabase.set(containerName, container);
|
|
167
|
-
}
|
|
168
|
-
return container;
|
|
169
|
+
return getOrCreate(MockContainerDatabase, containerName, () => /* @__PURE__ */ new Map());
|
|
169
170
|
}
|
|
170
171
|
};
|
|
171
172
|
var MockBlobClient = class {
|
|
@@ -175,12 +176,7 @@ var MockBlobClient = class {
|
|
|
175
176
|
name;
|
|
176
177
|
url;
|
|
177
178
|
get container() {
|
|
178
|
-
|
|
179
|
-
if (!container) {
|
|
180
|
-
container = /* @__PURE__ */ new Map();
|
|
181
|
-
MockContainerDatabase.set(this.containerName, container);
|
|
182
|
-
}
|
|
183
|
-
return container;
|
|
179
|
+
return getOrCreate(MockContainerDatabase, this.containerName, () => /* @__PURE__ */ new Map());
|
|
184
180
|
}
|
|
185
181
|
constructor(connectionString, containerName, blobName) {
|
|
186
182
|
this.connectionString = connectionString;
|
|
@@ -201,12 +197,7 @@ var MockBlobClient = class {
|
|
|
201
197
|
const sourceData = sourceContainer.get(sourceBlobName);
|
|
202
198
|
if (!sourceData) throw new MockRestError("Source blob not found", 404);
|
|
203
199
|
this.container.set(this.name, Buffer.from(sourceData));
|
|
204
|
-
const response = { _response: {
|
|
205
|
-
headers: toHttpHeadersLike(createHttpHeaders()),
|
|
206
|
-
parsedHeaders: {},
|
|
207
|
-
request: toWebResourceLike(createPipelineRequest({ url: `${this.url}?comp=copy` })),
|
|
208
|
-
status: 202
|
|
209
|
-
} };
|
|
200
|
+
const response = { _response: createMockResponse(202, `${this.url}?comp=copy`) };
|
|
210
201
|
return Promise.resolve({
|
|
211
202
|
cancelOperation: () => Promise.resolve(),
|
|
212
203
|
getOperationState: () => ({
|
|
@@ -228,23 +219,13 @@ var MockBlobClient = class {
|
|
|
228
219
|
delete() {
|
|
229
220
|
if (!this.container.has(this.name)) throw new MockRestError("The specified blob does not exist.", 404);
|
|
230
221
|
this.container.delete(this.name);
|
|
231
|
-
return Promise.resolve({ _response:
|
|
232
|
-
headers: toHttpHeadersLike(createHttpHeaders()),
|
|
233
|
-
parsedHeaders: {},
|
|
234
|
-
request: toWebResourceLike(createPipelineRequest({ url: "" })),
|
|
235
|
-
status: 200
|
|
236
|
-
} });
|
|
222
|
+
return Promise.resolve({ _response: createMockResponse(200) });
|
|
237
223
|
}
|
|
238
224
|
deleteIfExists() {
|
|
239
225
|
const succeeded = this.container.has(this.name);
|
|
240
226
|
if (succeeded) this.container.delete(this.name);
|
|
241
227
|
return Promise.resolve({
|
|
242
|
-
_response:
|
|
243
|
-
headers: toHttpHeadersLike(createHttpHeaders()),
|
|
244
|
-
parsedHeaders: {},
|
|
245
|
-
request: toWebResourceLike(createPipelineRequest({ url: "" })),
|
|
246
|
-
status: succeeded ? 200 : 404
|
|
247
|
-
},
|
|
228
|
+
_response: createMockResponse(succeeded ? 200 : 404),
|
|
248
229
|
succeeded
|
|
249
230
|
});
|
|
250
231
|
}
|
|
@@ -254,12 +235,7 @@ var MockBlobClient = class {
|
|
|
254
235
|
download() {
|
|
255
236
|
const buffer = this.container.get(this.name);
|
|
256
237
|
return Promise.resolve({
|
|
257
|
-
_response:
|
|
258
|
-
headers: toHttpHeadersLike(createHttpHeaders()),
|
|
259
|
-
parsedHeaders: {},
|
|
260
|
-
request: toWebResourceLike(createPipelineRequest({ url: "" })),
|
|
261
|
-
status: buffer ? 200 : 404
|
|
262
|
-
},
|
|
238
|
+
_response: createMockResponse(buffer ? 200 : 404),
|
|
263
239
|
readableStreamBody: buffer ? Readable.from(buffer) : void 0
|
|
264
240
|
});
|
|
265
241
|
}
|
|
@@ -278,8 +254,7 @@ var MockBlobClient = class {
|
|
|
278
254
|
throw new Error("Method not implemented.");
|
|
279
255
|
}
|
|
280
256
|
generateSasUrl(options) {
|
|
281
|
-
|
|
282
|
-
return Promise.resolve(`${MOCK_BLOB_BASE_URL}/${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=${sp}`);
|
|
257
|
+
return Promise.resolve(getMockSasUrl(this.url, options.permissions, "b"));
|
|
283
258
|
}
|
|
284
259
|
generateUserDelegationSasStringToSign() {
|
|
285
260
|
throw new Error("Method not implemented.");
|
|
@@ -388,12 +363,7 @@ var MockBlockBlobClient = class extends MockBlobClient {
|
|
|
388
363
|
}
|
|
389
364
|
async upload(body, _contentLength) {
|
|
390
365
|
this.container.set(this.name, await bodyToBuffer(body));
|
|
391
|
-
return { _response:
|
|
392
|
-
headers: toHttpHeadersLike(createHttpHeaders()),
|
|
393
|
-
parsedHeaders: {},
|
|
394
|
-
request: toWebResourceLike(createPipelineRequest({ url: "" })),
|
|
395
|
-
status: 201
|
|
396
|
-
} };
|
|
366
|
+
return { _response: createMockResponse(201) };
|
|
397
367
|
}
|
|
398
368
|
uploadBrowserData() {
|
|
399
369
|
throw new Error("Method not implemented.");
|
|
@@ -448,12 +418,7 @@ var MockContainerClient = class {
|
|
|
448
418
|
credential = new AnonymousCredential();
|
|
449
419
|
url;
|
|
450
420
|
get container() {
|
|
451
|
-
|
|
452
|
-
if (!container) {
|
|
453
|
-
container = /* @__PURE__ */ new Map();
|
|
454
|
-
MockContainerDatabase.set(this.containerName, container);
|
|
455
|
-
}
|
|
456
|
-
return container;
|
|
421
|
+
return getOrCreate(MockContainerDatabase, this.containerName, () => /* @__PURE__ */ new Map());
|
|
457
422
|
}
|
|
458
423
|
constructor(connectionString, containerName) {
|
|
459
424
|
this.connectionString = connectionString;
|
|
@@ -472,12 +437,7 @@ var MockContainerClient = class {
|
|
|
472
437
|
deleteBlob(blobName) {
|
|
473
438
|
if (!this.container.has(blobName)) throw new MockRestError("The specified blob does not exist.", 404);
|
|
474
439
|
this.container.delete(blobName);
|
|
475
|
-
return Promise.resolve({ _response: {
|
|
476
|
-
headers: toHttpHeadersLike(createHttpHeaders()),
|
|
477
|
-
parsedHeaders: {},
|
|
478
|
-
request: toWebResourceLike(createPipelineRequest({ url: `${this.url}/${blobName}` })),
|
|
479
|
-
status: 200
|
|
480
|
-
} });
|
|
440
|
+
return Promise.resolve({ _response: createMockResponse(200, `${this.url}/${blobName}`) });
|
|
481
441
|
}
|
|
482
442
|
deleteIfExists() {
|
|
483
443
|
throw new Error("Method not implemented.");
|
|
@@ -492,8 +452,7 @@ var MockContainerClient = class {
|
|
|
492
452
|
throw new Error("Method not implemented.");
|
|
493
453
|
}
|
|
494
454
|
generateSasUrl(options) {
|
|
495
|
-
|
|
496
|
-
return Promise.resolve(`${MOCK_BLOB_BASE_URL}/${this.containerName}?sv=2025-11-05&sr=c&sig=mock-signature&st=1970-01-01T00:00:00Z&se=2099-12-31T23:59:59Z&sp=${sp}`);
|
|
455
|
+
return Promise.resolve(getMockSasUrl(this.url, options.permissions, "c"));
|
|
497
456
|
}
|
|
498
457
|
generateUserDelegationSasStringToSign() {
|
|
499
458
|
throw new Error("Method not implemented.");
|
|
@@ -545,18 +504,15 @@ var MockContainerClient = class {
|
|
|
545
504
|
}
|
|
546
505
|
if (allBlobItems.length > 0 || allBlobPrefixes.length > 0) yield await Promise.resolve({
|
|
547
506
|
_response: {
|
|
507
|
+
...createMockResponse(200),
|
|
548
508
|
bodyAsText: getListBlobsXml(this.containerName, `${allBlobItemXml.join("")}${allBlobPrefixXml.join("")}`),
|
|
549
|
-
headers: toHttpHeadersLike(createHttpHeaders()),
|
|
550
509
|
parsedBody: {
|
|
551
510
|
containerName: this.containerName,
|
|
552
511
|
marker: "",
|
|
553
512
|
prefix: options?.prefix ?? "",
|
|
554
513
|
segment: { blobItems: allBlobItems },
|
|
555
514
|
serviceEndpoint: ""
|
|
556
|
-
}
|
|
557
|
-
parsedHeaders: {},
|
|
558
|
-
request: toWebResourceLike(createPipelineRequest({ url: "" })),
|
|
559
|
-
status: 200
|
|
515
|
+
}
|
|
560
516
|
},
|
|
561
517
|
containerName: this.containerName,
|
|
562
518
|
marker: "",
|
|
@@ -583,18 +539,15 @@ var MockContainerClient = class {
|
|
|
583
539
|
}
|
|
584
540
|
if (allBlobItems.length > 0) yield await Promise.resolve({
|
|
585
541
|
_response: {
|
|
542
|
+
...createMockResponse(200),
|
|
586
543
|
bodyAsText: getListBlobsXml(this.containerName, allBlobItemXml.join("")),
|
|
587
|
-
headers: toHttpHeadersLike(createHttpHeaders()),
|
|
588
544
|
parsedBody: {
|
|
589
545
|
containerName: this.containerName,
|
|
590
546
|
marker: "",
|
|
591
547
|
prefix: "",
|
|
592
548
|
segment: { blobItems: allBlobItems },
|
|
593
549
|
serviceEndpoint: ""
|
|
594
|
-
}
|
|
595
|
-
parsedHeaders: {},
|
|
596
|
-
request: toWebResourceLike(createPipelineRequest({ url: "" })),
|
|
597
|
-
status: 200
|
|
550
|
+
}
|
|
598
551
|
},
|
|
599
552
|
containerName: this.containerName,
|
|
600
553
|
marker: "",
|
|
@@ -690,9 +643,7 @@ var MockEventGridPublisherClient = class {
|
|
|
690
643
|
this.inputSchema = topicType;
|
|
691
644
|
}
|
|
692
645
|
send(newEvents) {
|
|
693
|
-
|
|
694
|
-
events.push(...newEvents);
|
|
695
|
-
MockEventGridDatabase.set(this.endpointUrl, events);
|
|
646
|
+
getOrCreate(MockEventGridDatabase, this.endpointUrl, () => []).push(...newEvents);
|
|
696
647
|
return Promise.resolve();
|
|
697
648
|
}
|
|
698
649
|
};
|
|
@@ -711,12 +662,7 @@ var MockQueueClient = class {
|
|
|
711
662
|
name;
|
|
712
663
|
url;
|
|
713
664
|
get queue() {
|
|
714
|
-
|
|
715
|
-
if (!messages) {
|
|
716
|
-
messages = [];
|
|
717
|
-
MockQueueDatabase.set(this.name, messages);
|
|
718
|
-
}
|
|
719
|
-
return messages;
|
|
665
|
+
return getOrCreate(MockQueueDatabase, this.name, () => []);
|
|
720
666
|
}
|
|
721
667
|
constructor(connectionString, queueName) {
|
|
722
668
|
this.connectionString = connectionString;
|
|
@@ -748,8 +694,7 @@ var MockQueueClient = class {
|
|
|
748
694
|
throw new Error("Method not implemented.");
|
|
749
695
|
}
|
|
750
696
|
generateSasUrl(options) {
|
|
751
|
-
|
|
752
|
-
return `${MOCK_QUEUE_BASE_URL}/${this.name}?sv=2025-11-05&sig=mock-signature&st=1970-01-01T00:00:00Z&se=2099-12-31T23:59:59Z&sp=${sp}`;
|
|
697
|
+
return getMockSasUrl(this.url, options.permissions);
|
|
753
698
|
}
|
|
754
699
|
generateUserDelegationSasUrl() {
|
|
755
700
|
throw new Error("Method not implemented.");
|
|
@@ -779,12 +724,9 @@ var MockQueueClient = class {
|
|
|
779
724
|
}));
|
|
780
725
|
return Promise.resolve({
|
|
781
726
|
_response: {
|
|
727
|
+
...createMockResponse(200, this.url),
|
|
782
728
|
bodyAsText: "",
|
|
783
|
-
|
|
784
|
-
parsedBody: peekedMessageItems,
|
|
785
|
-
parsedHeaders: {},
|
|
786
|
-
request: toWebResourceLike(createPipelineRequest({ url: this.url })),
|
|
787
|
-
status: 200
|
|
729
|
+
parsedBody: peekedMessageItems
|
|
788
730
|
},
|
|
789
731
|
peekedMessageItems
|
|
790
732
|
});
|
|
@@ -801,12 +743,9 @@ var MockQueueClient = class {
|
|
|
801
743
|
}));
|
|
802
744
|
return Promise.resolve({
|
|
803
745
|
_response: {
|
|
746
|
+
...createMockResponse(200, this.url),
|
|
804
747
|
bodyAsText: "",
|
|
805
|
-
|
|
806
|
-
parsedBody: receivedMessageItems,
|
|
807
|
-
parsedHeaders: {},
|
|
808
|
-
request: toWebResourceLike(createPipelineRequest({ url: this.url })),
|
|
809
|
-
status: 200
|
|
748
|
+
parsedBody: receivedMessageItems
|
|
810
749
|
},
|
|
811
750
|
receivedMessageItems
|
|
812
751
|
});
|
|
@@ -828,12 +767,9 @@ var MockQueueClient = class {
|
|
|
828
767
|
}];
|
|
829
768
|
return Promise.resolve({
|
|
830
769
|
_response: {
|
|
770
|
+
...createMockResponse(200, this.url),
|
|
831
771
|
bodyAsText: "",
|
|
832
|
-
|
|
833
|
-
parsedBody: enqueuedMessages,
|
|
834
|
-
parsedHeaders: {},
|
|
835
|
-
request: toWebResourceLike(createPipelineRequest({ url: this.url })),
|
|
836
|
-
status: 200
|
|
772
|
+
parsedBody: enqueuedMessages
|
|
837
773
|
},
|
|
838
774
|
expiresOn,
|
|
839
775
|
insertedOn,
|
|
@@ -973,12 +909,7 @@ var MockSearchClient = class {
|
|
|
973
909
|
indexName;
|
|
974
910
|
serviceVersion = "";
|
|
975
911
|
get documents() {
|
|
976
|
-
|
|
977
|
-
if (!documents) {
|
|
978
|
-
documents = [];
|
|
979
|
-
MockSearchDatabase.set(this.indexName, documents);
|
|
980
|
-
}
|
|
981
|
-
return documents;
|
|
912
|
+
return getOrCreate(MockSearchDatabase, this.indexName, () => []);
|
|
982
913
|
}
|
|
983
914
|
constructor(indexName) {
|
|
984
915
|
this.indexName = indexName;
|
|
@@ -1043,12 +974,7 @@ var MockTableClient = class {
|
|
|
1043
974
|
tableName;
|
|
1044
975
|
url;
|
|
1045
976
|
get table() {
|
|
1046
|
-
|
|
1047
|
-
if (!table) {
|
|
1048
|
-
table = /* @__PURE__ */ new Map();
|
|
1049
|
-
MockTableDatabase.set(this.tableName, table);
|
|
1050
|
-
}
|
|
1051
|
-
return table;
|
|
977
|
+
return getOrCreate(MockTableDatabase, this.tableName, () => /* @__PURE__ */ new Map());
|
|
1052
978
|
}
|
|
1053
979
|
constructor(_url, tableName) {
|
|
1054
980
|
this.tableName = tableName;
|
|
@@ -1209,4 +1135,4 @@ const applyFilter = (documents, clauses) => {
|
|
|
1209
1135
|
const predicate = createFilterPredicate(serializeClauses(clauses));
|
|
1210
1136
|
return documents.filter((document) => predicate(document));
|
|
1211
1137
|
};
|
|
1212
|
-
export { MOCK_BLOB_BASE_URL, MOCK_QUEUE_BASE_URL, MOCK_SEARCH_BASE_URL, MOCK_TABLE_BASE_URL, MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerClient, MockContainerDatabase, MockEventGridDatabase, MockEventGridPublisherClient, MockQueueClient, MockQueueDatabase, MockRestError, MockSearchClient, MockSearchDatabase, MockTableClient, MockTableDatabase, MockWebPubSubServiceClient, applyFilter, bodyToBuffer, compare, createFilterPredicate, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, getListBlobsXml, isNullClause, isReadableStream, toWebResourceLike };
|
|
1138
|
+
export { MOCK_BLOB_BASE_URL, MOCK_QUEUE_BASE_URL, MOCK_SEARCH_BASE_URL, MOCK_TABLE_BASE_URL, MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerClient, MockContainerDatabase, MockEventGridDatabase, MockEventGridPublisherClient, MockQueueClient, MockQueueDatabase, MockRestError, MockSearchClient, MockSearchDatabase, MockTableClient, MockTableDatabase, MockWebPubSubServiceClient, applyFilter, bodyToBuffer, compare, createFilterPredicate, createMockResponse, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, getListBlobsXml, getMockSasUrl, isNullClause, isReadableStream, toWebResourceLike };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "azure-mock",
|
|
3
|
-
"version": "2.34.
|
|
3
|
+
"version": "2.34.2",
|
|
4
4
|
"description": "A library that contains azure mock classes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"azure",
|
|
@@ -46,16 +46,16 @@
|
|
|
46
46
|
"typecheck": "tsgo"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@esposter/db": "2.34.
|
|
50
|
-
"@esposter/db-schema": "2.34.
|
|
51
|
-
"@esposter/shared": "2.34.
|
|
49
|
+
"@esposter/db": "2.34.2",
|
|
50
|
+
"@esposter/db-schema": "2.34.2",
|
|
51
|
+
"@esposter/shared": "2.34.2",
|
|
52
52
|
"fast-deep-equal": "^3.1.3"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@esposter/configuration": "2.34.
|
|
55
|
+
"@esposter/configuration": "2.34.2",
|
|
56
56
|
"ctix": "^2.8.1",
|
|
57
57
|
"rolldown": "^1.1.4",
|
|
58
|
-
"type-fest": "^5.
|
|
58
|
+
"type-fest": "^5.8.0",
|
|
59
59
|
"typedoc": "^0.28.19",
|
|
60
60
|
"vitest": "^4.1.9"
|
|
61
61
|
},
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"@azure/storage-blob": "^12.33.0",
|
|
69
69
|
"@azure/storage-queue": "^12.31.0"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "70032635c47bdf1e55414c7d84c955350f991055"
|
|
72
72
|
}
|