azure-mock 3.0.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 +80 -71
- package/dist/index.js +170 -168
- package/package.json +10 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { PipelineRequest, RestError } from "@azure/core-rest-pipeline";
|
|
2
1
|
import { HttpHeadersLike, WebResourceLike } from "@azure/core-http-compat";
|
|
3
|
-
import {
|
|
2
|
+
import { PipelineRequest, RestError } from "@azure/core-rest-pipeline";
|
|
4
3
|
import { AnonymousCredential, AppendBlobClient, BlobAbortCopyFromURLResponse, BlobBatchClient, BlobBatchDeleteBlobsResponse, BlobBeginCopyFromURLResponse, BlobClient, BlobCopyFromURLResponse, BlobCreateSnapshotResponse, BlobDeleteIfExistsResponse, BlobDeleteImmutabilityPolicyResponse, BlobDeleteOptions, BlobDeleteResponse, BlobDownloadResponseModel, BlobDownloadResponseParsed, BlobGenerateSasUrlOptions, BlobGetAccountInfoResponse, BlobGetPropertiesResponse, BlobGetTagsResponse, BlobHierarchyListSegment, BlobItem, BlobLeaseClient, BlobPrefix, BlobSetHTTPHeadersResponse, BlobSetImmutabilityPolicyResponse, BlobSetLegalHoldResponse, BlobSetMetadataResponse, BlobSetTagsResponse, BlobSetTierResponse, BlobUndeleteResponse, BlobUploadCommonResponse, BlockBlobClient, BlockBlobCommitBlockListResponse, BlockBlobGetBlockListResponse, BlockBlobPutBlobFromUrlResponse, BlockBlobStageBlockFromURLResponse, BlockBlobStageBlockResponse, BlockBlobUploadOptions, 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
4
|
import { BinaryOperator, Clause } from "@esposter/azure";
|
|
6
5
|
import { EventGridEvent, EventGridPublisherClient } from "@azure/eventgrid";
|
|
@@ -16,61 +15,6 @@ export declare const MOCK_QUEUE_BASE_URL = "https://mockaccount.queue.core.windo
|
|
|
16
15
|
export declare const MOCK_SEARCH_BASE_URL = "https://mockaccount.search.windows.net";
|
|
17
16
|
export declare const MOCK_TABLE_BASE_URL = "https://mockaccount.table.core.windows.net";
|
|
18
17
|
//#endregion
|
|
19
|
-
//#region src/models/MockResponse.d.ts
|
|
20
|
-
export interface MockResponse {
|
|
21
|
-
headers: HttpHeadersLike;
|
|
22
|
-
parsedHeaders: Record<string, never>;
|
|
23
|
-
request: WebResourceLike;
|
|
24
|
-
status: number;
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region src/models/MockRestError.d.ts
|
|
28
|
-
export declare class MockRestError extends RestError {
|
|
29
|
-
constructor(message: string, statusCode: number);
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/models/PageSettings.d.ts
|
|
33
|
-
/**
|
|
34
|
-
* An interface that tracks the settings for paged iteration
|
|
35
|
-
*/
|
|
36
|
-
export interface PageSettings {
|
|
37
|
-
/**
|
|
38
|
-
* The token that keeps track of where to continue the iterator
|
|
39
|
-
*/
|
|
40
|
-
continuationToken?: string;
|
|
41
|
-
/**
|
|
42
|
-
* The size of the page during paged iteration
|
|
43
|
-
*/
|
|
44
|
-
maxPageSize?: number;
|
|
45
|
-
}
|
|
46
|
-
//#endregion
|
|
47
|
-
//#region src/models/PagedAsyncIterableIterator.d.ts
|
|
48
|
-
/**
|
|
49
|
-
* An interface that allows async iterable iteration both to completion and by page.
|
|
50
|
-
*/
|
|
51
|
-
export interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings = PageSettings> {
|
|
52
|
-
/**
|
|
53
|
-
* The connection to the async iterator, part of the iteration protocol
|
|
54
|
-
*/
|
|
55
|
-
[Symbol.asyncIterator]: () => PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
|
|
56
|
-
/**
|
|
57
|
-
* Return an AsyncIterableIterator that works a page at a time
|
|
58
|
-
*/
|
|
59
|
-
byPage: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;
|
|
60
|
-
/**
|
|
61
|
-
* The next method, part of the iteration protocol
|
|
62
|
-
*/
|
|
63
|
-
next: () => Promise<IteratorResult<TElement>>;
|
|
64
|
-
}
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/services/createMockResponse.d.ts
|
|
67
|
-
export declare const createMockResponse: (status: number, url?: string) => MockResponse;
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region src/services/getMockSasUrl.d.ts
|
|
70
|
-
export declare const getMockSasUrl: (url: string, permissions: undefined | {
|
|
71
|
-
toString: () => string;
|
|
72
|
-
}, resourceType?: string) => string;
|
|
73
|
-
//#endregion
|
|
74
18
|
//#region src/models/container/MockBlobDates.d.ts
|
|
75
19
|
export interface MockBlobDates {
|
|
76
20
|
createdOn: Date;
|
|
@@ -109,6 +53,9 @@ export type BlobHierarchyItem = (BlobItem & {
|
|
|
109
53
|
kind: "prefix";
|
|
110
54
|
});
|
|
111
55
|
//#endregion
|
|
56
|
+
//#region src/util/types/MapValue.d.ts
|
|
57
|
+
export type MapValue<BaseType> = BaseType extends Map<unknown, infer ValueType> ? ValueType : never;
|
|
58
|
+
//#endregion
|
|
112
59
|
//#region src/models/container/MockBlobBatchClient.d.ts
|
|
113
60
|
export declare class MockBlobBatchClient implements BlobBatchClient {
|
|
114
61
|
#private;
|
|
@@ -124,7 +71,7 @@ export declare class MockBlobBatchClient implements BlobBatchClient {
|
|
|
124
71
|
getContainer(containerName: string): MapValue<typeof MockContainerDatabase>;
|
|
125
72
|
}
|
|
126
73
|
//#endregion
|
|
127
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
74
|
+
//#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/is-any.d.ts
|
|
128
75
|
/**
|
|
129
76
|
Returns a boolean for whether the given type is `any`.
|
|
130
77
|
|
|
@@ -155,7 +102,7 @@ const anyA = get(anyObject, 'a');
|
|
|
155
102
|
*/
|
|
156
103
|
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
157
104
|
//#endregion
|
|
158
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
105
|
+
//#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
159
106
|
/**
|
|
160
107
|
Returns a boolean for whether the given key is an optional key of type.
|
|
161
108
|
|
|
@@ -198,7 +145,7 @@ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
|
198
145
|
*/
|
|
199
146
|
type IsOptionalKeyOf<Type extends object, Key extends keyof Type> = IsAny<Type | Key> extends true ? never : Key extends keyof Type ? Type extends Record<Key, Type[Key]> ? false : true : false;
|
|
200
147
|
//#endregion
|
|
201
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
148
|
+
//#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
202
149
|
/**
|
|
203
150
|
Extract all optional keys from the given type.
|
|
204
151
|
|
|
@@ -236,7 +183,7 @@ type OptionalKeysOf<Type extends object> = Type extends unknown // For distribut
|
|
|
236
183
|
? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never; }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
|
|
237
184
|
: never; // Should never happen
|
|
238
185
|
//#endregion
|
|
239
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
186
|
+
//#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/required-keys-of.d.ts
|
|
240
187
|
/**
|
|
241
188
|
Extract all required keys from the given type.
|
|
242
189
|
|
|
@@ -270,7 +217,7 @@ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
|
|
|
270
217
|
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
271
218
|
? Exclude<keyof Type, OptionalKeysOf<Type>> : never; // Should never happen
|
|
272
219
|
//#endregion
|
|
273
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
220
|
+
//#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/is-never.d.ts
|
|
274
221
|
/**
|
|
275
222
|
Returns a boolean for whether the given type is `never`.
|
|
276
223
|
|
|
@@ -326,7 +273,7 @@ type B = IsTrueFixed<never>;
|
|
|
326
273
|
*/
|
|
327
274
|
type IsNever<T> = [T] extends [never] ? true : false;
|
|
328
275
|
//#endregion
|
|
329
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
276
|
+
//#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/if.d.ts
|
|
330
277
|
/**
|
|
331
278
|
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
332
279
|
|
|
@@ -421,7 +368,7 @@ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
|
|
|
421
368
|
*/
|
|
422
369
|
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
423
370
|
//#endregion
|
|
424
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
371
|
+
//#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/simplify.d.ts
|
|
425
372
|
/**
|
|
426
373
|
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
427
374
|
|
|
@@ -482,7 +429,7 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
482
429
|
*/
|
|
483
430
|
type Simplify<T> = { [KeyType in keyof T]: T[KeyType]; } & {};
|
|
484
431
|
//#endregion
|
|
485
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
432
|
+
//#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/is-equal.d.ts
|
|
486
433
|
/**
|
|
487
434
|
Returns a boolean for whether the two given types are equal.
|
|
488
435
|
|
|
@@ -513,7 +460,7 @@ type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false
|
|
|
513
460
|
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
514
461
|
type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
515
462
|
//#endregion
|
|
516
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
463
|
+
//#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
517
464
|
/**
|
|
518
465
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
519
466
|
|
|
@@ -607,7 +554,7 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
607
554
|
*/
|
|
608
555
|
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType]; };
|
|
609
556
|
//#endregion
|
|
610
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
557
|
+
//#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
611
558
|
/**
|
|
612
559
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
613
560
|
|
|
@@ -655,7 +602,7 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
655
602
|
*/
|
|
656
603
|
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType]; };
|
|
657
604
|
//#endregion
|
|
658
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
605
|
+
//#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/merge.d.ts
|
|
659
606
|
// Merges two objects without worrying about index signatures.
|
|
660
607
|
type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key]; } & Source>;
|
|
661
608
|
/**
|
|
@@ -726,7 +673,7 @@ type Merge<Destination, Source> = Destination extends unknown // For distributin
|
|
|
726
673
|
: never; // Should never happen
|
|
727
674
|
type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
728
675
|
//#endregion
|
|
729
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
676
|
+
//#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/internal/object.d.ts
|
|
730
677
|
/**
|
|
731
678
|
Merges user specified options with default options.
|
|
732
679
|
|
|
@@ -783,7 +730,7 @@ type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<
|
|
|
783
730
|
) ? Result : never;
|
|
784
731
|
type _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Merge<Defaults, { [Key in keyof SpecifiedOptions as undefined extends Required<Options>[Key & keyof Options] ? Key : undefined extends SpecifiedOptions[Key] ? never : Key]: SpecifiedOptions[Key]; }>>>;
|
|
785
732
|
//#endregion
|
|
786
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
733
|
+
//#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/except.d.ts
|
|
787
734
|
/**
|
|
788
735
|
Filter out keys from an object.
|
|
789
736
|
|
|
@@ -940,6 +887,40 @@ export declare class MockBlockBlobClient extends MockBlobClient implements Excep
|
|
|
940
887
|
uploadStream(): Promise<BlobUploadCommonResponse>;
|
|
941
888
|
}
|
|
942
889
|
//#endregion
|
|
890
|
+
//#region src/models/shared/PageSettings.d.ts
|
|
891
|
+
/**
|
|
892
|
+
* An interface that tracks the settings for paged iteration
|
|
893
|
+
*/
|
|
894
|
+
export interface PageSettings {
|
|
895
|
+
/**
|
|
896
|
+
* The token that keeps track of where to continue the iterator
|
|
897
|
+
*/
|
|
898
|
+
continuationToken?: string;
|
|
899
|
+
/**
|
|
900
|
+
* The size of the page during paged iteration
|
|
901
|
+
*/
|
|
902
|
+
maxPageSize?: number;
|
|
903
|
+
}
|
|
904
|
+
//#endregion
|
|
905
|
+
//#region src/models/shared/PagedAsyncIterableIterator.d.ts
|
|
906
|
+
/**
|
|
907
|
+
* An interface that allows async iterable iteration both to completion and by page.
|
|
908
|
+
*/
|
|
909
|
+
export interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings = PageSettings> {
|
|
910
|
+
/**
|
|
911
|
+
* The connection to the async iterator, part of the iteration protocol
|
|
912
|
+
*/
|
|
913
|
+
[Symbol.asyncIterator]: () => PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
|
|
914
|
+
/**
|
|
915
|
+
* Return an AsyncIterableIterator that works a page at a time
|
|
916
|
+
*/
|
|
917
|
+
byPage: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;
|
|
918
|
+
/**
|
|
919
|
+
* The next method, part of the iteration protocol
|
|
920
|
+
*/
|
|
921
|
+
next: () => Promise<IteratorResult<TElement>>;
|
|
922
|
+
}
|
|
923
|
+
//#endregion
|
|
943
924
|
//#region src/models/container/MockContainerClient.d.ts
|
|
944
925
|
/**
|
|
945
926
|
* An in-memory mock of the Azure ContainerClient — no emulator and no network.
|
|
@@ -1091,6 +1072,24 @@ export declare class MockServiceBusSender implements ServiceBusSender {
|
|
|
1091
1072
|
sendMessages(messages: ServiceBusMessage | ServiceBusMessage[] | ServiceBusMessageBatch): Promise<void>;
|
|
1092
1073
|
}
|
|
1093
1074
|
//#endregion
|
|
1075
|
+
//#region src/models/shared/MockResponse.d.ts
|
|
1076
|
+
export interface MockResponse {
|
|
1077
|
+
headers: HttpHeadersLike;
|
|
1078
|
+
parsedHeaders: Record<string, never>;
|
|
1079
|
+
request: WebResourceLike;
|
|
1080
|
+
status: number;
|
|
1081
|
+
}
|
|
1082
|
+
//#endregion
|
|
1083
|
+
//#region src/models/shared/MockRestError.d.ts
|
|
1084
|
+
export declare class MockRestError extends RestError {
|
|
1085
|
+
constructor(message: string, statusCode: number);
|
|
1086
|
+
}
|
|
1087
|
+
//#endregion
|
|
1088
|
+
//#region src/models/shared/NotImplementedError.d.ts
|
|
1089
|
+
export declare class NotImplementedError extends Error {
|
|
1090
|
+
constructor(name: string);
|
|
1091
|
+
}
|
|
1092
|
+
//#endregion
|
|
1094
1093
|
//#region src/models/table/MockTableClient.d.ts
|
|
1095
1094
|
/**
|
|
1096
1095
|
* An in-memory mock of the Azure TableClient — no emulator and no network.
|
|
@@ -1109,7 +1108,9 @@ export declare class MockTableClient<TEntity extends TableEntity = TableEntity>
|
|
|
1109
1108
|
constructor(_url: string, tableName: string);
|
|
1110
1109
|
createEntity<T extends object>(entity: TableEntity<T>): Promise<CreateTableEntityResponse>;
|
|
1111
1110
|
createTable(): Promise<void>;
|
|
1112
|
-
deleteEntity(partitionKey: string, rowKey: string
|
|
1111
|
+
deleteEntity(partitionKey: string, rowKey: string, options?: {
|
|
1112
|
+
etag?: string;
|
|
1113
|
+
}): Promise<TableDeleteEntityHeaders>;
|
|
1113
1114
|
deleteTable(): Promise<void>;
|
|
1114
1115
|
getAccessPolicy(): Promise<GetAccessPolicyResponse>;
|
|
1115
1116
|
getEntity<T extends object = Record<string, unknown>>(partitionKey: string, rowKey: string): Promise<GetTableEntityResponse<TableEntityResult<T>>>;
|
|
@@ -1223,6 +1224,14 @@ export declare const getMockQueueMessageItem: (messageText: string) => {
|
|
|
1223
1224
|
messageText: string;
|
|
1224
1225
|
};
|
|
1225
1226
|
//#endregion
|
|
1227
|
+
//#region src/services/shared/createMockResponse.d.ts
|
|
1228
|
+
export declare const createMockResponse: (status: number, url?: string) => MockResponse;
|
|
1229
|
+
//#endregion
|
|
1230
|
+
//#region src/services/shared/getMockSasUrl.d.ts
|
|
1231
|
+
export declare const getMockSasUrl: (url: string, permissions: undefined | {
|
|
1232
|
+
toString: () => string;
|
|
1233
|
+
}, resourceType?: string) => string;
|
|
1234
|
+
//#endregion
|
|
1226
1235
|
//#region src/services/table/compareByCompositeKey.d.ts
|
|
1227
1236
|
export declare const compareByCompositeKey: (firstEntity: TableEntity, secondEntity: TableEntity) => number;
|
|
1228
1237
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RestError, createHttpHeaders, createPipelineRequest } from "@azure/core-rest-pipeline";
|
|
2
|
-
import { toHttpHeadersLike } from "@azure/core-http-compat";
|
|
3
1
|
import { ID_SEPARATOR, InvalidOperationError, Operation, chunk, exhaustiveGuard, getDecodedUriComponent, getOrCreate, getResult, html, noop, streamToText, takeOne } from "@esposter/shared";
|
|
2
|
+
import { toHttpHeadersLike } from "@azure/core-http-compat";
|
|
3
|
+
import { RestError, createHttpHeaders, createPipelineRequest } from "@azure/core-rest-pipeline";
|
|
4
4
|
import { AnonymousCredential } from "@azure/storage-blob";
|
|
5
5
|
import { Readable } from "node:stream";
|
|
6
6
|
import { AZURE_MAX_PAGE_SIZE, AZURE_MAX_QUEUE_VISIBILITY_TIMEOUT_MS, BinaryOperator, deserializeClause, deserializeKey, getTableNullClause, serializeClauses } from "@esposter/azure";
|
|
@@ -13,52 +13,6 @@ const MOCK_QUEUE_BASE_URL = "https://mockaccount.queue.core.windows.net";
|
|
|
13
13
|
const MOCK_SEARCH_BASE_URL = "https://mockaccount.search.windows.net";
|
|
14
14
|
const MOCK_TABLE_BASE_URL = "https://mockaccount.table.core.windows.net";
|
|
15
15
|
//#endregion
|
|
16
|
-
//#region src/models/MockRestError.ts
|
|
17
|
-
var MockRestError = class extends RestError {
|
|
18
|
-
constructor(message, statusCode) {
|
|
19
|
-
super(message, { statusCode });
|
|
20
|
-
this.name = "MockRestError";
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/services/container/toWebResourceLike.ts
|
|
25
|
-
const toWebResourceLike = (request) => ({
|
|
26
|
-
abortSignal: request.abortSignal,
|
|
27
|
-
agent: request.agent,
|
|
28
|
-
body: request.body,
|
|
29
|
-
clone: () => {
|
|
30
|
-
throw new Error("Cannot clone a non-proxied WebResourceLike");
|
|
31
|
-
},
|
|
32
|
-
formData: request.formData,
|
|
33
|
-
headers: toHttpHeadersLike(request.headers),
|
|
34
|
-
keepAlive: request.disableKeepAlive,
|
|
35
|
-
method: request.method,
|
|
36
|
-
onDownloadProgress: request.onDownloadProgress,
|
|
37
|
-
onUploadProgress: request.onUploadProgress,
|
|
38
|
-
prepare: () => {
|
|
39
|
-
throw new Error("WebResourceLike.prepare() is not supported by @azure/core-http-compat");
|
|
40
|
-
},
|
|
41
|
-
proxySettings: request.proxySettings,
|
|
42
|
-
requestId: request.headers.get("x-ms-client-request-id") ?? request.requestId,
|
|
43
|
-
requestOverrides: request.requestOverrides,
|
|
44
|
-
streamResponseStatusCodes: request.streamResponseStatusCodes,
|
|
45
|
-
timeout: request.timeout,
|
|
46
|
-
url: request.url,
|
|
47
|
-
validateRequestProperties: noop,
|
|
48
|
-
withCredentials: request.withCredentials
|
|
49
|
-
});
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/services/createMockResponse.ts
|
|
52
|
-
const createMockResponse = (status, url = "") => ({
|
|
53
|
-
headers: toHttpHeadersLike(createHttpHeaders()),
|
|
54
|
-
parsedHeaders: {},
|
|
55
|
-
request: toWebResourceLike(createPipelineRequest({ url })),
|
|
56
|
-
status
|
|
57
|
-
});
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/services/getMockSasUrl.ts
|
|
60
|
-
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"}`;
|
|
61
|
-
//#endregion
|
|
62
16
|
//#region src/store/MockContainerBlobDatesDatabase.ts
|
|
63
17
|
const MockContainerBlobDatesDatabase = /* @__PURE__ */ new Map();
|
|
64
18
|
//#endregion
|
|
@@ -137,6 +91,49 @@ const getBlobUrlParts = (url) => {
|
|
|
137
91
|
};
|
|
138
92
|
};
|
|
139
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
|
|
102
|
+
//#region src/services/container/toWebResourceLike.ts
|
|
103
|
+
const toWebResourceLike = (request) => ({
|
|
104
|
+
abortSignal: request.abortSignal,
|
|
105
|
+
agent: request.agent,
|
|
106
|
+
body: request.body,
|
|
107
|
+
clone: () => {
|
|
108
|
+
throw new NotImplementedError(`${toWebResourceLike.name}(…).clone`);
|
|
109
|
+
},
|
|
110
|
+
formData: request.formData,
|
|
111
|
+
headers: toHttpHeadersLike(request.headers),
|
|
112
|
+
keepAlive: request.disableKeepAlive,
|
|
113
|
+
method: request.method,
|
|
114
|
+
onDownloadProgress: request.onDownloadProgress,
|
|
115
|
+
onUploadProgress: request.onUploadProgress,
|
|
116
|
+
prepare: () => {
|
|
117
|
+
throw new NotImplementedError(`${toWebResourceLike.name}(…).prepare`);
|
|
118
|
+
},
|
|
119
|
+
proxySettings: request.proxySettings,
|
|
120
|
+
requestId: request.headers.get("x-ms-client-request-id") ?? request.requestId,
|
|
121
|
+
requestOverrides: request.requestOverrides,
|
|
122
|
+
streamResponseStatusCodes: request.streamResponseStatusCodes,
|
|
123
|
+
timeout: request.timeout,
|
|
124
|
+
url: request.url,
|
|
125
|
+
validateRequestProperties: noop,
|
|
126
|
+
withCredentials: request.withCredentials
|
|
127
|
+
});
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/services/shared/createMockResponse.ts
|
|
130
|
+
const createMockResponse = (status, url = "") => ({
|
|
131
|
+
headers: toHttpHeadersLike(createHttpHeaders()),
|
|
132
|
+
parsedHeaders: {},
|
|
133
|
+
request: toWebResourceLike(createPipelineRequest({ url })),
|
|
134
|
+
status
|
|
135
|
+
});
|
|
136
|
+
//#endregion
|
|
140
137
|
//#region src/models/container/MockBlobBatchClient.ts
|
|
141
138
|
var MockBlobBatchClient = class {
|
|
142
139
|
url;
|
|
@@ -208,6 +205,14 @@ var MockBlobBatchClient = class {
|
|
|
208
205
|
}
|
|
209
206
|
};
|
|
210
207
|
//#endregion
|
|
208
|
+
//#region src/models/shared/MockRestError.ts
|
|
209
|
+
var MockRestError = class extends RestError {
|
|
210
|
+
constructor(message, statusCode) {
|
|
211
|
+
super(message, { statusCode });
|
|
212
|
+
this.name = "MockRestError";
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
//#endregion
|
|
211
216
|
//#region src/services/container/getBlobUrl.ts
|
|
212
217
|
const getBlobUrl = (containerName, blobName) => `${MOCK_BLOB_BASE_URL}/${containerName}/${blobName.split("/").map((segment) => encodeURIComponent(segment)).join("/")}`;
|
|
213
218
|
//#endregion
|
|
@@ -233,6 +238,9 @@ const storeMockBlobWrite = (containerName, blobName, isExisting) => {
|
|
|
233
238
|
});
|
|
234
239
|
};
|
|
235
240
|
//#endregion
|
|
241
|
+
//#region src/services/shared/getMockSasUrl.ts
|
|
242
|
+
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"}`;
|
|
243
|
+
//#endregion
|
|
236
244
|
//#region src/models/container/MockBlobClient.ts
|
|
237
245
|
var MockBlobClient = class {
|
|
238
246
|
connectionString;
|
|
@@ -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) => ({
|
|
@@ -841,36 +843,31 @@ var MockQueueClient = class {
|
|
|
841
843
|
sendMessage(messageText, _options) {
|
|
842
844
|
this.queue.push(messageText);
|
|
843
845
|
const { expiresOn, insertedOn, messageId } = getMockQueueMessageItem(messageText);
|
|
844
|
-
const
|
|
845
|
-
const popReceipt = crypto.randomUUID();
|
|
846
|
-
const enqueuedMessages = [{
|
|
846
|
+
const enqueuedMessage = {
|
|
847
847
|
expiresOn,
|
|
848
848
|
insertedOn,
|
|
849
849
|
messageId,
|
|
850
|
-
nextVisibleOn,
|
|
851
|
-
popReceipt
|
|
852
|
-
}
|
|
850
|
+
nextVisibleOn: insertedOn,
|
|
851
|
+
popReceipt: crypto.randomUUID()
|
|
852
|
+
};
|
|
853
|
+
const enqueuedMessages = [enqueuedMessage];
|
|
853
854
|
return Promise.resolve({
|
|
854
855
|
_response: {
|
|
855
856
|
...createMockResponse(200, this.url),
|
|
856
857
|
bodyAsText: "",
|
|
857
858
|
parsedBody: enqueuedMessages
|
|
858
859
|
},
|
|
859
|
-
|
|
860
|
-
insertedOn,
|
|
861
|
-
messageId,
|
|
862
|
-
nextVisibleOn,
|
|
863
|
-
popReceipt
|
|
860
|
+
...enqueuedMessage
|
|
864
861
|
});
|
|
865
862
|
}
|
|
866
863
|
setAccessPolicy(_identifiers) {
|
|
867
|
-
throw new
|
|
864
|
+
throw new NotImplementedError(this.setAccessPolicy.name);
|
|
868
865
|
}
|
|
869
866
|
setMetadata() {
|
|
870
|
-
throw new
|
|
867
|
+
throw new NotImplementedError(this.setMetadata.name);
|
|
871
868
|
}
|
|
872
869
|
updateMessage() {
|
|
873
|
-
throw new
|
|
870
|
+
throw new NotImplementedError(this.updateMessage.name);
|
|
874
871
|
}
|
|
875
872
|
};
|
|
876
873
|
//#endregion
|
|
@@ -883,7 +880,7 @@ const checkIsNullClause = (clause) => {
|
|
|
883
880
|
//#region src/services/filter/compare.ts
|
|
884
881
|
const compare = (operator, leftHandSide, rightHandSide) => {
|
|
885
882
|
if (rightHandSide === null || rightHandSide === void 0) {
|
|
886
|
-
if (operator !== BinaryOperator.
|
|
883
|
+
if (operator !== BinaryOperator.Eq) throw new InvalidOperationError(Operation.Read, compare.name, JSON.stringify({
|
|
887
884
|
leftHandSide,
|
|
888
885
|
operator,
|
|
889
886
|
rightHandSide
|
|
@@ -891,12 +888,12 @@ const compare = (operator, leftHandSide, rightHandSide) => {
|
|
|
891
888
|
return leftHandSide === null || leftHandSide === void 0;
|
|
892
889
|
}
|
|
893
890
|
switch (operator) {
|
|
894
|
-
case BinaryOperator.
|
|
895
|
-
case BinaryOperator.
|
|
896
|
-
case BinaryOperator.
|
|
897
|
-
case BinaryOperator.
|
|
898
|
-
case BinaryOperator.
|
|
899
|
-
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;
|
|
900
897
|
default: return exhaustiveGuard(operator);
|
|
901
898
|
}
|
|
902
899
|
};
|
|
@@ -916,7 +913,7 @@ const createFilterPredicate = (filter) => {
|
|
|
916
913
|
for (const { clause, isNull } of orGroup) {
|
|
917
914
|
const value = takeOne(document, clause.key);
|
|
918
915
|
let isMatched;
|
|
919
|
-
if (isNull) isMatched = compare(BinaryOperator.
|
|
916
|
+
if (isNull) isMatched = compare(BinaryOperator.Eq, value, null);
|
|
920
917
|
else {
|
|
921
918
|
const comparisonResult = compare(clause.operator, value, clause.value);
|
|
922
919
|
isMatched = clause.not ? !comparisonResult : comparisonResult;
|
|
@@ -942,7 +939,7 @@ const compareValues = (firstValue, secondValue) => {
|
|
|
942
939
|
const firstComparable = toComparable(firstValue);
|
|
943
940
|
const secondComparable = toComparable(secondValue);
|
|
944
941
|
if (typeof firstComparable === "number" && typeof secondComparable === "number") return firstComparable - secondComparable;
|
|
945
|
-
return String(firstComparable).localeCompare(String(secondComparable));
|
|
942
|
+
else return String(firstComparable).localeCompare(String(secondComparable));
|
|
946
943
|
};
|
|
947
944
|
const sortDocuments = (documents, orderBy) => {
|
|
948
945
|
const parsedOrderBy = orderBy.map((clause) => {
|
|
@@ -995,25 +992,25 @@ var MockSearchClient = class {
|
|
|
995
992
|
this.indexName = indexName;
|
|
996
993
|
}
|
|
997
994
|
autocomplete() {
|
|
998
|
-
throw new
|
|
995
|
+
throw new NotImplementedError(this.autocomplete.name);
|
|
999
996
|
}
|
|
1000
997
|
deleteDocuments() {
|
|
1001
|
-
throw new
|
|
998
|
+
throw new NotImplementedError(this.deleteDocuments.name);
|
|
1002
999
|
}
|
|
1003
1000
|
getDocument(_key, _options) {
|
|
1004
|
-
throw new
|
|
1001
|
+
throw new NotImplementedError(this.getDocument.name);
|
|
1005
1002
|
}
|
|
1006
1003
|
getDocumentsCount(_options) {
|
|
1007
1004
|
return Promise.resolve(this.documents.length);
|
|
1008
1005
|
}
|
|
1009
1006
|
indexDocuments(_batch, _options) {
|
|
1010
|
-
throw new
|
|
1007
|
+
throw new NotImplementedError(this.indexDocuments.name);
|
|
1011
1008
|
}
|
|
1012
1009
|
mergeDocuments(_documents, _options) {
|
|
1013
|
-
throw new
|
|
1010
|
+
throw new NotImplementedError(this.mergeDocuments.name);
|
|
1014
1011
|
}
|
|
1015
1012
|
mergeOrUploadDocuments(_documents, _options) {
|
|
1016
|
-
throw new
|
|
1013
|
+
throw new NotImplementedError(this.mergeOrUploadDocuments.name);
|
|
1017
1014
|
}
|
|
1018
1015
|
search(searchText, options) {
|
|
1019
1016
|
const { filter, includeTotalCount, orderBy, searchFields, skip = 0, top } = options ?? {};
|
|
@@ -1034,7 +1031,7 @@ var MockSearchClient = class {
|
|
|
1034
1031
|
});
|
|
1035
1032
|
}
|
|
1036
1033
|
suggest(_searchText, _suggesterName, _options) {
|
|
1037
|
-
throw new
|
|
1034
|
+
throw new NotImplementedError(this.suggest.name);
|
|
1038
1035
|
}
|
|
1039
1036
|
uploadDocuments(documents, _options) {
|
|
1040
1037
|
this.documents.push(...documents);
|
|
@@ -1062,14 +1059,14 @@ var MockServiceBusSender = class {
|
|
|
1062
1059
|
this.identifier = queueName;
|
|
1063
1060
|
}
|
|
1064
1061
|
cancelScheduledMessages() {
|
|
1065
|
-
throw new
|
|
1062
|
+
throw new NotImplementedError(this.cancelScheduledMessages.name);
|
|
1066
1063
|
}
|
|
1067
1064
|
close() {
|
|
1068
1065
|
this.isClosed = true;
|
|
1069
1066
|
return Promise.resolve();
|
|
1070
1067
|
}
|
|
1071
1068
|
createMessageBatch() {
|
|
1072
|
-
throw new
|
|
1069
|
+
throw new NotImplementedError(this.createMessageBatch.name);
|
|
1073
1070
|
}
|
|
1074
1071
|
scheduleMessages(messages, scheduledEnqueueTimeUtc) {
|
|
1075
1072
|
for (const message of Array.isArray(messages) ? messages : [messages]) this.queue.push({
|
|
@@ -1079,7 +1076,7 @@ var MockServiceBusSender = class {
|
|
|
1079
1076
|
return Promise.resolve([]);
|
|
1080
1077
|
}
|
|
1081
1078
|
sendMessages(messages) {
|
|
1082
|
-
if (!Array.isArray(messages) && "tryAddMessage" in messages) throw new
|
|
1079
|
+
if (!Array.isArray(messages) && "tryAddMessage" in messages) throw new NotImplementedError(`${this.sendMessages.name}(ServiceBusMessageBatch)`);
|
|
1083
1080
|
this.queue.push(...Array.isArray(messages) ? messages : [messages]);
|
|
1084
1081
|
return Promise.resolve();
|
|
1085
1082
|
}
|
|
@@ -1119,17 +1116,17 @@ var MockTableClient = class {
|
|
|
1119
1116
|
});
|
|
1120
1117
|
}
|
|
1121
1118
|
createTable() {
|
|
1122
|
-
throw new
|
|
1119
|
+
throw new NotImplementedError(this.createTable.name);
|
|
1123
1120
|
}
|
|
1124
|
-
deleteEntity(partitionKey, rowKey) {
|
|
1125
|
-
this.#applyDelete(partitionKey, rowKey);
|
|
1121
|
+
deleteEntity(partitionKey, rowKey, options) {
|
|
1122
|
+
this.#applyDelete(partitionKey, rowKey, options?.etag);
|
|
1126
1123
|
return Promise.resolve({});
|
|
1127
1124
|
}
|
|
1128
1125
|
deleteTable() {
|
|
1129
|
-
throw new
|
|
1126
|
+
throw new NotImplementedError(this.deleteTable.name);
|
|
1130
1127
|
}
|
|
1131
1128
|
getAccessPolicy() {
|
|
1132
|
-
throw new
|
|
1129
|
+
throw new NotImplementedError(this.getAccessPolicy.name);
|
|
1133
1130
|
}
|
|
1134
1131
|
getEntity(partitionKey, rowKey) {
|
|
1135
1132
|
const key = this.#getCompositeKey(partitionKey, rowKey);
|
|
@@ -1145,7 +1142,7 @@ var MockTableClient = class {
|
|
|
1145
1142
|
const filter = options?.queryOptions?.filter;
|
|
1146
1143
|
const tableEntities = [...this.table.values()];
|
|
1147
1144
|
const predicate = filter ? createFilterPredicate(filter) : void 0;
|
|
1148
|
-
const resultTableEntities = (predicate ? tableEntities.filter((
|
|
1145
|
+
const resultTableEntities = (predicate ? tableEntities.filter((entity) => predicate(entity)) : tableEntities).toSorted(compareByCompositeKey);
|
|
1149
1146
|
const entityIterator = (async function* (entities) {
|
|
1150
1147
|
for (const entity of entities) yield await Promise.resolve(withMetadata(entity));
|
|
1151
1148
|
})(resultTableEntities);
|
|
@@ -1155,10 +1152,10 @@ var MockTableClient = class {
|
|
|
1155
1152
|
else if (maxPageSize !== void 0 && maxPageSize > AZURE_MAX_PAGE_SIZE) throw new MockRestError("One of the request inputs is not valid.", 400);
|
|
1156
1153
|
if (entities.length === 0) return;
|
|
1157
1154
|
else if (!maxPageSize) {
|
|
1158
|
-
yield await Promise.resolve(entities.map((
|
|
1155
|
+
yield await Promise.resolve(entities.map((entity) => withMetadata(entity)));
|
|
1159
1156
|
return;
|
|
1160
1157
|
}
|
|
1161
|
-
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)));
|
|
1162
1159
|
})(resultTableEntities),
|
|
1163
1160
|
next: () => entityIterator.next(),
|
|
1164
1161
|
[Symbol.asyncIterator]() {
|
|
@@ -1167,7 +1164,7 @@ var MockTableClient = class {
|
|
|
1167
1164
|
};
|
|
1168
1165
|
}
|
|
1169
1166
|
setAccessPolicy() {
|
|
1170
|
-
throw new
|
|
1167
|
+
throw new NotImplementedError(this.setAccessPolicy.name);
|
|
1171
1168
|
}
|
|
1172
1169
|
submitTransaction(actions) {
|
|
1173
1170
|
let partitionKey;
|
|
@@ -1224,17 +1221,19 @@ var MockTableClient = class {
|
|
|
1224
1221
|
etag: this.#getEtag()
|
|
1225
1222
|
});
|
|
1226
1223
|
}
|
|
1227
|
-
#applyDelete(partitionKey, rowKey) {
|
|
1224
|
+
#applyDelete(partitionKey, rowKey, etag) {
|
|
1228
1225
|
const key = this.#getCompositeKey(partitionKey, rowKey);
|
|
1229
|
-
|
|
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);
|
|
1230
1229
|
this.table.delete(key);
|
|
1231
1230
|
}
|
|
1232
1231
|
#applyUpdate(entity, mode = "Merge", etag) {
|
|
1233
1232
|
const key = this.#getCompositeKey(entity.partitionKey, entity.rowKey);
|
|
1234
1233
|
const existingEntity = this.table.get(key);
|
|
1235
1234
|
if (!existingEntity) throw new MockRestError("The specified resource does not exist.", 404);
|
|
1236
|
-
|
|
1237
|
-
|
|
1235
|
+
this.#assertEtag(existingEntity.etag, etag);
|
|
1236
|
+
if (mode === "Merge") this.table.set(key, {
|
|
1238
1237
|
...existingEntity,
|
|
1239
1238
|
...entity,
|
|
1240
1239
|
etag: this.#getEtag()
|
|
@@ -1257,6 +1256,9 @@ var MockTableClient = class {
|
|
|
1257
1256
|
etag: this.#getEtag()
|
|
1258
1257
|
});
|
|
1259
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
|
+
}
|
|
1260
1262
|
#getCompositeKey(partitionKey, rowKey) {
|
|
1261
1263
|
return `${encodeURIComponent(partitionKey)}${ID_SEPARATOR}${encodeURIComponent(rowKey)}`;
|
|
1262
1264
|
}
|
|
@@ -1288,4 +1290,4 @@ const applyFilter = (documents, clauses) => {
|
|
|
1288
1290
|
return documents.filter((document) => predicate(document));
|
|
1289
1291
|
};
|
|
1290
1292
|
//#endregion
|
|
1291
|
-
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
|
-
"type-fest": "^5.
|
|
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
|
-
"type-fest": "5.
|
|
81
|
+
"type-fest": "5.10.0"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "5854a00717502d8de96adc8b44d3621ab85f9b57"
|
|
84
84
|
}
|