@wix/calendar 1.0.23 → 1.0.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/calendar",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -18,11 +18,11 @@
18
18
  "type-bundles"
19
19
  ],
20
20
  "dependencies": {
21
- "@wix/calendar_event-views": "1.0.1",
22
- "@wix/calendar_events": "1.0.12",
23
- "@wix/calendar_participations": "1.0.4",
24
- "@wix/calendar_schedule-time-frames": "1.0.9",
25
- "@wix/calendar_schedules": "1.0.13"
21
+ "@wix/calendar_event-views": "1.0.2",
22
+ "@wix/calendar_events": "1.0.13",
23
+ "@wix/calendar_participations": "1.0.5",
24
+ "@wix/calendar_schedule-time-frames": "1.0.10",
25
+ "@wix/calendar_schedules": "1.0.14"
26
26
  },
27
27
  "devDependencies": {
28
28
  "glob": "^10.4.1",
@@ -47,5 +47,5 @@
47
47
  "fqdn": ""
48
48
  }
49
49
  },
50
- "falconPackageHash": "5e4c6c70c229c3e6afe19daabd4e2229ba8643f29d03bbe6ad1ba83e"
50
+ "falconPackageHash": "cf1ce50599995870663b98ac4b15c0047934c647211c217ec4b23be4"
51
51
  }
@@ -12,6 +12,10 @@ type Host<Environment = unknown> = {
12
12
  }>;
13
13
  };
14
14
  environment?: Environment;
15
+ /**
16
+ * Optional name of the environment, use for logging
17
+ */
18
+ name?: string;
15
19
  /**
16
20
  * Optional bast url to use for API requests, for example `www.wixapis.com`
17
21
  */
@@ -63,16 +67,16 @@ type APIMetadata = {
63
67
  packageName?: string;
64
68
  };
65
69
  type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
66
- type EventDefinition$5<Payload = unknown, Type extends string = string> = {
70
+ type EventDefinition<Payload = unknown, Type extends string = string> = {
67
71
  __type: 'event-definition';
68
72
  type: Type;
69
73
  isDomainEvent?: boolean;
70
74
  transformations?: (envelope: unknown) => Payload;
71
75
  __payload: Payload;
72
76
  };
73
- declare function EventDefinition$5<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$5<Payload, Type>;
74
- type EventHandler$5<T extends EventDefinition$5> = (payload: T['__payload']) => void | Promise<void>;
75
- type BuildEventDefinition$5<T extends EventDefinition$5<any, string>> = (handler: EventHandler$5<T>) => void;
77
+ declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
78
+ type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
79
+ type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
76
80
 
77
81
  type ServicePluginMethodInput = {
78
82
  request: any;
@@ -271,6 +275,72 @@ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends Excep
271
275
  ? Partial<Record<KeysType, never>>
272
276
  : {});
273
277
 
278
+ /**
279
+ Returns a boolean for whether the given type is `never`.
280
+
281
+ @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
282
+ @link https://stackoverflow.com/a/53984913/10292952
283
+ @link https://www.zhenghao.io/posts/ts-never
284
+
285
+ Useful in type utilities, such as checking if something does not occur.
286
+
287
+ @example
288
+ ```
289
+ import type {IsNever, And} from 'type-fest';
290
+
291
+ // https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
292
+ type AreStringsEqual<A extends string, B extends string> =
293
+ And<
294
+ IsNever<Exclude<A, B>> extends true ? true : false,
295
+ IsNever<Exclude<B, A>> extends true ? true : false
296
+ >;
297
+
298
+ type EndIfEqual<I extends string, O extends string> =
299
+ AreStringsEqual<I, O> extends true
300
+ ? never
301
+ : void;
302
+
303
+ function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
304
+ if (input === output) {
305
+ process.exit(0);
306
+ }
307
+ }
308
+
309
+ endIfEqual('abc', 'abc');
310
+ //=> never
311
+
312
+ endIfEqual('abc', '123');
313
+ //=> void
314
+ ```
315
+
316
+ @category Type Guard
317
+ @category Utilities
318
+ */
319
+ type IsNever<T> = [T] extends [never] ? true : false;
320
+
321
+ /**
322
+ An if-else-like type that resolves depending on whether the given type is `never`.
323
+
324
+ @see {@link IsNever}
325
+
326
+ @example
327
+ ```
328
+ import type {IfNever} from 'type-fest';
329
+
330
+ type ShouldBeTrue = IfNever<never>;
331
+ //=> true
332
+
333
+ type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
334
+ //=> 'bar'
335
+ ```
336
+
337
+ @category Type Guard
338
+ @category Utilities
339
+ */
340
+ type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (
341
+ IsNever<T> extends true ? TypeIfNever : TypeIfNotNever
342
+ );
343
+
274
344
  /**
275
345
  Extract the keys from a type where the value type of the key extends the given `Condition`.
276
346
 
@@ -303,21 +373,19 @@ type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
303
373
 
304
374
  @category Object
305
375
  */
306
- type ConditionalKeys<Base, Condition> = NonNullable<
307
- // Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
376
+ type ConditionalKeys<Base, Condition> =
308
377
  {
309
378
  // Map through all the keys of the given base type.
310
- [Key in keyof Base]:
379
+ [Key in keyof Base]-?:
311
380
  // Pick only keys with types extending the given `Condition` type.
312
381
  Base[Key] extends Condition
313
- // Retain this key since the condition passes.
314
- ? Key
382
+ // Retain this key
383
+ // If the value for the key extends never, only include it if `Condition` also extends never
384
+ ? IfNever<Base[Key], IfNever<Condition, Key, never>, Key>
315
385
  // Discard this key since the condition fails.
316
386
  : never;
317
-
318
387
  // Convert the produced object into a union type of the keys which passed the conditional test.
319
- }[keyof Base]
320
- >;
388
+ }[keyof Base];
321
389
 
322
390
  /**
323
391
  Exclude keys from a shape that matches the given `Condition`.
@@ -367,7 +435,7 @@ ConditionalKeys<Base, Condition>
367
435
  * can either be a REST module or a host module.
368
436
  * This type is recursive, so it can describe nested modules.
369
437
  */
370
- type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition$5<any> | ServicePluginDefinition<any> | {
438
+ type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition<any> | ServicePluginDefinition<any> | {
371
439
  [key: string]: Descriptors | PublicMetadata | any;
372
440
  };
373
441
  /**
@@ -380,7 +448,7 @@ type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, De
380
448
  done: T;
381
449
  recurse: T extends {
382
450
  __type: typeof SERVICE_PLUGIN_ERROR_TYPE;
383
- } ? never : T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition$5<any> ? BuildEventDefinition$5<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
451
+ } ? never : T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition<any> ? BuildEventDefinition<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
384
452
  [Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
385
453
  -1,
386
454
  0,
@@ -2485,30 +2553,12 @@ interface ListEventsByMemberIdSignature {
2485
2553
  */
2486
2554
  (memberId: string | null, options?: ListEventsByMemberIdOptions | undefined): Promise<ListEventsByMemberIdResponse & ListEventsByMemberIdResponseNonNullableFields>;
2487
2555
  }
2488
- declare const onEventCreated$1: EventDefinition$5<EventCreatedEnvelope, "wix.calendar.v3.event_created">;
2489
- declare const onEventUpdated$1: EventDefinition$5<EventUpdatedEnvelope, "wix.calendar.v3.event_updated">;
2490
- declare const onEventRecurringSplit$1: EventDefinition$5<EventRecurringSplitEnvelope, "wix.calendar.v3.event_recurring_split">;
2491
- declare const onEventCancelled$1: EventDefinition$5<EventCancelledEnvelope, "wix.calendar.v3.event_cancelled">;
2556
+ declare const onEventCreated$1: EventDefinition<EventCreatedEnvelope, "wix.calendar.v3.event_created">;
2557
+ declare const onEventUpdated$1: EventDefinition<EventUpdatedEnvelope, "wix.calendar.v3.event_updated">;
2558
+ declare const onEventRecurringSplit$1: EventDefinition<EventRecurringSplitEnvelope, "wix.calendar.v3.event_recurring_split">;
2559
+ declare const onEventCancelled$1: EventDefinition<EventCancelledEnvelope, "wix.calendar.v3.event_cancelled">;
2492
2560
 
2493
- type EventDefinition$4<Payload = unknown, Type extends string = string> = {
2494
- __type: 'event-definition';
2495
- type: Type;
2496
- isDomainEvent?: boolean;
2497
- transformations?: (envelope: unknown) => Payload;
2498
- __payload: Payload;
2499
- };
2500
- declare function EventDefinition$4<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$4<Payload, Type>;
2501
- type EventHandler$4<T extends EventDefinition$4> = (payload: T['__payload']) => void | Promise<void>;
2502
- type BuildEventDefinition$4<T extends EventDefinition$4<any, string>> = (handler: EventHandler$4<T>) => void;
2503
-
2504
- declare global {
2505
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
2506
- interface SymbolConstructor {
2507
- readonly observable: symbol;
2508
- }
2509
- }
2510
-
2511
- declare function createEventModule$4<T extends EventDefinition$4<any, string>>(eventDefinition: T): BuildEventDefinition$4<T> & T;
2561
+ declare function createEventModule$4<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
2512
2562
 
2513
2563
  declare const getEvent: MaybeContext<BuildRESTFunction<typeof getEvent$1> & typeof getEvent$1>;
2514
2564
  declare const listEvents: MaybeContext<BuildRESTFunction<typeof listEvents$1> & typeof listEvents$1>;
@@ -3319,28 +3369,10 @@ interface GetEventsViewSignature {
3319
3369
  */
3320
3370
  (): Promise<GetEventsViewResponse>;
3321
3371
  }
3322
- declare const onEventsViewProjectionUpdated$1: EventDefinition$5<EventsViewProjectionUpdatedEnvelope, "wix.calendar.v3.events_view_projection_updated">;
3323
- declare const onEventsViewExtended$1: EventDefinition$5<EventsViewExtendedEnvelope, "wix.calendar.v3.events_view_extended">;
3324
-
3325
- type EventDefinition$3<Payload = unknown, Type extends string = string> = {
3326
- __type: 'event-definition';
3327
- type: Type;
3328
- isDomainEvent?: boolean;
3329
- transformations?: (envelope: unknown) => Payload;
3330
- __payload: Payload;
3331
- };
3332
- declare function EventDefinition$3<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$3<Payload, Type>;
3333
- type EventHandler$3<T extends EventDefinition$3> = (payload: T['__payload']) => void | Promise<void>;
3334
- type BuildEventDefinition$3<T extends EventDefinition$3<any, string>> = (handler: EventHandler$3<T>) => void;
3335
-
3336
- declare global {
3337
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
3338
- interface SymbolConstructor {
3339
- readonly observable: symbol;
3340
- }
3341
- }
3372
+ declare const onEventsViewProjectionUpdated$1: EventDefinition<EventsViewProjectionUpdatedEnvelope, "wix.calendar.v3.events_view_projection_updated">;
3373
+ declare const onEventsViewExtended$1: EventDefinition<EventsViewExtendedEnvelope, "wix.calendar.v3.events_view_extended">;
3342
3374
 
3343
- declare function createEventModule$3<T extends EventDefinition$3<any, string>>(eventDefinition: T): BuildEventDefinition$3<T> & T;
3375
+ declare function createEventModule$3<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
3344
3376
 
3345
3377
  declare const getEventsView: MaybeContext<BuildRESTFunction<typeof getEventsView$1> & typeof getEventsView$1>;
3346
3378
 
@@ -3891,29 +3923,11 @@ interface DeleteParticipationSignature {
3891
3923
  */
3892
3924
  (participationId: string | null): Promise<void>;
3893
3925
  }
3894
- declare const onParticipationCreated$1: EventDefinition$5<ParticipationCreatedEnvelope, "wix.calendar.v3.participation_created">;
3895
- declare const onParticipationUpdated$1: EventDefinition$5<ParticipationUpdatedEnvelope, "wix.calendar.v3.participation_updated">;
3896
- declare const onParticipationDeleted$1: EventDefinition$5<ParticipationDeletedEnvelope, "wix.calendar.v3.participation_deleted">;
3926
+ declare const onParticipationCreated$1: EventDefinition<ParticipationCreatedEnvelope, "wix.calendar.v3.participation_created">;
3927
+ declare const onParticipationUpdated$1: EventDefinition<ParticipationUpdatedEnvelope, "wix.calendar.v3.participation_updated">;
3928
+ declare const onParticipationDeleted$1: EventDefinition<ParticipationDeletedEnvelope, "wix.calendar.v3.participation_deleted">;
3897
3929
 
3898
- type EventDefinition$2<Payload = unknown, Type extends string = string> = {
3899
- __type: 'event-definition';
3900
- type: Type;
3901
- isDomainEvent?: boolean;
3902
- transformations?: (envelope: unknown) => Payload;
3903
- __payload: Payload;
3904
- };
3905
- declare function EventDefinition$2<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$2<Payload, Type>;
3906
- type EventHandler$2<T extends EventDefinition$2> = (payload: T['__payload']) => void | Promise<void>;
3907
- type BuildEventDefinition$2<T extends EventDefinition$2<any, string>> = (handler: EventHandler$2<T>) => void;
3908
-
3909
- declare global {
3910
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
3911
- interface SymbolConstructor {
3912
- readonly observable: symbol;
3913
- }
3914
- }
3915
-
3916
- declare function createEventModule$2<T extends EventDefinition$2<any, string>>(eventDefinition: T): BuildEventDefinition$2<T> & T;
3930
+ declare function createEventModule$2<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
3917
3931
 
3918
3932
  declare const getParticipation: MaybeContext<BuildRESTFunction<typeof getParticipation$1> & typeof getParticipation$1>;
3919
3933
  declare const queryParticipations: MaybeContext<BuildRESTFunction<typeof queryParticipations$1> & typeof queryParticipations$1>;
@@ -5276,30 +5290,12 @@ interface CancelScheduleSignature {
5276
5290
  */
5277
5291
  (scheduleId: string | null, options?: CancelScheduleOptions | undefined): Promise<CancelScheduleResponse & CancelScheduleResponseNonNullableFields>;
5278
5292
  }
5279
- declare const onScheduleCreated$1: EventDefinition$5<ScheduleCreatedEnvelope, "wix.calendar.v3.schedule_created">;
5280
- declare const onScheduleUpdated$1: EventDefinition$5<ScheduleUpdatedEnvelope, "wix.calendar.v3.schedule_updated">;
5281
- declare const onScheduleCloned$1: EventDefinition$5<ScheduleClonedEnvelope, "wix.calendar.v3.schedule_cloned">;
5282
- declare const onScheduleCancelled$1: EventDefinition$5<ScheduleCancelledEnvelope, "wix.calendar.v3.schedule_cancelled">;
5283
-
5284
- type EventDefinition$1<Payload = unknown, Type extends string = string> = {
5285
- __type: 'event-definition';
5286
- type: Type;
5287
- isDomainEvent?: boolean;
5288
- transformations?: (envelope: unknown) => Payload;
5289
- __payload: Payload;
5290
- };
5291
- declare function EventDefinition$1<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$1<Payload, Type>;
5292
- type EventHandler$1<T extends EventDefinition$1> = (payload: T['__payload']) => void | Promise<void>;
5293
- type BuildEventDefinition$1<T extends EventDefinition$1<any, string>> = (handler: EventHandler$1<T>) => void;
5294
-
5295
- declare global {
5296
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
5297
- interface SymbolConstructor {
5298
- readonly observable: symbol;
5299
- }
5300
- }
5293
+ declare const onScheduleCreated$1: EventDefinition<ScheduleCreatedEnvelope, "wix.calendar.v3.schedule_created">;
5294
+ declare const onScheduleUpdated$1: EventDefinition<ScheduleUpdatedEnvelope, "wix.calendar.v3.schedule_updated">;
5295
+ declare const onScheduleCloned$1: EventDefinition<ScheduleClonedEnvelope, "wix.calendar.v3.schedule_cloned">;
5296
+ declare const onScheduleCancelled$1: EventDefinition<ScheduleCancelledEnvelope, "wix.calendar.v3.schedule_cancelled">;
5301
5297
 
5302
- declare function createEventModule$1<T extends EventDefinition$1<any, string>>(eventDefinition: T): BuildEventDefinition$1<T> & T;
5298
+ declare function createEventModule$1<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
5303
5299
 
5304
5300
  declare const getSchedule: MaybeContext<BuildRESTFunction<typeof getSchedule$1> & typeof getSchedule$1>;
5305
5301
  declare const querySchedules: MaybeContext<BuildRESTFunction<typeof querySchedules$1> & typeof querySchedules$1>;
@@ -5994,25 +5990,7 @@ interface ListScheduleTimeFramesSignature {
5994
5990
  */
5995
5991
  (ids: string[], options?: ListScheduleTimeFramesOptions | undefined): Promise<ListScheduleTimeFramesResponse & ListScheduleTimeFramesResponseNonNullableFields>;
5996
5992
  }
5997
- declare const onScheduleTimeFrameUpdated$1: EventDefinition$5<ScheduleTimeFrameUpdatedEnvelope, "wix.calendar.v3.schedule_time_frame_updated">;
5998
-
5999
- type EventDefinition<Payload = unknown, Type extends string = string> = {
6000
- __type: 'event-definition';
6001
- type: Type;
6002
- isDomainEvent?: boolean;
6003
- transformations?: (envelope: unknown) => Payload;
6004
- __payload: Payload;
6005
- };
6006
- declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
6007
- type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
6008
- type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
6009
-
6010
- declare global {
6011
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
6012
- interface SymbolConstructor {
6013
- readonly observable: symbol;
6014
- }
6015
- }
5993
+ declare const onScheduleTimeFrameUpdated$1: EventDefinition<ScheduleTimeFrameUpdatedEnvelope, "wix.calendar.v3.schedule_time_frame_updated">;
6016
5994
 
6017
5995
  declare function createEventModule<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
6018
5996
 
@@ -12,6 +12,10 @@ type Host<Environment = unknown> = {
12
12
  }>;
13
13
  };
14
14
  environment?: Environment;
15
+ /**
16
+ * Optional name of the environment, use for logging
17
+ */
18
+ name?: string;
15
19
  /**
16
20
  * Optional bast url to use for API requests, for example `www.wixapis.com`
17
21
  */
@@ -63,16 +67,16 @@ type APIMetadata = {
63
67
  packageName?: string;
64
68
  };
65
69
  type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
66
- type EventDefinition$5<Payload = unknown, Type extends string = string> = {
70
+ type EventDefinition<Payload = unknown, Type extends string = string> = {
67
71
  __type: 'event-definition';
68
72
  type: Type;
69
73
  isDomainEvent?: boolean;
70
74
  transformations?: (envelope: unknown) => Payload;
71
75
  __payload: Payload;
72
76
  };
73
- declare function EventDefinition$5<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$5<Payload, Type>;
74
- type EventHandler$5<T extends EventDefinition$5> = (payload: T['__payload']) => void | Promise<void>;
75
- type BuildEventDefinition$5<T extends EventDefinition$5<any, string>> = (handler: EventHandler$5<T>) => void;
77
+ declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
78
+ type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
79
+ type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
76
80
 
77
81
  type ServicePluginMethodInput = {
78
82
  request: any;
@@ -271,6 +275,72 @@ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends Excep
271
275
  ? Partial<Record<KeysType, never>>
272
276
  : {});
273
277
 
278
+ /**
279
+ Returns a boolean for whether the given type is `never`.
280
+
281
+ @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
282
+ @link https://stackoverflow.com/a/53984913/10292952
283
+ @link https://www.zhenghao.io/posts/ts-never
284
+
285
+ Useful in type utilities, such as checking if something does not occur.
286
+
287
+ @example
288
+ ```
289
+ import type {IsNever, And} from 'type-fest';
290
+
291
+ // https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
292
+ type AreStringsEqual<A extends string, B extends string> =
293
+ And<
294
+ IsNever<Exclude<A, B>> extends true ? true : false,
295
+ IsNever<Exclude<B, A>> extends true ? true : false
296
+ >;
297
+
298
+ type EndIfEqual<I extends string, O extends string> =
299
+ AreStringsEqual<I, O> extends true
300
+ ? never
301
+ : void;
302
+
303
+ function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
304
+ if (input === output) {
305
+ process.exit(0);
306
+ }
307
+ }
308
+
309
+ endIfEqual('abc', 'abc');
310
+ //=> never
311
+
312
+ endIfEqual('abc', '123');
313
+ //=> void
314
+ ```
315
+
316
+ @category Type Guard
317
+ @category Utilities
318
+ */
319
+ type IsNever<T> = [T] extends [never] ? true : false;
320
+
321
+ /**
322
+ An if-else-like type that resolves depending on whether the given type is `never`.
323
+
324
+ @see {@link IsNever}
325
+
326
+ @example
327
+ ```
328
+ import type {IfNever} from 'type-fest';
329
+
330
+ type ShouldBeTrue = IfNever<never>;
331
+ //=> true
332
+
333
+ type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
334
+ //=> 'bar'
335
+ ```
336
+
337
+ @category Type Guard
338
+ @category Utilities
339
+ */
340
+ type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (
341
+ IsNever<T> extends true ? TypeIfNever : TypeIfNotNever
342
+ );
343
+
274
344
  /**
275
345
  Extract the keys from a type where the value type of the key extends the given `Condition`.
276
346
 
@@ -303,21 +373,19 @@ type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
303
373
 
304
374
  @category Object
305
375
  */
306
- type ConditionalKeys<Base, Condition> = NonNullable<
307
- // Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
376
+ type ConditionalKeys<Base, Condition> =
308
377
  {
309
378
  // Map through all the keys of the given base type.
310
- [Key in keyof Base]:
379
+ [Key in keyof Base]-?:
311
380
  // Pick only keys with types extending the given `Condition` type.
312
381
  Base[Key] extends Condition
313
- // Retain this key since the condition passes.
314
- ? Key
382
+ // Retain this key
383
+ // If the value for the key extends never, only include it if `Condition` also extends never
384
+ ? IfNever<Base[Key], IfNever<Condition, Key, never>, Key>
315
385
  // Discard this key since the condition fails.
316
386
  : never;
317
-
318
387
  // Convert the produced object into a union type of the keys which passed the conditional test.
319
- }[keyof Base]
320
- >;
388
+ }[keyof Base];
321
389
 
322
390
  /**
323
391
  Exclude keys from a shape that matches the given `Condition`.
@@ -367,7 +435,7 @@ ConditionalKeys<Base, Condition>
367
435
  * can either be a REST module or a host module.
368
436
  * This type is recursive, so it can describe nested modules.
369
437
  */
370
- type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition$5<any> | ServicePluginDefinition<any> | {
438
+ type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition<any> | ServicePluginDefinition<any> | {
371
439
  [key: string]: Descriptors | PublicMetadata | any;
372
440
  };
373
441
  /**
@@ -380,7 +448,7 @@ type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, De
380
448
  done: T;
381
449
  recurse: T extends {
382
450
  __type: typeof SERVICE_PLUGIN_ERROR_TYPE;
383
- } ? never : T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition$5<any> ? BuildEventDefinition$5<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
451
+ } ? never : T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition<any> ? BuildEventDefinition<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
384
452
  [Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
385
453
  -1,
386
454
  0,
@@ -2485,30 +2553,12 @@ interface ListEventsByMemberIdSignature {
2485
2553
  */
2486
2554
  (memberId: string | null, options?: ListEventsByMemberIdOptions | undefined): Promise<ListEventsByMemberIdResponse & ListEventsByMemberIdResponseNonNullableFields>;
2487
2555
  }
2488
- declare const onEventCreated$1: EventDefinition$5<EventCreatedEnvelope, "wix.calendar.v3.event_created">;
2489
- declare const onEventUpdated$1: EventDefinition$5<EventUpdatedEnvelope, "wix.calendar.v3.event_updated">;
2490
- declare const onEventRecurringSplit$1: EventDefinition$5<EventRecurringSplitEnvelope, "wix.calendar.v3.event_recurring_split">;
2491
- declare const onEventCancelled$1: EventDefinition$5<EventCancelledEnvelope, "wix.calendar.v3.event_cancelled">;
2556
+ declare const onEventCreated$1: EventDefinition<EventCreatedEnvelope, "wix.calendar.v3.event_created">;
2557
+ declare const onEventUpdated$1: EventDefinition<EventUpdatedEnvelope, "wix.calendar.v3.event_updated">;
2558
+ declare const onEventRecurringSplit$1: EventDefinition<EventRecurringSplitEnvelope, "wix.calendar.v3.event_recurring_split">;
2559
+ declare const onEventCancelled$1: EventDefinition<EventCancelledEnvelope, "wix.calendar.v3.event_cancelled">;
2492
2560
 
2493
- type EventDefinition$4<Payload = unknown, Type extends string = string> = {
2494
- __type: 'event-definition';
2495
- type: Type;
2496
- isDomainEvent?: boolean;
2497
- transformations?: (envelope: unknown) => Payload;
2498
- __payload: Payload;
2499
- };
2500
- declare function EventDefinition$4<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$4<Payload, Type>;
2501
- type EventHandler$4<T extends EventDefinition$4> = (payload: T['__payload']) => void | Promise<void>;
2502
- type BuildEventDefinition$4<T extends EventDefinition$4<any, string>> = (handler: EventHandler$4<T>) => void;
2503
-
2504
- declare global {
2505
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
2506
- interface SymbolConstructor {
2507
- readonly observable: symbol;
2508
- }
2509
- }
2510
-
2511
- declare function createEventModule$4<T extends EventDefinition$4<any, string>>(eventDefinition: T): BuildEventDefinition$4<T> & T;
2561
+ declare function createEventModule$4<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
2512
2562
 
2513
2563
  declare const getEvent: MaybeContext<BuildRESTFunction<typeof getEvent$1> & typeof getEvent$1>;
2514
2564
  declare const listEvents: MaybeContext<BuildRESTFunction<typeof listEvents$1> & typeof listEvents$1>;
@@ -3319,28 +3369,10 @@ interface GetEventsViewSignature {
3319
3369
  */
3320
3370
  (): Promise<GetEventsViewResponse>;
3321
3371
  }
3322
- declare const onEventsViewProjectionUpdated$1: EventDefinition$5<EventsViewProjectionUpdatedEnvelope, "wix.calendar.v3.events_view_projection_updated">;
3323
- declare const onEventsViewExtended$1: EventDefinition$5<EventsViewExtendedEnvelope, "wix.calendar.v3.events_view_extended">;
3324
-
3325
- type EventDefinition$3<Payload = unknown, Type extends string = string> = {
3326
- __type: 'event-definition';
3327
- type: Type;
3328
- isDomainEvent?: boolean;
3329
- transformations?: (envelope: unknown) => Payload;
3330
- __payload: Payload;
3331
- };
3332
- declare function EventDefinition$3<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$3<Payload, Type>;
3333
- type EventHandler$3<T extends EventDefinition$3> = (payload: T['__payload']) => void | Promise<void>;
3334
- type BuildEventDefinition$3<T extends EventDefinition$3<any, string>> = (handler: EventHandler$3<T>) => void;
3335
-
3336
- declare global {
3337
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
3338
- interface SymbolConstructor {
3339
- readonly observable: symbol;
3340
- }
3341
- }
3372
+ declare const onEventsViewProjectionUpdated$1: EventDefinition<EventsViewProjectionUpdatedEnvelope, "wix.calendar.v3.events_view_projection_updated">;
3373
+ declare const onEventsViewExtended$1: EventDefinition<EventsViewExtendedEnvelope, "wix.calendar.v3.events_view_extended">;
3342
3374
 
3343
- declare function createEventModule$3<T extends EventDefinition$3<any, string>>(eventDefinition: T): BuildEventDefinition$3<T> & T;
3375
+ declare function createEventModule$3<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
3344
3376
 
3345
3377
  declare const getEventsView: MaybeContext<BuildRESTFunction<typeof getEventsView$1> & typeof getEventsView$1>;
3346
3378
 
@@ -3891,29 +3923,11 @@ interface DeleteParticipationSignature {
3891
3923
  */
3892
3924
  (participationId: string | null): Promise<void>;
3893
3925
  }
3894
- declare const onParticipationCreated$1: EventDefinition$5<ParticipationCreatedEnvelope, "wix.calendar.v3.participation_created">;
3895
- declare const onParticipationUpdated$1: EventDefinition$5<ParticipationUpdatedEnvelope, "wix.calendar.v3.participation_updated">;
3896
- declare const onParticipationDeleted$1: EventDefinition$5<ParticipationDeletedEnvelope, "wix.calendar.v3.participation_deleted">;
3926
+ declare const onParticipationCreated$1: EventDefinition<ParticipationCreatedEnvelope, "wix.calendar.v3.participation_created">;
3927
+ declare const onParticipationUpdated$1: EventDefinition<ParticipationUpdatedEnvelope, "wix.calendar.v3.participation_updated">;
3928
+ declare const onParticipationDeleted$1: EventDefinition<ParticipationDeletedEnvelope, "wix.calendar.v3.participation_deleted">;
3897
3929
 
3898
- type EventDefinition$2<Payload = unknown, Type extends string = string> = {
3899
- __type: 'event-definition';
3900
- type: Type;
3901
- isDomainEvent?: boolean;
3902
- transformations?: (envelope: unknown) => Payload;
3903
- __payload: Payload;
3904
- };
3905
- declare function EventDefinition$2<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$2<Payload, Type>;
3906
- type EventHandler$2<T extends EventDefinition$2> = (payload: T['__payload']) => void | Promise<void>;
3907
- type BuildEventDefinition$2<T extends EventDefinition$2<any, string>> = (handler: EventHandler$2<T>) => void;
3908
-
3909
- declare global {
3910
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
3911
- interface SymbolConstructor {
3912
- readonly observable: symbol;
3913
- }
3914
- }
3915
-
3916
- declare function createEventModule$2<T extends EventDefinition$2<any, string>>(eventDefinition: T): BuildEventDefinition$2<T> & T;
3930
+ declare function createEventModule$2<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
3917
3931
 
3918
3932
  declare const getParticipation: MaybeContext<BuildRESTFunction<typeof getParticipation$1> & typeof getParticipation$1>;
3919
3933
  declare const queryParticipations: MaybeContext<BuildRESTFunction<typeof queryParticipations$1> & typeof queryParticipations$1>;
@@ -5276,30 +5290,12 @@ interface CancelScheduleSignature {
5276
5290
  */
5277
5291
  (scheduleId: string | null, options?: CancelScheduleOptions | undefined): Promise<CancelScheduleResponse & CancelScheduleResponseNonNullableFields>;
5278
5292
  }
5279
- declare const onScheduleCreated$1: EventDefinition$5<ScheduleCreatedEnvelope, "wix.calendar.v3.schedule_created">;
5280
- declare const onScheduleUpdated$1: EventDefinition$5<ScheduleUpdatedEnvelope, "wix.calendar.v3.schedule_updated">;
5281
- declare const onScheduleCloned$1: EventDefinition$5<ScheduleClonedEnvelope, "wix.calendar.v3.schedule_cloned">;
5282
- declare const onScheduleCancelled$1: EventDefinition$5<ScheduleCancelledEnvelope, "wix.calendar.v3.schedule_cancelled">;
5283
-
5284
- type EventDefinition$1<Payload = unknown, Type extends string = string> = {
5285
- __type: 'event-definition';
5286
- type: Type;
5287
- isDomainEvent?: boolean;
5288
- transformations?: (envelope: unknown) => Payload;
5289
- __payload: Payload;
5290
- };
5291
- declare function EventDefinition$1<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$1<Payload, Type>;
5292
- type EventHandler$1<T extends EventDefinition$1> = (payload: T['__payload']) => void | Promise<void>;
5293
- type BuildEventDefinition$1<T extends EventDefinition$1<any, string>> = (handler: EventHandler$1<T>) => void;
5294
-
5295
- declare global {
5296
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
5297
- interface SymbolConstructor {
5298
- readonly observable: symbol;
5299
- }
5300
- }
5293
+ declare const onScheduleCreated$1: EventDefinition<ScheduleCreatedEnvelope, "wix.calendar.v3.schedule_created">;
5294
+ declare const onScheduleUpdated$1: EventDefinition<ScheduleUpdatedEnvelope, "wix.calendar.v3.schedule_updated">;
5295
+ declare const onScheduleCloned$1: EventDefinition<ScheduleClonedEnvelope, "wix.calendar.v3.schedule_cloned">;
5296
+ declare const onScheduleCancelled$1: EventDefinition<ScheduleCancelledEnvelope, "wix.calendar.v3.schedule_cancelled">;
5301
5297
 
5302
- declare function createEventModule$1<T extends EventDefinition$1<any, string>>(eventDefinition: T): BuildEventDefinition$1<T> & T;
5298
+ declare function createEventModule$1<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
5303
5299
 
5304
5300
  declare const getSchedule: MaybeContext<BuildRESTFunction<typeof getSchedule$1> & typeof getSchedule$1>;
5305
5301
  declare const querySchedules: MaybeContext<BuildRESTFunction<typeof querySchedules$1> & typeof querySchedules$1>;
@@ -5994,25 +5990,7 @@ interface ListScheduleTimeFramesSignature {
5994
5990
  */
5995
5991
  (ids: string[], options?: ListScheduleTimeFramesOptions | undefined): Promise<ListScheduleTimeFramesResponse & ListScheduleTimeFramesResponseNonNullableFields>;
5996
5992
  }
5997
- declare const onScheduleTimeFrameUpdated$1: EventDefinition$5<ScheduleTimeFrameUpdatedEnvelope, "wix.calendar.v3.schedule_time_frame_updated">;
5998
-
5999
- type EventDefinition<Payload = unknown, Type extends string = string> = {
6000
- __type: 'event-definition';
6001
- type: Type;
6002
- isDomainEvent?: boolean;
6003
- transformations?: (envelope: unknown) => Payload;
6004
- __payload: Payload;
6005
- };
6006
- declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
6007
- type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
6008
- type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
6009
-
6010
- declare global {
6011
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
6012
- interface SymbolConstructor {
6013
- readonly observable: symbol;
6014
- }
6015
- }
5993
+ declare const onScheduleTimeFrameUpdated$1: EventDefinition<ScheduleTimeFrameUpdatedEnvelope, "wix.calendar.v3.schedule_time_frame_updated">;
6016
5994
 
6017
5995
  declare function createEventModule<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
6018
5996