azure-mock 2.16.0 → 2.18.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,19 +1,70 @@
1
1
  import { MapValue } from "@esposter/shared";
2
2
  import { BinaryOperator, Clause } from "@esposter/db-schema";
3
- import { AnonymousCredential, AppendBlobClient, BlobAbortCopyFromURLResponse, BlobBatchClient, BlobBatchDeleteBlobsResponse, BlobBeginCopyFromURLResponse, BlobClient, BlobCopyFromURLResponse, BlobCreateSnapshotResponse, BlobDeleteIfExistsResponse, BlobDeleteImmutabilityPolicyResponse, BlobDeleteOptions, BlobDeleteResponse, BlobDownloadResponseModel, BlobDownloadResponseParsed, BlobGetAccountInfoResponse, BlobGetPropertiesResponse, BlobGetTagsResponse, BlobItem, BlobLeaseClient, BlobPrefix, BlobSetHTTPHeadersResponse, BlobSetImmutabilityPolicyResponse, BlobSetLegalHoldResponse, BlobSetMetadataResponse, BlobSetTagsResponse, BlobSetTierResponse, BlobUndeleteResponse, BlobUploadCommonResponse, BlockBlobClient, BlockBlobCommitBlockListResponse, BlockBlobGetBlockListResponse, BlockBlobPutBlobFromUrlResponse, BlockBlobStageBlockFromURLResponse, BlockBlobStageBlockResponse, BlockBlobUploadResponse, ContainerClient, ContainerCreateIfNotExistsResponse, ContainerCreateResponse, ContainerDeleteIfExistsResponse, ContainerDeleteResponse, ContainerFindBlobsByTagsSegmentResponse, ContainerGetAccessPolicyResponse, ContainerGetAccountInfoResponse, ContainerGetPropertiesResponse, ContainerListBlobFlatSegmentResponse, ContainerListBlobHierarchySegmentResponse, ContainerListBlobsOptions, ContainerSetAccessPolicyResponse, ContainerSetMetadataResponse, FilterBlobItem, HttpRequestBody, PageBlobClient, PollOperationState, PollerLikeWithCancellation, StorageSharedKeyCredential } from "@azure/storage-blob";
3
+ import { EventGridEvent, EventGridPublisherClient } from "@azure/eventgrid";
4
4
  import { CreateTableEntityResponse, GetAccessPolicyResponse, GetTableEntityResponse, ListTableEntitiesOptions, TableClient, TableDeleteEntityHeaders, TableEntity, TableEntityResult, TableEntityResultPage, TableMergeEntityHeaders, TableSetAccessPolicyHeaders, TableTransactionResponse, UpdateMode } from "@azure/data-tables";
5
+ import { AnonymousCredential, AppendBlobClient, BlobAbortCopyFromURLResponse, BlobBatchClient, BlobBatchDeleteBlobsResponse, BlobBeginCopyFromURLResponse, BlobClient, BlobCopyFromURLResponse, BlobCreateSnapshotResponse, BlobDeleteIfExistsResponse, BlobDeleteImmutabilityPolicyResponse, BlobDeleteOptions, BlobDeleteResponse, BlobDownloadResponseModel, BlobDownloadResponseParsed, BlobGetAccountInfoResponse, BlobGetPropertiesResponse, BlobGetTagsResponse, BlobItem, BlobLeaseClient, BlobPrefix, BlobSetHTTPHeadersResponse, BlobSetImmutabilityPolicyResponse, BlobSetLegalHoldResponse, BlobSetMetadataResponse, BlobSetTagsResponse, BlobSetTierResponse, BlobUndeleteResponse, BlobUploadCommonResponse, BlockBlobClient, BlockBlobCommitBlockListResponse, BlockBlobGetBlockListResponse, BlockBlobPutBlobFromUrlResponse, BlockBlobStageBlockFromURLResponse, BlockBlobStageBlockResponse, BlockBlobUploadResponse, ContainerClient, ContainerCreateIfNotExistsResponse, ContainerCreateResponse, ContainerDeleteIfExistsResponse, ContainerDeleteResponse, ContainerFindBlobsByTagsSegmentResponse, ContainerGetAccessPolicyResponse, ContainerGetAccountInfoResponse, ContainerGetPropertiesResponse, ContainerListBlobFlatSegmentResponse, ContainerListBlobHierarchySegmentResponse, ContainerListBlobsOptions, ContainerSetAccessPolicyResponse, ContainerSetMetadataResponse, FilterBlobItem, HttpRequestBody, PageBlobClient, PollOperationState, PollerLikeWithCancellation, StorageSharedKeyCredential } from "@azure/storage-blob";
6
+ import { QueueClearMessagesResponse, QueueClient, QueueCreateIfNotExistsResponse, QueueCreateOptions, QueueCreateResponse, QueueDeleteIfExistsResponse, QueueDeleteMessageResponse, QueueDeleteResponse, QueueGetAccessPolicyResponse, QueueGetPropertiesResponse, QueueItem, QueuePeekMessagesOptions, QueuePeekMessagesResponse, QueueReceiveMessageOptions, QueueReceiveMessageResponse, QueueSendMessageOptions, QueueSendMessageResponse, QueueServiceProperties, QueueSetAccessPolicyResponse, QueueSetMetadataResponse, QueueUpdateMessageResponse, SignedIdentifier } from "@azure/storage-queue";
5
7
 
6
- //#region src/models/BlobHierarchyItem.d.ts
8
+ //#region src/models/MockRestError.d.ts
9
+ declare class MockRestError extends Error {
10
+ statusCode: number;
11
+ constructor(message: string, statusCode: number);
12
+ }
13
+ //#endregion
14
+ //#region src/models/PageSettings.d.ts
15
+ /**
16
+ * An interface that tracks the settings for paged iteration
17
+ */
18
+ interface PageSettings {
19
+ /**
20
+ * The token that keeps track of where to continue the iterator
21
+ */
22
+ continuationToken?: string;
23
+ /**
24
+ * The size of the page during paged iteration
25
+ */
26
+ maxPageSize?: number;
27
+ }
28
+ //#endregion
29
+ //#region src/models/PagedAsyncIterableIterator.d.ts
30
+ /**
31
+ * An interface that allows async iterable iteration both to completion and by page.
32
+ */
33
+ interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings = PageSettings> {
34
+ /**
35
+ * The connection to the async iterator, part of the iteration protocol
36
+ */
37
+ [Symbol.asyncIterator](): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
38
+ /**
39
+ * Return an AsyncIterableIterator that works a page at a time
40
+ */
41
+ byPage: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;
42
+ /**
43
+ * The next method, part of the iteration protocol
44
+ */
45
+ next(): Promise<IteratorResult<TElement>>;
46
+ }
47
+ //#endregion
48
+ //#region src/store/MockContainerDatabase.d.ts
49
+ declare const MockContainerDatabase: Map<string, Map<string, Buffer>>;
50
+ //#endregion
51
+ //#region src/store/MockEventGridDatabase.d.ts
52
+ declare const MockEventGridDatabase: Map<string, EventGridEvent<unknown>[]>;
53
+ //#endregion
54
+ //#region src/store/MockQueueDatabase.d.ts
55
+ declare const MockQueueDatabase: Map<string, string[]>;
56
+ //#endregion
57
+ //#region src/store/MockTableDatabase.d.ts
58
+ declare const MockTableDatabase: Map<string, Map<string, TableEntity>>;
59
+ //#endregion
60
+ //#region src/models/container/BlobHierarchyItem.d.ts
7
61
  type BlobHierarchyItem = (BlobItem & {
8
62
  kind: "blob";
9
63
  }) | (BlobPrefix & {
10
64
  kind: "prefix";
11
65
  });
12
66
  //#endregion
13
- //#region src/store/MockContainerDatabase.d.ts
14
- declare const MockContainerDatabase: Map<string, Map<string, Buffer>>;
15
- //#endregion
16
- //#region src/models/MockBlobBatchClient.d.ts
67
+ //#region src/models/container/MockBlobBatchClient.d.ts
17
68
  declare class MockBlobBatchClient implements BlobBatchClient {
18
69
  url: string;
19
70
  constructor(url: string);
@@ -27,7 +78,7 @@ declare class MockBlobBatchClient implements BlobBatchClient {
27
78
  getContainer(containerName: string): MapValue<typeof MockContainerDatabase>;
28
79
  }
29
80
  //#endregion
30
- //#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/is-any.d.ts
81
+ //#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/is-any.d.ts
31
82
  /**
32
83
  Returns a boolean for whether the given type is `any`.
33
84
 
@@ -42,8 +93,8 @@ import type {IsAny} from 'type-fest';
42
93
  const typedObject = {a: 1, b: 2} as const;
43
94
  const anyObject: any = {a: 1, b: 2};
44
95
 
45
- function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
46
- return obj[key];
96
+ function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
97
+ return object[key];
47
98
  }
48
99
 
49
100
  const typedA = get(typedObject, 'a');
@@ -56,9 +107,9 @@ const anyA = get(anyObject, 'a');
56
107
  @category Type Guard
57
108
  @category Utilities
58
109
  */
59
- type IsAny<T$1> = 0 extends 1 & NoInfer<T$1> ? true : false;
110
+ type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
60
111
  //#endregion
61
- //#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/is-optional-key-of.d.ts
112
+ //#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/is-optional-key-of.d.ts
62
113
  /**
63
114
  Returns a boolean for whether the given key is an optional key of type.
64
115
 
@@ -68,17 +119,17 @@ This is useful when writing utility types or schema validators that need to diff
68
119
  ```
69
120
  import type {IsOptionalKeyOf} from 'type-fest';
70
121
 
71
- interface User {
122
+ type User = {
72
123
  name: string;
73
124
  surname: string;
74
125
 
75
126
  luckyNumber?: number;
76
- }
127
+ };
77
128
 
78
- interface Admin {
129
+ type Admin = {
79
130
  name: string;
80
131
  surname?: string;
81
- }
132
+ };
82
133
 
83
134
  type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
84
135
  //=> true
@@ -101,7 +152,7 @@ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
101
152
  */
102
153
  type IsOptionalKeyOf<Type extends object, Key$1 extends keyof Type> = IsAny<Type | Key$1> extends true ? never : Key$1 extends keyof Type ? Type extends Record<Key$1, Type[Key$1]> ? false : true : false;
103
154
  //#endregion
104
- //#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/optional-keys-of.d.ts
155
+ //#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/optional-keys-of.d.ts
105
156
  /**
106
157
  Extract all optional keys from the given type.
107
158
 
@@ -111,12 +162,12 @@ This is useful when you want to create a new type that contains different type v
111
162
  ```
112
163
  import type {OptionalKeysOf, Except} from 'type-fest';
113
164
 
114
- interface User {
165
+ type User = {
115
166
  name: string;
116
167
  surname: string;
117
168
 
118
169
  luckyNumber?: number;
119
- }
170
+ };
120
171
 
121
172
  const REMOVE_FIELD = Symbol('remove field symbol');
122
173
  type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
@@ -124,12 +175,12 @@ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKe
124
175
  };
125
176
 
126
177
  const update1: UpdateOperation<User> = {
127
- name: 'Alice'
178
+ name: 'Alice',
128
179
  };
129
180
 
130
181
  const update2: UpdateOperation<User> = {
131
182
  name: 'Bob',
132
- luckyNumber: REMOVE_FIELD
183
+ luckyNumber: REMOVE_FIELD,
133
184
  };
134
185
  ```
135
186
 
@@ -139,7 +190,7 @@ type OptionalKeysOf<Type extends object> = Type extends unknown // For distribut
139
190
  ? (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`
140
191
  : never;
141
192
  //#endregion
142
- //#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/required-keys-of.d.ts
193
+ //#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/required-keys-of.d.ts
143
194
  /**
144
195
  Extract all required keys from the given type.
145
196
 
@@ -149,17 +200,23 @@ This is useful when you want to create a new type that contains different type v
149
200
  ```
150
201
  import type {RequiredKeysOf} from 'type-fest';
151
202
 
152
- declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
203
+ declare function createValidation<
204
+ Entity extends object,
205
+ Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
206
+ >(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
153
207
 
154
- interface User {
208
+ type User = {
155
209
  name: string;
156
210
  surname: string;
157
-
158
211
  luckyNumber?: number;
159
- }
212
+ };
160
213
 
161
214
  const validator1 = createValidation<User>('name', value => value.length < 25);
162
215
  const validator2 = createValidation<User>('surname', value => value.length < 25);
216
+
217
+ // @ts-expect-error
218
+ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
219
+ // Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
163
220
  ```
164
221
 
165
222
  @category Utilities
@@ -167,7 +224,7 @@ const validator2 = createValidation<User>('surname', value => value.length < 25)
167
224
  type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
168
225
  ? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
169
226
  //#endregion
170
- //#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/is-never.d.ts
227
+ //#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/is-never.d.ts
171
228
  /**
172
229
  Returns a boolean for whether the given type is `never`.
173
230
 
@@ -181,37 +238,49 @@ Useful in type utilities, such as checking if something does not occur.
181
238
  ```
182
239
  import type {IsNever, And} from 'type-fest';
183
240
 
184
- // https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
185
- type AreStringsEqual<A extends string, B extends string> =
186
- And<
187
- IsNever<Exclude<A, B>> extends true ? true : false,
188
- IsNever<Exclude<B, A>> extends true ? true : false
189
- >;
190
-
191
- type EndIfEqual<I extends string, O extends string> =
192
- AreStringsEqual<I, O> extends true
193
- ? never
194
- : void;
195
-
196
- function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
197
- if (input === output) {
198
- process.exit(0);
199
- }
200
- }
241
+ type A = IsNever<never>;
242
+ //=> true
201
243
 
202
- endIfEqual('abc', 'abc');
203
- //=> never
244
+ type B = IsNever<any>;
245
+ //=> false
246
+
247
+ type C = IsNever<unknown>;
248
+ //=> false
204
249
 
205
- endIfEqual('abc', '123');
206
- //=> void
250
+ type D = IsNever<never[]>;
251
+ //=> false
252
+
253
+ type E = IsNever<object>;
254
+ //=> false
255
+
256
+ type F = IsNever<string>;
257
+ //=> false
258
+ ```
259
+
260
+ @example
261
+ ```
262
+ import type {IsNever} from 'type-fest';
263
+
264
+ type IsTrue<T> = T extends true ? true : false;
265
+
266
+ // When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
267
+ type A = IsTrue<never>;
268
+ // ^? type A = never
269
+
270
+ // If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
271
+ type IsTrueFixed<T> =
272
+ IsNever<T> extends true ? false : T extends true ? true : false;
273
+
274
+ type B = IsTrueFixed<never>;
275
+ // ^? type B = false
207
276
  ```
208
277
 
209
278
  @category Type Guard
210
279
  @category Utilities
211
280
  */
212
- type IsNever<T$1> = [T$1] extends [never] ? true : false;
281
+ type IsNever<T> = [T] extends [never] ? true : false;
213
282
  //#endregion
214
- //#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/if.d.ts
283
+ //#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/if.d.ts
215
284
  /**
216
285
  An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
217
286
 
@@ -224,7 +293,7 @@ Note:
224
293
 
225
294
  @example
226
295
  ```
227
- import {If} from 'type-fest';
296
+ import type {If} from 'type-fest';
228
297
 
229
298
  type A = If<true, 'yes', 'no'>;
230
299
  //=> 'yes'
@@ -244,7 +313,7 @@ type E = If<never, 'yes', 'no'>;
244
313
 
245
314
  @example
246
315
  ```
247
- import {If, IsAny, IsNever} from 'type-fest';
316
+ import type {If, IsAny, IsNever} from 'type-fest';
248
317
 
249
318
  type A = If<IsAny<unknown>, 'is any', 'not any'>;
250
319
  //=> 'not any'
@@ -255,7 +324,7 @@ type B = If<IsNever<never>, 'is never', 'not never'>;
255
324
 
256
325
  @example
257
326
  ```
258
- import {If, IsEqual} from 'type-fest';
327
+ import type {If, IsEqual} from 'type-fest';
259
328
 
260
329
  type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
261
330
 
@@ -266,12 +335,47 @@ type B = IfEqual<string, number, 'equal', 'not equal'>;
266
335
  //=> 'not equal'
267
336
  ```
268
337
 
338
+ Note: Sometimes using the `If` type can make an implementation non–tail-recursive, which can impact performance. In such cases, it’s better to use a conditional directly. Refer to the following example:
339
+
340
+ @example
341
+ ```
342
+ import type {If, IsEqual, StringRepeat} from 'type-fest';
343
+
344
+ type HundredZeroes = StringRepeat<'0', 100>;
345
+
346
+ // The following implementation is not tail recursive
347
+ type Includes<S extends string, Char extends string> =
348
+ S extends `${infer First}${infer Rest}`
349
+ ? If<IsEqual<First, Char>,
350
+ 'found',
351
+ Includes<Rest, Char>>
352
+ : 'not found';
353
+
354
+ // Hence, instantiations with long strings will fail
355
+ // @ts-expect-error
356
+ type Fails = Includes<HundredZeroes, '1'>;
357
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
358
+ // Error: Type instantiation is excessively deep and possibly infinite.
359
+
360
+ // However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
361
+ type IncludesWithoutIf<S extends string, Char extends string> =
362
+ S extends `${infer First}${infer Rest}`
363
+ ? IsEqual<First, Char> extends true
364
+ ? 'found'
365
+ : IncludesWithoutIf<Rest, Char>
366
+ : 'not found';
367
+
368
+ // Now, instantiations with long strings will work
369
+ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
370
+ //=> 'not found'
371
+ ```
372
+
269
373
  @category Type Guard
270
374
  @category Utilities
271
375
  */
272
376
  type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
273
377
  //#endregion
274
- //#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/simplify.d.ts
378
+ //#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/simplify.d.ts
275
379
  /**
276
380
  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.
277
381
 
@@ -317,21 +421,22 @@ const literal = {foo: 123, bar: 'hello', baz: 456};
317
421
  const someType: SomeType = literal;
318
422
  const someInterface: SomeInterface = literal;
319
423
 
320
- function fn(object: Record<string, unknown>): void {}
424
+ declare function fn(object: Record<string, unknown>): void;
321
425
 
322
426
  fn(literal); // Good: literal object type is sealed
323
427
  fn(someType); // Good: type is sealed
428
+ // @ts-expect-error
324
429
  fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
325
430
  fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
326
431
  ```
327
432
 
328
433
  @link https://github.com/microsoft/TypeScript/issues/15300
329
- @see SimplifyDeep
434
+ @see {@link SimplifyDeep}
330
435
  @category Object
331
436
  */
332
- type Simplify<T$1> = { [KeyType in keyof T$1]: T$1[KeyType] } & {};
437
+ type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
333
438
  //#endregion
334
- //#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/is-equal.d.ts
439
+ //#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/is-equal.d.ts
335
440
  /**
336
441
  Returns a boolean for whether the two given types are equal.
337
442
 
@@ -358,11 +463,11 @@ type Includes<Value extends readonly any[], Item> =
358
463
  @category Type Guard
359
464
  @category Utilities
360
465
  */
361
- type IsEqual<A, B> = [A, B] extends [infer AA, infer BB] ? [AA] extends [never] ? [BB] extends [never] ? true : false : [BB] extends [never] ? false : _IsEqual<AA, BB> : false;
466
+ type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
362
467
  // This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
363
468
  type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
364
469
  //#endregion
365
- //#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/omit-index-signature.d.ts
470
+ //#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/omit-index-signature.d.ts
366
471
  /**
367
472
  Omit any index signatures from the given object type, leaving only explicitly defined properties.
368
473
 
@@ -380,6 +485,7 @@ It relies on the fact that an empty object (`{}`) is assignable to an object wit
380
485
  ```
381
486
  const indexed: Record<string, unknown> = {}; // Allowed
382
487
 
488
+ // @ts-expect-error
383
489
  const keyed: Record<'foo', unknown> = {}; // Error
384
490
  // => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
385
491
  ```
@@ -393,16 +499,14 @@ type Indexed = {} extends Record<string, unknown>
393
499
  // => '✅ `{}` is assignable to `Record<string, unknown>`'
394
500
 
395
501
  type Keyed = {} extends Record<'foo' | 'bar', unknown>
396
- ? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
397
- : "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
502
+ ? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
503
+ : '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
398
504
  // => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
399
505
  ```
400
506
 
401
507
  Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
402
508
 
403
509
  ```
404
- import type {OmitIndexSignature} from 'type-fest';
405
-
406
510
  type OmitIndexSignature<ObjectType> = {
407
511
  [KeyType in keyof ObjectType // Map each key of `ObjectType`...
408
512
  ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
@@ -412,14 +516,12 @@ type OmitIndexSignature<ObjectType> = {
412
516
  ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
413
517
 
414
518
  ```
415
- import type {OmitIndexSignature} from 'type-fest';
416
-
417
519
  type OmitIndexSignature<ObjectType> = {
418
520
  [KeyType in keyof ObjectType
419
- // Is `{}` assignable to `Record<KeyType, unknown>`?
420
- as {} extends Record<KeyType, unknown>
421
- ? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
422
- : ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
521
+ // Is `{}` assignable to `Record<KeyType, unknown>`?
522
+ as {} extends Record<KeyType, unknown>
523
+ ? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
524
+ : KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
423
525
  ]: ObjectType[KeyType];
424
526
  };
425
527
  ```
@@ -430,32 +532,32 @@ If `{}` is assignable, it means that `KeyType` is an index signature and we want
430
532
  ```
431
533
  import type {OmitIndexSignature} from 'type-fest';
432
534
 
433
- interface Example {
535
+ type Example = {
434
536
  // These index signatures will be removed.
435
- [x: string]: any
436
- [x: number]: any
437
- [x: symbol]: any
438
- [x: `head-${string}`]: string
439
- [x: `${string}-tail`]: string
440
- [x: `head-${string}-tail`]: string
441
- [x: `${bigint}`]: string
442
- [x: `embedded-${number}`]: string
537
+ [x: string]: any;
538
+ [x: number]: any;
539
+ [x: symbol]: any;
540
+ [x: `head-${string}`]: string;
541
+ [x: `${string}-tail`]: string;
542
+ [x: `head-${string}-tail`]: string;
543
+ [x: `${bigint}`]: string;
544
+ [x: `embedded-${number}`]: string;
443
545
 
444
546
  // These explicitly defined keys will remain.
445
547
  foo: 'bar';
446
548
  qux?: 'baz';
447
- }
549
+ };
448
550
 
449
551
  type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
450
552
  // => { foo: 'bar'; qux?: 'baz' | undefined; }
451
553
  ```
452
554
 
453
- @see PickIndexSignature
555
+ @see {@link PickIndexSignature}
454
556
  @category Object
455
557
  */
456
558
  type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
457
559
  //#endregion
458
- //#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/pick-index-signature.d.ts
560
+ //#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/pick-index-signature.d.ts
459
561
  /**
460
562
  Pick only index signatures from the given object type, leaving out all explicitly defined properties.
461
563
 
@@ -498,12 +600,12 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
498
600
  // }
499
601
  ```
500
602
 
501
- @see OmitIndexSignature
603
+ @see {@link OmitIndexSignature}
502
604
  @category Object
503
605
  */
504
606
  type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
505
607
  //#endregion
506
- //#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/merge.d.ts
608
+ //#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/merge.d.ts
507
609
  // Merges two objects without worrying about index signatures.
508
610
  type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
509
611
 
@@ -514,12 +616,12 @@ Merge two types into a new type. Keys of the second type overrides keys of the f
514
616
  ```
515
617
  import type {Merge} from 'type-fest';
516
618
 
517
- interface Foo {
619
+ type Foo = {
518
620
  [x: string]: unknown;
519
621
  [x: number]: unknown;
520
622
  foo: string;
521
623
  bar: symbol;
522
- }
624
+ };
523
625
 
524
626
  type Bar = {
525
627
  [x: number]: number;
@@ -543,8 +645,7 @@ export type FooBar = Merge<Foo, Bar>;
543
645
  */
544
646
  type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
545
647
  //#endregion
546
- //#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/internal/object.d.ts
547
-
648
+ //#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/internal/object.d.ts
548
649
  /**
549
650
  Merges user specified options with default options.
550
651
 
@@ -597,9 +698,9 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
597
698
  // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
598
699
  ```
599
700
  */
600
- type ApplyDefaultOptions<Options$1 extends object, Defaults extends Simplify<Omit<Required<Options$1>, RequiredKeysOf<Options$1>> & Partial<Record<RequiredKeysOf<Options$1>, never>>>, SpecifiedOptions extends Options$1> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options$1> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options$1>>>>;
701
+ type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
601
702
  //#endregion
602
- //#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/except.d.ts
703
+ //#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/except.d.ts
603
704
  /**
604
705
  Filter out keys from an object.
605
706
 
@@ -661,12 +762,14 @@ type Foo = {
661
762
  type FooWithoutA = Except<Foo, 'a'>;
662
763
  //=> {b: string}
663
764
 
765
+ // @ts-expect-error
664
766
  const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
665
767
  //=> errors: 'a' does not exist in type '{ b: string; }'
666
768
 
667
769
  type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
668
770
  //=> {a: number} & Partial<Record<"b", never>>
669
771
 
772
+ // @ts-expect-error
670
773
  const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
671
774
  //=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
672
775
 
@@ -683,20 +786,20 @@ type UserData = {
683
786
 
684
787
  // `Omit` clearly doesn't behave as expected in this case:
685
788
  type PostPayload = Omit<UserData, 'email'>;
686
- //=> type PostPayload = { [x: string]: string; [x: number]: string; }
789
+ //=> { [x: string]: string; [x: number]: string; }
687
790
 
688
791
  // In situations like this, `Except` works better.
689
792
  // It simply removes the `email` key while preserving all the other keys.
690
- type PostPayload = Except<UserData, 'email'>;
691
- //=> type PostPayload = { [x: string]: string; name: string; role: 'admin' | 'user'; }
793
+ type PostPayloadFixed = Except<UserData, 'email'>;
794
+ //=> { [x: string]: string; name: string; role: 'admin' | 'user'; }
692
795
  ```
693
796
 
694
797
  @category Object
695
798
  */
696
- type Except<ObjectType, KeysType extends keyof ObjectType, Options$1 extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options$1>>;
697
- type _Except<ObjectType, KeysType extends keyof ObjectType, Options$1 extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType] } & (Options$1['requireExactProps'] extends true ? Partial<Record<KeysType, never>> : {});
799
+ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
800
+ 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>> : {});
698
801
  //#endregion
699
- //#region src/models/MockBlobClient.d.ts
802
+ //#region src/models/container/MockBlobClient.d.ts
700
803
  declare class MockBlobClient implements Except<BlobClient, "accountName"> {
701
804
  connectionString: string;
702
805
  containerName: string;
@@ -738,7 +841,7 @@ declare class MockBlobClient implements Except<BlobClient, "accountName"> {
738
841
  withVersion(): BlobClient;
739
842
  }
740
843
  //#endregion
741
- //#region src/models/MockBlockBlobClient.d.ts
844
+ //#region src/models/container/MockBlockBlobClient.d.ts
742
845
  declare class MockBlockBlobClient extends MockBlobClient implements Except<BlockBlobClient, "accountName"> {
743
846
  commitBlockList(): Promise<BlockBlobCommitBlockListResponse>;
744
847
  getBlockList(): Promise<BlockBlobGetBlockListResponse>;
@@ -753,41 +856,7 @@ declare class MockBlockBlobClient extends MockBlobClient implements Except<Block
753
856
  uploadStream(): Promise<BlobUploadCommonResponse>;
754
857
  }
755
858
  //#endregion
756
- //#region src/models/PageSettings.d.ts
757
- /**
758
- * An interface that tracks the settings for paged iteration
759
- */
760
- interface PageSettings {
761
- /**
762
- * The token that keeps track of where to continue the iterator
763
- */
764
- continuationToken?: string;
765
- /**
766
- * The size of the page during paged iteration
767
- */
768
- maxPageSize?: number;
769
- }
770
- //#endregion
771
- //#region src/models/PagedAsyncIterableIterator.d.ts
772
- /**
773
- * An interface that allows async iterable iteration both to completion and by page.
774
- */
775
- interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings = PageSettings> {
776
- /**
777
- * The connection to the async iterator, part of the iteration protocol
778
- */
779
- [Symbol.asyncIterator](): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
780
- /**
781
- * Return an AsyncIterableIterator that works a page at a time
782
- */
783
- byPage: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;
784
- /**
785
- * The next method, part of the iteration protocol
786
- */
787
- next(): Promise<IteratorResult<TElement>>;
788
- }
789
- //#endregion
790
- //#region src/models/MockContainerClient.d.ts
859
+ //#region src/models/container/MockContainerClient.d.ts
791
860
  /**
792
861
  * An in-memory mock of the Azure ContainerClient.
793
862
  * It uses a Map to simulate blob storage.
@@ -837,16 +906,57 @@ declare class MockContainerClient implements Except<ContainerClient, "accountNam
837
906
  private getBlobItemIterator;
838
907
  }
839
908
  //#endregion
840
- //#region src/models/MockRestError.d.ts
841
- declare class MockRestError extends Error {
842
- statusCode: number;
843
- constructor(message: string, statusCode: number);
909
+ //#region src/models/eventGrid/MockEventGridPublisherClient.d.ts
910
+ /**
911
+ * An in-memory mock of the Azure EventGridPublisherClient.
912
+ * It uses a Map to simulate event grid storage and correctly implements the EventGridPublisherClient interface.
913
+ */
914
+ declare class MockEventGridPublisherClient implements Except<EventGridPublisherClient<"EventGrid">, "apiVersion" | "endpointUrl"> {
915
+ endpoint: string;
916
+ topicType: "EventGrid";
917
+ constructor(endpoint: string, topicType: "EventGrid");
918
+ send(newEvents: EventGridEvent<unknown>[]): Promise<void>;
844
919
  }
845
920
  //#endregion
846
- //#region src/store/MockTableDatabase.d.ts
847
- declare const MockTableDatabase: Map<string, Map<string, TableEntity>>;
921
+ //#region src/models/queue/MockQueueClient.d.ts
922
+ /**
923
+ * An in-memory mock of the Azure QueueClient.
924
+ * It uses a Map to simulate queue storage and correctly implements the QueueClient interface.
925
+ *
926
+ * @example
927
+ * const mockQueueClient = new MockQueueClient("", "hello world");
928
+ * await mockQueueClient.createIfNotExists();
929
+ * await mockQueueClient.sendMessage("hello world");
930
+ * const messages = await mockQueueClient.peekMessages();
931
+ */
932
+ declare class MockQueueClient implements Except<QueueClient, "accountName"> {
933
+ connectionString: string;
934
+ name: string;
935
+ url: string;
936
+ get queue(): MapValue<typeof MockQueueDatabase>;
937
+ constructor(connectionString: string, queueName: string);
938
+ clearMessages(): Promise<QueueClearMessagesResponse>;
939
+ create(_options?: QueueCreateOptions): Promise<QueueCreateResponse>;
940
+ createIfNotExists(): Promise<QueueCreateIfNotExistsResponse>;
941
+ delete(): Promise<QueueDeleteResponse>;
942
+ deleteIfExists(): Promise<QueueDeleteIfExistsResponse>;
943
+ deleteMessage(): Promise<QueueDeleteMessageResponse>;
944
+ exists(): Promise<boolean>;
945
+ generateSasStringToSign(): string;
946
+ generateSasUrl(): string;
947
+ getAccessPolicy(): Promise<QueueGetAccessPolicyResponse>;
948
+ getProperties(): Promise<QueueGetPropertiesResponse>;
949
+ getServiceProperties(): Promise<QueueServiceProperties>;
950
+ listQueues(): AsyncIterableIterator<QueueItem>;
951
+ peekMessages(_options?: QueuePeekMessagesOptions): Promise<QueuePeekMessagesResponse>;
952
+ receiveMessages(_options?: QueueReceiveMessageOptions): Promise<QueueReceiveMessageResponse>;
953
+ sendMessage(messageText: string, _options?: QueueSendMessageOptions): Promise<QueueSendMessageResponse>;
954
+ setAccessPolicy(_identifiers?: SignedIdentifier[]): Promise<QueueSetAccessPolicyResponse>;
955
+ setMetadata(): Promise<QueueSetMetadataResponse>;
956
+ updateMessage(): Promise<QueueUpdateMessageResponse>;
957
+ }
848
958
  //#endregion
849
- //#region src/models/MockTableClient.d.ts
959
+ //#region src/models/table/MockTableClient.d.ts
850
960
  /**
851
961
  * An in-memory mock of the Azure TableClient.
852
962
  * It uses a Map to simulate table storage and correctly implements the TableClient interface.
@@ -878,10 +988,10 @@ declare class MockTableClient implements Except<TableClient, "pipeline"> {
878
988
  private withMetadata;
879
989
  }
880
990
  //#endregion
881
- //#region src/services/blob/bodyToBuffer.d.ts
991
+ //#region src/services/container/bodyToBuffer.d.ts
882
992
  declare const bodyToBuffer: (body: HttpRequestBody) => Promise<Buffer>;
883
993
  //#endregion
884
- //#region src/services/blob/getAzureErrorXml.d.ts
994
+ //#region src/services/container/getAzureErrorXml.d.ts
885
995
  /**
886
996
  * Generates a standard Azure Storage error XML response body.
887
997
  * @param errorCode The official Azure error code (e.g., "BlobNotFound").
@@ -890,16 +1000,16 @@ declare const bodyToBuffer: (body: HttpRequestBody) => Promise<Buffer>;
890
1000
  */
891
1001
  declare const getAzureErrorXml: (errorCode: string, errorMessage: string) => string;
892
1002
  //#endregion
893
- //#region src/services/blob/getBlobItemXml.d.ts
1003
+ //#region src/services/container/getBlobItemXml.d.ts
894
1004
  declare const getBlobItemXml: ({
895
1005
  name,
896
1006
  properties
897
1007
  }: BlobItem) => string;
898
1008
  //#endregion
899
- //#region src/services/blob/getBlobPrefixXml.d.ts
1009
+ //#region src/services/container/getBlobPrefixXml.d.ts
900
1010
  declare const getBlobPrefixXml: (name: string) => string;
901
1011
  //#endregion
902
- //#region src/services/blob/getListBlobsXml.d.ts
1012
+ //#region src/services/container/getListBlobsXml.d.ts
903
1013
  /**
904
1014
  * Generates a standard Azure Storage list blobs XML response body.
905
1015
  * @param containerName The container name.
@@ -908,7 +1018,7 @@ declare const getBlobPrefixXml: (name: string) => string;
908
1018
  */
909
1019
  declare const getListBlobsXml: (containerName: string, blobsXml: string) => string;
910
1020
  //#endregion
911
- //#region src/services/blob/isReadableStream.d.ts
1021
+ //#region src/services/container/isReadableStream.d.ts
912
1022
  declare const isReadableStream: (value: unknown) => value is NodeJS.ReadableStream;
913
1023
  //#endregion
914
1024
  //#region ../../node_modules/.pnpm/@azure+abort-controller@2.1.2/node_modules/@azure/abort-controller/dist/esm/AbortSignalLike.d.ts
@@ -976,7 +1086,7 @@ interface OperationTracingOptions {
976
1086
  tracingContext?: TracingContext;
977
1087
  }
978
1088
  //#endregion
979
- //#region ../../node_modules/.pnpm/@azure+core-rest-pipeline@1.22.1/node_modules/@azure/core-rest-pipeline/dist/esm/interfaces.d.ts
1089
+ //#region ../../node_modules/.pnpm/@azure+core-rest-pipeline@1.22.2/node_modules/@azure/core-rest-pipeline/dist/esm/interfaces.d.ts
980
1090
  /**
981
1091
  * A HttpHeaders collection represented as a simple JSON object.
982
1092
  */
@@ -1301,7 +1411,7 @@ interface PxfObject {
1301
1411
  passphrase?: string | undefined;
1302
1412
  }
1303
1413
  //#endregion
1304
- //#region ../../node_modules/.pnpm/@azure+core-rest-pipeline@1.22.1/node_modules/@azure/core-rest-pipeline/dist/esm/index.d.ts
1414
+ //#region ../../node_modules/.pnpm/@azure+core-rest-pipeline@1.22.2/node_modules/@azure/core-rest-pipeline/dist/esm/index.d.ts
1305
1415
  declare global {
1306
1416
  interface FormData {}
1307
1417
  interface Blob {}
@@ -1532,7 +1642,7 @@ type TransferProgressEvent = {
1532
1642
  loadedBytes: number;
1533
1643
  };
1534
1644
  //#endregion
1535
- //#region src/services/blob/toWebResourceLike.d.ts
1645
+ //#region src/services/container/toWebResourceLike.d.ts
1536
1646
  declare const toWebResourceLike: (request: PipelineRequest) => WebResourceLike;
1537
1647
  //#endregion
1538
1648
  //#region src/services/table/applyTableFilter.d.ts
@@ -1547,4 +1657,4 @@ declare const createTableFilterPredicate: <T extends Record<string, unknown>>(fi
1547
1657
  //#region src/services/table/isTableNullClause.d.ts
1548
1658
  declare const isTableNullClause: (clause: Clause) => boolean;
1549
1659
  //#endregion
1550
- export { BlobHierarchyItem, MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerClient, MockContainerDatabase, MockRestError, MockTableClient, MockTableDatabase, PageSettings, PagedAsyncIterableIterator, applyTableFilter, bodyToBuffer, compare, createTableFilterPredicate, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, getListBlobsXml, isReadableStream, isTableNullClause, toWebResourceLike };
1660
+ export { BlobHierarchyItem, MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerClient, MockContainerDatabase, MockEventGridDatabase, MockEventGridPublisherClient, MockQueueClient, MockQueueDatabase, MockRestError, MockTableClient, MockTableDatabase, PageSettings, PagedAsyncIterableIterator, applyTableFilter, bodyToBuffer, compare, createTableFilterPredicate, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, getListBlobsXml, isReadableStream, isTableNullClause, toWebResourceLike };