azure-mock 3.2.0 → 3.3.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 +8 -1
- package/dist/index.js +118 -111
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -1085,6 +1085,11 @@ export declare class MockRestError extends RestError {
|
|
|
1085
1085
|
constructor(message: string, statusCode: number);
|
|
1086
1086
|
}
|
|
1087
1087
|
//#endregion
|
|
1088
|
+
//#region src/models/shared/NotImplementedError.d.ts
|
|
1089
|
+
export declare class NotImplementedError extends Error {
|
|
1090
|
+
constructor(name: string);
|
|
1091
|
+
}
|
|
1092
|
+
//#endregion
|
|
1088
1093
|
//#region src/models/table/MockTableClient.d.ts
|
|
1089
1094
|
/**
|
|
1090
1095
|
* An in-memory mock of the Azure TableClient — no emulator and no network.
|
|
@@ -1103,7 +1108,9 @@ export declare class MockTableClient<TEntity extends TableEntity = TableEntity>
|
|
|
1103
1108
|
constructor(_url: string, tableName: string);
|
|
1104
1109
|
createEntity<T extends object>(entity: TableEntity<T>): Promise<CreateTableEntityResponse>;
|
|
1105
1110
|
createTable(): Promise<void>;
|
|
1106
|
-
deleteEntity(partitionKey: string, rowKey: string
|
|
1111
|
+
deleteEntity(partitionKey: string, rowKey: string, options?: {
|
|
1112
|
+
etag?: string;
|
|
1113
|
+
}): Promise<TableDeleteEntityHeaders>;
|
|
1107
1114
|
deleteTable(): Promise<void>;
|
|
1108
1115
|
getAccessPolicy(): Promise<GetAccessPolicyResponse>;
|
|
1109
1116
|
getEntity<T extends object = Record<string, unknown>>(partitionKey: string, rowKey: string): Promise<GetTableEntityResponse<TableEntityResult<T>>>;
|
package/dist/index.js
CHANGED
|
@@ -91,13 +91,21 @@ const getBlobUrlParts = (url) => {
|
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
93
|
//#endregion
|
|
94
|
+
//#region src/models/shared/NotImplementedError.ts
|
|
95
|
+
var NotImplementedError = class extends Error {
|
|
96
|
+
constructor(name) {
|
|
97
|
+
super(`${name} is not implemented in the mock`);
|
|
98
|
+
this.name = "NotImplementedError";
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
//#endregion
|
|
94
102
|
//#region src/services/container/toWebResourceLike.ts
|
|
95
103
|
const toWebResourceLike = (request) => ({
|
|
96
104
|
abortSignal: request.abortSignal,
|
|
97
105
|
agent: request.agent,
|
|
98
106
|
body: request.body,
|
|
99
107
|
clone: () => {
|
|
100
|
-
throw new
|
|
108
|
+
throw new NotImplementedError(`${toWebResourceLike.name}(…).clone`);
|
|
101
109
|
},
|
|
102
110
|
formData: request.formData,
|
|
103
111
|
headers: toHttpHeadersLike(request.headers),
|
|
@@ -106,7 +114,7 @@ const toWebResourceLike = (request) => ({
|
|
|
106
114
|
onDownloadProgress: request.onDownloadProgress,
|
|
107
115
|
onUploadProgress: request.onUploadProgress,
|
|
108
116
|
prepare: () => {
|
|
109
|
-
throw new
|
|
117
|
+
throw new NotImplementedError(`${toWebResourceLike.name}(…).prepare`);
|
|
110
118
|
},
|
|
111
119
|
proxySettings: request.proxySettings,
|
|
112
120
|
requestId: request.headers.get("x-ms-client-request-id") ?? request.requestId,
|
|
@@ -250,7 +258,7 @@ var MockBlobClient = class {
|
|
|
250
258
|
this.url = getBlobUrl(this.containerName, this.name);
|
|
251
259
|
}
|
|
252
260
|
abortCopyFromURL() {
|
|
253
|
-
throw new
|
|
261
|
+
throw new NotImplementedError(this.abortCopyFromURL.name);
|
|
254
262
|
}
|
|
255
263
|
beginCopyFromURL(copySource) {
|
|
256
264
|
const sourceParts = getBlobUrlParts(copySource);
|
|
@@ -279,27 +287,21 @@ var MockBlobClient = class {
|
|
|
279
287
|
});
|
|
280
288
|
}
|
|
281
289
|
createSnapshot() {
|
|
282
|
-
throw new
|
|
290
|
+
throw new NotImplementedError(this.createSnapshot.name);
|
|
283
291
|
}
|
|
284
292
|
delete() {
|
|
285
|
-
if (!this.
|
|
286
|
-
this.container.delete(this.name);
|
|
287
|
-
MockContainerBlobDatesDatabase.delete(getMockBlobKey(this.containerName, this.name));
|
|
293
|
+
if (!deleteMockBlob(this.containerName, this.name)) throw new MockRestError(BLOB_NOT_FOUND_MESSAGE, 404);
|
|
288
294
|
return Promise.resolve({ _response: createMockResponse(200) });
|
|
289
295
|
}
|
|
290
296
|
deleteIfExists() {
|
|
291
|
-
const succeeded = this.
|
|
292
|
-
if (succeeded) {
|
|
293
|
-
this.container.delete(this.name);
|
|
294
|
-
MockContainerBlobDatesDatabase.delete(getMockBlobKey(this.containerName, this.name));
|
|
295
|
-
}
|
|
297
|
+
const succeeded = deleteMockBlob(this.containerName, this.name);
|
|
296
298
|
return Promise.resolve({
|
|
297
299
|
_response: createMockResponse(succeeded ? 200 : 404),
|
|
298
300
|
succeeded
|
|
299
301
|
});
|
|
300
302
|
}
|
|
301
303
|
deleteImmutabilityPolicy() {
|
|
302
|
-
throw new
|
|
304
|
+
throw new NotImplementedError(this.deleteImmutabilityPolicy.name);
|
|
303
305
|
}
|
|
304
306
|
download() {
|
|
305
307
|
const buffer = this.container.get(this.name);
|
|
@@ -314,37 +316,37 @@ var MockBlobClient = class {
|
|
|
314
316
|
return Promise.resolve(Buffer.from(data));
|
|
315
317
|
}
|
|
316
318
|
downloadToFile() {
|
|
317
|
-
throw new
|
|
319
|
+
throw new NotImplementedError(this.downloadToFile.name);
|
|
318
320
|
}
|
|
319
321
|
exists() {
|
|
320
322
|
return Promise.resolve(this.container.has(this.name));
|
|
321
323
|
}
|
|
322
324
|
generateSasStringToSign() {
|
|
323
|
-
throw new
|
|
325
|
+
throw new NotImplementedError(this.generateSasStringToSign.name);
|
|
324
326
|
}
|
|
325
327
|
generateSasUrl(options) {
|
|
326
328
|
return Promise.resolve(getMockSasUrl(this.url, options.permissions, "b"));
|
|
327
329
|
}
|
|
328
330
|
generateUserDelegationSasStringToSign() {
|
|
329
|
-
throw new
|
|
331
|
+
throw new NotImplementedError(this.generateUserDelegationSasStringToSign.name);
|
|
330
332
|
}
|
|
331
333
|
generateUserDelegationSasUrl() {
|
|
332
|
-
throw new
|
|
334
|
+
throw new NotImplementedError(this.generateUserDelegationSasUrl.name);
|
|
333
335
|
}
|
|
334
336
|
getAccountInfo() {
|
|
335
|
-
throw new
|
|
337
|
+
throw new NotImplementedError(this.getAccountInfo.name);
|
|
336
338
|
}
|
|
337
339
|
getAppendBlobClient() {
|
|
338
|
-
throw new
|
|
340
|
+
throw new NotImplementedError(this.getAppendBlobClient.name);
|
|
339
341
|
}
|
|
340
342
|
getBlobLeaseClient() {
|
|
341
|
-
throw new
|
|
343
|
+
throw new NotImplementedError(this.getBlobLeaseClient.name);
|
|
342
344
|
}
|
|
343
345
|
getBlockBlobClient() {
|
|
344
|
-
throw new
|
|
346
|
+
throw new NotImplementedError(this.getBlockBlobClient.name);
|
|
345
347
|
}
|
|
346
348
|
getPageBlobClient() {
|
|
347
|
-
throw new
|
|
349
|
+
throw new NotImplementedError(this.getPageBlobClient.name);
|
|
348
350
|
}
|
|
349
351
|
getProperties() {
|
|
350
352
|
const blob = this.container.get(this.name);
|
|
@@ -356,37 +358,37 @@ var MockBlobClient = class {
|
|
|
356
358
|
});
|
|
357
359
|
}
|
|
358
360
|
getTags() {
|
|
359
|
-
throw new
|
|
361
|
+
throw new NotImplementedError(this.getTags.name);
|
|
360
362
|
}
|
|
361
363
|
setAccessTier() {
|
|
362
|
-
throw new
|
|
364
|
+
throw new NotImplementedError(this.setAccessTier.name);
|
|
363
365
|
}
|
|
364
366
|
setHTTPHeaders() {
|
|
365
|
-
throw new
|
|
367
|
+
throw new NotImplementedError(this.setHTTPHeaders.name);
|
|
366
368
|
}
|
|
367
369
|
setImmutabilityPolicy() {
|
|
368
|
-
throw new
|
|
370
|
+
throw new NotImplementedError(this.setImmutabilityPolicy.name);
|
|
369
371
|
}
|
|
370
372
|
setLegalHold() {
|
|
371
|
-
throw new
|
|
373
|
+
throw new NotImplementedError(this.setLegalHold.name);
|
|
372
374
|
}
|
|
373
375
|
setMetadata() {
|
|
374
|
-
throw new
|
|
376
|
+
throw new NotImplementedError(this.setMetadata.name);
|
|
375
377
|
}
|
|
376
378
|
setTags() {
|
|
377
|
-
throw new
|
|
379
|
+
throw new NotImplementedError(this.setTags.name);
|
|
378
380
|
}
|
|
379
381
|
syncCopyFromURL() {
|
|
380
|
-
throw new
|
|
382
|
+
throw new NotImplementedError(this.syncCopyFromURL.name);
|
|
381
383
|
}
|
|
382
384
|
undelete() {
|
|
383
|
-
throw new
|
|
385
|
+
throw new NotImplementedError(this.undelete.name);
|
|
384
386
|
}
|
|
385
387
|
withSnapshot() {
|
|
386
|
-
throw new
|
|
388
|
+
throw new NotImplementedError(this.withSnapshot.name);
|
|
387
389
|
}
|
|
388
390
|
withVersion() {
|
|
389
|
-
throw new
|
|
391
|
+
throw new NotImplementedError(this.withVersion.name);
|
|
390
392
|
}
|
|
391
393
|
};
|
|
392
394
|
//#endregion
|
|
@@ -415,7 +417,7 @@ const bodyToBuffer = async (body) => {
|
|
|
415
417
|
else chunks.push(value);
|
|
416
418
|
}
|
|
417
419
|
return Buffer.concat(chunks);
|
|
418
|
-
} else if (body instanceof FormData) throw new
|
|
420
|
+
} else if (body instanceof FormData) throw new NotImplementedError(`${bodyToBuffer.name}(FormData)`);
|
|
419
421
|
else {
|
|
420
422
|
exhaustiveGuard(body);
|
|
421
423
|
return Buffer.alloc(0);
|
|
@@ -425,22 +427,22 @@ const bodyToBuffer = async (body) => {
|
|
|
425
427
|
//#region src/models/container/MockBlockBlobClient.ts
|
|
426
428
|
var MockBlockBlobClient = class extends MockBlobClient {
|
|
427
429
|
commitBlockList() {
|
|
428
|
-
throw new
|
|
430
|
+
throw new NotImplementedError(this.commitBlockList.name);
|
|
429
431
|
}
|
|
430
432
|
getBlockList() {
|
|
431
|
-
throw new
|
|
433
|
+
throw new NotImplementedError(this.getBlockList.name);
|
|
432
434
|
}
|
|
433
435
|
query() {
|
|
434
|
-
throw new
|
|
436
|
+
throw new NotImplementedError(this.query.name);
|
|
435
437
|
}
|
|
436
438
|
stageBlock() {
|
|
437
|
-
throw new
|
|
439
|
+
throw new NotImplementedError(this.stageBlock.name);
|
|
438
440
|
}
|
|
439
441
|
stageBlockFromURL() {
|
|
440
|
-
throw new
|
|
442
|
+
throw new NotImplementedError(this.stageBlockFromURL.name);
|
|
441
443
|
}
|
|
442
444
|
syncUploadFromURL() {
|
|
443
|
-
throw new
|
|
445
|
+
throw new NotImplementedError(this.syncUploadFromURL.name);
|
|
444
446
|
}
|
|
445
447
|
async upload(body, _contentLength, options) {
|
|
446
448
|
const buffer = await bodyToBuffer(body);
|
|
@@ -452,16 +454,16 @@ var MockBlockBlobClient = class extends MockBlobClient {
|
|
|
452
454
|
return { _response: createMockResponse(201) };
|
|
453
455
|
}
|
|
454
456
|
uploadBrowserData() {
|
|
455
|
-
throw new
|
|
457
|
+
throw new NotImplementedError(this.uploadBrowserData.name);
|
|
456
458
|
}
|
|
457
459
|
uploadData() {
|
|
458
|
-
throw new
|
|
460
|
+
throw new NotImplementedError(this.uploadData.name);
|
|
459
461
|
}
|
|
460
462
|
uploadFile() {
|
|
461
|
-
throw new
|
|
463
|
+
throw new NotImplementedError(this.uploadFile.name);
|
|
462
464
|
}
|
|
463
465
|
uploadStream() {
|
|
464
|
-
throw new
|
|
466
|
+
throw new NotImplementedError(this.uploadStream.name);
|
|
465
467
|
}
|
|
466
468
|
};
|
|
467
469
|
//#endregion
|
|
@@ -541,47 +543,47 @@ var MockContainerClient = class {
|
|
|
541
543
|
this.url = `${MOCK_BLOB_BASE_URL}/${this.containerName}`;
|
|
542
544
|
}
|
|
543
545
|
create() {
|
|
544
|
-
throw new
|
|
546
|
+
throw new NotImplementedError(this.create.name);
|
|
545
547
|
}
|
|
546
548
|
createIfNotExists() {
|
|
547
|
-
throw new
|
|
549
|
+
throw new NotImplementedError(this.createIfNotExists.name);
|
|
548
550
|
}
|
|
549
551
|
delete() {
|
|
550
|
-
throw new
|
|
552
|
+
throw new NotImplementedError(this.delete.name);
|
|
551
553
|
}
|
|
552
554
|
deleteBlob(blobName) {
|
|
553
555
|
if (!deleteMockBlob(this.containerName, blobName)) throw new MockRestError(BLOB_NOT_FOUND_MESSAGE, 404);
|
|
554
556
|
return Promise.resolve({ _response: createMockResponse(200, getBlobUrl(this.containerName, blobName)) });
|
|
555
557
|
}
|
|
556
558
|
deleteIfExists() {
|
|
557
|
-
throw new
|
|
559
|
+
throw new NotImplementedError(this.deleteIfExists.name);
|
|
558
560
|
}
|
|
559
561
|
exists() {
|
|
560
|
-
throw new
|
|
562
|
+
throw new NotImplementedError(this.exists.name);
|
|
561
563
|
}
|
|
562
564
|
findBlobsByTags() {
|
|
563
|
-
throw new
|
|
565
|
+
throw new NotImplementedError(this.findBlobsByTags.name);
|
|
564
566
|
}
|
|
565
567
|
generateSasStringToSign() {
|
|
566
|
-
throw new
|
|
568
|
+
throw new NotImplementedError(this.generateSasStringToSign.name);
|
|
567
569
|
}
|
|
568
570
|
generateSasUrl(options) {
|
|
569
571
|
return Promise.resolve(getMockSasUrl(this.url, options.permissions, "c"));
|
|
570
572
|
}
|
|
571
573
|
generateUserDelegationSasStringToSign() {
|
|
572
|
-
throw new
|
|
574
|
+
throw new NotImplementedError(this.generateUserDelegationSasStringToSign.name);
|
|
573
575
|
}
|
|
574
576
|
generateUserDelegationSasUrl() {
|
|
575
|
-
throw new
|
|
577
|
+
throw new NotImplementedError(this.generateUserDelegationSasUrl.name);
|
|
576
578
|
}
|
|
577
579
|
getAccessPolicy() {
|
|
578
|
-
throw new
|
|
580
|
+
throw new NotImplementedError(this.getAccessPolicy.name);
|
|
579
581
|
}
|
|
580
582
|
getAccountInfo() {
|
|
581
|
-
throw new
|
|
583
|
+
throw new NotImplementedError(this.getAccountInfo.name);
|
|
582
584
|
}
|
|
583
585
|
getAppendBlobClient() {
|
|
584
|
-
throw new
|
|
586
|
+
throw new NotImplementedError(this.getAppendBlobClient.name);
|
|
585
587
|
}
|
|
586
588
|
getBlobBatchClient() {
|
|
587
589
|
return new MockBlobBatchClient(this.url);
|
|
@@ -590,16 +592,16 @@ var MockContainerClient = class {
|
|
|
590
592
|
return new MockBlockBlobClient(this.connectionString, this.containerName, blobName);
|
|
591
593
|
}
|
|
592
594
|
getBlobLeaseClient() {
|
|
593
|
-
throw new
|
|
595
|
+
throw new NotImplementedError(this.getBlobLeaseClient.name);
|
|
594
596
|
}
|
|
595
597
|
getBlockBlobClient(blobName) {
|
|
596
598
|
return new MockBlockBlobClient(this.connectionString, this.containerName, blobName);
|
|
597
599
|
}
|
|
598
600
|
getPageBlobClient() {
|
|
599
|
-
throw new
|
|
601
|
+
throw new NotImplementedError(this.getPageBlobClient.name);
|
|
600
602
|
}
|
|
601
603
|
getProperties() {
|
|
602
|
-
throw new
|
|
604
|
+
throw new NotImplementedError(this.getProperties.name);
|
|
603
605
|
}
|
|
604
606
|
listBlobsByHierarchy(delimiter, options) {
|
|
605
607
|
const blobHierarchyItemIterator = this.#getBlobHierarchyItemIterator(delimiter, options);
|
|
@@ -646,10 +648,10 @@ var MockContainerClient = class {
|
|
|
646
648
|
};
|
|
647
649
|
}
|
|
648
650
|
setAccessPolicy() {
|
|
649
|
-
throw new
|
|
651
|
+
throw new NotImplementedError(this.setAccessPolicy.name);
|
|
650
652
|
}
|
|
651
653
|
setMetadata() {
|
|
652
|
-
throw new
|
|
654
|
+
throw new NotImplementedError(this.setMetadata.name);
|
|
653
655
|
}
|
|
654
656
|
async uploadBlockBlob(blobName, body, contentLength) {
|
|
655
657
|
const blockBlobClient = this.getBlockBlobClient(blobName);
|
|
@@ -763,49 +765,49 @@ var MockQueueClient = class {
|
|
|
763
765
|
this.url = `${MOCK_QUEUE_BASE_URL}/${this.name}`;
|
|
764
766
|
}
|
|
765
767
|
clearMessages() {
|
|
766
|
-
throw new
|
|
768
|
+
throw new NotImplementedError(this.clearMessages.name);
|
|
767
769
|
}
|
|
768
770
|
create(_options) {
|
|
769
|
-
throw new
|
|
771
|
+
throw new NotImplementedError(this.create.name);
|
|
770
772
|
}
|
|
771
773
|
createIfNotExists() {
|
|
772
|
-
throw new
|
|
774
|
+
throw new NotImplementedError(this.createIfNotExists.name);
|
|
773
775
|
}
|
|
774
776
|
delete() {
|
|
775
|
-
throw new
|
|
777
|
+
throw new NotImplementedError(this.delete.name);
|
|
776
778
|
}
|
|
777
779
|
deleteIfExists() {
|
|
778
|
-
throw new
|
|
780
|
+
throw new NotImplementedError(this.deleteIfExists.name);
|
|
779
781
|
}
|
|
780
782
|
deleteMessage() {
|
|
781
|
-
throw new
|
|
783
|
+
throw new NotImplementedError(this.deleteMessage.name);
|
|
782
784
|
}
|
|
783
785
|
exists() {
|
|
784
|
-
throw new
|
|
786
|
+
throw new NotImplementedError(this.exists.name);
|
|
785
787
|
}
|
|
786
788
|
generateSasStringToSign() {
|
|
787
|
-
throw new
|
|
789
|
+
throw new NotImplementedError(this.generateSasStringToSign.name);
|
|
788
790
|
}
|
|
789
791
|
generateSasUrl(options) {
|
|
790
792
|
return getMockSasUrl(this.url, options.permissions);
|
|
791
793
|
}
|
|
792
794
|
generateUserDelegationSasUrl() {
|
|
793
|
-
throw new
|
|
795
|
+
throw new NotImplementedError(this.generateUserDelegationSasUrl.name);
|
|
794
796
|
}
|
|
795
797
|
generateUserDelegationStringToSign() {
|
|
796
|
-
throw new
|
|
798
|
+
throw new NotImplementedError(this.generateUserDelegationStringToSign.name);
|
|
797
799
|
}
|
|
798
800
|
getAccessPolicy() {
|
|
799
|
-
throw new
|
|
801
|
+
throw new NotImplementedError(this.getAccessPolicy.name);
|
|
800
802
|
}
|
|
801
803
|
getProperties() {
|
|
802
|
-
throw new
|
|
804
|
+
throw new NotImplementedError(this.getProperties.name);
|
|
803
805
|
}
|
|
804
806
|
getServiceProperties() {
|
|
805
|
-
throw new
|
|
807
|
+
throw new NotImplementedError(this.getServiceProperties.name);
|
|
806
808
|
}
|
|
807
809
|
listQueues() {
|
|
808
|
-
throw new
|
|
810
|
+
throw new NotImplementedError(this.listQueues.name);
|
|
809
811
|
}
|
|
810
812
|
peekMessages(_options) {
|
|
811
813
|
const peekedMessageItems = this.queue.map((text) => ({
|
|
@@ -859,13 +861,13 @@ var MockQueueClient = class {
|
|
|
859
861
|
});
|
|
860
862
|
}
|
|
861
863
|
setAccessPolicy(_identifiers) {
|
|
862
|
-
throw new
|
|
864
|
+
throw new NotImplementedError(this.setAccessPolicy.name);
|
|
863
865
|
}
|
|
864
866
|
setMetadata() {
|
|
865
|
-
throw new
|
|
867
|
+
throw new NotImplementedError(this.setMetadata.name);
|
|
866
868
|
}
|
|
867
869
|
updateMessage() {
|
|
868
|
-
throw new
|
|
870
|
+
throw new NotImplementedError(this.updateMessage.name);
|
|
869
871
|
}
|
|
870
872
|
};
|
|
871
873
|
//#endregion
|
|
@@ -878,7 +880,7 @@ const checkIsNullClause = (clause) => {
|
|
|
878
880
|
//#region src/services/filter/compare.ts
|
|
879
881
|
const compare = (operator, leftHandSide, rightHandSide) => {
|
|
880
882
|
if (rightHandSide === null || rightHandSide === void 0) {
|
|
881
|
-
if (operator !== BinaryOperator.
|
|
883
|
+
if (operator !== BinaryOperator.Eq) throw new InvalidOperationError(Operation.Read, compare.name, JSON.stringify({
|
|
882
884
|
leftHandSide,
|
|
883
885
|
operator,
|
|
884
886
|
rightHandSide
|
|
@@ -886,12 +888,12 @@ const compare = (operator, leftHandSide, rightHandSide) => {
|
|
|
886
888
|
return leftHandSide === null || leftHandSide === void 0;
|
|
887
889
|
}
|
|
888
890
|
switch (operator) {
|
|
889
|
-
case BinaryOperator.
|
|
890
|
-
case BinaryOperator.
|
|
891
|
-
case BinaryOperator.
|
|
892
|
-
case BinaryOperator.
|
|
893
|
-
case BinaryOperator.
|
|
894
|
-
case BinaryOperator.
|
|
891
|
+
case BinaryOperator.Eq: return leftHandSide === rightHandSide;
|
|
892
|
+
case BinaryOperator.Ge: return leftHandSide >= rightHandSide;
|
|
893
|
+
case BinaryOperator.Gt: return leftHandSide > rightHandSide;
|
|
894
|
+
case BinaryOperator.Le: return leftHandSide <= rightHandSide;
|
|
895
|
+
case BinaryOperator.Lt: return leftHandSide < rightHandSide;
|
|
896
|
+
case BinaryOperator.Ne: return leftHandSide !== rightHandSide;
|
|
895
897
|
default: return exhaustiveGuard(operator);
|
|
896
898
|
}
|
|
897
899
|
};
|
|
@@ -911,7 +913,7 @@ const createFilterPredicate = (filter) => {
|
|
|
911
913
|
for (const { clause, isNull } of orGroup) {
|
|
912
914
|
const value = takeOne(document, clause.key);
|
|
913
915
|
let isMatched;
|
|
914
|
-
if (isNull) isMatched = compare(BinaryOperator.
|
|
916
|
+
if (isNull) isMatched = compare(BinaryOperator.Eq, value, null);
|
|
915
917
|
else {
|
|
916
918
|
const comparisonResult = compare(clause.operator, value, clause.value);
|
|
917
919
|
isMatched = clause.not ? !comparisonResult : comparisonResult;
|
|
@@ -937,7 +939,7 @@ const compareValues = (firstValue, secondValue) => {
|
|
|
937
939
|
const firstComparable = toComparable(firstValue);
|
|
938
940
|
const secondComparable = toComparable(secondValue);
|
|
939
941
|
if (typeof firstComparable === "number" && typeof secondComparable === "number") return firstComparable - secondComparable;
|
|
940
|
-
return String(firstComparable).localeCompare(String(secondComparable));
|
|
942
|
+
else return String(firstComparable).localeCompare(String(secondComparable));
|
|
941
943
|
};
|
|
942
944
|
const sortDocuments = (documents, orderBy) => {
|
|
943
945
|
const parsedOrderBy = orderBy.map((clause) => {
|
|
@@ -990,25 +992,25 @@ var MockSearchClient = class {
|
|
|
990
992
|
this.indexName = indexName;
|
|
991
993
|
}
|
|
992
994
|
autocomplete() {
|
|
993
|
-
throw new
|
|
995
|
+
throw new NotImplementedError(this.autocomplete.name);
|
|
994
996
|
}
|
|
995
997
|
deleteDocuments() {
|
|
996
|
-
throw new
|
|
998
|
+
throw new NotImplementedError(this.deleteDocuments.name);
|
|
997
999
|
}
|
|
998
1000
|
getDocument(_key, _options) {
|
|
999
|
-
throw new
|
|
1001
|
+
throw new NotImplementedError(this.getDocument.name);
|
|
1000
1002
|
}
|
|
1001
1003
|
getDocumentsCount(_options) {
|
|
1002
1004
|
return Promise.resolve(this.documents.length);
|
|
1003
1005
|
}
|
|
1004
1006
|
indexDocuments(_batch, _options) {
|
|
1005
|
-
throw new
|
|
1007
|
+
throw new NotImplementedError(this.indexDocuments.name);
|
|
1006
1008
|
}
|
|
1007
1009
|
mergeDocuments(_documents, _options) {
|
|
1008
|
-
throw new
|
|
1010
|
+
throw new NotImplementedError(this.mergeDocuments.name);
|
|
1009
1011
|
}
|
|
1010
1012
|
mergeOrUploadDocuments(_documents, _options) {
|
|
1011
|
-
throw new
|
|
1013
|
+
throw new NotImplementedError(this.mergeOrUploadDocuments.name);
|
|
1012
1014
|
}
|
|
1013
1015
|
search(searchText, options) {
|
|
1014
1016
|
const { filter, includeTotalCount, orderBy, searchFields, skip = 0, top } = options ?? {};
|
|
@@ -1029,7 +1031,7 @@ var MockSearchClient = class {
|
|
|
1029
1031
|
});
|
|
1030
1032
|
}
|
|
1031
1033
|
suggest(_searchText, _suggesterName, _options) {
|
|
1032
|
-
throw new
|
|
1034
|
+
throw new NotImplementedError(this.suggest.name);
|
|
1033
1035
|
}
|
|
1034
1036
|
uploadDocuments(documents, _options) {
|
|
1035
1037
|
this.documents.push(...documents);
|
|
@@ -1057,14 +1059,14 @@ var MockServiceBusSender = class {
|
|
|
1057
1059
|
this.identifier = queueName;
|
|
1058
1060
|
}
|
|
1059
1061
|
cancelScheduledMessages() {
|
|
1060
|
-
throw new
|
|
1062
|
+
throw new NotImplementedError(this.cancelScheduledMessages.name);
|
|
1061
1063
|
}
|
|
1062
1064
|
close() {
|
|
1063
1065
|
this.isClosed = true;
|
|
1064
1066
|
return Promise.resolve();
|
|
1065
1067
|
}
|
|
1066
1068
|
createMessageBatch() {
|
|
1067
|
-
throw new
|
|
1069
|
+
throw new NotImplementedError(this.createMessageBatch.name);
|
|
1068
1070
|
}
|
|
1069
1071
|
scheduleMessages(messages, scheduledEnqueueTimeUtc) {
|
|
1070
1072
|
for (const message of Array.isArray(messages) ? messages : [messages]) this.queue.push({
|
|
@@ -1074,7 +1076,7 @@ var MockServiceBusSender = class {
|
|
|
1074
1076
|
return Promise.resolve([]);
|
|
1075
1077
|
}
|
|
1076
1078
|
sendMessages(messages) {
|
|
1077
|
-
if (!Array.isArray(messages) && "tryAddMessage" in messages) throw new
|
|
1079
|
+
if (!Array.isArray(messages) && "tryAddMessage" in messages) throw new NotImplementedError(`${this.sendMessages.name}(ServiceBusMessageBatch)`);
|
|
1078
1080
|
this.queue.push(...Array.isArray(messages) ? messages : [messages]);
|
|
1079
1081
|
return Promise.resolve();
|
|
1080
1082
|
}
|
|
@@ -1114,17 +1116,17 @@ var MockTableClient = class {
|
|
|
1114
1116
|
});
|
|
1115
1117
|
}
|
|
1116
1118
|
createTable() {
|
|
1117
|
-
throw new
|
|
1119
|
+
throw new NotImplementedError(this.createTable.name);
|
|
1118
1120
|
}
|
|
1119
|
-
deleteEntity(partitionKey, rowKey) {
|
|
1120
|
-
this.#applyDelete(partitionKey, rowKey);
|
|
1121
|
+
deleteEntity(partitionKey, rowKey, options) {
|
|
1122
|
+
this.#applyDelete(partitionKey, rowKey, options?.etag);
|
|
1121
1123
|
return Promise.resolve({});
|
|
1122
1124
|
}
|
|
1123
1125
|
deleteTable() {
|
|
1124
|
-
throw new
|
|
1126
|
+
throw new NotImplementedError(this.deleteTable.name);
|
|
1125
1127
|
}
|
|
1126
1128
|
getAccessPolicy() {
|
|
1127
|
-
throw new
|
|
1129
|
+
throw new NotImplementedError(this.getAccessPolicy.name);
|
|
1128
1130
|
}
|
|
1129
1131
|
getEntity(partitionKey, rowKey) {
|
|
1130
1132
|
const key = this.#getCompositeKey(partitionKey, rowKey);
|
|
@@ -1140,7 +1142,7 @@ var MockTableClient = class {
|
|
|
1140
1142
|
const filter = options?.queryOptions?.filter;
|
|
1141
1143
|
const tableEntities = [...this.table.values()];
|
|
1142
1144
|
const predicate = filter ? createFilterPredicate(filter) : void 0;
|
|
1143
|
-
const resultTableEntities = (predicate ? tableEntities.filter((
|
|
1145
|
+
const resultTableEntities = (predicate ? tableEntities.filter((entity) => predicate(entity)) : tableEntities).toSorted(compareByCompositeKey);
|
|
1144
1146
|
const entityIterator = (async function* (entities) {
|
|
1145
1147
|
for (const entity of entities) yield await Promise.resolve(withMetadata(entity));
|
|
1146
1148
|
})(resultTableEntities);
|
|
@@ -1150,10 +1152,10 @@ var MockTableClient = class {
|
|
|
1150
1152
|
else if (maxPageSize !== void 0 && maxPageSize > AZURE_MAX_PAGE_SIZE) throw new MockRestError("One of the request inputs is not valid.", 400);
|
|
1151
1153
|
if (entities.length === 0) return;
|
|
1152
1154
|
else if (!maxPageSize) {
|
|
1153
|
-
yield await Promise.resolve(entities.map((
|
|
1155
|
+
yield await Promise.resolve(entities.map((entity) => withMetadata(entity)));
|
|
1154
1156
|
return;
|
|
1155
1157
|
}
|
|
1156
|
-
for (const page of chunk(entities, maxPageSize)) yield await Promise.resolve(page.map((
|
|
1158
|
+
for (const page of chunk(entities, maxPageSize)) yield await Promise.resolve(page.map((entity) => withMetadata(entity)));
|
|
1157
1159
|
})(resultTableEntities),
|
|
1158
1160
|
next: () => entityIterator.next(),
|
|
1159
1161
|
[Symbol.asyncIterator]() {
|
|
@@ -1162,7 +1164,7 @@ var MockTableClient = class {
|
|
|
1162
1164
|
};
|
|
1163
1165
|
}
|
|
1164
1166
|
setAccessPolicy() {
|
|
1165
|
-
throw new
|
|
1167
|
+
throw new NotImplementedError(this.setAccessPolicy.name);
|
|
1166
1168
|
}
|
|
1167
1169
|
submitTransaction(actions) {
|
|
1168
1170
|
let partitionKey;
|
|
@@ -1219,17 +1221,19 @@ var MockTableClient = class {
|
|
|
1219
1221
|
etag: this.#getEtag()
|
|
1220
1222
|
});
|
|
1221
1223
|
}
|
|
1222
|
-
#applyDelete(partitionKey, rowKey) {
|
|
1224
|
+
#applyDelete(partitionKey, rowKey, etag) {
|
|
1223
1225
|
const key = this.#getCompositeKey(partitionKey, rowKey);
|
|
1224
|
-
|
|
1226
|
+
const existingEntity = this.table.get(key);
|
|
1227
|
+
if (!existingEntity) throw new MockRestError("The specified resource does not exist.", 404);
|
|
1228
|
+
this.#assertEtag(existingEntity.etag, etag);
|
|
1225
1229
|
this.table.delete(key);
|
|
1226
1230
|
}
|
|
1227
1231
|
#applyUpdate(entity, mode = "Merge", etag) {
|
|
1228
1232
|
const key = this.#getCompositeKey(entity.partitionKey, entity.rowKey);
|
|
1229
1233
|
const existingEntity = this.table.get(key);
|
|
1230
1234
|
if (!existingEntity) throw new MockRestError("The specified resource does not exist.", 404);
|
|
1231
|
-
|
|
1232
|
-
|
|
1235
|
+
this.#assertEtag(existingEntity.etag, etag);
|
|
1236
|
+
if (mode === "Merge") this.table.set(key, {
|
|
1233
1237
|
...existingEntity,
|
|
1234
1238
|
...entity,
|
|
1235
1239
|
etag: this.#getEtag()
|
|
@@ -1252,6 +1256,9 @@ var MockTableClient = class {
|
|
|
1252
1256
|
etag: this.#getEtag()
|
|
1253
1257
|
});
|
|
1254
1258
|
}
|
|
1259
|
+
#assertEtag(existingEtag, etag) {
|
|
1260
|
+
if (etag !== void 0 && etag !== "*" && etag !== existingEtag) throw new MockRestError("The update condition specified in the request was not satisfied.", 412);
|
|
1261
|
+
}
|
|
1255
1262
|
#getCompositeKey(partitionKey, rowKey) {
|
|
1256
1263
|
return `${encodeURIComponent(partitionKey)}${ID_SEPARATOR}${encodeURIComponent(rowKey)}`;
|
|
1257
1264
|
}
|
|
@@ -1283,4 +1290,4 @@ const applyFilter = (documents, clauses) => {
|
|
|
1283
1290
|
return documents.filter((document) => predicate(document));
|
|
1284
1291
|
};
|
|
1285
1292
|
//#endregion
|
|
1286
|
-
export { BLOB_NOT_FOUND_ERROR_CODE, BLOB_NOT_FOUND_MESSAGE, MOCK_BLOB_BASE_URL, MOCK_BLOB_SEEDED_DATE, MOCK_BLOB_SEEDED_PROPERTIES, MOCK_QUEUE_BASE_URL, MOCK_SEARCH_BASE_URL, MOCK_TABLE_BASE_URL, MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerBlobDatesDatabase, MockContainerBlobMetadataDatabase, MockContainerClient, MockContainerDatabase, MockEventGridDatabase, MockEventGridPublisherClient, MockQueueClient, MockQueueDatabase, MockRestError, MockSearchClient, MockSearchDatabase, MockServiceBusDatabase, MockServiceBusSender, MockTableClient, MockTableDatabase, MockWebPubSubServiceClient, applyFilter, bodyToBuffer, checkIsNullClause, checkIsReadableStream, compare, compareByCompositeKey, createFilterPredicate, createMockResponse, deleteMockBlob, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, getBlobUrl, getBlobUrlParts, getListBlobsSegmentResponse, getListBlobsXml, getMockBlobKey, getMockContainer, getMockQueueMessageItem, getMockSasUrl, readMockBlobDates, readMockBlobMetadata, storeMockBlobMetadata, storeMockBlobWrite, toWebResourceLike };
|
|
1293
|
+
export { BLOB_NOT_FOUND_ERROR_CODE, BLOB_NOT_FOUND_MESSAGE, MOCK_BLOB_BASE_URL, MOCK_BLOB_SEEDED_DATE, MOCK_BLOB_SEEDED_PROPERTIES, MOCK_QUEUE_BASE_URL, MOCK_SEARCH_BASE_URL, MOCK_TABLE_BASE_URL, MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerBlobDatesDatabase, MockContainerBlobMetadataDatabase, MockContainerClient, MockContainerDatabase, MockEventGridDatabase, MockEventGridPublisherClient, MockQueueClient, MockQueueDatabase, MockRestError, MockSearchClient, MockSearchDatabase, MockServiceBusDatabase, MockServiceBusSender, MockTableClient, MockTableDatabase, MockWebPubSubServiceClient, NotImplementedError, applyFilter, bodyToBuffer, checkIsNullClause, checkIsReadableStream, compare, compareByCompositeKey, createFilterPredicate, createMockResponse, deleteMockBlob, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, getBlobUrl, getBlobUrlParts, getListBlobsSegmentResponse, getListBlobsXml, getMockBlobKey, getMockContainer, getMockQueueMessageItem, getMockSasUrl, readMockBlobDates, readMockBlobMetadata, storeMockBlobMetadata, storeMockBlobWrite, toWebResourceLike };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "azure-mock",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "A library that contains azure mock classes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"azure",
|
|
@@ -54,18 +54,18 @@
|
|
|
54
54
|
"typecheck": "tsc"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@esposter/azure": "3.
|
|
58
|
-
"@esposter/shared": "3.
|
|
57
|
+
"@esposter/azure": "3.3.0",
|
|
58
|
+
"@esposter/shared": "3.3.0",
|
|
59
59
|
"fast-deep-equal": "^3.1.3"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@arethetypeswrong/core": "^0.18.5",
|
|
63
|
-
"@esposter/configuration": "3.
|
|
63
|
+
"@esposter/configuration": "3.3.0",
|
|
64
64
|
"publint": "^0.3.24",
|
|
65
65
|
"tsdown": "^0.23.0",
|
|
66
66
|
"type-fest": "^5.10.0",
|
|
67
67
|
"typedoc": "^0.28.20",
|
|
68
|
-
"vitest": "^5.0.
|
|
68
|
+
"vitest": "^5.0.2"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"@azure/core-http-compat": "^2.5.0",
|
|
@@ -74,11 +74,11 @@
|
|
|
74
74
|
"@azure/eventgrid": "^5.12.0",
|
|
75
75
|
"@azure/search-documents": "^13.0.0",
|
|
76
76
|
"@azure/service-bus": "^7.9.5",
|
|
77
|
-
"@azure/storage-blob": "^12.
|
|
78
|
-
"@azure/storage-queue": "^12.
|
|
77
|
+
"@azure/storage-blob": "^12.34.0",
|
|
78
|
+
"@azure/storage-queue": "^12.32.0"
|
|
79
79
|
},
|
|
80
80
|
"inlinedDependencies": {
|
|
81
81
|
"type-fest": "5.10.0"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "5854a00717502d8de96adc8b44d3621ab85f9b57"
|
|
84
84
|
}
|