azure-mock 2.36.0 → 2.37.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,30 +1,32 @@
1
1
  import { PipelineRequest, RestError } from "@azure/core-rest-pipeline";
2
2
  import { HttpHeadersLike, WebResourceLike } from "@azure/core-http-compat";
3
3
  import { MapValue } from "@esposter/shared";
4
- import { AnonymousCredential, AppendBlobClient, BlobAbortCopyFromURLResponse, BlobBatchClient, BlobBatchDeleteBlobsResponse, BlobBeginCopyFromURLResponse, BlobClient, BlobCopyFromURLResponse, BlobCreateSnapshotResponse, BlobDeleteIfExistsResponse, BlobDeleteImmutabilityPolicyResponse, BlobDeleteOptions, BlobDeleteResponse, BlobDownloadResponseModel, BlobDownloadResponseParsed, BlobGenerateSasUrlOptions, BlobGetAccountInfoResponse, BlobGetPropertiesResponse, BlobGetTagsResponse, BlobItem, BlobLeaseClient, BlobPrefix, BlobSetHTTPHeadersResponse, BlobSetImmutabilityPolicyResponse, BlobSetLegalHoldResponse, BlobSetMetadataResponse, BlobSetTagsResponse, BlobSetTierResponse, BlobUndeleteResponse, BlobUploadCommonResponse, BlockBlobClient, BlockBlobCommitBlockListResponse, BlockBlobGetBlockListResponse, BlockBlobPutBlobFromUrlResponse, BlockBlobStageBlockFromURLResponse, BlockBlobStageBlockResponse, 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";
4
+ 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
5
  import { BinaryOperator, Clause } from "@esposter/db-schema";
6
6
  import { EventGridEvent, EventGridPublisherClient } from "@azure/eventgrid";
7
7
  import { ServiceBusMessage, ServiceBusMessageBatch, ServiceBusSender } from "@azure/service-bus";
8
8
  import { CreateTableEntityResponse, GetAccessPolicyResponse, GetTableEntityResponse, ListTableEntitiesOptions, TableClient, TableDeleteEntityHeaders, TableEntity, TableEntityResult, TableEntityResultPage, TableMergeEntityHeaders, TableSetAccessPolicyHeaders, TableTransactionResponse, UpdateMode } from "@azure/data-tables";
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
- declare const MOCK_BLOB_BASE_URL = "https://mockaccount.blob.core.windows.net";
12
- declare const MOCK_QUEUE_BASE_URL = "https://mockaccount.queue.core.windows.net";
13
- declare const MOCK_SEARCH_BASE_URL = "https://mockaccount.search.windows.net";
14
- declare const MOCK_TABLE_BASE_URL = "https://mockaccount.table.core.windows.net";
15
- interface MockResponse {
11
+ export declare const BLOB_NOT_FOUND_ERROR_CODE = "BlobNotFound";
12
+ export declare const BLOB_NOT_FOUND_MESSAGE = "The specified blob does not exist.";
13
+ export declare const MOCK_BLOB_BASE_URL = "https://mockaccount.blob.core.windows.net";
14
+ export declare const MOCK_QUEUE_BASE_URL = "https://mockaccount.queue.core.windows.net";
15
+ export declare const MOCK_SEARCH_BASE_URL = "https://mockaccount.search.windows.net";
16
+ export declare const MOCK_TABLE_BASE_URL = "https://mockaccount.table.core.windows.net";
17
+ export interface MockResponse {
16
18
  headers: HttpHeadersLike;
17
19
  parsedHeaders: Record<string, never>;
18
20
  request: WebResourceLike;
19
21
  status: number;
20
22
  }
21
- declare class MockRestError extends RestError {
23
+ export declare class MockRestError extends RestError {
22
24
  constructor(message: string, statusCode: number);
23
25
  }
24
26
  /**
25
27
  * An interface that tracks the settings for paged iteration
26
28
  */
27
- interface PageSettings {
29
+ export interface PageSettings {
28
30
  /**
29
31
  * The token that keeps track of where to continue the iterator
30
32
  */
@@ -37,7 +39,7 @@ interface PageSettings {
37
39
  /**
38
40
  * An interface that allows async iterable iteration both to completion and by page.
39
41
  */
40
- interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings = PageSettings> {
42
+ export interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings = PageSettings> {
41
43
  /**
42
44
  * The connection to the async iterator, part of the iteration protocol
43
45
  */
@@ -51,25 +53,26 @@ interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings
51
53
  */
52
54
  next: () => Promise<IteratorResult<TElement>>;
53
55
  }
54
- declare const createMockResponse: (status: number, url?: string) => MockResponse;
55
- declare const getMockSasUrl: (url: string, permissions: undefined | {
56
+ export declare const createMockResponse: (status: number, url?: string) => MockResponse;
57
+ export declare const getMockSasUrl: (url: string, permissions: undefined | {
56
58
  toString: () => string;
57
59
  }, resourceType?: string) => string;
58
- declare const MockContainerCreatedOnDatabase: Map<string, Date>;
59
- declare const MOCK_BLOB_SEEDED_CREATED_ON: Date;
60
- declare const getMockContainerCreatedOnKey: (containerName: string, blobName: string) => string;
61
- declare const MockContainerDatabase: Map<string, Map<string, Buffer>>;
62
- declare const MockEventGridDatabase: Map<string, EventGridEvent<unknown>[]>;
63
- declare const MockQueueDatabase: Map<string, string[]>;
64
- declare const MockSearchDatabase: Map<string, object[]>;
65
- declare const MockServiceBusDatabase: Map<string, ServiceBusMessage[]>;
66
- declare const MockTableDatabase: Map<string, Map<string, TableEntity>>;
67
- type BlobHierarchyItem = (BlobItem & {
60
+ export declare const MockContainerCreatedOnDatabase: Map<string, Date>;
61
+ export declare const MOCK_BLOB_SEEDED_CREATED_ON: Date;
62
+ export declare const getMockContainerCreatedOnKey: (containerName: string, blobName: string) => string;
63
+ export declare const MockContainerDatabase: Map<string, Map<string, Buffer>>;
64
+ export declare const MockEventGridDatabase: Map<string, EventGridEvent<unknown>[]>;
65
+ export declare const MockQueueDatabase: Map<string, string[]>;
66
+ export declare const MockSearchDatabase: Map<string, object[]>;
67
+ export declare const MockServiceBusDatabase: Map<string, ServiceBusMessage[]>;
68
+ export declare const MockTableDatabase: Map<string, Map<string, TableEntity>>;
69
+ export type BlobHierarchyItem = (BlobItem & {
68
70
  kind: "blob";
69
71
  }) | (BlobPrefix & {
70
72
  kind: "prefix";
71
73
  });
72
- declare class MockBlobBatchClient implements BlobBatchClient {
74
+ export declare class MockBlobBatchClient implements BlobBatchClient {
75
+ #private;
73
76
  url: string;
74
77
  constructor(url: string);
75
78
  /**
@@ -814,7 +817,7 @@ type PostPayloadFixed = Except<UserData, 'email'>;
814
817
  */
815
818
  type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
816
819
  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>> : {});
817
- declare class MockBlobClient implements Except<BlobClient, "accountName"> {
820
+ export declare class MockBlobClient implements Except<BlobClient, "accountName"> {
818
821
  connectionString: string;
819
822
  containerName: string;
820
823
  credential: AnonymousCredential;
@@ -854,7 +857,7 @@ declare class MockBlobClient implements Except<BlobClient, "accountName"> {
854
857
  withSnapshot(): BlockBlobClient;
855
858
  withVersion(): BlobClient;
856
859
  }
857
- declare class MockBlockBlobClient extends MockBlobClient implements Except<BlockBlobClient, "accountName"> {
860
+ export declare class MockBlockBlobClient extends MockBlobClient implements Except<BlockBlobClient, "accountName"> {
858
861
  commitBlockList(): Promise<BlockBlobCommitBlockListResponse>;
859
862
  getBlockList(): Promise<BlockBlobGetBlockListResponse>;
860
863
  query(): Promise<BlobDownloadResponseModel>;
@@ -877,7 +880,7 @@ declare class MockBlockBlobClient extends MockBlobClient implements Except<Block
877
880
  * await blockBlobClient.upload("hello world", 11);
878
881
  * const content = await blockBlobClient.downloadToBuffer();
879
882
  */
880
- declare class MockContainerClient implements Except<ContainerClient, "accountName"> {
883
+ export declare class MockContainerClient implements Except<ContainerClient, "accountName"> {
881
884
  #private;
882
885
  connectionString: string;
883
886
  containerName: string;
@@ -919,7 +922,7 @@ declare class MockContainerClient implements Except<ContainerClient, "accountNam
919
922
  * It uses a Map to simulate event grid storage and correctly implements the EventGridPublisherClient interface.
920
923
  * `client` is excluded because it is a private member of the real class and cannot be satisfied structurally.
921
924
  */
922
- declare class MockEventGridPublisherClient implements Except<EventGridPublisherClient<"EventGrid">, "apiVersion"> {
925
+ export declare class MockEventGridPublisherClient implements Except<EventGridPublisherClient<"EventGrid">, "apiVersion"> {
923
926
  readonly endpointUrl: string;
924
927
  readonly inputSchema: "EventGrid";
925
928
  readonly topicType: "EventGrid";
@@ -936,7 +939,7 @@ declare class MockEventGridPublisherClient implements Except<EventGridPublisherC
936
939
  * await mockQueueClient.sendMessage("hello world");
937
940
  * const messages = await mockQueueClient.peekMessages();
938
941
  */
939
- declare class MockQueueClient implements Except<QueueClient, "accountName"> {
942
+ export declare class MockQueueClient implements Except<QueueClient, "accountName"> {
940
943
  connectionString: string;
941
944
  name: string;
942
945
  url: string;
@@ -973,7 +976,7 @@ declare class MockQueueClient implements Except<QueueClient, "accountName"> {
973
976
  * await mockSearchClient.uploadDocuments([{ ... }]);
974
977
  * const { count, results } = await mockSearchClient.search("*", { filter, includeTotalCount: true });
975
978
  */
976
- declare class MockSearchClient<TModel extends object = Record<string, unknown>> implements Except<SearchClient<TModel>, "pipeline"> {
979
+ export declare class MockSearchClient<TModel extends object = Record<string, unknown>> implements Except<SearchClient<TModel>, "pipeline"> {
977
980
  readonly apiVersion: string;
978
981
  readonly endpoint: string;
979
982
  readonly indexName: string;
@@ -1000,7 +1003,7 @@ declare class MockSearchClient<TModel extends object = Record<string, unknown>>
1000
1003
  * const mockServiceBusSender = new MockServiceBusSender("hello world");
1001
1004
  * await mockServiceBusSender.scheduleMessages({ body: "hello world" }, new Date());
1002
1005
  */
1003
- declare class MockServiceBusSender implements ServiceBusSender {
1006
+ export declare class MockServiceBusSender implements ServiceBusSender {
1004
1007
  entityPath: string;
1005
1008
  identifier: string;
1006
1009
  isClosed: boolean;
@@ -1021,7 +1024,7 @@ declare class MockServiceBusSender implements ServiceBusSender {
1021
1024
  * await mockTableClient.createEntity({ partitionKey: "partitionKey", rowKey: "rowKey" });
1022
1025
  * const entity = await mockTableClient.getEntity("partitionKey", "rowKey");
1023
1026
  */
1024
- declare class MockTableClient<TEntity extends TableEntity = TableEntity> implements Except<TableClient, "pipeline"> {
1027
+ export declare class MockTableClient<TEntity extends TableEntity = TableEntity> implements Except<TableClient, "pipeline"> {
1025
1028
  #private;
1026
1029
  entityType: TEntity;
1027
1030
  tableName: string;
@@ -1046,38 +1049,45 @@ declare class MockTableClient<TEntity extends TableEntity = TableEntity> impleme
1046
1049
  * A minimal mock of the Azure WebPubSubServiceClient for testing purposes.
1047
1050
  * Only implements `group().sendToAll` — the only method used in azure-functions tests.
1048
1051
  */
1049
- declare class MockWebPubSubServiceClient {
1052
+ export declare class MockWebPubSubServiceClient {
1050
1053
  group(_groupName: string): {
1051
1054
  sendToAll: () => Promise<void>;
1052
1055
  };
1053
1056
  }
1054
- declare const bodyToBuffer: (body: HttpRequestBody) => Promise<Buffer>;
1057
+ export declare const bodyToBuffer: (body: HttpRequestBody) => Promise<Buffer>;
1055
1058
  /**
1056
1059
  * Generates a standard Azure Storage error XML response body.
1057
1060
  * @param errorCode The official Azure error code (e.g., "BlobNotFound").
1058
1061
  * @param errorMessage The user-friendly error message.
1059
1062
  * @returns A formatted XML string.
1060
1063
  */
1061
- declare const getAzureErrorXml: (errorCode: string, errorMessage: string) => string;
1062
- declare const getBlobItemXml: ({ name, properties }: BlobItem) => string;
1063
- declare const getBlobPrefixXml: (name: string) => string;
1064
- declare const getBlobUrl: (containerName: string, blobName: string) => string;
1065
- declare const getBlobUrlParts: (url: string) => undefined | {
1064
+ export declare const getAzureErrorXml: (errorCode: string, errorMessage: string) => string;
1065
+ export declare const getBlobItemXml: ({ name, properties }: BlobItem) => string;
1066
+ export declare const getBlobPrefixXml: (name: string) => string;
1067
+ export declare const getBlobUrl: (containerName: string, blobName: string) => string;
1068
+ export declare const getBlobUrlParts: (url: string) => undefined | {
1066
1069
  blobName: string;
1067
1070
  containerName: string;
1068
1071
  };
1072
+ export declare const getListBlobsSegmentResponse: (containerName: string, prefix: string, segment: BlobHierarchyListSegment, blobsXml: string) => ContainerListBlobHierarchySegmentResponse;
1069
1073
  /**
1070
1074
  * Generates a standard Azure Storage list blobs XML response body.
1071
1075
  * @param containerName The container name.
1072
1076
  * @param blobsXml The blobs xml data.
1073
1077
  * @returns A formatted XML string.
1074
1078
  */
1075
- declare const getListBlobsXml: (containerName: string, blobsXml: string) => string;
1076
- declare const isReadableStream: (value: unknown) => value is NodeJS.ReadableStream;
1077
- declare const toWebResourceLike: (request: PipelineRequest) => WebResourceLike;
1078
- declare const applyFilter: <T extends Record<string, unknown>>(documents: T[], clauses: Clause<T>[]) => T[];
1079
- declare const compare: <T>(operator: BinaryOperator, leftHandSide: T, rightHandSide: null | T) => boolean;
1080
- declare const createFilterPredicate: (filter: string) => ((document: Record<string, unknown>) => boolean);
1081
- declare const isNullClause: (clause: Clause<Record<string, unknown>>) => boolean;
1082
- declare const compareByCompositeKey: (a: TableEntity, b: TableEntity) => number;
1083
- export { 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, getListBlobsXml, getMockContainerCreatedOnKey, getMockSasUrl, isNullClause, isReadableStream, toWebResourceLike };
1079
+ export declare const getListBlobsXml: (containerName: string, blobsXml: string) => string;
1080
+ export declare const getMockContainer: (containerName: string) => MapValue<typeof MockContainerDatabase>;
1081
+ export declare const isReadableStream: (value: unknown) => value is NodeJS.ReadableStream;
1082
+ export declare const toWebResourceLike: (request: PipelineRequest) => WebResourceLike;
1083
+ export declare const applyFilter: <T extends Record<string, unknown>>(documents: T[], clauses: Clause<T>[]) => T[];
1084
+ export declare const compare: <T>(operator: BinaryOperator, leftHandSide: T, rightHandSide: null | T) => boolean;
1085
+ export declare const createFilterPredicate: (filter: string) => ((document: Record<string, unknown>) => boolean);
1086
+ export declare const isNullClause: (clause: Clause<Record<string, unknown>>) => boolean;
1087
+ export declare const getMockQueueMessageItem: (messageText: string) => {
1088
+ expiresOn: Date;
1089
+ insertedOn: Date;
1090
+ messageId: string;
1091
+ messageText: string;
1092
+ };
1093
+ export declare const compareByCompositeKey: (a: TableEntity, b: TableEntity) => number;