azure-mock 2.38.1 → 2.39.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 +84 -69
- package/dist/index.js +80 -48
- package/package.json +11 -12
package/dist/index.d.ts
CHANGED
|
@@ -9,15 +9,15 @@ import { CreateTableEntityResponse, GetAccessPolicyResponse, GetTableEntityRespo
|
|
|
9
9
|
import { QueueClearMessagesResponse, QueueClient, QueueCreateIfNotExistsResponse, QueueCreateOptions, QueueCreateResponse, QueueDeleteIfExistsResponse, QueueDeleteMessageResponse, QueueDeleteResponse, QueueGenerateSasUrlOptions, QueueGetAccessPolicyResponse, QueueGetPropertiesResponse, QueueItem, QueuePeekMessagesOptions, QueuePeekMessagesResponse, QueueReceiveMessageOptions, QueueReceiveMessageResponse, QueueSendMessageOptions, QueueSendMessageResponse, QueueServiceProperties, QueueSetAccessPolicyResponse, QueueSetMetadataResponse, QueueUpdateMessageResponse, SignedIdentifier } from "@azure/storage-queue";
|
|
10
10
|
import { AutocompleteResult, CountDocumentsOptions, DeleteDocumentsOptions, GetDocumentOptions, IndexDocumentsBatch, IndexDocumentsOptions, IndexDocumentsResult, MergeDocumentsOptions, MergeOrUploadDocumentsOptions, NarrowedModel, SearchClient, SearchDocumentsResult, SearchOptions, SelectFields, SuggestDocumentsResult, SuggestOptions, UploadDocumentsOptions } from "@azure/search-documents";
|
|
11
11
|
//#region src/constants.d.ts
|
|
12
|
-
declare const BLOB_NOT_FOUND_ERROR_CODE = "BlobNotFound";
|
|
13
|
-
declare const BLOB_NOT_FOUND_MESSAGE = "The specified blob does not exist.";
|
|
14
|
-
declare const MOCK_BLOB_BASE_URL = "https://mockaccount.blob.core.windows.net";
|
|
15
|
-
declare const MOCK_QUEUE_BASE_URL = "https://mockaccount.queue.core.windows.net";
|
|
16
|
-
declare const MOCK_SEARCH_BASE_URL = "https://mockaccount.search.windows.net";
|
|
17
|
-
declare const MOCK_TABLE_BASE_URL = "https://mockaccount.table.core.windows.net";
|
|
12
|
+
export declare const BLOB_NOT_FOUND_ERROR_CODE = "BlobNotFound";
|
|
13
|
+
export declare const BLOB_NOT_FOUND_MESSAGE = "The specified blob does not exist.";
|
|
14
|
+
export declare const MOCK_BLOB_BASE_URL = "https://mockaccount.blob.core.windows.net";
|
|
15
|
+
export declare const MOCK_QUEUE_BASE_URL = "https://mockaccount.queue.core.windows.net";
|
|
16
|
+
export declare const MOCK_SEARCH_BASE_URL = "https://mockaccount.search.windows.net";
|
|
17
|
+
export declare const MOCK_TABLE_BASE_URL = "https://mockaccount.table.core.windows.net";
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/models/MockResponse.d.ts
|
|
20
|
-
interface MockResponse {
|
|
20
|
+
export interface MockResponse {
|
|
21
21
|
headers: HttpHeadersLike;
|
|
22
22
|
parsedHeaders: Record<string, never>;
|
|
23
23
|
request: WebResourceLike;
|
|
@@ -25,7 +25,7 @@ interface MockResponse {
|
|
|
25
25
|
}
|
|
26
26
|
//#endregion
|
|
27
27
|
//#region src/models/MockRestError.d.ts
|
|
28
|
-
declare class MockRestError extends RestError {
|
|
28
|
+
export declare class MockRestError extends RestError {
|
|
29
29
|
constructor(message: string, statusCode: number);
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
@@ -33,7 +33,7 @@ declare class MockRestError extends RestError {
|
|
|
33
33
|
/**
|
|
34
34
|
* An interface that tracks the settings for paged iteration
|
|
35
35
|
*/
|
|
36
|
-
interface PageSettings {
|
|
36
|
+
export interface PageSettings {
|
|
37
37
|
/**
|
|
38
38
|
* The token that keeps track of where to continue the iterator
|
|
39
39
|
*/
|
|
@@ -48,7 +48,7 @@ interface PageSettings {
|
|
|
48
48
|
/**
|
|
49
49
|
* An interface that allows async iterable iteration both to completion and by page.
|
|
50
50
|
*/
|
|
51
|
-
interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings = PageSettings> {
|
|
51
|
+
export interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings = PageSettings> {
|
|
52
52
|
/**
|
|
53
53
|
* The connection to the async iterator, part of the iteration protocol
|
|
54
54
|
*/
|
|
@@ -64,45 +64,58 @@ interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings
|
|
|
64
64
|
}
|
|
65
65
|
//#endregion
|
|
66
66
|
//#region src/services/createMockResponse.d.ts
|
|
67
|
-
declare const createMockResponse: (status: number, url?: string) => MockResponse;
|
|
67
|
+
export declare const createMockResponse: (status: number, url?: string) => MockResponse;
|
|
68
68
|
//#endregion
|
|
69
69
|
//#region src/services/getMockSasUrl.d.ts
|
|
70
|
-
declare const getMockSasUrl: (url: string, permissions: undefined | {
|
|
70
|
+
export declare const getMockSasUrl: (url: string, permissions: undefined | {
|
|
71
71
|
toString: () => string;
|
|
72
72
|
}, resourceType?: string) => string;
|
|
73
73
|
//#endregion
|
|
74
|
-
//#region src/store/
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
//#region src/store/MockContainerBlobDatesDatabase.d.ts
|
|
75
|
+
export interface MockBlobDates {
|
|
76
|
+
createdOn: Date;
|
|
77
|
+
etag: string;
|
|
78
|
+
lastModified: Date;
|
|
79
|
+
}
|
|
80
|
+
export declare const MockContainerBlobDatesDatabase: Map<string, MockBlobDates>;
|
|
81
|
+
export declare const MOCK_BLOB_SEEDED_DATE: Date;
|
|
82
|
+
export declare const getMockContainerBlobDatesKey: (containerName: string, blobName: string) => string;
|
|
83
|
+
export declare const storeMockBlobWrite: (containerName: string, blobName: string, isExisting: boolean) => void;
|
|
84
|
+
export declare const MOCK_BLOB_SEEDED_PROPERTIES: MockBlobDates;
|
|
85
|
+
export declare const readMockBlobDates: (containerName: string, blobName: string) => MockBlobDates;
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/store/MockContainerBlobMetadataDatabase.d.ts
|
|
88
|
+
export declare const MockContainerBlobMetadataDatabase: Map<string, Record<string, string>>;
|
|
89
|
+
export declare const storeMockBlobMetadata: (containerName: string, blobName: string, metadata: Record<string, string> | undefined) => void;
|
|
90
|
+
export declare const readMockBlobMetadata: (containerName: string, blobName: string) => Record<string, string> | undefined;
|
|
78
91
|
//#endregion
|
|
79
92
|
//#region src/store/MockContainerDatabase.d.ts
|
|
80
|
-
declare const MockContainerDatabase: Map<string, Map<string, Buffer>>;
|
|
93
|
+
export declare const MockContainerDatabase: Map<string, Map<string, Buffer>>;
|
|
81
94
|
//#endregion
|
|
82
95
|
//#region src/store/MockEventGridDatabase.d.ts
|
|
83
|
-
declare const MockEventGridDatabase: Map<string, EventGridEvent<unknown>[]>;
|
|
96
|
+
export declare const MockEventGridDatabase: Map<string, EventGridEvent<unknown>[]>;
|
|
84
97
|
//#endregion
|
|
85
98
|
//#region src/store/MockQueueDatabase.d.ts
|
|
86
|
-
declare const MockQueueDatabase: Map<string, string[]>;
|
|
99
|
+
export declare const MockQueueDatabase: Map<string, string[]>;
|
|
87
100
|
//#endregion
|
|
88
101
|
//#region src/store/MockSearchDatabase.d.ts
|
|
89
|
-
declare const MockSearchDatabase: Map<string, object[]>;
|
|
102
|
+
export declare const MockSearchDatabase: Map<string, object[]>;
|
|
90
103
|
//#endregion
|
|
91
104
|
//#region src/store/MockServiceBusDatabase.d.ts
|
|
92
|
-
declare const MockServiceBusDatabase: Map<string, ServiceBusMessage[]>;
|
|
105
|
+
export declare const MockServiceBusDatabase: Map<string, ServiceBusMessage[]>;
|
|
93
106
|
//#endregion
|
|
94
107
|
//#region src/store/MockTableDatabase.d.ts
|
|
95
|
-
declare const MockTableDatabase: Map<string, Map<string, TableEntity>>;
|
|
108
|
+
export declare const MockTableDatabase: Map<string, Map<string, TableEntity>>;
|
|
96
109
|
//#endregion
|
|
97
110
|
//#region src/models/container/BlobHierarchyItem.d.ts
|
|
98
|
-
type BlobHierarchyItem = (BlobItem & {
|
|
111
|
+
export type BlobHierarchyItem = (BlobItem & {
|
|
99
112
|
kind: "blob";
|
|
100
113
|
}) | (BlobPrefix & {
|
|
101
114
|
kind: "prefix";
|
|
102
115
|
});
|
|
103
116
|
//#endregion
|
|
104
117
|
//#region src/models/container/MockBlobBatchClient.d.ts
|
|
105
|
-
declare class MockBlobBatchClient implements BlobBatchClient {
|
|
118
|
+
export declare class MockBlobBatchClient implements BlobBatchClient {
|
|
106
119
|
#private;
|
|
107
120
|
url: string;
|
|
108
121
|
constructor(url: string);
|
|
@@ -116,7 +129,7 @@ declare class MockBlobBatchClient implements BlobBatchClient {
|
|
|
116
129
|
getContainer(containerName: string): MapValue<typeof MockContainerDatabase>;
|
|
117
130
|
}
|
|
118
131
|
//#endregion
|
|
119
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
132
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/is-any.d.ts
|
|
120
133
|
/**
|
|
121
134
|
Returns a boolean for whether the given type is `any`.
|
|
122
135
|
|
|
@@ -147,7 +160,7 @@ const anyA = get(anyObject, 'a');
|
|
|
147
160
|
*/
|
|
148
161
|
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
149
162
|
//#endregion
|
|
150
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
163
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
151
164
|
/**
|
|
152
165
|
Returns a boolean for whether the given key is an optional key of type.
|
|
153
166
|
|
|
@@ -190,7 +203,7 @@ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
|
190
203
|
*/
|
|
191
204
|
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;
|
|
192
205
|
//#endregion
|
|
193
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
206
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
194
207
|
/**
|
|
195
208
|
Extract all optional keys from the given type.
|
|
196
209
|
|
|
@@ -228,7 +241,7 @@ type OptionalKeysOf<Type extends object> = Type extends unknown // For distribut
|
|
|
228
241
|
? (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`
|
|
229
242
|
: never; // Should never happen
|
|
230
243
|
//#endregion
|
|
231
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
244
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/required-keys-of.d.ts
|
|
232
245
|
/**
|
|
233
246
|
Extract all required keys from the given type.
|
|
234
247
|
|
|
@@ -262,7 +275,7 @@ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
|
|
|
262
275
|
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
263
276
|
? Exclude<keyof Type, OptionalKeysOf<Type>> : never; // Should never happen
|
|
264
277
|
//#endregion
|
|
265
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
278
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/is-never.d.ts
|
|
266
279
|
/**
|
|
267
280
|
Returns a boolean for whether the given type is `never`.
|
|
268
281
|
|
|
@@ -318,7 +331,7 @@ type B = IsTrueFixed<never>;
|
|
|
318
331
|
*/
|
|
319
332
|
type IsNever<T> = [T] extends [never] ? true : false;
|
|
320
333
|
//#endregion
|
|
321
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
334
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/if.d.ts
|
|
322
335
|
/**
|
|
323
336
|
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
324
337
|
|
|
@@ -413,7 +426,7 @@ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
|
|
|
413
426
|
*/
|
|
414
427
|
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
415
428
|
//#endregion
|
|
416
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
429
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/simplify.d.ts
|
|
417
430
|
/**
|
|
418
431
|
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.
|
|
419
432
|
|
|
@@ -474,7 +487,7 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
474
487
|
*/
|
|
475
488
|
type Simplify<T> = { [KeyType in keyof T]: T[KeyType]; } & {};
|
|
476
489
|
//#endregion
|
|
477
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
490
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/is-equal.d.ts
|
|
478
491
|
/**
|
|
479
492
|
Returns a boolean for whether the two given types are equal.
|
|
480
493
|
|
|
@@ -505,7 +518,7 @@ type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false
|
|
|
505
518
|
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
506
519
|
type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
507
520
|
//#endregion
|
|
508
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
521
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
509
522
|
/**
|
|
510
523
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
511
524
|
|
|
@@ -599,7 +612,7 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
599
612
|
*/
|
|
600
613
|
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType]; };
|
|
601
614
|
//#endregion
|
|
602
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
615
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
603
616
|
/**
|
|
604
617
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
605
618
|
|
|
@@ -647,7 +660,7 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
647
660
|
*/
|
|
648
661
|
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType]; };
|
|
649
662
|
//#endregion
|
|
650
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
663
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/merge.d.ts
|
|
651
664
|
// Merges two objects without worrying about index signatures.
|
|
652
665
|
type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key]; } & Source>;
|
|
653
666
|
/**
|
|
@@ -718,7 +731,7 @@ type Merge<Destination, Source> = Destination extends unknown // For distributin
|
|
|
718
731
|
: never; // Should never happen
|
|
719
732
|
type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
720
733
|
//#endregion
|
|
721
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
734
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/internal/object.d.ts
|
|
722
735
|
/**
|
|
723
736
|
Merges user specified options with default options.
|
|
724
737
|
|
|
@@ -775,7 +788,7 @@ type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<
|
|
|
775
788
|
) ? Result : never;
|
|
776
789
|
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]; }>>>;
|
|
777
790
|
//#endregion
|
|
778
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
791
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/except.d.ts
|
|
779
792
|
/**
|
|
780
793
|
Filter out keys from an object.
|
|
781
794
|
|
|
@@ -876,7 +889,7 @@ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends Excep
|
|
|
876
889
|
type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType]; } & (Options['requireExactProps'] extends true ? Partial<Record<KeysType, never>> : {});
|
|
877
890
|
//#endregion
|
|
878
891
|
//#region src/models/container/MockBlobClient.d.ts
|
|
879
|
-
declare class MockBlobClient implements Except<BlobClient, "accountName"> {
|
|
892
|
+
export declare class MockBlobClient implements Except<BlobClient, "accountName"> {
|
|
880
893
|
connectionString: string;
|
|
881
894
|
containerName: string;
|
|
882
895
|
credential: AnonymousCredential;
|
|
@@ -918,7 +931,7 @@ declare class MockBlobClient implements Except<BlobClient, "accountName"> {
|
|
|
918
931
|
}
|
|
919
932
|
//#endregion
|
|
920
933
|
//#region src/models/container/MockBlockBlobClient.d.ts
|
|
921
|
-
declare class MockBlockBlobClient extends MockBlobClient implements Except<BlockBlobClient, "accountName"> {
|
|
934
|
+
export declare class MockBlockBlobClient extends MockBlobClient implements Except<BlockBlobClient, "accountName"> {
|
|
922
935
|
commitBlockList(): Promise<BlockBlobCommitBlockListResponse>;
|
|
923
936
|
getBlockList(): Promise<BlockBlobGetBlockListResponse>;
|
|
924
937
|
query(): Promise<BlobDownloadResponseModel>;
|
|
@@ -942,7 +955,7 @@ declare class MockBlockBlobClient extends MockBlobClient implements Except<Block
|
|
|
942
955
|
* await blockBlobClient.upload("hello world", 11);
|
|
943
956
|
* const content = await blockBlobClient.downloadToBuffer();
|
|
944
957
|
*/
|
|
945
|
-
declare class MockContainerClient implements Except<ContainerClient, "accountName"> {
|
|
958
|
+
export declare class MockContainerClient implements Except<ContainerClient, "accountName"> {
|
|
946
959
|
#private;
|
|
947
960
|
connectionString: string;
|
|
948
961
|
containerName: string;
|
|
@@ -985,7 +998,7 @@ declare class MockContainerClient implements Except<ContainerClient, "accountNam
|
|
|
985
998
|
* An in-memory mock of the Azure EventGridPublisherClient — no emulator and no network.
|
|
986
999
|
* `client` is excluded because it is a private member of the real class and cannot be satisfied structurally.
|
|
987
1000
|
*/
|
|
988
|
-
declare class MockEventGridPublisherClient implements Except<EventGridPublisherClient<"EventGrid">, "apiVersion"> {
|
|
1001
|
+
export declare class MockEventGridPublisherClient implements Except<EventGridPublisherClient<"EventGrid">, "apiVersion"> {
|
|
989
1002
|
readonly endpointUrl: string;
|
|
990
1003
|
readonly inputSchema: "EventGrid";
|
|
991
1004
|
readonly topicType: "EventGrid";
|
|
@@ -1003,7 +1016,7 @@ declare class MockEventGridPublisherClient implements Except<EventGridPublisherC
|
|
|
1003
1016
|
* await mockQueueClient.sendMessage("hello world");
|
|
1004
1017
|
* const messages = await mockQueueClient.peekMessages();
|
|
1005
1018
|
*/
|
|
1006
|
-
declare class MockQueueClient implements Except<QueueClient, "accountName"> {
|
|
1019
|
+
export declare class MockQueueClient implements Except<QueueClient, "accountName"> {
|
|
1007
1020
|
connectionString: string;
|
|
1008
1021
|
name: string;
|
|
1009
1022
|
url: string;
|
|
@@ -1042,7 +1055,7 @@ declare class MockQueueClient implements Except<QueueClient, "accountName"> {
|
|
|
1042
1055
|
* await mockSearchClient.uploadDocuments([{ ... }]);
|
|
1043
1056
|
* const { count, results } = await mockSearchClient.search("*", { filter, includeTotalCount: true });
|
|
1044
1057
|
*/
|
|
1045
|
-
declare class MockSearchClient<TModel extends object = Record<string, unknown>> implements Except<SearchClient<TModel>, "pipeline"> {
|
|
1058
|
+
export declare class MockSearchClient<TModel extends object = Record<string, unknown>> implements Except<SearchClient<TModel>, "pipeline"> {
|
|
1046
1059
|
readonly apiVersion: string;
|
|
1047
1060
|
readonly endpoint: string;
|
|
1048
1061
|
readonly indexName: string;
|
|
@@ -1070,7 +1083,7 @@ declare class MockSearchClient<TModel extends object = Record<string, unknown>>
|
|
|
1070
1083
|
* const mockServiceBusSender = new MockServiceBusSender("hello world");
|
|
1071
1084
|
* await mockServiceBusSender.scheduleMessages({ body: "hello world" }, new Date());
|
|
1072
1085
|
*/
|
|
1073
|
-
declare class MockServiceBusSender implements ServiceBusSender {
|
|
1086
|
+
export declare class MockServiceBusSender implements ServiceBusSender {
|
|
1074
1087
|
entityPath: string;
|
|
1075
1088
|
identifier: string;
|
|
1076
1089
|
isClosed: boolean;
|
|
@@ -1092,7 +1105,7 @@ declare class MockServiceBusSender implements ServiceBusSender {
|
|
|
1092
1105
|
* await mockTableClient.createEntity({ partitionKey: "partitionKey", rowKey: "rowKey" });
|
|
1093
1106
|
* const entity = await mockTableClient.getEntity("partitionKey", "rowKey");
|
|
1094
1107
|
*/
|
|
1095
|
-
declare class MockTableClient<TEntity extends TableEntity = TableEntity> implements Except<TableClient, "pipeline"> {
|
|
1108
|
+
export declare class MockTableClient<TEntity extends TableEntity = TableEntity> implements Except<TableClient, "pipeline"> {
|
|
1096
1109
|
#private;
|
|
1097
1110
|
entityType: TEntity;
|
|
1098
1111
|
tableName: string;
|
|
@@ -1119,14 +1132,20 @@ declare class MockTableClient<TEntity extends TableEntity = TableEntity> impleme
|
|
|
1119
1132
|
* A minimal mock of the Azure WebPubSubServiceClient for testing purposes.
|
|
1120
1133
|
* Only implements `group().sendToAll` — the only method used in azure-functions tests.
|
|
1121
1134
|
*/
|
|
1122
|
-
declare class MockWebPubSubServiceClient {
|
|
1135
|
+
export declare class MockWebPubSubServiceClient {
|
|
1123
1136
|
group(_groupName: string): {
|
|
1124
1137
|
sendToAll: () => Promise<void>;
|
|
1125
1138
|
};
|
|
1126
1139
|
}
|
|
1127
1140
|
//#endregion
|
|
1128
1141
|
//#region src/services/container/bodyToBuffer.d.ts
|
|
1129
|
-
declare const bodyToBuffer: (body: HttpRequestBody) => Promise<Buffer>;
|
|
1142
|
+
export declare const bodyToBuffer: (body: HttpRequestBody) => Promise<Buffer>;
|
|
1143
|
+
//#endregion
|
|
1144
|
+
//#region src/services/container/checkIsReadableStream.d.ts
|
|
1145
|
+
export declare const checkIsReadableStream: (value: unknown) => value is NodeJS.ReadableStream;
|
|
1146
|
+
//#endregion
|
|
1147
|
+
//#region src/services/container/deleteMockBlob.d.ts
|
|
1148
|
+
export declare const deleteMockBlob: (containerName: string, blobName: string) => boolean;
|
|
1130
1149
|
//#endregion
|
|
1131
1150
|
//#region src/services/container/getAzureErrorXml.d.ts
|
|
1132
1151
|
/**
|
|
@@ -1135,25 +1154,25 @@ declare const bodyToBuffer: (body: HttpRequestBody) => Promise<Buffer>;
|
|
|
1135
1154
|
* @param errorMessage The user-friendly error message.
|
|
1136
1155
|
* @returns A formatted XML string.
|
|
1137
1156
|
*/
|
|
1138
|
-
declare const getAzureErrorXml: (errorCode: string, errorMessage: string) => string;
|
|
1157
|
+
export declare const getAzureErrorXml: (errorCode: string, errorMessage: string) => string;
|
|
1139
1158
|
//#endregion
|
|
1140
1159
|
//#region src/services/container/getBlobItemXml.d.ts
|
|
1141
|
-
declare const getBlobItemXml: ({ name, properties }: BlobItem) => string;
|
|
1160
|
+
export declare const getBlobItemXml: ({ name, properties }: BlobItem) => string;
|
|
1142
1161
|
//#endregion
|
|
1143
1162
|
//#region src/services/container/getBlobPrefixXml.d.ts
|
|
1144
|
-
declare const getBlobPrefixXml: (name: string) => string;
|
|
1163
|
+
export declare const getBlobPrefixXml: (name: string) => string;
|
|
1145
1164
|
//#endregion
|
|
1146
1165
|
//#region src/services/container/getBlobUrl.d.ts
|
|
1147
|
-
declare const getBlobUrl: (containerName: string, blobName: string) => string;
|
|
1166
|
+
export declare const getBlobUrl: (containerName: string, blobName: string) => string;
|
|
1148
1167
|
//#endregion
|
|
1149
1168
|
//#region src/services/container/getBlobUrlParts.d.ts
|
|
1150
|
-
declare const getBlobUrlParts: (url: string) => undefined | {
|
|
1169
|
+
export declare const getBlobUrlParts: (url: string) => undefined | {
|
|
1151
1170
|
blobName: string;
|
|
1152
1171
|
containerName: string;
|
|
1153
1172
|
};
|
|
1154
1173
|
//#endregion
|
|
1155
1174
|
//#region src/services/container/getListBlobsSegmentResponse.d.ts
|
|
1156
|
-
declare const getListBlobsSegmentResponse: (containerName: string, prefix: string, segment: BlobHierarchyListSegment, blobsXml: string) => ContainerListBlobHierarchySegmentResponse;
|
|
1175
|
+
export declare const getListBlobsSegmentResponse: (containerName: string, prefix: string, segment: BlobHierarchyListSegment, blobsXml: string) => ContainerListBlobHierarchySegmentResponse;
|
|
1157
1176
|
//#endregion
|
|
1158
1177
|
//#region src/services/container/getListBlobsXml.d.ts
|
|
1159
1178
|
/**
|
|
@@ -1162,31 +1181,28 @@ declare const getListBlobsSegmentResponse: (containerName: string, prefix: strin
|
|
|
1162
1181
|
* @param blobsXml The blobs xml data.
|
|
1163
1182
|
* @returns A formatted XML string.
|
|
1164
1183
|
*/
|
|
1165
|
-
declare const getListBlobsXml: (containerName: string, blobsXml: string) => string;
|
|
1184
|
+
export declare const getListBlobsXml: (containerName: string, blobsXml: string) => string;
|
|
1166
1185
|
//#endregion
|
|
1167
1186
|
//#region src/services/container/getMockContainer.d.ts
|
|
1168
|
-
declare const getMockContainer: (containerName: string) => MapValue<typeof MockContainerDatabase>;
|
|
1169
|
-
//#endregion
|
|
1170
|
-
//#region src/services/container/isReadableStream.d.ts
|
|
1171
|
-
declare const isReadableStream: (value: unknown) => value is NodeJS.ReadableStream;
|
|
1187
|
+
export declare const getMockContainer: (containerName: string) => MapValue<typeof MockContainerDatabase>;
|
|
1172
1188
|
//#endregion
|
|
1173
1189
|
//#region src/services/container/toWebResourceLike.d.ts
|
|
1174
|
-
declare const toWebResourceLike: (request: PipelineRequest) => WebResourceLike;
|
|
1190
|
+
export declare const toWebResourceLike: (request: PipelineRequest) => WebResourceLike;
|
|
1175
1191
|
//#endregion
|
|
1176
1192
|
//#region src/services/filter/applyFilter.d.ts
|
|
1177
|
-
declare const applyFilter: <T extends Record<string, unknown>>(documents: T[], clauses: Clause<T>[]) => T[];
|
|
1193
|
+
export declare const applyFilter: <T extends Record<string, unknown>>(documents: T[], clauses: Clause<T>[]) => T[];
|
|
1194
|
+
//#endregion
|
|
1195
|
+
//#region src/services/filter/checkIsNullClause.d.ts
|
|
1196
|
+
export declare const checkIsNullClause: (clause: Clause<Record<string, unknown>>) => boolean;
|
|
1178
1197
|
//#endregion
|
|
1179
1198
|
//#region src/services/filter/compare.d.ts
|
|
1180
|
-
declare const compare: <T>(operator: BinaryOperator, leftHandSide: T, rightHandSide: null | T) => boolean;
|
|
1199
|
+
export declare const compare: <T>(operator: BinaryOperator, leftHandSide: T, rightHandSide: null | T) => boolean;
|
|
1181
1200
|
//#endregion
|
|
1182
1201
|
//#region src/services/filter/createFilterPredicate.d.ts
|
|
1183
|
-
declare const createFilterPredicate: (filter: string) => ((document: Record<string, unknown>) => boolean);
|
|
1184
|
-
//#endregion
|
|
1185
|
-
//#region src/services/filter/isNullClause.d.ts
|
|
1186
|
-
declare const isNullClause: (clause: Clause<Record<string, unknown>>) => boolean;
|
|
1202
|
+
export declare const createFilterPredicate: (filter: string) => ((document: Record<string, unknown>) => boolean);
|
|
1187
1203
|
//#endregion
|
|
1188
1204
|
//#region src/services/queue/getMockQueueMessageItem.d.ts
|
|
1189
|
-
declare const getMockQueueMessageItem: (messageText: string) => {
|
|
1205
|
+
export declare const getMockQueueMessageItem: (messageText: string) => {
|
|
1190
1206
|
expiresOn: Date;
|
|
1191
1207
|
insertedOn: Date;
|
|
1192
1208
|
messageId: string;
|
|
@@ -1194,6 +1210,5 @@ declare const getMockQueueMessageItem: (messageText: string) => {
|
|
|
1194
1210
|
};
|
|
1195
1211
|
//#endregion
|
|
1196
1212
|
//#region src/services/table/compareByCompositeKey.d.ts
|
|
1197
|
-
declare const compareByCompositeKey: (
|
|
1198
|
-
//#endregion
|
|
1199
|
-
export { BLOB_NOT_FOUND_ERROR_CODE, BLOB_NOT_FOUND_MESSAGE, BlobHierarchyItem, MOCK_BLOB_BASE_URL, MOCK_BLOB_SEEDED_CREATED_ON, MOCK_QUEUE_BASE_URL, MOCK_SEARCH_BASE_URL, MOCK_TABLE_BASE_URL, MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerClient, MockContainerCreatedOnDatabase, MockContainerDatabase, MockEventGridDatabase, MockEventGridPublisherClient, MockQueueClient, MockQueueDatabase, MockResponse, MockRestError, MockSearchClient, MockSearchDatabase, MockServiceBusDatabase, MockServiceBusSender, MockTableClient, MockTableDatabase, MockWebPubSubServiceClient, PageSettings, PagedAsyncIterableIterator, applyFilter, bodyToBuffer, compare, compareByCompositeKey, createFilterPredicate, createMockResponse, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, getBlobUrl, getBlobUrlParts, getListBlobsSegmentResponse, getListBlobsXml, getMockContainer, getMockContainerCreatedOnKey, getMockQueueMessageItem, getMockSasUrl, isNullClause, isReadableStream, toWebResourceLike };
|
|
1213
|
+
export declare const compareByCompositeKey: (firstEntity: TableEntity, secondEntity: TableEntity) => number;
|
|
1214
|
+
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -59,16 +59,41 @@ const createMockResponse = (status, url = "") => ({
|
|
|
59
59
|
//#region src/services/getMockSasUrl.ts
|
|
60
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
61
|
//#endregion
|
|
62
|
-
//#region src/store/
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const
|
|
62
|
+
//#region src/store/MockContainerBlobDatesDatabase.ts
|
|
63
|
+
const MockContainerBlobDatesDatabase = /* @__PURE__ */ new Map();
|
|
64
|
+
const MOCK_BLOB_SEEDED_DATE = /* @__PURE__ */ new Date(-864e13);
|
|
65
|
+
const getMockContainerBlobDatesKey = (containerName, blobName) => `${containerName}/${blobName}`;
|
|
66
|
+
const storeMockBlobWrite = (containerName, blobName, isExisting) => {
|
|
67
|
+
const key = getMockContainerBlobDatesKey(containerName, blobName);
|
|
68
|
+
const lastModified = /* @__PURE__ */ new Date();
|
|
69
|
+
MockContainerBlobDatesDatabase.set(key, {
|
|
70
|
+
createdOn: MockContainerBlobDatesDatabase.get(key)?.createdOn ?? (isExisting ? MOCK_BLOB_SEEDED_DATE : lastModified),
|
|
71
|
+
etag: `"${crypto.randomUUID()}"`,
|
|
72
|
+
lastModified
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
const MOCK_BLOB_SEEDED_PROPERTIES = {
|
|
76
|
+
createdOn: MOCK_BLOB_SEEDED_DATE,
|
|
77
|
+
etag: "\"seeded\"",
|
|
78
|
+
lastModified: MOCK_BLOB_SEEDED_DATE
|
|
79
|
+
};
|
|
80
|
+
const readMockBlobDates = (containerName, blobName) => MockContainerBlobDatesDatabase.get(getMockContainerBlobDatesKey(containerName, blobName)) ?? MOCK_BLOB_SEEDED_PROPERTIES;
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/store/MockContainerBlobMetadataDatabase.ts
|
|
83
|
+
const MockContainerBlobMetadataDatabase = /* @__PURE__ */ new Map();
|
|
84
|
+
const storeMockBlobMetadata = (containerName, blobName, metadata) => {
|
|
85
|
+
const key = getMockContainerBlobDatesKey(containerName, blobName);
|
|
86
|
+
if (metadata) MockContainerBlobMetadataDatabase.set(key, metadata);
|
|
87
|
+
else MockContainerBlobMetadataDatabase.delete(key);
|
|
88
|
+
};
|
|
89
|
+
const readMockBlobMetadata = (containerName, blobName) => MockContainerBlobMetadataDatabase.get(getMockContainerBlobDatesKey(containerName, blobName));
|
|
66
90
|
//#endregion
|
|
67
91
|
//#region src/store/MockContainerDatabase.ts
|
|
68
92
|
var MockContainerDatabaseMap = class extends Map {
|
|
69
93
|
clear() {
|
|
70
94
|
super.clear();
|
|
71
|
-
|
|
95
|
+
MockContainerBlobDatesDatabase.clear();
|
|
96
|
+
MockContainerBlobMetadataDatabase.clear();
|
|
72
97
|
}
|
|
73
98
|
};
|
|
74
99
|
const MockContainerDatabase = new MockContainerDatabaseMap();
|
|
@@ -88,6 +113,17 @@ const MockServiceBusDatabase = /* @__PURE__ */ new Map();
|
|
|
88
113
|
//#region src/store/MockTableDatabase.ts
|
|
89
114
|
const MockTableDatabase = /* @__PURE__ */ new Map();
|
|
90
115
|
//#endregion
|
|
116
|
+
//#region src/services/container/getMockContainer.ts
|
|
117
|
+
const getMockContainer = (containerName) => getOrCreate(MockContainerDatabase, containerName, () => /* @__PURE__ */ new Map());
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/services/container/deleteMockBlob.ts
|
|
120
|
+
const deleteMockBlob = (containerName, blobName) => {
|
|
121
|
+
if (!getMockContainer(containerName).delete(blobName)) return false;
|
|
122
|
+
MockContainerBlobDatesDatabase.delete(getMockContainerBlobDatesKey(containerName, blobName));
|
|
123
|
+
storeMockBlobMetadata(containerName, blobName, void 0);
|
|
124
|
+
return true;
|
|
125
|
+
};
|
|
126
|
+
//#endregion
|
|
91
127
|
//#region src/services/container/getAzureErrorXml.ts
|
|
92
128
|
/**
|
|
93
129
|
* Generates a standard Azure Storage error XML response body.
|
|
@@ -114,9 +150,6 @@ const getBlobUrlParts = (url) => {
|
|
|
114
150
|
};
|
|
115
151
|
};
|
|
116
152
|
//#endregion
|
|
117
|
-
//#region src/services/container/getMockContainer.ts
|
|
118
|
-
const getMockContainer = (containerName) => getOrCreate(MockContainerDatabase, containerName, () => /* @__PURE__ */ new Map());
|
|
119
|
-
//#endregion
|
|
120
153
|
//#region src/models/container/MockBlobBatchClient.ts
|
|
121
154
|
var MockBlobBatchClient = class {
|
|
122
155
|
url;
|
|
@@ -141,10 +174,7 @@ var MockBlobBatchClient = class {
|
|
|
141
174
|
continue;
|
|
142
175
|
}
|
|
143
176
|
const { blobName, containerName } = urlParts;
|
|
144
|
-
|
|
145
|
-
if (container.has(blobName)) {
|
|
146
|
-
container.delete(blobName);
|
|
147
|
-
MockContainerCreatedOnDatabase.delete(getMockContainerCreatedOnKey(containerName, blobName));
|
|
177
|
+
if (deleteMockBlob(containerName, blobName)) {
|
|
148
178
|
subResponses.push({
|
|
149
179
|
_request: {
|
|
150
180
|
credential,
|
|
@@ -221,8 +251,8 @@ var MockBlobClient = class {
|
|
|
221
251
|
if (!sourceContainer) throw new MockRestError("Source container not found", 404);
|
|
222
252
|
const sourceData = sourceContainer.get(sourceBlobName);
|
|
223
253
|
if (!sourceData) throw new MockRestError("Source blob not found", 404);
|
|
254
|
+
storeMockBlobWrite(this.containerName, this.name, this.container.has(this.name));
|
|
224
255
|
this.container.set(this.name, Buffer.from(sourceData));
|
|
225
|
-
MockContainerCreatedOnDatabase.set(getMockContainerCreatedOnKey(this.containerName, this.name), /* @__PURE__ */ new Date());
|
|
226
256
|
const response = { _response: createMockResponse(202, `${this.url}?comp=copy`) };
|
|
227
257
|
return Promise.resolve({
|
|
228
258
|
cancelOperation: () => Promise.resolve(),
|
|
@@ -245,14 +275,14 @@ var MockBlobClient = class {
|
|
|
245
275
|
delete() {
|
|
246
276
|
if (!this.container.has(this.name)) throw new MockRestError(BLOB_NOT_FOUND_MESSAGE, 404);
|
|
247
277
|
this.container.delete(this.name);
|
|
248
|
-
|
|
278
|
+
MockContainerBlobDatesDatabase.delete(getMockContainerBlobDatesKey(this.containerName, this.name));
|
|
249
279
|
return Promise.resolve({ _response: createMockResponse(200) });
|
|
250
280
|
}
|
|
251
281
|
deleteIfExists() {
|
|
252
282
|
const succeeded = this.container.has(this.name);
|
|
253
283
|
if (succeeded) {
|
|
254
284
|
this.container.delete(this.name);
|
|
255
|
-
|
|
285
|
+
MockContainerBlobDatesDatabase.delete(getMockContainerBlobDatesKey(this.containerName, this.name));
|
|
256
286
|
}
|
|
257
287
|
return Promise.resolve({
|
|
258
288
|
_response: createMockResponse(succeeded ? 200 : 404),
|
|
@@ -313,7 +343,7 @@ var MockBlobClient = class {
|
|
|
313
343
|
return Promise.resolve({
|
|
314
344
|
_response: createMockResponse(200),
|
|
315
345
|
contentLength: blob.byteLength,
|
|
316
|
-
|
|
346
|
+
...readMockBlobDates(this.containerName, this.name)
|
|
317
347
|
});
|
|
318
348
|
}
|
|
319
349
|
getTags() {
|
|
@@ -351,8 +381,8 @@ var MockBlobClient = class {
|
|
|
351
381
|
}
|
|
352
382
|
};
|
|
353
383
|
//#endregion
|
|
354
|
-
//#region src/services/container/
|
|
355
|
-
const
|
|
384
|
+
//#region src/services/container/checkIsReadableStream.ts
|
|
385
|
+
const checkIsReadableStream = (value) => value instanceof Readable;
|
|
356
386
|
//#endregion
|
|
357
387
|
//#region src/services/container/bodyToBuffer.ts
|
|
358
388
|
const bodyToBuffer = async (body) => {
|
|
@@ -366,7 +396,7 @@ const bodyToBuffer = async (body) => {
|
|
|
366
396
|
} else if (body instanceof Blob) {
|
|
367
397
|
const arrayBuffer = await body.arrayBuffer();
|
|
368
398
|
return Buffer.from(arrayBuffer);
|
|
369
|
-
} else if (
|
|
399
|
+
} else if (checkIsReadableStream(body)) return Buffer.from(await streamToText(body));
|
|
370
400
|
else if (body instanceof ReadableStream) {
|
|
371
401
|
const reader = body.getReader();
|
|
372
402
|
const chunks = [];
|
|
@@ -406,8 +436,10 @@ var MockBlockBlobClient = class extends MockBlobClient {
|
|
|
406
436
|
async upload(body, _contentLength, options) {
|
|
407
437
|
const buffer = await bodyToBuffer(body);
|
|
408
438
|
if (options?.conditions?.ifNoneMatch === "*" && this.container.has(this.name)) throw new MockRestError("The specified blob already exists.", 409);
|
|
439
|
+
if (options?.conditions?.ifMatch !== void 0 && options.conditions.ifMatch !== (this.container.has(this.name) ? readMockBlobDates(this.containerName, this.name).etag : void 0)) throw new MockRestError("The condition specified using HTTP conditional header(s) is not met.", 412);
|
|
440
|
+
storeMockBlobWrite(this.containerName, this.name, this.container.has(this.name));
|
|
441
|
+
storeMockBlobMetadata(this.containerName, this.name, options?.metadata);
|
|
409
442
|
this.container.set(this.name, buffer);
|
|
410
|
-
MockContainerCreatedOnDatabase.set(getMockContainerCreatedOnKey(this.containerName, this.name), /* @__PURE__ */ new Date());
|
|
411
443
|
return { _response: createMockResponse(201) };
|
|
412
444
|
}
|
|
413
445
|
uploadBrowserData() {
|
|
@@ -506,9 +538,7 @@ var MockContainerClient = class {
|
|
|
506
538
|
throw new Error("Method not implemented.");
|
|
507
539
|
}
|
|
508
540
|
deleteBlob(blobName) {
|
|
509
|
-
if (!this.
|
|
510
|
-
this.container.delete(blobName);
|
|
511
|
-
MockContainerCreatedOnDatabase.delete(getMockContainerCreatedOnKey(this.containerName, blobName));
|
|
541
|
+
if (!deleteMockBlob(this.containerName, blobName)) throw new MockRestError(BLOB_NOT_FOUND_MESSAGE, 404);
|
|
512
542
|
return Promise.resolve({ _response: createMockResponse(200, getBlobUrl(this.containerName, blobName)) });
|
|
513
543
|
}
|
|
514
544
|
deleteIfExists() {
|
|
@@ -624,7 +654,7 @@ var MockContainerClient = class {
|
|
|
624
654
|
if (!name.startsWith(prefix)) continue;
|
|
625
655
|
const nameAfterPrefix = name.slice(prefix.length);
|
|
626
656
|
const delimiterIndex = nameAfterPrefix.indexOf(delimiter);
|
|
627
|
-
if (delimiterIndex === -1) blobsInCurrentLevel.push(this.#getBlobItem(name, buffer));
|
|
657
|
+
if (delimiterIndex === -1) blobsInCurrentLevel.push(this.#getBlobItem(name, buffer, options?.includeMetadata));
|
|
628
658
|
else {
|
|
629
659
|
const subprefix = `${prefix}${nameAfterPrefix.slice(0, delimiterIndex + delimiter.length)}`;
|
|
630
660
|
uniqueSubprefixes.add(subprefix);
|
|
@@ -639,17 +669,19 @@ var MockContainerClient = class {
|
|
|
639
669
|
...blobItem
|
|
640
670
|
});
|
|
641
671
|
}
|
|
642
|
-
#getBlobItem(name, buffer) {
|
|
672
|
+
#getBlobItem(name, buffer, isMetadataIncluded) {
|
|
673
|
+
const { createdOn, etag, lastModified } = readMockBlobDates(this.containerName, name);
|
|
643
674
|
return {
|
|
644
675
|
deleted: false,
|
|
676
|
+
...isMetadataIncluded && { metadata: readMockBlobMetadata(this.containerName, name) },
|
|
645
677
|
name,
|
|
646
678
|
properties: {
|
|
647
679
|
blobType: "BlockBlob",
|
|
648
680
|
contentLength: buffer.length,
|
|
649
681
|
contentType: "application/octet-stream",
|
|
650
|
-
createdOn
|
|
651
|
-
etag
|
|
652
|
-
lastModified
|
|
682
|
+
createdOn,
|
|
683
|
+
etag,
|
|
684
|
+
lastModified,
|
|
653
685
|
leaseState: "available",
|
|
654
686
|
leaseStatus: "unlocked"
|
|
655
687
|
},
|
|
@@ -660,7 +692,7 @@ var MockContainerClient = class {
|
|
|
660
692
|
const prefix = options?.prefix ?? "";
|
|
661
693
|
for (const [name, buffer] of this.container.entries()) {
|
|
662
694
|
if (!name.startsWith(prefix)) continue;
|
|
663
|
-
yield await Promise.resolve(this.#getBlobItem(name, buffer));
|
|
695
|
+
yield await Promise.resolve(this.#getBlobItem(name, buffer, options?.includeMetadata));
|
|
664
696
|
}
|
|
665
697
|
}
|
|
666
698
|
};
|
|
@@ -830,6 +862,12 @@ var MockQueueClient = class {
|
|
|
830
862
|
}
|
|
831
863
|
};
|
|
832
864
|
//#endregion
|
|
865
|
+
//#region src/services/filter/checkIsNullClause.ts
|
|
866
|
+
const checkIsNullClause = (clause) => {
|
|
867
|
+
const tableNullClause = getTableNullClause(clause.key);
|
|
868
|
+
return deepEqual(clause, tableNullClause);
|
|
869
|
+
};
|
|
870
|
+
//#endregion
|
|
833
871
|
//#region src/services/filter/compare.ts
|
|
834
872
|
const compare = (operator, leftHandSide, rightHandSide) => {
|
|
835
873
|
if (rightHandSide === null || rightHandSide === void 0) {
|
|
@@ -851,19 +889,13 @@ const compare = (operator, leftHandSide, rightHandSide) => {
|
|
|
851
889
|
}
|
|
852
890
|
};
|
|
853
891
|
//#endregion
|
|
854
|
-
//#region src/services/filter/isNullClause.ts
|
|
855
|
-
const isNullClause = (clause) => {
|
|
856
|
-
const tableNullClause = getTableNullClause(clause.key);
|
|
857
|
-
return deepEqual(clause, tableNullClause);
|
|
858
|
-
};
|
|
859
|
-
//#endregion
|
|
860
892
|
//#region src/services/filter/createFilterPredicate.ts
|
|
861
893
|
const createFilterPredicate = (filter) => {
|
|
862
894
|
const orGroups = filter.replaceAll(String.raw`(`, " ").replaceAll(String.raw`)`, "").split(/\s+and\s+/iu).filter(Boolean).map((group) => group.split(/\s+or\s+/iu).filter(Boolean).map((clauseString) => {
|
|
863
895
|
const clause = deserializeClause(clauseString);
|
|
864
896
|
return {
|
|
865
897
|
clause,
|
|
866
|
-
isNull:
|
|
898
|
+
isNull: checkIsNullClause(clause)
|
|
867
899
|
};
|
|
868
900
|
}));
|
|
869
901
|
return (document) => {
|
|
@@ -894,11 +926,11 @@ const toComparable = (value) => {
|
|
|
894
926
|
else if (typeof value === "number" || typeof value === "string") return value;
|
|
895
927
|
else return String(value);
|
|
896
928
|
};
|
|
897
|
-
const compareValues = (
|
|
898
|
-
const
|
|
899
|
-
const
|
|
900
|
-
if (typeof
|
|
901
|
-
return String(
|
|
929
|
+
const compareValues = (firstValue, secondValue) => {
|
|
930
|
+
const firstComparable = toComparable(firstValue);
|
|
931
|
+
const secondComparable = toComparable(secondValue);
|
|
932
|
+
if (typeof firstComparable === "number" && typeof secondComparable === "number") return firstComparable - secondComparable;
|
|
933
|
+
return String(firstComparable).localeCompare(String(secondComparable));
|
|
902
934
|
};
|
|
903
935
|
const sortDocuments = (documents, orderBy) => {
|
|
904
936
|
const parsedOrderBy = orderBy.map((clause) => {
|
|
@@ -908,9 +940,9 @@ const sortDocuments = (documents, orderBy) => {
|
|
|
908
940
|
key: deserializeKey(field)
|
|
909
941
|
};
|
|
910
942
|
});
|
|
911
|
-
return documents.toSorted((
|
|
943
|
+
return documents.toSorted((firstDocument, secondDocument) => {
|
|
912
944
|
for (const { direction, key } of parsedOrderBy) {
|
|
913
|
-
const comparison = compareValues(
|
|
945
|
+
const comparison = compareValues(firstDocument[key], secondDocument[key]);
|
|
914
946
|
if (comparison !== 0) return direction === "desc" ? -comparison : comparison;
|
|
915
947
|
}
|
|
916
948
|
return 0;
|
|
@@ -1041,10 +1073,10 @@ var MockServiceBusSender = class {
|
|
|
1041
1073
|
};
|
|
1042
1074
|
//#endregion
|
|
1043
1075
|
//#region src/services/table/compareByCompositeKey.ts
|
|
1044
|
-
const compareByCompositeKey = (
|
|
1045
|
-
if (
|
|
1046
|
-
else if (
|
|
1047
|
-
else return
|
|
1076
|
+
const compareByCompositeKey = (firstEntity, secondEntity) => {
|
|
1077
|
+
if (firstEntity.partitionKey !== secondEntity.partitionKey) return firstEntity.partitionKey < secondEntity.partitionKey ? -1 : 1;
|
|
1078
|
+
else if (firstEntity.rowKey === secondEntity.rowKey) return 0;
|
|
1079
|
+
else return firstEntity.rowKey < secondEntity.rowKey ? -1 : 1;
|
|
1048
1080
|
};
|
|
1049
1081
|
//#endregion
|
|
1050
1082
|
//#region src/models/table/MockTableClient.ts
|
|
@@ -1243,4 +1275,4 @@ const applyFilter = (documents, clauses) => {
|
|
|
1243
1275
|
return documents.filter((document) => predicate(document));
|
|
1244
1276
|
};
|
|
1245
1277
|
//#endregion
|
|
1246
|
-
export { BLOB_NOT_FOUND_ERROR_CODE, BLOB_NOT_FOUND_MESSAGE, MOCK_BLOB_BASE_URL,
|
|
1278
|
+
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, getMockContainer, getMockContainerBlobDatesKey, getMockQueueMessageItem, getMockSasUrl, readMockBlobDates, readMockBlobMetadata, storeMockBlobMetadata, storeMockBlobWrite, toWebResourceLike };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "azure-mock",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.39.0",
|
|
4
4
|
"description": "A library that contains azure mock classes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"azure",
|
|
@@ -44,27 +44,26 @@
|
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
|
-
"build": "
|
|
48
|
-
"export:gen": "
|
|
47
|
+
"build": "tsdown",
|
|
48
|
+
"export:gen": "generate-exports",
|
|
49
49
|
"format": "oxfmt",
|
|
50
50
|
"format:check": "oxfmt --check",
|
|
51
51
|
"lint": "eslint .",
|
|
52
52
|
"lint:fix": "eslint --fix .",
|
|
53
53
|
"test": "vitest",
|
|
54
|
-
"typecheck": "
|
|
54
|
+
"typecheck": "tsc"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@esposter/azure": "2.
|
|
58
|
-
"@esposter/shared": "2.
|
|
57
|
+
"@esposter/azure": "2.39.0",
|
|
58
|
+
"@esposter/shared": "2.39.0",
|
|
59
59
|
"fast-deep-equal": "^3.1.3"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@arethetypeswrong/core": "^0.18.5",
|
|
63
|
-
"@esposter/configuration": "2.
|
|
64
|
-
"ctix": "^2.8.2",
|
|
63
|
+
"@esposter/configuration": "2.39.0",
|
|
65
64
|
"publint": "^0.3.24",
|
|
66
|
-
"tsdown": "^0.
|
|
67
|
-
"type-fest": "^5.
|
|
65
|
+
"tsdown": "^0.23.0",
|
|
66
|
+
"type-fest": "^5.9.0",
|
|
68
67
|
"typedoc": "^0.28.20",
|
|
69
68
|
"vitest": "^4.1.11"
|
|
70
69
|
},
|
|
@@ -79,7 +78,7 @@
|
|
|
79
78
|
"@azure/storage-queue": "^12.31.0"
|
|
80
79
|
},
|
|
81
80
|
"inlinedDependencies": {
|
|
82
|
-
"type-fest": "5.
|
|
81
|
+
"type-fest": "5.9.0"
|
|
83
82
|
},
|
|
84
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "98f89a176510bb274865731121f990e48c6d056a"
|
|
85
84
|
}
|