azure-mock 2.32.1 → 2.33.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 +0 -87
- package/dist/index.js +4 -58
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -7,20 +7,14 @@ import { EventGridEvent, EventGridPublisherClient } from "@azure/eventgrid";
|
|
|
7
7
|
import { CreateTableEntityResponse, GetAccessPolicyResponse, GetTableEntityResponse, ListTableEntitiesOptions, TableClient, TableDeleteEntityHeaders, TableEntity, TableEntityResult, TableEntityResultPage, TableMergeEntityHeaders, TableSetAccessPolicyHeaders, TableTransactionResponse, UpdateMode } from "@azure/data-tables";
|
|
8
8
|
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";
|
|
9
9
|
import { AutocompleteResult, CountDocumentsOptions, DeleteDocumentsOptions, GetDocumentOptions, IndexDocumentsBatch, IndexDocumentsOptions, IndexDocumentsResult, MergeDocumentsOptions, MergeOrUploadDocumentsOptions, NarrowedModel, SearchClient, SearchDocumentsResult, SearchOptions, SelectFields, SuggestDocumentsResult, SuggestOptions, UploadDocumentsOptions } from "@azure/search-documents";
|
|
10
|
-
|
|
11
|
-
//#region src/constants.d.ts
|
|
12
10
|
declare const MOCK_BLOB_BASE_URL = "https://mockaccount.blob.core.windows.net";
|
|
13
11
|
declare const MOCK_QUEUE_BASE_URL = "https://mockaccount.queue.core.windows.net";
|
|
14
12
|
declare const MOCK_SEARCH_BASE_URL = "https://mockaccount.search.windows.net";
|
|
15
13
|
declare const MOCK_TABLE_BASE_URL = "https://mockaccount.table.core.windows.net";
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/models/MockRestError.d.ts
|
|
18
14
|
declare class MockRestError extends Error {
|
|
19
15
|
statusCode: number;
|
|
20
16
|
constructor(message: string, statusCode: number);
|
|
21
17
|
}
|
|
22
|
-
//#endregion
|
|
23
|
-
//#region src/models/PageSettings.d.ts
|
|
24
18
|
/**
|
|
25
19
|
* An interface that tracks the settings for paged iteration
|
|
26
20
|
*/
|
|
@@ -34,8 +28,6 @@ interface PageSettings {
|
|
|
34
28
|
*/
|
|
35
29
|
maxPageSize?: number;
|
|
36
30
|
}
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/models/PagedAsyncIterableIterator.d.ts
|
|
39
31
|
/**
|
|
40
32
|
* An interface that allows async iterable iteration both to completion and by page.
|
|
41
33
|
*/
|
|
@@ -53,30 +45,16 @@ interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings
|
|
|
53
45
|
*/
|
|
54
46
|
next: () => Promise<IteratorResult<TElement>>;
|
|
55
47
|
}
|
|
56
|
-
//#endregion
|
|
57
|
-
//#region src/store/MockContainerDatabase.d.ts
|
|
58
48
|
declare const MockContainerDatabase: Map<string, Map<string, Buffer>>;
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region src/store/MockEventGridDatabase.d.ts
|
|
61
49
|
declare const MockEventGridDatabase: Map<string, EventGridEvent<unknown>[]>;
|
|
62
|
-
//#endregion
|
|
63
|
-
//#region src/store/MockQueueDatabase.d.ts
|
|
64
50
|
declare const MockQueueDatabase: Map<string, string[]>;
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/store/MockSearchDatabase.d.ts
|
|
67
51
|
declare const MockSearchDatabase: Map<string, object[]>;
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region src/store/MockTableDatabase.d.ts
|
|
70
52
|
declare const MockTableDatabase: Map<string, Map<string, TableEntity>>;
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/models/container/BlobHierarchyItem.d.ts
|
|
73
53
|
type BlobHierarchyItem = (BlobItem & {
|
|
74
54
|
kind: "blob";
|
|
75
55
|
}) | (BlobPrefix & {
|
|
76
56
|
kind: "prefix";
|
|
77
57
|
});
|
|
78
|
-
//#endregion
|
|
79
|
-
//#region src/models/container/MockBlobBatchClient.d.ts
|
|
80
58
|
declare class MockBlobBatchClient implements BlobBatchClient {
|
|
81
59
|
url: string;
|
|
82
60
|
constructor(url: string);
|
|
@@ -89,8 +67,6 @@ declare class MockBlobBatchClient implements BlobBatchClient {
|
|
|
89
67
|
deleteBlobs(urls: string[], credential: AnonymousCredential | StorageSharedKeyCredential, _options?: BlobDeleteOptions): Promise<BlobBatchDeleteBlobsResponse>;
|
|
90
68
|
getContainer(containerName: string): MapValue<typeof MockContainerDatabase>;
|
|
91
69
|
}
|
|
92
|
-
//#endregion
|
|
93
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-any.d.ts
|
|
94
70
|
/**
|
|
95
71
|
Returns a boolean for whether the given type is `any`.
|
|
96
72
|
|
|
@@ -120,8 +96,6 @@ const anyA = get(anyObject, 'a');
|
|
|
120
96
|
@category Utilities
|
|
121
97
|
*/
|
|
122
98
|
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
123
|
-
//#endregion
|
|
124
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
125
99
|
/**
|
|
126
100
|
Returns a boolean for whether the given key is an optional key of type.
|
|
127
101
|
|
|
@@ -163,8 +137,6 @@ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
|
163
137
|
@category Utilities
|
|
164
138
|
*/
|
|
165
139
|
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;
|
|
166
|
-
//#endregion
|
|
167
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
168
140
|
/**
|
|
169
141
|
Extract all optional keys from the given type.
|
|
170
142
|
|
|
@@ -201,8 +173,6 @@ const update2: UpdateOperation<User> = {
|
|
|
201
173
|
type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
202
174
|
? (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`
|
|
203
175
|
: never;
|
|
204
|
-
//#endregion
|
|
205
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/required-keys-of.d.ts
|
|
206
176
|
/**
|
|
207
177
|
Extract all required keys from the given type.
|
|
208
178
|
|
|
@@ -235,8 +205,6 @@ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
|
|
|
235
205
|
*/
|
|
236
206
|
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
237
207
|
? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
|
|
238
|
-
//#endregion
|
|
239
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-never.d.ts
|
|
240
208
|
/**
|
|
241
209
|
Returns a boolean for whether the given type is `never`.
|
|
242
210
|
|
|
@@ -291,8 +259,6 @@ type B = IsTrueFixed<never>;
|
|
|
291
259
|
@category Utilities
|
|
292
260
|
*/
|
|
293
261
|
type IsNever<T> = [T] extends [never] ? true : false;
|
|
294
|
-
//#endregion
|
|
295
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/if.d.ts
|
|
296
262
|
/**
|
|
297
263
|
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
298
264
|
|
|
@@ -386,8 +352,6 @@ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
|
|
|
386
352
|
@category Utilities
|
|
387
353
|
*/
|
|
388
354
|
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
389
|
-
//#endregion
|
|
390
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/simplify.d.ts
|
|
391
355
|
/**
|
|
392
356
|
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.
|
|
393
357
|
|
|
@@ -447,8 +411,6 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
447
411
|
@category Object
|
|
448
412
|
*/
|
|
449
413
|
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
450
|
-
//#endregion
|
|
451
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-equal.d.ts
|
|
452
414
|
/**
|
|
453
415
|
Returns a boolean for whether the two given types are equal.
|
|
454
416
|
|
|
@@ -478,8 +440,6 @@ type Includes<Value extends readonly any[], Item> =
|
|
|
478
440
|
type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
|
|
479
441
|
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
480
442
|
type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
481
|
-
//#endregion
|
|
482
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
483
443
|
/**
|
|
484
444
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
485
445
|
|
|
@@ -572,8 +532,6 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
572
532
|
@category Object
|
|
573
533
|
*/
|
|
574
534
|
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
575
|
-
//#endregion
|
|
576
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
577
535
|
/**
|
|
578
536
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
579
537
|
|
|
@@ -620,8 +578,6 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
620
578
|
@category Object
|
|
621
579
|
*/
|
|
622
580
|
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
623
|
-
//#endregion
|
|
624
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/merge.d.ts
|
|
625
581
|
// Merges two objects without worrying about index signatures.
|
|
626
582
|
type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source>;
|
|
627
583
|
/**
|
|
@@ -692,8 +648,6 @@ type Merge<Destination, Source> = Destination extends unknown // For distributin
|
|
|
692
648
|
: never;
|
|
693
649
|
// Should never happen
|
|
694
650
|
type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
695
|
-
//#endregion
|
|
696
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/object.d.ts
|
|
697
651
|
/**
|
|
698
652
|
Merges user specified options with default options.
|
|
699
653
|
|
|
@@ -776,8 +730,6 @@ type E = CollapseLiterals<LiteralUnion<'foo' | 'bar', string> | null | undefined
|
|
|
776
730
|
//=> string | null | undefined
|
|
777
731
|
```
|
|
778
732
|
*/
|
|
779
|
-
//#endregion
|
|
780
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/except.d.ts
|
|
781
733
|
/**
|
|
782
734
|
Filter out keys from an object.
|
|
783
735
|
|
|
@@ -874,8 +826,6 @@ type PostPayloadFixed = Except<UserData, 'email'>;
|
|
|
874
826
|
*/
|
|
875
827
|
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
|
|
876
828
|
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
|
-
//#endregion
|
|
878
|
-
//#region src/models/container/MockBlobClient.d.ts
|
|
879
829
|
declare class MockBlobClient implements Except<BlobClient, "accountName"> {
|
|
880
830
|
connectionString: string;
|
|
881
831
|
containerName: string;
|
|
@@ -916,8 +866,6 @@ declare class MockBlobClient implements Except<BlobClient, "accountName"> {
|
|
|
916
866
|
withSnapshot(): BlockBlobClient;
|
|
917
867
|
withVersion(): BlobClient;
|
|
918
868
|
}
|
|
919
|
-
//#endregion
|
|
920
|
-
//#region src/models/container/MockBlockBlobClient.d.ts
|
|
921
869
|
declare class MockBlockBlobClient extends MockBlobClient implements Except<BlockBlobClient, "accountName"> {
|
|
922
870
|
commitBlockList(): Promise<BlockBlobCommitBlockListResponse>;
|
|
923
871
|
getBlockList(): Promise<BlockBlobGetBlockListResponse>;
|
|
@@ -931,8 +879,6 @@ declare class MockBlockBlobClient extends MockBlobClient implements Except<Block
|
|
|
931
879
|
uploadFile(): Promise<BlobUploadCommonResponse>;
|
|
932
880
|
uploadStream(): Promise<BlobUploadCommonResponse>;
|
|
933
881
|
}
|
|
934
|
-
//#endregion
|
|
935
|
-
//#region src/models/container/MockContainerClient.d.ts
|
|
936
882
|
/**
|
|
937
883
|
* An in-memory mock of the Azure ContainerClient.
|
|
938
884
|
* It uses a Map to simulate blob storage.
|
|
@@ -980,8 +926,6 @@ declare class MockContainerClient implements Except<ContainerClient, "accountNam
|
|
|
980
926
|
response: BlockBlobUploadResponse;
|
|
981
927
|
}>;
|
|
982
928
|
}
|
|
983
|
-
//#endregion
|
|
984
|
-
//#region src/models/eventGrid/MockEventGridPublisherClient.d.ts
|
|
985
929
|
/**
|
|
986
930
|
* An in-memory mock of the Azure EventGridPublisherClient.
|
|
987
931
|
* It uses a Map to simulate event grid storage and correctly implements the EventGridPublisherClient interface.
|
|
@@ -994,8 +938,6 @@ declare class MockEventGridPublisherClient implements Except<EventGridPublisherC
|
|
|
994
938
|
constructor(endpoint: string, topicType: "EventGrid");
|
|
995
939
|
send(newEvents: EventGridEvent<unknown>[]): Promise<void>;
|
|
996
940
|
}
|
|
997
|
-
//#endregion
|
|
998
|
-
//#region src/models/queue/MockQueueClient.d.ts
|
|
999
941
|
/**
|
|
1000
942
|
* An in-memory mock of the Azure QueueClient.
|
|
1001
943
|
* It uses a Map to simulate queue storage and correctly implements the QueueClient interface.
|
|
@@ -1034,8 +976,6 @@ declare class MockQueueClient implements Except<QueueClient, "accountName"> {
|
|
|
1034
976
|
setMetadata(): Promise<QueueSetMetadataResponse>;
|
|
1035
977
|
updateMessage(): Promise<QueueUpdateMessageResponse>;
|
|
1036
978
|
}
|
|
1037
|
-
//#endregion
|
|
1038
|
-
//#region src/models/search/MockSearchClient.d.ts
|
|
1039
979
|
/**
|
|
1040
980
|
* An in-memory mock of the Azure SearchClient.
|
|
1041
981
|
* It uses a Map to simulate the search index and applies the same OData filtering as the other mock clients.
|
|
@@ -1064,8 +1004,6 @@ declare class MockSearchClient<TModel extends object = Record<string, unknown>>
|
|
|
1064
1004
|
suggest<TFields extends SelectFields<TModel> = never>(_searchText: string, _suggesterName: string, _options?: SuggestOptions<TModel, TFields>): Promise<SuggestDocumentsResult<TModel, TFields>>;
|
|
1065
1005
|
uploadDocuments(documents: TModel[], _options?: UploadDocumentsOptions): Promise<IndexDocumentsResult>;
|
|
1066
1006
|
}
|
|
1067
|
-
//#endregion
|
|
1068
|
-
//#region src/models/table/MockTableClient.d.ts
|
|
1069
1007
|
/**
|
|
1070
1008
|
* An in-memory mock of the Azure TableClient.
|
|
1071
1009
|
* It uses a Map to simulate table storage and correctly implements the TableClient interface.
|
|
@@ -1094,8 +1032,6 @@ declare class MockTableClient<TEntity extends TableEntity = TableEntity> impleme
|
|
|
1094
1032
|
updateEntity<T extends object>(entity: TableEntity<T>, mode?: UpdateMode): Promise<TableMergeEntityHeaders>;
|
|
1095
1033
|
upsertEntity<T extends object>(entity: TableEntity<T>, mode?: UpdateMode): Promise<TableMergeEntityHeaders>;
|
|
1096
1034
|
}
|
|
1097
|
-
//#endregion
|
|
1098
|
-
//#region src/models/webPubSub/MockWebPubSubServiceClient.d.ts
|
|
1099
1035
|
/**
|
|
1100
1036
|
* A minimal mock of the Azure WebPubSubServiceClient for testing purposes.
|
|
1101
1037
|
* Only implements `group().sendToAll` — the only method used in azure-functions tests.
|
|
@@ -1105,11 +1041,7 @@ declare class MockWebPubSubServiceClient {
|
|
|
1105
1041
|
sendToAll: () => Promise<void>;
|
|
1106
1042
|
};
|
|
1107
1043
|
}
|
|
1108
|
-
//#endregion
|
|
1109
|
-
//#region src/services/container/bodyToBuffer.d.ts
|
|
1110
1044
|
declare const bodyToBuffer: (body: HttpRequestBody) => Promise<Buffer>;
|
|
1111
|
-
//#endregion
|
|
1112
|
-
//#region src/services/container/getAzureErrorXml.d.ts
|
|
1113
1045
|
/**
|
|
1114
1046
|
* Generates a standard Azure Storage error XML response body.
|
|
1115
1047
|
* @param errorCode The official Azure error code (e.g., "BlobNotFound").
|
|
@@ -1117,17 +1049,11 @@ declare const bodyToBuffer: (body: HttpRequestBody) => Promise<Buffer>;
|
|
|
1117
1049
|
* @returns A formatted XML string.
|
|
1118
1050
|
*/
|
|
1119
1051
|
declare const getAzureErrorXml: (errorCode: string, errorMessage: string) => string;
|
|
1120
|
-
//#endregion
|
|
1121
|
-
//#region src/services/container/getBlobItemXml.d.ts
|
|
1122
1052
|
declare const getBlobItemXml: ({
|
|
1123
1053
|
name,
|
|
1124
1054
|
properties
|
|
1125
1055
|
}: BlobItem) => string;
|
|
1126
|
-
//#endregion
|
|
1127
|
-
//#region src/services/container/getBlobPrefixXml.d.ts
|
|
1128
1056
|
declare const getBlobPrefixXml: (name: string) => string;
|
|
1129
|
-
//#endregion
|
|
1130
|
-
//#region src/services/container/getListBlobsXml.d.ts
|
|
1131
1057
|
/**
|
|
1132
1058
|
* Generates a standard Azure Storage list blobs XML response body.
|
|
1133
1059
|
* @param containerName The container name.
|
|
@@ -1135,23 +1061,10 @@ declare const getBlobPrefixXml: (name: string) => string;
|
|
|
1135
1061
|
* @returns A formatted XML string.
|
|
1136
1062
|
*/
|
|
1137
1063
|
declare const getListBlobsXml: (containerName: string, blobsXml: string) => string;
|
|
1138
|
-
//#endregion
|
|
1139
|
-
//#region src/services/container/isReadableStream.d.ts
|
|
1140
1064
|
declare const isReadableStream: (value: unknown) => value is NodeJS.ReadableStream;
|
|
1141
|
-
//#endregion
|
|
1142
|
-
//#region src/services/container/toWebResourceLike.d.ts
|
|
1143
1065
|
declare const toWebResourceLike: (request: PipelineRequest) => WebResourceLike;
|
|
1144
|
-
//#endregion
|
|
1145
|
-
//#region src/services/filter/applyFilter.d.ts
|
|
1146
1066
|
declare const applyFilter: <T extends Record<string, unknown>>(documents: T[], clauses: Clause<T>[]) => T[];
|
|
1147
|
-
//#endregion
|
|
1148
|
-
//#region src/services/filter/compare.d.ts
|
|
1149
1067
|
declare const compare: <T>(operator: BinaryOperator, leftHandSide: T, rightHandSide: null | T) => boolean;
|
|
1150
|
-
//#endregion
|
|
1151
|
-
//#region src/services/filter/createFilterPredicate.d.ts
|
|
1152
1068
|
declare const createFilterPredicate: (filter: string) => ((document: Record<string, unknown>) => boolean);
|
|
1153
|
-
//#endregion
|
|
1154
|
-
//#region src/services/filter/isNullClause.d.ts
|
|
1155
1069
|
declare const isNullClause: (clause: Clause<Record<string, unknown>>) => boolean;
|
|
1156
|
-
//#endregion
|
|
1157
1070
|
export { BlobHierarchyItem, MOCK_BLOB_BASE_URL, MOCK_QUEUE_BASE_URL, MOCK_SEARCH_BASE_URL, MOCK_TABLE_BASE_URL, MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerClient, MockContainerDatabase, MockEventGridDatabase, MockEventGridPublisherClient, MockQueueClient, MockQueueDatabase, MockRestError, MockSearchClient, MockSearchDatabase, MockTableClient, MockTableDatabase, MockWebPubSubServiceClient, PageSettings, PagedAsyncIterableIterator, applyFilter, bodyToBuffer, compare, createFilterPredicate, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, getListBlobsXml, isNullClause, isReadableStream, toWebResourceLike };
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,6 @@ import { AnonymousCredential } from "@azure/storage-blob";
|
|
|
5
5
|
import { Readable } from "node:stream";
|
|
6
6
|
import { MAX_QUEUE_VISIBILITY_TIMEOUT_MS, deserializeClause, deserializeKey, getTableNullClause, serializeClauses } from "@esposter/db";
|
|
7
7
|
import { BinaryOperator } from "@esposter/db-schema";
|
|
8
|
-
//#region \0rolldown/runtime.js
|
|
9
8
|
var __create = Object.create;
|
|
10
9
|
var __defProp = Object.defineProperty;
|
|
11
10
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -27,14 +26,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
26
|
value: mod,
|
|
28
27
|
enumerable: true
|
|
29
28
|
}) : target, mod));
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/constants.ts
|
|
32
29
|
const MOCK_BLOB_BASE_URL = "https://mockaccount.blob.core.windows.net";
|
|
33
30
|
const MOCK_QUEUE_BASE_URL = "https://mockaccount.queue.core.windows.net";
|
|
34
31
|
const MOCK_SEARCH_BASE_URL = "https://mockaccount.search.windows.net";
|
|
35
32
|
const MOCK_TABLE_BASE_URL = "https://mockaccount.table.core.windows.net";
|
|
36
|
-
//#endregion
|
|
37
|
-
//#region src/models/MockRestError.ts
|
|
38
33
|
var MockRestError = class extends Error {
|
|
39
34
|
statusCode;
|
|
40
35
|
constructor(message, statusCode) {
|
|
@@ -43,23 +38,11 @@ var MockRestError = class extends Error {
|
|
|
43
38
|
this.statusCode = statusCode;
|
|
44
39
|
}
|
|
45
40
|
};
|
|
46
|
-
//#endregion
|
|
47
|
-
//#region src/store/MockContainerDatabase.ts
|
|
48
41
|
const MockContainerDatabase = /* @__PURE__ */ new Map();
|
|
49
|
-
//#endregion
|
|
50
|
-
//#region src/store/MockEventGridDatabase.ts
|
|
51
42
|
const MockEventGridDatabase = /* @__PURE__ */ new Map();
|
|
52
|
-
//#endregion
|
|
53
|
-
//#region src/store/MockQueueDatabase.ts
|
|
54
43
|
const MockQueueDatabase = /* @__PURE__ */ new Map();
|
|
55
|
-
//#endregion
|
|
56
|
-
//#region src/store/MockSearchDatabase.ts
|
|
57
44
|
const MockSearchDatabase = /* @__PURE__ */ new Map();
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/store/MockTableDatabase.ts
|
|
60
45
|
const MockTableDatabase = /* @__PURE__ */ new Map();
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region src/services/container/getAzureErrorXml.ts
|
|
63
46
|
/**
|
|
64
47
|
* Generates a standard Azure Storage error XML response body.
|
|
65
48
|
* @param errorCode The official Azure error code (e.g., "BlobNotFound").
|
|
@@ -71,8 +54,6 @@ const getAzureErrorXml = (errorCode, errorMessage) => html`<?xml version="1.0" e
|
|
|
71
54
|
<code>${errorCode}</code>
|
|
72
55
|
<Message>${errorMessage}</Message>
|
|
73
56
|
</Error>`;
|
|
74
|
-
//#endregion
|
|
75
|
-
//#region src/services/container/toWebResourceLike.ts
|
|
76
57
|
const toWebResourceLike = (request) => ({
|
|
77
58
|
abortSignal: request.abortSignal,
|
|
78
59
|
agent: request.agent,
|
|
@@ -98,8 +79,6 @@ const toWebResourceLike = (request) => ({
|
|
|
98
79
|
validateRequestProperties: noop,
|
|
99
80
|
withCredentials: request.withCredentials
|
|
100
81
|
});
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region src/models/container/MockBlobBatchClient.ts
|
|
103
82
|
var MockBlobBatchClient = class {
|
|
104
83
|
url;
|
|
105
84
|
constructor(url) {
|
|
@@ -189,8 +168,6 @@ var MockBlobBatchClient = class {
|
|
|
189
168
|
return container;
|
|
190
169
|
}
|
|
191
170
|
};
|
|
192
|
-
//#endregion
|
|
193
|
-
//#region src/models/container/MockBlobClient.ts
|
|
194
171
|
var MockBlobClient = class {
|
|
195
172
|
connectionString;
|
|
196
173
|
containerName;
|
|
@@ -362,18 +339,16 @@ var MockBlobClient = class {
|
|
|
362
339
|
throw new Error("Method not implemented.");
|
|
363
340
|
}
|
|
364
341
|
};
|
|
365
|
-
//#endregion
|
|
366
|
-
//#region src/services/container/isReadableStream.ts
|
|
367
342
|
const isReadableStream = (value) => value instanceof Readable;
|
|
368
|
-
//#endregion
|
|
369
|
-
//#region src/services/container/bodyToBuffer.ts
|
|
370
343
|
const bodyToBuffer = async (body) => {
|
|
371
344
|
if (body === null) return Buffer.alloc(0);
|
|
372
345
|
else if (typeof body === "string") return Buffer.from(body);
|
|
373
346
|
else if (body instanceof ArrayBuffer) return Buffer.from(body);
|
|
374
347
|
else if (ArrayBuffer.isView(body)) return Buffer.from(body.buffer, body.byteOffset, body.byteLength);
|
|
375
|
-
else if (typeof body === "function")
|
|
376
|
-
|
|
348
|
+
else if (typeof body === "function") {
|
|
349
|
+
const streamOrBlob = body();
|
|
350
|
+
return bodyToBuffer(streamOrBlob);
|
|
351
|
+
} else if (body instanceof Blob) {
|
|
377
352
|
const arrayBuffer = await body.arrayBuffer();
|
|
378
353
|
return Buffer.from(arrayBuffer);
|
|
379
354
|
} else if (isReadableStream(body)) return Buffer.from(await streamToText(body));
|
|
@@ -392,8 +367,6 @@ const bodyToBuffer = async (body) => {
|
|
|
392
367
|
return Buffer.alloc(0);
|
|
393
368
|
}
|
|
394
369
|
};
|
|
395
|
-
//#endregion
|
|
396
|
-
//#region src/models/container/MockBlockBlobClient.ts
|
|
397
370
|
var MockBlockBlobClient = class extends MockBlobClient {
|
|
398
371
|
commitBlockList() {
|
|
399
372
|
throw new Error("Method not implemented.");
|
|
@@ -435,8 +408,6 @@ var MockBlockBlobClient = class extends MockBlobClient {
|
|
|
435
408
|
throw new Error("Method not implemented.");
|
|
436
409
|
}
|
|
437
410
|
};
|
|
438
|
-
//#endregion
|
|
439
|
-
//#region src/services/container/getBlobItemXml.ts
|
|
440
411
|
const getBlobItemXml = ({ name, properties }) => html`<Blob>
|
|
441
412
|
<Name>${name}</Name>
|
|
442
413
|
<Properties>
|
|
@@ -449,11 +420,7 @@ const getBlobItemXml = ({ name, properties }) => html`<Blob>
|
|
|
449
420
|
<LeaseState>available</LeaseState>
|
|
450
421
|
</Properties>
|
|
451
422
|
</Blob>`;
|
|
452
|
-
//#endregion
|
|
453
|
-
//#region src/services/container/getBlobPrefixXml.ts
|
|
454
423
|
const getBlobPrefixXml = (name) => html`<BlobPrefix><Name>${name}</Name></BlobPrefix>`;
|
|
455
|
-
//#endregion
|
|
456
|
-
//#region src/services/container/getListBlobsXml.ts
|
|
457
424
|
/**
|
|
458
425
|
* Generates a standard Azure Storage list blobs XML response body.
|
|
459
426
|
* @param containerName The container name.
|
|
@@ -465,8 +432,6 @@ const getListBlobsXml = (containerName, blobsXml) => html`<?xml version="1.0" en
|
|
|
465
432
|
<Blobs>${blobsXml}</Blobs>
|
|
466
433
|
<NextMarker />
|
|
467
434
|
</EnumerationResults>`;
|
|
468
|
-
//#endregion
|
|
469
|
-
//#region src/models/container/MockContainerClient.ts
|
|
470
435
|
/**
|
|
471
436
|
* An in-memory mock of the Azure ContainerClient.
|
|
472
437
|
* It uses a Map to simulate blob storage.
|
|
@@ -710,8 +675,6 @@ var MockContainerClient = class {
|
|
|
710
675
|
});
|
|
711
676
|
}
|
|
712
677
|
};
|
|
713
|
-
//#endregion
|
|
714
|
-
//#region src/models/eventGrid/MockEventGridPublisherClient.ts
|
|
715
678
|
/**
|
|
716
679
|
* An in-memory mock of the Azure EventGridPublisherClient.
|
|
717
680
|
* It uses a Map to simulate event grid storage and correctly implements the EventGridPublisherClient interface.
|
|
@@ -733,8 +696,6 @@ var MockEventGridPublisherClient = class {
|
|
|
733
696
|
return Promise.resolve();
|
|
734
697
|
}
|
|
735
698
|
};
|
|
736
|
-
//#endregion
|
|
737
|
-
//#region src/models/queue/MockQueueClient.ts
|
|
738
699
|
/**
|
|
739
700
|
* An in-memory mock of the Azure QueueClient.
|
|
740
701
|
* It uses a Map to simulate queue storage and correctly implements the QueueClient interface.
|
|
@@ -891,8 +852,6 @@ var MockQueueClient = class {
|
|
|
891
852
|
throw new Error("Method not implemented.");
|
|
892
853
|
}
|
|
893
854
|
};
|
|
894
|
-
//#endregion
|
|
895
|
-
//#region src/services/filter/compare.ts
|
|
896
855
|
const compare = (operator, leftHandSide, rightHandSide) => {
|
|
897
856
|
if (rightHandSide === null || rightHandSide === void 0) {
|
|
898
857
|
if (operator !== BinaryOperator.eq) throw new InvalidOperationError(Operation.Read, compare.name, JSON.stringify({
|
|
@@ -912,8 +871,6 @@ const compare = (operator, leftHandSide, rightHandSide) => {
|
|
|
912
871
|
default: return exhaustiveGuard(operator);
|
|
913
872
|
}
|
|
914
873
|
};
|
|
915
|
-
//#endregion
|
|
916
|
-
//#region src/services/filter/isNullClause.ts
|
|
917
874
|
var import_fast_deep_equal = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
918
875
|
module.exports = function equal(a, b) {
|
|
919
876
|
if (a === b) return true;
|
|
@@ -945,8 +902,6 @@ var import_fast_deep_equal = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJS
|
|
|
945
902
|
const isNullClause = (clause) => {
|
|
946
903
|
return (0, import_fast_deep_equal.default)(clause, getTableNullClause(clause.key));
|
|
947
904
|
};
|
|
948
|
-
//#endregion
|
|
949
|
-
//#region src/services/filter/createFilterPredicate.ts
|
|
950
905
|
const createFilterPredicate = (filter) => {
|
|
951
906
|
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));
|
|
952
907
|
return (document) => {
|
|
@@ -971,8 +926,6 @@ const createFilterPredicate = (filter) => {
|
|
|
971
926
|
return true;
|
|
972
927
|
};
|
|
973
928
|
};
|
|
974
|
-
//#endregion
|
|
975
|
-
//#region src/models/search/MockSearchClient.ts
|
|
976
929
|
const toComparable = (value) => {
|
|
977
930
|
if (value instanceof Date) return value.getTime();
|
|
978
931
|
else if (typeof value === "number" || typeof value === "string") return value;
|
|
@@ -1077,8 +1030,6 @@ var MockSearchClient = class {
|
|
|
1077
1030
|
return Promise.resolve({ results: [] });
|
|
1078
1031
|
}
|
|
1079
1032
|
};
|
|
1080
|
-
//#endregion
|
|
1081
|
-
//#region src/models/table/MockTableClient.ts
|
|
1082
1033
|
/**
|
|
1083
1034
|
* An in-memory mock of the Azure TableClient.
|
|
1084
1035
|
* It uses a Map to simulate table storage and correctly implements the TableClient interface.
|
|
@@ -1245,8 +1196,6 @@ var MockTableClient = class {
|
|
|
1245
1196
|
};
|
|
1246
1197
|
}
|
|
1247
1198
|
};
|
|
1248
|
-
//#endregion
|
|
1249
|
-
//#region src/models/webPubSub/MockWebPubSubServiceClient.ts
|
|
1250
1199
|
/**
|
|
1251
1200
|
* A minimal mock of the Azure WebPubSubServiceClient for testing purposes.
|
|
1252
1201
|
* Only implements `group().sendToAll` — the only method used in azure-functions tests.
|
|
@@ -1256,11 +1205,8 @@ var MockWebPubSubServiceClient = class {
|
|
|
1256
1205
|
return { sendToAll: () => Promise.resolve() };
|
|
1257
1206
|
}
|
|
1258
1207
|
};
|
|
1259
|
-
//#endregion
|
|
1260
|
-
//#region src/services/filter/applyFilter.ts
|
|
1261
1208
|
const applyFilter = (documents, clauses) => {
|
|
1262
1209
|
const predicate = createFilterPredicate(serializeClauses(clauses));
|
|
1263
1210
|
return documents.filter((document) => predicate(document));
|
|
1264
1211
|
};
|
|
1265
|
-
//#endregion
|
|
1266
1212
|
export { MOCK_BLOB_BASE_URL, MOCK_QUEUE_BASE_URL, MOCK_SEARCH_BASE_URL, MOCK_TABLE_BASE_URL, MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerClient, MockContainerDatabase, MockEventGridDatabase, MockEventGridPublisherClient, MockQueueClient, MockQueueDatabase, MockRestError, MockSearchClient, MockSearchDatabase, MockTableClient, MockTableDatabase, MockWebPubSubServiceClient, applyFilter, bodyToBuffer, compare, createFilterPredicate, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, getListBlobsXml, isNullClause, isReadableStream, toWebResourceLike };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "azure-mock",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.33.0",
|
|
4
4
|
"description": "A library that contains azure mock classes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"azure",
|
|
@@ -46,15 +46,15 @@
|
|
|
46
46
|
"typecheck": "tsgo"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@esposter/db": "2.
|
|
50
|
-
"@esposter/db-schema": "2.
|
|
51
|
-
"@esposter/shared": "2.
|
|
49
|
+
"@esposter/db": "2.33.0",
|
|
50
|
+
"@esposter/db-schema": "2.33.0",
|
|
51
|
+
"@esposter/shared": "2.33.0",
|
|
52
52
|
"fast-deep-equal": "^3.1.3"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@esposter/configuration": "2.
|
|
55
|
+
"@esposter/configuration": "2.33.0",
|
|
56
56
|
"ctix": "^2.8.1",
|
|
57
|
-
"rolldown": "^1.1.
|
|
57
|
+
"rolldown": "^1.1.4",
|
|
58
58
|
"type-fest": "^5.7.0",
|
|
59
59
|
"typedoc": "^0.28.19",
|
|
60
60
|
"vitest": "^4.1.9"
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"@azure/storage-blob": "^12.33.0",
|
|
69
69
|
"@azure/storage-queue": "^12.31.0"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "f2eebd70bbe8cdffe31774c76a23d942a17740c7"
|
|
72
72
|
}
|