azure-mock 2.38.0 → 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.
Files changed (3) hide show
  1. package/dist/index.d.ts +133 -7
  2. package/dist/index.js +153 -94
  3. package/package.json +23 -13
package/dist/index.d.ts CHANGED
@@ -2,27 +2,34 @@ 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
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
- import { BinaryOperator, Clause } from "@esposter/db-schema";
5
+ import { BinaryOperator, Clause } from "@esposter/azure";
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
+ //#region src/constants.d.ts
11
12
  export declare const BLOB_NOT_FOUND_ERROR_CODE = "BlobNotFound";
12
13
  export declare const BLOB_NOT_FOUND_MESSAGE = "The specified blob does not exist.";
13
14
  export declare const MOCK_BLOB_BASE_URL = "https://mockaccount.blob.core.windows.net";
14
15
  export declare const MOCK_QUEUE_BASE_URL = "https://mockaccount.queue.core.windows.net";
15
16
  export declare const MOCK_SEARCH_BASE_URL = "https://mockaccount.search.windows.net";
16
17
  export declare const MOCK_TABLE_BASE_URL = "https://mockaccount.table.core.windows.net";
18
+ //#endregion
19
+ //#region src/models/MockResponse.d.ts
17
20
  export interface MockResponse {
18
21
  headers: HttpHeadersLike;
19
22
  parsedHeaders: Record<string, never>;
20
23
  request: WebResourceLike;
21
24
  status: number;
22
25
  }
26
+ //#endregion
27
+ //#region src/models/MockRestError.d.ts
23
28
  export declare class MockRestError extends RestError {
24
29
  constructor(message: string, statusCode: number);
25
30
  }
31
+ //#endregion
32
+ //#region src/models/PageSettings.d.ts
26
33
  /**
27
34
  * An interface that tracks the settings for paged iteration
28
35
  */
@@ -36,6 +43,8 @@ export interface PageSettings {
36
43
  */
37
44
  maxPageSize?: number;
38
45
  }
46
+ //#endregion
47
+ //#region src/models/PagedAsyncIterableIterator.d.ts
39
48
  /**
40
49
  * An interface that allows async iterable iteration both to completion and by page.
41
50
  */
@@ -53,24 +62,59 @@ export interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageS
53
62
  */
54
63
  next: () => Promise<IteratorResult<TElement>>;
55
64
  }
65
+ //#endregion
66
+ //#region src/services/createMockResponse.d.ts
56
67
  export declare const createMockResponse: (status: number, url?: string) => MockResponse;
68
+ //#endregion
69
+ //#region src/services/getMockSasUrl.d.ts
57
70
  export declare const getMockSasUrl: (url: string, permissions: undefined | {
58
71
  toString: () => string;
59
72
  }, resourceType?: string) => string;
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;
73
+ //#endregion
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;
91
+ //#endregion
92
+ //#region src/store/MockContainerDatabase.d.ts
63
93
  export declare const MockContainerDatabase: Map<string, Map<string, Buffer>>;
94
+ //#endregion
95
+ //#region src/store/MockEventGridDatabase.d.ts
64
96
  export declare const MockEventGridDatabase: Map<string, EventGridEvent<unknown>[]>;
97
+ //#endregion
98
+ //#region src/store/MockQueueDatabase.d.ts
65
99
  export declare const MockQueueDatabase: Map<string, string[]>;
100
+ //#endregion
101
+ //#region src/store/MockSearchDatabase.d.ts
66
102
  export declare const MockSearchDatabase: Map<string, object[]>;
103
+ //#endregion
104
+ //#region src/store/MockServiceBusDatabase.d.ts
67
105
  export declare const MockServiceBusDatabase: Map<string, ServiceBusMessage[]>;
106
+ //#endregion
107
+ //#region src/store/MockTableDatabase.d.ts
68
108
  export declare const MockTableDatabase: Map<string, Map<string, TableEntity>>;
109
+ //#endregion
110
+ //#region src/models/container/BlobHierarchyItem.d.ts
69
111
  export type BlobHierarchyItem = (BlobItem & {
70
112
  kind: "blob";
71
113
  }) | (BlobPrefix & {
72
114
  kind: "prefix";
73
115
  });
116
+ //#endregion
117
+ //#region src/models/container/MockBlobBatchClient.d.ts
74
118
  export declare class MockBlobBatchClient implements BlobBatchClient {
75
119
  #private;
76
120
  url: string;
@@ -84,6 +128,8 @@ export declare class MockBlobBatchClient implements BlobBatchClient {
84
128
  deleteBlobs(urls: string[], credential: AnonymousCredential | StorageSharedKeyCredential, _options?: BlobDeleteOptions): Promise<BlobBatchDeleteBlobsResponse>;
85
129
  getContainer(containerName: string): MapValue<typeof MockContainerDatabase>;
86
130
  }
131
+ //#endregion
132
+ //#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/is-any.d.ts
87
133
  /**
88
134
  Returns a boolean for whether the given type is `any`.
89
135
 
@@ -113,6 +159,8 @@ const anyA = get(anyObject, 'a');
113
159
  @category Utilities
114
160
  */
115
161
  type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
162
+ //#endregion
163
+ //#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/is-optional-key-of.d.ts
116
164
  /**
117
165
  Returns a boolean for whether the given key is an optional key of type.
118
166
 
@@ -154,6 +202,8 @@ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
154
202
  @category Utilities
155
203
  */
156
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;
205
+ //#endregion
206
+ //#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/optional-keys-of.d.ts
157
207
  /**
158
208
  Extract all optional keys from the given type.
159
209
 
@@ -190,6 +240,8 @@ const update2: UpdateOperation<User> = {
190
240
  type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
191
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`
192
242
  : never; // Should never happen
243
+ //#endregion
244
+ //#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/required-keys-of.d.ts
193
245
  /**
194
246
  Extract all required keys from the given type.
195
247
 
@@ -222,6 +274,8 @@ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
222
274
  */
223
275
  type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
224
276
  ? Exclude<keyof Type, OptionalKeysOf<Type>> : never; // Should never happen
277
+ //#endregion
278
+ //#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/is-never.d.ts
225
279
  /**
226
280
  Returns a boolean for whether the given type is `never`.
227
281
 
@@ -276,6 +330,8 @@ type B = IsTrueFixed<never>;
276
330
  @category Utilities
277
331
  */
278
332
  type IsNever<T> = [T] extends [never] ? true : false;
333
+ //#endregion
334
+ //#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/if.d.ts
279
335
  /**
280
336
  An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
281
337
 
@@ -369,6 +425,8 @@ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
369
425
  @category Utilities
370
426
  */
371
427
  type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
428
+ //#endregion
429
+ //#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/simplify.d.ts
372
430
  /**
373
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.
374
432
 
@@ -428,6 +486,8 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
428
486
  @category Object
429
487
  */
430
488
  type Simplify<T> = { [KeyType in keyof T]: T[KeyType]; } & {};
489
+ //#endregion
490
+ //#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/is-equal.d.ts
431
491
  /**
432
492
  Returns a boolean for whether the two given types are equal.
433
493
 
@@ -457,6 +517,8 @@ type Includes<Value extends readonly any[], Item> =
457
517
  type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
458
518
  // This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
459
519
  type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
520
+ //#endregion
521
+ //#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/omit-index-signature.d.ts
460
522
  /**
461
523
  Omit any index signatures from the given object type, leaving only explicitly defined properties.
462
524
 
@@ -549,6 +611,8 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
549
611
  @category Object
550
612
  */
551
613
  type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType]; };
614
+ //#endregion
615
+ //#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/pick-index-signature.d.ts
552
616
  /**
553
617
  Pick only index signatures from the given object type, leaving out all explicitly defined properties.
554
618
 
@@ -595,6 +659,8 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
595
659
  @category Object
596
660
  */
597
661
  type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType]; };
662
+ //#endregion
663
+ //#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/merge.d.ts
598
664
  // Merges two objects without worrying about index signatures.
599
665
  type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key]; } & Source>;
600
666
  /**
@@ -664,6 +730,8 @@ type Merge<Destination, Source> = Destination extends unknown // For distributin
664
730
  ? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>> : never // Should never happen
665
731
  : never; // Should never happen
666
732
  type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
733
+ //#endregion
734
+ //#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/internal/object.d.ts
667
735
  /**
668
736
  Merges user specified options with default options.
669
737
 
@@ -719,6 +787,8 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
719
787
  type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> extends (infer Result extends Required<Options> // `extends Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
720
788
  ) ? Result : never;
721
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]; }>>>;
790
+ //#endregion
791
+ //#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/except.d.ts
722
792
  /**
723
793
  Filter out keys from an object.
724
794
 
@@ -817,6 +887,8 @@ type PostPayloadFixed = Except<UserData, 'email'>;
817
887
  */
818
888
  type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
819
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>> : {});
890
+ //#endregion
891
+ //#region src/models/container/MockBlobClient.d.ts
820
892
  export declare class MockBlobClient implements Except<BlobClient, "accountName"> {
821
893
  connectionString: string;
822
894
  containerName: string;
@@ -857,6 +929,8 @@ export declare class MockBlobClient implements Except<BlobClient, "accountName">
857
929
  withSnapshot(): BlockBlobClient;
858
930
  withVersion(): BlobClient;
859
931
  }
932
+ //#endregion
933
+ //#region src/models/container/MockBlockBlobClient.d.ts
860
934
  export declare class MockBlockBlobClient extends MockBlobClient implements Except<BlockBlobClient, "accountName"> {
861
935
  commitBlockList(): Promise<BlockBlobCommitBlockListResponse>;
862
936
  getBlockList(): Promise<BlockBlobGetBlockListResponse>;
@@ -870,6 +944,8 @@ export declare class MockBlockBlobClient extends MockBlobClient implements Excep
870
944
  uploadFile(): Promise<BlobUploadCommonResponse>;
871
945
  uploadStream(): Promise<BlobUploadCommonResponse>;
872
946
  }
947
+ //#endregion
948
+ //#region src/models/container/MockContainerClient.d.ts
873
949
  /**
874
950
  * An in-memory mock of the Azure ContainerClient — no emulator and no network.
875
951
  *
@@ -916,6 +992,8 @@ export declare class MockContainerClient implements Except<ContainerClient, "acc
916
992
  response: BlockBlobUploadResponse;
917
993
  }>;
918
994
  }
995
+ //#endregion
996
+ //#region src/models/eventGrid/MockEventGridPublisherClient.d.ts
919
997
  /**
920
998
  * An in-memory mock of the Azure EventGridPublisherClient — no emulator and no network.
921
999
  * `client` is excluded because it is a private member of the real class and cannot be satisfied structurally.
@@ -927,6 +1005,8 @@ export declare class MockEventGridPublisherClient implements Except<EventGridPub
927
1005
  constructor(endpoint: string, topicType: "EventGrid");
928
1006
  send(newEvents: EventGridEvent<unknown>[]): Promise<void>;
929
1007
  }
1008
+ //#endregion
1009
+ //#region src/models/queue/MockQueueClient.d.ts
930
1010
  /**
931
1011
  * An in-memory mock of the Azure QueueClient — no emulator and no network.
932
1012
  *
@@ -964,6 +1044,8 @@ export declare class MockQueueClient implements Except<QueueClient, "accountName
964
1044
  setMetadata(): Promise<QueueSetMetadataResponse>;
965
1045
  updateMessage(): Promise<QueueUpdateMessageResponse>;
966
1046
  }
1047
+ //#endregion
1048
+ //#region src/models/search/MockSearchClient.d.ts
967
1049
  /**
968
1050
  * An in-memory mock of the Azure SearchClient — no emulator and no network. It applies the same OData filtering
969
1051
  * as the other mock clients, so a query behaves the same here as it does against the service.
@@ -992,6 +1074,8 @@ export declare class MockSearchClient<TModel extends object = Record<string, unk
992
1074
  suggest<TFields extends SelectFields<TModel> = never>(_searchText: string, _suggesterName: string, _options?: SuggestOptions<TModel, TFields>): Promise<SuggestDocumentsResult<TModel, TFields>>;
993
1075
  uploadDocuments(documents: TModel[], _options?: UploadDocumentsOptions): Promise<IndexDocumentsResult>;
994
1076
  }
1077
+ //#endregion
1078
+ //#region src/models/serviceBus/MockServiceBusSender.d.ts
995
1079
  /**
996
1080
  * An in-memory mock of the Azure ServiceBusSender — no emulator and no network.
997
1081
  *
@@ -1011,6 +1095,8 @@ export declare class MockServiceBusSender implements ServiceBusSender {
1011
1095
  scheduleMessages(messages: ServiceBusMessage | ServiceBusMessage[], scheduledEnqueueTimeUtc: Date): Promise<never[]>;
1012
1096
  sendMessages(messages: ServiceBusMessage | ServiceBusMessage[] | ServiceBusMessageBatch): Promise<void>;
1013
1097
  }
1098
+ //#endregion
1099
+ //#region src/models/table/MockTableClient.d.ts
1014
1100
  /**
1015
1101
  * An in-memory mock of the Azure TableClient — no emulator and no network.
1016
1102
  *
@@ -1040,6 +1126,8 @@ export declare class MockTableClient<TEntity extends TableEntity = TableEntity>
1040
1126
  }): Promise<TableMergeEntityHeaders>;
1041
1127
  upsertEntity<T extends object>(entity: TableEntity<T>, mode?: UpdateMode): Promise<TableMergeEntityHeaders>;
1042
1128
  }
1129
+ //#endregion
1130
+ //#region src/models/webPubSub/MockWebPubSubServiceClient.d.ts
1043
1131
  /**
1044
1132
  * A minimal mock of the Azure WebPubSubServiceClient for testing purposes.
1045
1133
  * Only implements `group().sendToAll` — the only method used in azure-functions tests.
@@ -1049,7 +1137,17 @@ export declare class MockWebPubSubServiceClient {
1049
1137
  sendToAll: () => Promise<void>;
1050
1138
  };
1051
1139
  }
1140
+ //#endregion
1141
+ //#region src/services/container/bodyToBuffer.d.ts
1052
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;
1149
+ //#endregion
1150
+ //#region src/services/container/getAzureErrorXml.d.ts
1053
1151
  /**
1054
1152
  * Generates a standard Azure Storage error XML response body.
1055
1153
  * @param errorCode The official Azure error code (e.g., "BlobNotFound").
@@ -1057,14 +1155,26 @@ export declare const bodyToBuffer: (body: HttpRequestBody) => Promise<Buffer>;
1057
1155
  * @returns A formatted XML string.
1058
1156
  */
1059
1157
  export declare const getAzureErrorXml: (errorCode: string, errorMessage: string) => string;
1158
+ //#endregion
1159
+ //#region src/services/container/getBlobItemXml.d.ts
1060
1160
  export declare const getBlobItemXml: ({ name, properties }: BlobItem) => string;
1161
+ //#endregion
1162
+ //#region src/services/container/getBlobPrefixXml.d.ts
1061
1163
  export declare const getBlobPrefixXml: (name: string) => string;
1164
+ //#endregion
1165
+ //#region src/services/container/getBlobUrl.d.ts
1062
1166
  export declare const getBlobUrl: (containerName: string, blobName: string) => string;
1167
+ //#endregion
1168
+ //#region src/services/container/getBlobUrlParts.d.ts
1063
1169
  export declare const getBlobUrlParts: (url: string) => undefined | {
1064
1170
  blobName: string;
1065
1171
  containerName: string;
1066
1172
  };
1173
+ //#endregion
1174
+ //#region src/services/container/getListBlobsSegmentResponse.d.ts
1067
1175
  export declare const getListBlobsSegmentResponse: (containerName: string, prefix: string, segment: BlobHierarchyListSegment, blobsXml: string) => ContainerListBlobHierarchySegmentResponse;
1176
+ //#endregion
1177
+ //#region src/services/container/getListBlobsXml.d.ts
1068
1178
  /**
1069
1179
  * Generates a standard Azure Storage list blobs XML response body.
1070
1180
  * @param containerName The container name.
@@ -1072,17 +1182,33 @@ export declare const getListBlobsSegmentResponse: (containerName: string, prefix
1072
1182
  * @returns A formatted XML string.
1073
1183
  */
1074
1184
  export declare const getListBlobsXml: (containerName: string, blobsXml: string) => string;
1185
+ //#endregion
1186
+ //#region src/services/container/getMockContainer.d.ts
1075
1187
  export declare const getMockContainer: (containerName: string) => MapValue<typeof MockContainerDatabase>;
1076
- export declare const isReadableStream: (value: unknown) => value is NodeJS.ReadableStream;
1188
+ //#endregion
1189
+ //#region src/services/container/toWebResourceLike.d.ts
1077
1190
  export declare const toWebResourceLike: (request: PipelineRequest) => WebResourceLike;
1191
+ //#endregion
1192
+ //#region src/services/filter/applyFilter.d.ts
1078
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;
1197
+ //#endregion
1198
+ //#region src/services/filter/compare.d.ts
1079
1199
  export declare const compare: <T>(operator: BinaryOperator, leftHandSide: T, rightHandSide: null | T) => boolean;
1200
+ //#endregion
1201
+ //#region src/services/filter/createFilterPredicate.d.ts
1080
1202
  export declare const createFilterPredicate: (filter: string) => ((document: Record<string, unknown>) => boolean);
1081
- export declare const isNullClause: (clause: Clause<Record<string, unknown>>) => boolean;
1203
+ //#endregion
1204
+ //#region src/services/queue/getMockQueueMessageItem.d.ts
1082
1205
  export declare const getMockQueueMessageItem: (messageText: string) => {
1083
1206
  expiresOn: Date;
1084
1207
  insertedOn: Date;
1085
1208
  messageId: string;
1086
1209
  messageText: string;
1087
1210
  };
1088
- export declare const compareByCompositeKey: (a: TableEntity, b: TableEntity) => number;
1211
+ //#endregion
1212
+ //#region src/services/table/compareByCompositeKey.d.ts
1213
+ export declare const compareByCompositeKey: (firstEntity: TableEntity, secondEntity: TableEntity) => number;
1214
+ //#endregion
package/dist/index.js CHANGED
@@ -3,41 +3,25 @@ import { toHttpHeadersLike } from "@azure/core-http-compat";
3
3
  import { ID_SEPARATOR, InvalidOperationError, Operation, chunk, exhaustiveGuard, getDecodedUriComponent, getOrCreate, getResult, html, noop, streamToText, takeOne } from "@esposter/shared";
4
4
  import { AnonymousCredential } from "@azure/storage-blob";
5
5
  import { Readable } from "node:stream";
6
- import { MAX_QUEUE_VISIBILITY_TIMEOUT_MS, deserializeClause, deserializeKey, getTableNullClause, serializeClauses } from "@esposter/db";
7
- import { AZURE_MAX_PAGE_SIZE, BinaryOperator } from "@esposter/db-schema";
8
- var __create = Object.create;
9
- var __defProp = Object.defineProperty;
10
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
- var __getOwnPropNames = Object.getOwnPropertyNames;
12
- var __getProtoOf = Object.getPrototypeOf;
13
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
15
- var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
17
- key = keys[i];
18
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
19
- get: ((k) => from[k]).bind(null, key),
20
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
21
- });
22
- }
23
- return to;
24
- };
25
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: true
28
- }) : target, mod));
6
+ import { AZURE_MAX_PAGE_SIZE, AZURE_MAX_QUEUE_VISIBILITY_TIMEOUT_MS, BinaryOperator, deserializeClause, deserializeKey, getTableNullClause, serializeClauses } from "@esposter/azure";
7
+ import deepEqual from "fast-deep-equal";
8
+ //#region src/constants.ts
29
9
  const BLOB_NOT_FOUND_ERROR_CODE = "BlobNotFound";
30
10
  const BLOB_NOT_FOUND_MESSAGE = "The specified blob does not exist.";
31
11
  const MOCK_BLOB_BASE_URL = "https://mockaccount.blob.core.windows.net";
32
12
  const MOCK_QUEUE_BASE_URL = "https://mockaccount.queue.core.windows.net";
33
13
  const MOCK_SEARCH_BASE_URL = "https://mockaccount.search.windows.net";
34
14
  const MOCK_TABLE_BASE_URL = "https://mockaccount.table.core.windows.net";
15
+ //#endregion
16
+ //#region src/models/MockRestError.ts
35
17
  var MockRestError = class extends RestError {
36
18
  constructor(message, statusCode) {
37
19
  super(message, { statusCode });
38
20
  this.name = "MockRestError";
39
21
  }
40
22
  };
23
+ //#endregion
24
+ //#region src/services/container/toWebResourceLike.ts
41
25
  const toWebResourceLike = (request) => ({
42
26
  abortSignal: request.abortSignal,
43
27
  agent: request.agent,
@@ -63,28 +47,84 @@ const toWebResourceLike = (request) => ({
63
47
  validateRequestProperties: noop,
64
48
  withCredentials: request.withCredentials
65
49
  });
50
+ //#endregion
51
+ //#region src/services/createMockResponse.ts
66
52
  const createMockResponse = (status, url = "") => ({
67
53
  headers: toHttpHeadersLike(createHttpHeaders()),
68
54
  parsedHeaders: {},
69
55
  request: toWebResourceLike(createPipelineRequest({ url })),
70
56
  status
71
57
  });
58
+ //#endregion
59
+ //#region src/services/getMockSasUrl.ts
72
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"}`;
73
- const MockContainerCreatedOnDatabase = /* @__PURE__ */ new Map();
74
- const MOCK_BLOB_SEEDED_CREATED_ON = /* @__PURE__ */ new Date(-864e13);
75
- const getMockContainerCreatedOnKey = (containerName, blobName) => `${containerName}/${blobName}`;
61
+ //#endregion
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));
90
+ //#endregion
91
+ //#region src/store/MockContainerDatabase.ts
76
92
  var MockContainerDatabaseMap = class extends Map {
77
93
  clear() {
78
94
  super.clear();
79
- MockContainerCreatedOnDatabase.clear();
95
+ MockContainerBlobDatesDatabase.clear();
96
+ MockContainerBlobMetadataDatabase.clear();
80
97
  }
81
98
  };
82
99
  const MockContainerDatabase = new MockContainerDatabaseMap();
100
+ //#endregion
101
+ //#region src/store/MockEventGridDatabase.ts
83
102
  const MockEventGridDatabase = /* @__PURE__ */ new Map();
103
+ //#endregion
104
+ //#region src/store/MockQueueDatabase.ts
84
105
  const MockQueueDatabase = /* @__PURE__ */ new Map();
106
+ //#endregion
107
+ //#region src/store/MockSearchDatabase.ts
85
108
  const MockSearchDatabase = /* @__PURE__ */ new Map();
109
+ //#endregion
110
+ //#region src/store/MockServiceBusDatabase.ts
86
111
  const MockServiceBusDatabase = /* @__PURE__ */ new Map();
112
+ //#endregion
113
+ //#region src/store/MockTableDatabase.ts
87
114
  const MockTableDatabase = /* @__PURE__ */ new Map();
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
127
+ //#region src/services/container/getAzureErrorXml.ts
88
128
  /**
89
129
  * Generates a standard Azure Storage error XML response body.
90
130
  * @param errorCode The official Azure error code (e.g., "BlobNotFound").
@@ -96,6 +136,8 @@ const getAzureErrorXml = (errorCode, errorMessage) => html`<?xml version="1.0" e
96
136
  <code>${errorCode}</code>
97
137
  <Message>${errorMessage}</Message>
98
138
  </Error>`;
139
+ //#endregion
140
+ //#region src/services/container/getBlobUrlParts.ts
99
141
  const decodeSegment = (segment) => getDecodedUriComponent(segment, segment);
100
142
  const getBlobUrlParts = (url) => {
101
143
  const parsedUrl = getResult(() => new URL(url)).unwrapOr(void 0);
@@ -107,7 +149,8 @@ const getBlobUrlParts = (url) => {
107
149
  containerName: decodeSegment(takeOne(pathSegments))
108
150
  };
109
151
  };
110
- const getMockContainer = (containerName) => getOrCreate(MockContainerDatabase, containerName, () => /* @__PURE__ */ new Map());
152
+ //#endregion
153
+ //#region src/models/container/MockBlobBatchClient.ts
111
154
  var MockBlobBatchClient = class {
112
155
  url;
113
156
  constructor(url) {
@@ -131,10 +174,7 @@ var MockBlobBatchClient = class {
131
174
  continue;
132
175
  }
133
176
  const { blobName, containerName } = urlParts;
134
- const container = this.getContainer(containerName);
135
- if (container.has(blobName)) {
136
- container.delete(blobName);
137
- MockContainerCreatedOnDatabase.delete(getMockContainerCreatedOnKey(containerName, blobName));
177
+ if (deleteMockBlob(containerName, blobName)) {
138
178
  subResponses.push({
139
179
  _request: {
140
180
  credential,
@@ -180,7 +220,11 @@ var MockBlobBatchClient = class {
180
220
  };
181
221
  }
182
222
  };
223
+ //#endregion
224
+ //#region src/services/container/getBlobUrl.ts
183
225
  const getBlobUrl = (containerName, blobName) => `${MOCK_BLOB_BASE_URL}/${containerName}/${blobName.split("/").map((segment) => encodeURIComponent(segment)).join("/")}`;
226
+ //#endregion
227
+ //#region src/models/container/MockBlobClient.ts
184
228
  var MockBlobClient = class {
185
229
  connectionString;
186
230
  containerName;
@@ -207,8 +251,8 @@ var MockBlobClient = class {
207
251
  if (!sourceContainer) throw new MockRestError("Source container not found", 404);
208
252
  const sourceData = sourceContainer.get(sourceBlobName);
209
253
  if (!sourceData) throw new MockRestError("Source blob not found", 404);
254
+ storeMockBlobWrite(this.containerName, this.name, this.container.has(this.name));
210
255
  this.container.set(this.name, Buffer.from(sourceData));
211
- MockContainerCreatedOnDatabase.set(getMockContainerCreatedOnKey(this.containerName, this.name), /* @__PURE__ */ new Date());
212
256
  const response = { _response: createMockResponse(202, `${this.url}?comp=copy`) };
213
257
  return Promise.resolve({
214
258
  cancelOperation: () => Promise.resolve(),
@@ -231,14 +275,14 @@ var MockBlobClient = class {
231
275
  delete() {
232
276
  if (!this.container.has(this.name)) throw new MockRestError(BLOB_NOT_FOUND_MESSAGE, 404);
233
277
  this.container.delete(this.name);
234
- MockContainerCreatedOnDatabase.delete(getMockContainerCreatedOnKey(this.containerName, this.name));
278
+ MockContainerBlobDatesDatabase.delete(getMockContainerBlobDatesKey(this.containerName, this.name));
235
279
  return Promise.resolve({ _response: createMockResponse(200) });
236
280
  }
237
281
  deleteIfExists() {
238
282
  const succeeded = this.container.has(this.name);
239
283
  if (succeeded) {
240
284
  this.container.delete(this.name);
241
- MockContainerCreatedOnDatabase.delete(getMockContainerCreatedOnKey(this.containerName, this.name));
285
+ MockContainerBlobDatesDatabase.delete(getMockContainerBlobDatesKey(this.containerName, this.name));
242
286
  }
243
287
  return Promise.resolve({
244
288
  _response: createMockResponse(succeeded ? 200 : 404),
@@ -299,7 +343,7 @@ var MockBlobClient = class {
299
343
  return Promise.resolve({
300
344
  _response: createMockResponse(200),
301
345
  contentLength: blob.byteLength,
302
- createdOn: MockContainerCreatedOnDatabase.get(getMockContainerCreatedOnKey(this.containerName, this.name))
346
+ ...readMockBlobDates(this.containerName, this.name)
303
347
  });
304
348
  }
305
349
  getTags() {
@@ -336,7 +380,11 @@ var MockBlobClient = class {
336
380
  throw new Error("Method not implemented.");
337
381
  }
338
382
  };
339
- const isReadableStream = (value) => value instanceof Readable;
383
+ //#endregion
384
+ //#region src/services/container/checkIsReadableStream.ts
385
+ const checkIsReadableStream = (value) => value instanceof Readable;
386
+ //#endregion
387
+ //#region src/services/container/bodyToBuffer.ts
340
388
  const bodyToBuffer = async (body) => {
341
389
  if (body === null) return Buffer.alloc(0);
342
390
  else if (typeof body === "string") return Buffer.from(body);
@@ -348,7 +396,7 @@ const bodyToBuffer = async (body) => {
348
396
  } else if (body instanceof Blob) {
349
397
  const arrayBuffer = await body.arrayBuffer();
350
398
  return Buffer.from(arrayBuffer);
351
- } else if (isReadableStream(body)) return Buffer.from(await streamToText(body));
399
+ } else if (checkIsReadableStream(body)) return Buffer.from(await streamToText(body));
352
400
  else if (body instanceof ReadableStream) {
353
401
  const reader = body.getReader();
354
402
  const chunks = [];
@@ -364,6 +412,8 @@ const bodyToBuffer = async (body) => {
364
412
  return Buffer.alloc(0);
365
413
  }
366
414
  };
415
+ //#endregion
416
+ //#region src/models/container/MockBlockBlobClient.ts
367
417
  var MockBlockBlobClient = class extends MockBlobClient {
368
418
  commitBlockList() {
369
419
  throw new Error("Method not implemented.");
@@ -386,8 +436,10 @@ var MockBlockBlobClient = class extends MockBlobClient {
386
436
  async upload(body, _contentLength, options) {
387
437
  const buffer = await bodyToBuffer(body);
388
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);
389
442
  this.container.set(this.name, buffer);
390
- MockContainerCreatedOnDatabase.set(getMockContainerCreatedOnKey(this.containerName, this.name), /* @__PURE__ */ new Date());
391
443
  return { _response: createMockResponse(201) };
392
444
  }
393
445
  uploadBrowserData() {
@@ -403,6 +455,8 @@ var MockBlockBlobClient = class extends MockBlobClient {
403
455
  throw new Error("Method not implemented.");
404
456
  }
405
457
  };
458
+ //#endregion
459
+ //#region src/services/container/getBlobItemXml.ts
406
460
  const getBlobItemXml = ({ name, properties }) => html`<Blob>
407
461
  <Name>${name}</Name>
408
462
  <Properties>
@@ -415,7 +469,11 @@ const getBlobItemXml = ({ name, properties }) => html`<Blob>
415
469
  <LeaseState>available</LeaseState>
416
470
  </Properties>
417
471
  </Blob>`;
472
+ //#endregion
473
+ //#region src/services/container/getBlobPrefixXml.ts
418
474
  const getBlobPrefixXml = (name) => html`<BlobPrefix><Name>${name}</Name></BlobPrefix>`;
475
+ //#endregion
476
+ //#region src/services/container/getListBlobsXml.ts
419
477
  /**
420
478
  * Generates a standard Azure Storage list blobs XML response body.
421
479
  * @param containerName The container name.
@@ -427,6 +485,8 @@ const getListBlobsXml = (containerName, blobsXml) => html`<?xml version="1.0" en
427
485
  <Blobs>${blobsXml}</Blobs>
428
486
  <NextMarker />
429
487
  </EnumerationResults>`;
488
+ //#endregion
489
+ //#region src/services/container/getListBlobsSegmentResponse.ts
430
490
  const getListBlobsSegmentResponse = (containerName, prefix, segment, blobsXml) => {
431
491
  const segmentResponse = {
432
492
  containerName,
@@ -444,6 +504,8 @@ const getListBlobsSegmentResponse = (containerName, prefix, segment, blobsXml) =
444
504
  ...segmentResponse
445
505
  };
446
506
  };
507
+ //#endregion
508
+ //#region src/models/container/MockContainerClient.ts
447
509
  /**
448
510
  * An in-memory mock of the Azure ContainerClient — no emulator and no network.
449
511
  *
@@ -476,9 +538,7 @@ var MockContainerClient = class {
476
538
  throw new Error("Method not implemented.");
477
539
  }
478
540
  deleteBlob(blobName) {
479
- if (!this.container.has(blobName)) throw new MockRestError(BLOB_NOT_FOUND_MESSAGE, 404);
480
- this.container.delete(blobName);
481
- MockContainerCreatedOnDatabase.delete(getMockContainerCreatedOnKey(this.containerName, blobName));
541
+ if (!deleteMockBlob(this.containerName, blobName)) throw new MockRestError(BLOB_NOT_FOUND_MESSAGE, 404);
482
542
  return Promise.resolve({ _response: createMockResponse(200, getBlobUrl(this.containerName, blobName)) });
483
543
  }
484
544
  deleteIfExists() {
@@ -594,7 +654,7 @@ var MockContainerClient = class {
594
654
  if (!name.startsWith(prefix)) continue;
595
655
  const nameAfterPrefix = name.slice(prefix.length);
596
656
  const delimiterIndex = nameAfterPrefix.indexOf(delimiter);
597
- if (delimiterIndex === -1) blobsInCurrentLevel.push(this.#getBlobItem(name, buffer));
657
+ if (delimiterIndex === -1) blobsInCurrentLevel.push(this.#getBlobItem(name, buffer, options?.includeMetadata));
598
658
  else {
599
659
  const subprefix = `${prefix}${nameAfterPrefix.slice(0, delimiterIndex + delimiter.length)}`;
600
660
  uniqueSubprefixes.add(subprefix);
@@ -609,17 +669,19 @@ var MockContainerClient = class {
609
669
  ...blobItem
610
670
  });
611
671
  }
612
- #getBlobItem(name, buffer) {
672
+ #getBlobItem(name, buffer, isMetadataIncluded) {
673
+ const { createdOn, etag, lastModified } = readMockBlobDates(this.containerName, name);
613
674
  return {
614
675
  deleted: false,
676
+ ...isMetadataIncluded && { metadata: readMockBlobMetadata(this.containerName, name) },
615
677
  name,
616
678
  properties: {
617
679
  blobType: "BlockBlob",
618
680
  contentLength: buffer.length,
619
681
  contentType: "application/octet-stream",
620
- createdOn: MockContainerCreatedOnDatabase.get(getMockContainerCreatedOnKey(this.containerName, name)) ?? MOCK_BLOB_SEEDED_CREATED_ON,
621
- etag: `"${crypto.randomUUID()}"`,
622
- lastModified: /* @__PURE__ */ new Date(),
682
+ createdOn,
683
+ etag,
684
+ lastModified,
623
685
  leaseState: "available",
624
686
  leaseStatus: "unlocked"
625
687
  },
@@ -630,10 +692,12 @@ var MockContainerClient = class {
630
692
  const prefix = options?.prefix ?? "";
631
693
  for (const [name, buffer] of this.container.entries()) {
632
694
  if (!name.startsWith(prefix)) continue;
633
- yield await Promise.resolve(this.#getBlobItem(name, buffer));
695
+ yield await Promise.resolve(this.#getBlobItem(name, buffer, options?.includeMetadata));
634
696
  }
635
697
  }
636
698
  };
699
+ //#endregion
700
+ //#region src/models/eventGrid/MockEventGridPublisherClient.ts
637
701
  /**
638
702
  * An in-memory mock of the Azure EventGridPublisherClient — no emulator and no network.
639
703
  * `client` is excluded because it is a private member of the real class and cannot be satisfied structurally.
@@ -652,15 +716,19 @@ var MockEventGridPublisherClient = class {
652
716
  return Promise.resolve();
653
717
  }
654
718
  };
719
+ //#endregion
720
+ //#region src/services/queue/getMockQueueMessageItem.ts
655
721
  const getMockQueueMessageItem = (messageText) => {
656
722
  const insertedOn = /* @__PURE__ */ new Date();
657
723
  return {
658
- expiresOn: new Date(insertedOn.getTime() + MAX_QUEUE_VISIBILITY_TIMEOUT_MS),
724
+ expiresOn: new Date(insertedOn.getTime() + AZURE_MAX_QUEUE_VISIBILITY_TIMEOUT_MS),
659
725
  insertedOn,
660
726
  messageId: crypto.randomUUID(),
661
727
  messageText
662
728
  };
663
729
  };
730
+ //#endregion
731
+ //#region src/models/queue/MockQueueClient.ts
664
732
  /**
665
733
  * An in-memory mock of the Azure QueueClient — no emulator and no network.
666
734
  *
@@ -793,6 +861,14 @@ var MockQueueClient = class {
793
861
  throw new Error("Method not implemented.");
794
862
  }
795
863
  };
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
871
+ //#region src/services/filter/compare.ts
796
872
  const compare = (operator, leftHandSide, rightHandSide) => {
797
873
  if (rightHandSide === null || rightHandSide === void 0) {
798
874
  if (operator !== BinaryOperator.eq) throw new InvalidOperationError(Operation.Read, compare.name, JSON.stringify({
@@ -812,44 +888,14 @@ const compare = (operator, leftHandSide, rightHandSide) => {
812
888
  default: return exhaustiveGuard(operator);
813
889
  }
814
890
  };
815
- var import_fast_deep_equal = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
816
- module.exports = function equal(a, b) {
817
- if (a === b) return true;
818
- if (a && b && typeof a == "object" && typeof b == "object") {
819
- if (a.constructor !== b.constructor) return false;
820
- var length, i, keys;
821
- if (Array.isArray(a)) {
822
- length = a.length;
823
- if (length != b.length) return false;
824
- for (i = length; i-- !== 0;) if (!equal(a[i], b[i])) return false;
825
- return true;
826
- }
827
- if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
828
- if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
829
- if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
830
- keys = Object.keys(a);
831
- length = keys.length;
832
- if (length !== Object.keys(b).length) return false;
833
- for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
834
- for (i = length; i-- !== 0;) {
835
- var key = keys[i];
836
- if (!equal(a[key], b[key])) return false;
837
- }
838
- return true;
839
- }
840
- return a !== a && b !== b;
841
- };
842
- })))(), 1);
843
- const isNullClause = (clause) => {
844
- const tableNullClause = getTableNullClause(clause.key);
845
- return (0, import_fast_deep_equal.default)(clause, tableNullClause);
846
- };
891
+ //#endregion
892
+ //#region src/services/filter/createFilterPredicate.ts
847
893
  const createFilterPredicate = (filter) => {
848
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) => {
849
895
  const clause = deserializeClause(clauseString);
850
896
  return {
851
897
  clause,
852
- isNull: isNullClause(clause)
898
+ isNull: checkIsNullClause(clause)
853
899
  };
854
900
  }));
855
901
  return (document) => {
@@ -873,16 +919,18 @@ const createFilterPredicate = (filter) => {
873
919
  return true;
874
920
  };
875
921
  };
922
+ //#endregion
923
+ //#region src/models/search/MockSearchClient.ts
876
924
  const toComparable = (value) => {
877
925
  if (value instanceof Date) return value.getTime();
878
926
  else if (typeof value === "number" || typeof value === "string") return value;
879
927
  else return String(value);
880
928
  };
881
- const compareValues = (leftHandSide, rightHandSide) => {
882
- const left = toComparable(leftHandSide);
883
- const right = toComparable(rightHandSide);
884
- if (typeof left === "number" && typeof right === "number") return left - right;
885
- return String(left).localeCompare(String(right));
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));
886
934
  };
887
935
  const sortDocuments = (documents, orderBy) => {
888
936
  const parsedOrderBy = orderBy.map((clause) => {
@@ -892,9 +940,9 @@ const sortDocuments = (documents, orderBy) => {
892
940
  key: deserializeKey(field)
893
941
  };
894
942
  });
895
- return documents.toSorted((leftHandSide, rightHandSide) => {
943
+ return documents.toSorted((firstDocument, secondDocument) => {
896
944
  for (const { direction, key } of parsedOrderBy) {
897
- const comparison = compareValues(leftHandSide[key], rightHandSide[key]);
945
+ const comparison = compareValues(firstDocument[key], secondDocument[key]);
898
946
  if (comparison !== 0) return direction === "desc" ? -comparison : comparison;
899
947
  }
900
948
  return 0;
@@ -980,6 +1028,8 @@ var MockSearchClient = class {
980
1028
  return Promise.resolve({ results: [] });
981
1029
  }
982
1030
  };
1031
+ //#endregion
1032
+ //#region src/models/serviceBus/MockServiceBusSender.ts
983
1033
  /**
984
1034
  * An in-memory mock of the Azure ServiceBusSender — no emulator and no network.
985
1035
  *
@@ -1021,11 +1071,15 @@ var MockServiceBusSender = class {
1021
1071
  return Promise.resolve();
1022
1072
  }
1023
1073
  };
1024
- const compareByCompositeKey = (a, b) => {
1025
- if (a.partitionKey !== b.partitionKey) return a.partitionKey < b.partitionKey ? -1 : 1;
1026
- else if (a.rowKey === b.rowKey) return 0;
1027
- else return a.rowKey < b.rowKey ? -1 : 1;
1074
+ //#endregion
1075
+ //#region src/services/table/compareByCompositeKey.ts
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;
1028
1080
  };
1081
+ //#endregion
1082
+ //#region src/models/table/MockTableClient.ts
1029
1083
  /**
1030
1084
  * An in-memory mock of the Azure TableClient — no emulator and no network.
1031
1085
  *
@@ -1203,6 +1257,8 @@ var MockTableClient = class {
1203
1257
  };
1204
1258
  }
1205
1259
  };
1260
+ //#endregion
1261
+ //#region src/models/webPubSub/MockWebPubSubServiceClient.ts
1206
1262
  /**
1207
1263
  * A minimal mock of the Azure WebPubSubServiceClient for testing purposes.
1208
1264
  * Only implements `group().sendToAll` — the only method used in azure-functions tests.
@@ -1212,8 +1268,11 @@ var MockWebPubSubServiceClient = class {
1212
1268
  return { sendToAll: () => Promise.resolve() };
1213
1269
  }
1214
1270
  };
1271
+ //#endregion
1272
+ //#region src/services/filter/applyFilter.ts
1215
1273
  const applyFilter = (documents, clauses) => {
1216
1274
  const predicate = createFilterPredicate(serializeClauses(clauses));
1217
1275
  return documents.filter((document) => predicate(document));
1218
1276
  };
1219
- export { BLOB_NOT_FOUND_ERROR_CODE, BLOB_NOT_FOUND_MESSAGE, 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, MockRestError, MockSearchClient, MockSearchDatabase, MockServiceBusDatabase, MockServiceBusSender, MockTableClient, MockTableDatabase, MockWebPubSubServiceClient, applyFilter, bodyToBuffer, compare, compareByCompositeKey, createFilterPredicate, createMockResponse, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, getBlobUrl, getBlobUrlParts, getListBlobsSegmentResponse, getListBlobsXml, getMockContainer, getMockContainerCreatedOnKey, getMockQueueMessageItem, getMockSasUrl, isNullClause, isReadableStream, toWebResourceLike };
1277
+ //#endregion
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.38.0",
3
+ "version": "2.39.0",
4
4
  "description": "A library that contains azure mock classes.",
5
5
  "keywords": [
6
6
  "azure",
@@ -31,32 +31,39 @@
31
31
  "dist"
32
32
  ],
33
33
  "type": "module",
34
- "main": "dist/index.js",
34
+ "sideEffects": false,
35
35
  "types": "dist/index.d.ts",
36
+ "imports": {
37
+ "#src/*": "./src/*.ts"
38
+ },
39
+ "exports": {
40
+ ".": "./dist/index.js",
41
+ "./package.json": "./package.json"
42
+ },
36
43
  "publishConfig": {
37
44
  "access": "public"
38
45
  },
39
46
  "scripts": {
40
- "build": "pnpm export:gen && rolldown --config rolldown.config.ts",
41
- "export:gen": "ctix build --config ../configuration/.ctirc-ts",
47
+ "build": "tsdown",
48
+ "export:gen": "generate-exports",
42
49
  "format": "oxfmt",
43
50
  "format:check": "oxfmt --check",
44
51
  "lint": "eslint .",
45
52
  "lint:fix": "eslint --fix .",
46
53
  "test": "vitest",
47
- "typecheck": "tsgo"
54
+ "typecheck": "tsc"
48
55
  },
49
56
  "dependencies": {
50
- "@esposter/db": "2.38.0",
51
- "@esposter/db-schema": "2.38.0",
52
- "@esposter/shared": "2.38.0",
57
+ "@esposter/azure": "2.39.0",
58
+ "@esposter/shared": "2.39.0",
53
59
  "fast-deep-equal": "^3.1.3"
54
60
  },
55
61
  "devDependencies": {
56
- "@esposter/configuration": "2.38.0",
57
- "ctix": "^2.8.2",
58
- "rolldown": "^1.2.5",
59
- "type-fest": "^5.8.0",
62
+ "@arethetypeswrong/core": "^0.18.5",
63
+ "@esposter/configuration": "2.39.0",
64
+ "publint": "^0.3.24",
65
+ "tsdown": "^0.23.0",
66
+ "type-fest": "^5.9.0",
60
67
  "typedoc": "^0.28.20",
61
68
  "vitest": "^4.1.11"
62
69
  },
@@ -70,5 +77,8 @@
70
77
  "@azure/storage-blob": "^12.33.0",
71
78
  "@azure/storage-queue": "^12.31.0"
72
79
  },
73
- "gitHead": "41f54a9cc8f41c4c1d2ee1fa3214d144ee52c4ad"
80
+ "inlinedDependencies": {
81
+ "type-fest": "5.9.0"
82
+ },
83
+ "gitHead": "98f89a176510bb274865731121f990e48c6d056a"
74
84
  }