@wix/notifications 1.0.36 → 1.0.38

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.
@@ -1,9 +1,9 @@
1
- type HostModule$1<T, H extends Host$1> = {
1
+ type HostModule<T, H extends Host> = {
2
2
  __type: 'host';
3
3
  create(host: H): T;
4
4
  };
5
- type HostModuleAPI$1<T extends HostModule$1<any, any>> = T extends HostModule$1<infer U, any> ? U : never;
6
- type Host$1<Environment = unknown> = {
5
+ type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never;
6
+ type Host<Environment = unknown> = {
7
7
  channel: {
8
8
  observeState(callback: (props: unknown, environment: Environment) => unknown): {
9
9
  disconnect: () => void;
@@ -36,92 +36,92 @@ type Host$1<Environment = unknown> = {
36
36
  };
37
37
  };
38
38
 
39
- type RESTFunctionDescriptor$1<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient$1) => T;
40
- interface HttpClient$1 {
41
- request<TResponse, TData = any>(req: RequestOptionsFactory$1<TResponse, TData>): Promise<HttpResponse$1<TResponse>>;
39
+ type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
40
+ interface HttpClient {
41
+ request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
42
42
  fetchWithAuth: typeof fetch;
43
43
  wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
44
44
  getActiveToken?: () => string | undefined;
45
45
  }
46
- type RequestOptionsFactory$1<TResponse = any, TData = any> = (context: any) => RequestOptions$1<TResponse, TData>;
47
- type HttpResponse$1<T = any> = {
46
+ type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
47
+ type HttpResponse<T = any> = {
48
48
  data: T;
49
49
  status: number;
50
50
  statusText: string;
51
51
  headers: any;
52
52
  request?: any;
53
53
  };
54
- type RequestOptions$1<_TResponse = any, Data = any> = {
54
+ type RequestOptions<_TResponse = any, Data = any> = {
55
55
  method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
56
56
  url: string;
57
57
  data?: Data;
58
58
  params?: URLSearchParams;
59
- } & APIMetadata$1;
60
- type APIMetadata$1 = {
59
+ } & APIMetadata;
60
+ type APIMetadata = {
61
61
  methodFqn?: string;
62
62
  entityFqdn?: string;
63
63
  packageName?: string;
64
64
  };
65
- type BuildRESTFunction$1<T extends RESTFunctionDescriptor$1> = T extends RESTFunctionDescriptor$1<infer U> ? U : never;
66
- type EventDefinition$1<Payload = unknown, Type extends string = string> = {
65
+ type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
66
+ type EventDefinition<Payload = unknown, Type extends string = string> = {
67
67
  __type: 'event-definition';
68
68
  type: Type;
69
69
  isDomainEvent?: boolean;
70
70
  transformations?: (envelope: unknown) => Payload;
71
71
  __payload: Payload;
72
72
  };
73
- declare function EventDefinition$1<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition$1<Payload, Type>;
74
- type EventHandler$1<T extends EventDefinition$1> = (payload: T['__payload']) => void | Promise<void>;
75
- type BuildEventDefinition$1<T extends EventDefinition$1<any, string>> = (handler: EventHandler$1<T>) => void;
73
+ declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
74
+ type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
75
+ type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
76
76
 
77
- type ServicePluginMethodInput$1 = {
77
+ type ServicePluginMethodInput = {
78
78
  request: any;
79
79
  metadata: any;
80
80
  };
81
- type ServicePluginContract$1 = Record<string, (payload: ServicePluginMethodInput$1) => unknown | Promise<unknown>>;
82
- type ServicePluginMethodMetadata$1 = {
81
+ type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
82
+ type ServicePluginMethodMetadata = {
83
83
  name: string;
84
84
  primaryHttpMappingPath: string;
85
85
  transformations: {
86
- fromREST: (...args: unknown[]) => ServicePluginMethodInput$1;
86
+ fromREST: (...args: unknown[]) => ServicePluginMethodInput;
87
87
  toREST: (...args: unknown[]) => unknown;
88
88
  };
89
89
  };
90
- type ServicePluginDefinition$1<Contract extends ServicePluginContract$1> = {
90
+ type ServicePluginDefinition<Contract extends ServicePluginContract> = {
91
91
  __type: 'service-plugin-definition';
92
92
  componentType: string;
93
- methods: ServicePluginMethodMetadata$1[];
93
+ methods: ServicePluginMethodMetadata[];
94
94
  __contract: Contract;
95
95
  };
96
- declare function ServicePluginDefinition$1<Contract extends ServicePluginContract$1>(componentType: string, methods: ServicePluginMethodMetadata$1[]): ServicePluginDefinition$1<Contract>;
97
- type BuildServicePluginDefinition$1<T extends ServicePluginDefinition$1<any>> = (implementation: T['__contract']) => void;
98
- declare const SERVICE_PLUGIN_ERROR_TYPE$1 = "wix_spi_error";
96
+ declare function ServicePluginDefinition<Contract extends ServicePluginContract>(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>;
97
+ type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = (implementation: T['__contract']) => void;
98
+ declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
99
99
 
100
- type RequestContext$1 = {
100
+ type RequestContext = {
101
101
  isSSR: boolean;
102
102
  host: string;
103
103
  protocol?: string;
104
104
  };
105
- type ResponseTransformer$1 = (data: any, headers?: any) => any;
105
+ type ResponseTransformer = (data: any, headers?: any) => any;
106
106
  /**
107
107
  * Ambassador request options types are copied mostly from AxiosRequestConfig.
108
108
  * They are copied and not imported to reduce the amount of dependencies (to reduce install time).
109
109
  * https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
110
110
  */
111
- type Method$1 = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
112
- type AmbassadorRequestOptions$1<T = any> = {
111
+ type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
112
+ type AmbassadorRequestOptions<T = any> = {
113
113
  _?: T;
114
114
  url?: string;
115
- method?: Method$1;
115
+ method?: Method;
116
116
  params?: any;
117
117
  data?: any;
118
- transformResponse?: ResponseTransformer$1 | ResponseTransformer$1[];
118
+ transformResponse?: ResponseTransformer | ResponseTransformer[];
119
119
  };
120
- type AmbassadorFactory$1<Request, Response> = (payload: Request) => ((context: RequestContext$1) => AmbassadorRequestOptions$1<Response>) & {
120
+ type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
121
121
  __isAmbassador: boolean;
122
122
  };
123
- type AmbassadorFunctionDescriptor$1<Request = any, Response = any> = AmbassadorFactory$1<Request, Response>;
124
- type BuildAmbassadorFunction$1<T extends AmbassadorFunctionDescriptor$1> = T extends AmbassadorFunctionDescriptor$1<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
123
+ type AmbassadorFunctionDescriptor<Request = any, Response = any> = AmbassadorFactory<Request, Response>;
124
+ type BuildAmbassadorFunction<T extends AmbassadorFunctionDescriptor> = T extends AmbassadorFunctionDescriptor<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
125
125
 
126
126
  declare global {
127
127
  // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
@@ -130,7 +130,7 @@ declare global {
130
130
  }
131
131
  }
132
132
 
133
- declare const emptyObjectSymbol$1: unique symbol;
133
+ declare const emptyObjectSymbol: unique symbol;
134
134
 
135
135
  /**
136
136
  Represents a strictly empty plain object, the `{}` value.
@@ -158,7 +158,7 @@ Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<n
158
158
 
159
159
  @category Object
160
160
  */
161
- type EmptyObject$1 = {[emptyObjectSymbol$1]?: never};
161
+ type EmptyObject = {[emptyObjectSymbol]?: never};
162
162
 
163
163
  /**
164
164
  Returns a boolean for whether the two given types are equal.
@@ -186,7 +186,7 @@ type Includes<Value extends readonly any[], Item> =
186
186
  @category Type Guard
187
187
  @category Utilities
188
188
  */
189
- type IsEqual$1<A, B> =
189
+ type IsEqual<A, B> =
190
190
  (<G>() => G extends A ? 1 : 2) extends
191
191
  (<G>() => G extends B ? 1 : 2)
192
192
  ? true
@@ -219,9 +219,9 @@ type Filtered = Filter<'bar', 'foo'>;
219
219
 
220
220
  @see {Except}
221
221
  */
222
- type Filter$1<KeyType, ExcludeType> = IsEqual$1<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
222
+ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
223
223
 
224
- type ExceptOptions$1 = {
224
+ type ExceptOptions = {
225
225
  /**
226
226
  Disallow assigning non-specified properties.
227
227
 
@@ -265,8 +265,8 @@ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
265
265
 
266
266
  @category Object
267
267
  */
268
- type Except$1<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions$1 = {requireExactProps: false}> = {
269
- [KeyType in keyof ObjectType as Filter$1<KeyType, KeysType>]: ObjectType[KeyType];
268
+ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = {
269
+ [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
270
270
  } & (Options['requireExactProps'] extends true
271
271
  ? Partial<Record<KeysType, never>>
272
272
  : {});
@@ -303,7 +303,7 @@ type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
303
303
 
304
304
  @category Object
305
305
  */
306
- type ConditionalKeys$1<Base, Condition> = NonNullable<
306
+ type ConditionalKeys<Base, Condition> = NonNullable<
307
307
  // Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
308
308
  {
309
309
  // Map through all the keys of the given base type.
@@ -357,9 +357,9 @@ type NonStringKeysOnly = ConditionalExcept<Example, string>;
357
357
 
358
358
  @category Object
359
359
  */
360
- type ConditionalExcept$1<Base, Condition> = Except$1<
360
+ type ConditionalExcept<Base, Condition> = Except<
361
361
  Base,
362
- ConditionalKeys$1<Base, Condition>
362
+ ConditionalKeys<Base, Condition>
363
363
  >;
364
364
 
365
365
  /**
@@ -367,8 +367,8 @@ ConditionalKeys$1<Base, Condition>
367
367
  * can either be a REST module or a host module.
368
368
  * This type is recursive, so it can describe nested modules.
369
369
  */
370
- type Descriptors$1 = RESTFunctionDescriptor$1 | AmbassadorFunctionDescriptor$1 | HostModule$1<any, any> | EventDefinition$1<any> | ServicePluginDefinition$1<any> | {
371
- [key: string]: Descriptors$1 | PublicMetadata$1 | any;
370
+ type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition<any> | ServicePluginDefinition<any> | {
371
+ [key: string]: Descriptors | PublicMetadata | any;
372
372
  };
373
373
  /**
374
374
  * This type takes in a descriptors object of a certain Host (including an `unknown` host)
@@ -376,12 +376,12 @@ type Descriptors$1 = RESTFunctionDescriptor$1 | AmbassadorFunctionDescriptor$1 |
376
376
  * Any non-descriptor properties are removed from the returned object, including descriptors that
377
377
  * do not match the given host (as they will not work with the given host).
378
378
  */
379
- type BuildDescriptors$1<T extends Descriptors$1, H extends Host$1<any> | undefined, Depth extends number = 5> = {
379
+ type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
380
380
  done: T;
381
381
  recurse: T extends {
382
- __type: typeof SERVICE_PLUGIN_ERROR_TYPE$1;
383
- } ? never : T extends AmbassadorFunctionDescriptor$1 ? BuildAmbassadorFunction$1<T> : T extends RESTFunctionDescriptor$1 ? BuildRESTFunction$1<T> : T extends EventDefinition$1<any> ? BuildEventDefinition$1<T> : T extends ServicePluginDefinition$1<any> ? BuildServicePluginDefinition$1<T> : T extends HostModule$1<any, any> ? HostModuleAPI$1<T> : ConditionalExcept$1<{
384
- [Key in keyof T]: T[Key] extends Descriptors$1 ? BuildDescriptors$1<T[Key], H, [
382
+ __type: typeof SERVICE_PLUGIN_ERROR_TYPE;
383
+ } ? 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
+ [Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
385
385
  -1,
386
386
  0,
387
387
  1,
@@ -390,9 +390,9 @@ type BuildDescriptors$1<T extends Descriptors$1, H extends Host$1<any> | undefin
390
390
  4,
391
391
  5
392
392
  ][Depth]> : never;
393
- }, EmptyObject$1>;
393
+ }, EmptyObject>;
394
394
  }[Depth extends -1 ? 'done' : 'recurse'];
395
- type PublicMetadata$1 = {
395
+ type PublicMetadata = {
396
396
  PACKAGE_NAME?: string;
397
397
  };
398
398
 
@@ -404,47 +404,37 @@ declare global {
404
404
  * A type used to create concerete types from SDK descriptors in
405
405
  * case a contextual client is available.
406
406
  */
407
- type MaybeContext$1<T extends Descriptors$1> = globalThis.ContextualClient extends {
408
- host: Host$1;
409
- } ? BuildDescriptors$1<T, globalThis.ContextualClient['host']> : T;
407
+ type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
408
+ host: Host;
409
+ } ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
410
410
 
411
411
  interface Public_notification {
412
412
  /** Notification ID. */
413
413
  _id?: string | null;
414
414
  }
415
415
  interface PublicNotifyRequest extends PublicNotifyRequestRecipientsFilterOneOf, PublicNotifyRequestActionTargetOneOf {
416
- /** List of site contributors to notify. */
416
+ /** Send to [site contributors]((https://support.wix.com/en/article/roles-permissions-overview)). This includes site administrators, website managers, and back office managers. */
417
417
  toSiteContributors?: ToSiteContributors;
418
- /** List of contacts to notify. */
418
+ /** Send to [site contacts](https://support.wix.com/en/article/about-your-contact-list). */
419
419
  toContacts?: ToContacts;
420
420
  /** URL to navigate to when the `action` text is clicked. */
421
421
  targetUrl?: string | null;
422
- /** URL of Dashboard page to navigate to when the `action` text is clicked. */
422
+ /** Dashboard page to open when the notification action is clicked. */
423
423
  targetDashboardPage?: DashboardPages;
424
- /**
425
- * Notification title. Only displayed on mobile and browser notifications.
426
- *
427
- * Max: 512 characters
428
- */
424
+ /** Title of the notification. Max: 512 characters. */
429
425
  title?: string | null;
430
426
  /**
431
- * Contents of the notification.
432
- *
427
+ * Body of the notification. This contains the main content of the notification.
433
428
  * Max: 512 characters
434
429
  */
435
430
  body?: string | null;
436
- /**
437
- * Clickable text that links to the `targetUrl` or `targetDashboardPage`. For example, "Click this!".
438
- *
439
- * Max: 512 characters
440
- */
431
+ /** Title of the notification action. Clicking the action refers the user to a target URL or a dashboard page. */
441
432
  action?: string | null;
442
433
  /**
443
- * The channels to send the notification on. One or more of:
444
- *
434
+ * Channel through which users receive the notification.
445
435
  * - `"Mobile"`: Sends the notification to the Wix App.
446
- * - `"Dashboard"`: Sends the notification to the contributor's Wix Dashboard.
447
- * - `"Browser"`: Sends the notification to the contributor's browser.
436
+ * - `"Dashboard"`: Sends the notification to the collaborator's Wix Dashboard.
437
+ * - `"Browser"`: Sends the notification to the collaborator's browser.
448
438
  */
449
439
  channels?: Channel[];
450
440
  }
@@ -459,15 +449,14 @@ interface PublicNotifyRequestRecipientsFilterOneOf {
459
449
  interface PublicNotifyRequestActionTargetOneOf {
460
450
  /** URL to navigate to when the `action` text is clicked. */
461
451
  targetUrl?: string | null;
462
- /** URL of Dashboard page to navigate to when the `action` text is clicked. */
452
+ /** Dashboard page to open when the notification action is clicked. */
463
453
  targetDashboardPage?: DashboardPages;
464
454
  }
465
455
  interface ToSiteContributors {
466
456
  /**
467
- * Roles to receive the notification. One of:
468
- *
469
- * - `"All_Contributors"`: All site contributors (default).
470
- * - `"Owner"`: Only the site owner.
457
+ * Role assigned to site contributors. Only contributors with the specified roles receive the notification:
458
+ * - `"All_Contributors"`: All site collaborators (default).
459
+ * - `"Owner"`: Site owner only.
471
460
  */
472
461
  withRole?: Role;
473
462
  }
@@ -478,13 +467,13 @@ declare enum Role {
478
467
  Owner = "Owner"
479
468
  }
480
469
  interface ToContacts {
481
- /** List of contact IDs. */
470
+ /** Contacts that receive the notification. */
482
471
  contactIds?: string[];
483
472
  }
484
473
  interface ToTopicsSubscribers {
485
- /** List of topics. */
474
+ /** Notification topics to which the recipients have subscribed. Only contacts who subscribed to the specified topics receive the notification. */
486
475
  topics?: string[];
487
- /** List of contact IDs to exclude from notification. */
476
+ /** Excluded contact IDs. Contacts with these IDs don't receive the notification. */
488
477
  excludedContactIds?: string[];
489
478
  }
490
479
  declare enum Channel {
@@ -509,25 +498,21 @@ interface NotifyOptions$1 extends PublicNotifyRequestRecipientsFilterOneOf, Publ
509
498
  toSiteContributors?: ToSiteContributors;
510
499
  /** List of contacts to notify. */
511
500
  toContacts?: ToContacts;
512
- /**
513
- * Notification title. Only displayed on mobile and browser notifications.
514
- *
515
- * Max: 512 characters
516
- */
501
+ /** Title of the notification. Max: 512 characters. */
517
502
  title?: string | null;
518
503
  /**
519
- * Clickable text that links to the `targetUrl` or `targetDashboardPage`. For example, "Click this!".
504
+ * Title of the notification action. Clicking the action refers the user to a target URL or a dashboard page.
520
505
  *
521
- * Max: 512 characters
506
+ * Max: 512 characters.
522
507
  */
523
508
  action?: string | null;
524
- /** URL to navigate to when the `action` text is clicked. */
509
+ /** External URL to open when the notification action is clicked. */
525
510
  targetUrl?: string | null;
526
- /** URL of Dashboard page to navigate to when the `action` text is clicked. */
511
+ /** Dashboard page to open when the notification action is clicked. */
527
512
  targetDashboardPage?: DashboardPages;
528
513
  }
529
514
 
530
- declare function notify$3(httpClient: HttpClient$1): NotifySignature$1;
515
+ declare function notify$3(httpClient: HttpClient): NotifySignature$1;
531
516
  interface NotifySignature$1 {
532
517
  /**
533
518
  * Sends a notification.
@@ -539,20 +524,17 @@ interface NotifySignature$1 {
539
524
  *
540
525
  * List the recipients for the notification in the `toContacts`, `toSiteContributors`, and `toTopicsSubscribers` parameters.
541
526
  * @param - Notification options.
542
- * @param - The body of the notification.
543
- *
544
- * Max: 512 characters
545
- * @param - The channels to send the notification on. One or more of:
546
- *
527
+ * @param - Body of the notification. This contains the main content of the notification.
528
+ * @param - Channel through which users receive the notification.
547
529
  * - `"Mobile"`: Sends the notification to the Wix App.
548
- * - `"Dashboard"`: Sends the notification to the contributor's Wix Dashboard.
549
- * - `"Browser"`: Sends the notification to the contributor's browser.
530
+ * - `"Dashboard"`: Sends the notification to the collaborator's Wix Dashboard.
531
+ * - `"Browser"`: Sends the notification to the collaborator's browser.
550
532
  * @returns Fulfilled when the send notification request is received.
551
533
  */
552
534
  (body: string | null, channels: Channel[], options?: NotifyOptions$1 | undefined): Promise<void>;
553
535
  }
554
536
 
555
- declare const notify$2: MaybeContext$1<BuildRESTFunction$1<typeof notify$3> & typeof notify$3>;
537
+ declare const notify$2: MaybeContext<BuildRESTFunction<typeof notify$3> & typeof notify$3>;
556
538
 
557
539
  type context$1_Channel = Channel;
558
540
  declare const context$1_Channel: typeof Channel;
@@ -572,416 +554,6 @@ declare namespace context$1 {
572
554
  export { context$1_Channel as Channel, context$1_DashboardPages as DashboardPages, type context$1_Empty as Empty, type NotifyOptions$1 as NotifyOptions, type context$1_PublicNotifyRequest as PublicNotifyRequest, type context$1_PublicNotifyRequestActionTargetOneOf as PublicNotifyRequestActionTargetOneOf, type context$1_PublicNotifyRequestRecipientsFilterOneOf as PublicNotifyRequestRecipientsFilterOneOf, type context$1_Public_notification as Public_notification, context$1_Role as Role, type context$1_ToContacts as ToContacts, type context$1_ToSiteContributors as ToSiteContributors, type context$1_ToTopicsSubscribers as ToTopicsSubscribers, notify$2 as notify };
573
555
  }
574
556
 
575
- type HostModule<T, H extends Host> = {
576
- __type: 'host';
577
- create(host: H): T;
578
- };
579
- type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never;
580
- type Host<Environment = unknown> = {
581
- channel: {
582
- observeState(callback: (props: unknown, environment: Environment) => unknown): {
583
- disconnect: () => void;
584
- } | Promise<{
585
- disconnect: () => void;
586
- }>;
587
- };
588
- environment?: Environment;
589
- /**
590
- * Optional bast url to use for API requests, for example `www.wixapis.com`
591
- */
592
- apiBaseUrl?: string;
593
- /**
594
- * Possible data to be provided by every host, for cross cutting concerns
595
- * like internationalization, billing, etc.
596
- */
597
- essentials?: {
598
- /**
599
- * The language of the currently viewed session
600
- */
601
- language?: string;
602
- /**
603
- * The locale of the currently viewed session
604
- */
605
- locale?: string;
606
- /**
607
- * Any headers that should be passed through to the API requests
608
- */
609
- passThroughHeaders?: Record<string, string>;
610
- };
611
- };
612
-
613
- type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
614
- interface HttpClient {
615
- request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
616
- fetchWithAuth: typeof fetch;
617
- wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
618
- getActiveToken?: () => string | undefined;
619
- }
620
- type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
621
- type HttpResponse<T = any> = {
622
- data: T;
623
- status: number;
624
- statusText: string;
625
- headers: any;
626
- request?: any;
627
- };
628
- type RequestOptions<_TResponse = any, Data = any> = {
629
- method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
630
- url: string;
631
- data?: Data;
632
- params?: URLSearchParams;
633
- } & APIMetadata;
634
- type APIMetadata = {
635
- methodFqn?: string;
636
- entityFqdn?: string;
637
- packageName?: string;
638
- };
639
- type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
640
- type EventDefinition<Payload = unknown, Type extends string = string> = {
641
- __type: 'event-definition';
642
- type: Type;
643
- isDomainEvent?: boolean;
644
- transformations?: (envelope: unknown) => Payload;
645
- __payload: Payload;
646
- };
647
- declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
648
- type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
649
- type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
650
-
651
- type ServicePluginMethodInput = {
652
- request: any;
653
- metadata: any;
654
- };
655
- type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
656
- type ServicePluginMethodMetadata = {
657
- name: string;
658
- primaryHttpMappingPath: string;
659
- transformations: {
660
- fromREST: (...args: unknown[]) => ServicePluginMethodInput;
661
- toREST: (...args: unknown[]) => unknown;
662
- };
663
- };
664
- type ServicePluginDefinition<Contract extends ServicePluginContract> = {
665
- __type: 'service-plugin-definition';
666
- componentType: string;
667
- methods: ServicePluginMethodMetadata[];
668
- __contract: Contract;
669
- };
670
- declare function ServicePluginDefinition<Contract extends ServicePluginContract>(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>;
671
- type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = (implementation: T['__contract']) => void;
672
- declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
673
-
674
- type RequestContext = {
675
- isSSR: boolean;
676
- host: string;
677
- protocol?: string;
678
- };
679
- type ResponseTransformer = (data: any, headers?: any) => any;
680
- /**
681
- * Ambassador request options types are copied mostly from AxiosRequestConfig.
682
- * They are copied and not imported to reduce the amount of dependencies (to reduce install time).
683
- * https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
684
- */
685
- type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
686
- type AmbassadorRequestOptions<T = any> = {
687
- _?: T;
688
- url?: string;
689
- method?: Method;
690
- params?: any;
691
- data?: any;
692
- transformResponse?: ResponseTransformer | ResponseTransformer[];
693
- };
694
- type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
695
- __isAmbassador: boolean;
696
- };
697
- type AmbassadorFunctionDescriptor<Request = any, Response = any> = AmbassadorFactory<Request, Response>;
698
- type BuildAmbassadorFunction<T extends AmbassadorFunctionDescriptor> = T extends AmbassadorFunctionDescriptor<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
699
-
700
- declare global {
701
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
702
- interface SymbolConstructor {
703
- readonly observable: symbol;
704
- }
705
- }
706
-
707
- declare const emptyObjectSymbol: unique symbol;
708
-
709
- /**
710
- Represents a strictly empty plain object, the `{}` value.
711
-
712
- When you annotate something as the type `{}`, it can be anything except `null` and `undefined`. This means that you cannot use `{}` to represent an empty plain object ([read more](https://stackoverflow.com/questions/47339869/typescript-empty-object-and-any-difference/52193484#52193484)).
713
-
714
- @example
715
- ```
716
- import type {EmptyObject} from 'type-fest';
717
-
718
- // The following illustrates the problem with `{}`.
719
- const foo1: {} = {}; // Pass
720
- const foo2: {} = []; // Pass
721
- const foo3: {} = 42; // Pass
722
- const foo4: {} = {a: 1}; // Pass
723
-
724
- // With `EmptyObject` only the first case is valid.
725
- const bar1: EmptyObject = {}; // Pass
726
- const bar2: EmptyObject = 42; // Fail
727
- const bar3: EmptyObject = []; // Fail
728
- const bar4: EmptyObject = {a: 1}; // Fail
729
- ```
730
-
731
- Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<never, never>` do not work. See {@link https://github.com/sindresorhus/type-fest/issues/395 #395}.
732
-
733
- @category Object
734
- */
735
- type EmptyObject = {[emptyObjectSymbol]?: never};
736
-
737
- /**
738
- Returns a boolean for whether the two given types are equal.
739
-
740
- @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
741
- @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
742
-
743
- Use-cases:
744
- - If you want to make a conditional branch based on the result of a comparison of two types.
745
-
746
- @example
747
- ```
748
- import type {IsEqual} from 'type-fest';
749
-
750
- // This type returns a boolean for whether the given array includes the given item.
751
- // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
752
- type Includes<Value extends readonly any[], Item> =
753
- Value extends readonly [Value[0], ...infer rest]
754
- ? IsEqual<Value[0], Item> extends true
755
- ? true
756
- : Includes<rest, Item>
757
- : false;
758
- ```
759
-
760
- @category Type Guard
761
- @category Utilities
762
- */
763
- type IsEqual<A, B> =
764
- (<G>() => G extends A ? 1 : 2) extends
765
- (<G>() => G extends B ? 1 : 2)
766
- ? true
767
- : false;
768
-
769
- /**
770
- Filter out keys from an object.
771
-
772
- Returns `never` if `Exclude` is strictly equal to `Key`.
773
- Returns `never` if `Key` extends `Exclude`.
774
- Returns `Key` otherwise.
775
-
776
- @example
777
- ```
778
- type Filtered = Filter<'foo', 'foo'>;
779
- //=> never
780
- ```
781
-
782
- @example
783
- ```
784
- type Filtered = Filter<'bar', string>;
785
- //=> never
786
- ```
787
-
788
- @example
789
- ```
790
- type Filtered = Filter<'bar', 'foo'>;
791
- //=> 'bar'
792
- ```
793
-
794
- @see {Except}
795
- */
796
- type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
797
-
798
- type ExceptOptions = {
799
- /**
800
- Disallow assigning non-specified properties.
801
-
802
- Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
803
-
804
- @default false
805
- */
806
- requireExactProps?: boolean;
807
- };
808
-
809
- /**
810
- Create a type from an object type without certain keys.
811
-
812
- We recommend setting the `requireExactProps` option to `true`.
813
-
814
- This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
815
-
816
- This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
817
-
818
- @example
819
- ```
820
- import type {Except} from 'type-fest';
821
-
822
- type Foo = {
823
- a: number;
824
- b: string;
825
- };
826
-
827
- type FooWithoutA = Except<Foo, 'a'>;
828
- //=> {b: string}
829
-
830
- const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
831
- //=> errors: 'a' does not exist in type '{ b: string; }'
832
-
833
- type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
834
- //=> {a: number} & Partial<Record<"b", never>>
835
-
836
- const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
837
- //=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
838
- ```
839
-
840
- @category Object
841
- */
842
- type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = {
843
- [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
844
- } & (Options['requireExactProps'] extends true
845
- ? Partial<Record<KeysType, never>>
846
- : {});
847
-
848
- /**
849
- Extract the keys from a type where the value type of the key extends the given `Condition`.
850
-
851
- Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
852
-
853
- @example
854
- ```
855
- import type {ConditionalKeys} from 'type-fest';
856
-
857
- interface Example {
858
- a: string;
859
- b: string | number;
860
- c?: string;
861
- d: {};
862
- }
863
-
864
- type StringKeysOnly = ConditionalKeys<Example, string>;
865
- //=> 'a'
866
- ```
867
-
868
- To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
869
-
870
- @example
871
- ```
872
- import type {ConditionalKeys} from 'type-fest';
873
-
874
- type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
875
- //=> 'a' | 'c'
876
- ```
877
-
878
- @category Object
879
- */
880
- type ConditionalKeys<Base, Condition> = NonNullable<
881
- // Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
882
- {
883
- // Map through all the keys of the given base type.
884
- [Key in keyof Base]:
885
- // Pick only keys with types extending the given `Condition` type.
886
- Base[Key] extends Condition
887
- // Retain this key since the condition passes.
888
- ? Key
889
- // Discard this key since the condition fails.
890
- : never;
891
-
892
- // Convert the produced object into a union type of the keys which passed the conditional test.
893
- }[keyof Base]
894
- >;
895
-
896
- /**
897
- Exclude keys from a shape that matches the given `Condition`.
898
-
899
- This is useful when you want to create a new type with a specific set of keys from a shape. For example, you might want to exclude all the primitive properties from a class and form a new shape containing everything but the primitive properties.
900
-
901
- @example
902
- ```
903
- import type {Primitive, ConditionalExcept} from 'type-fest';
904
-
905
- class Awesome {
906
- name: string;
907
- successes: number;
908
- failures: bigint;
909
-
910
- run() {}
911
- }
912
-
913
- type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
914
- //=> {run: () => void}
915
- ```
916
-
917
- @example
918
- ```
919
- import type {ConditionalExcept} from 'type-fest';
920
-
921
- interface Example {
922
- a: string;
923
- b: string | number;
924
- c: () => void;
925
- d: {};
926
- }
927
-
928
- type NonStringKeysOnly = ConditionalExcept<Example, string>;
929
- //=> {b: string | number; c: () => void; d: {}}
930
- ```
931
-
932
- @category Object
933
- */
934
- type ConditionalExcept<Base, Condition> = Except<
935
- Base,
936
- ConditionalKeys<Base, Condition>
937
- >;
938
-
939
- /**
940
- * Descriptors are objects that describe the API of a module, and the module
941
- * can either be a REST module or a host module.
942
- * This type is recursive, so it can describe nested modules.
943
- */
944
- type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition<any> | ServicePluginDefinition<any> | {
945
- [key: string]: Descriptors | PublicMetadata | any;
946
- };
947
- /**
948
- * This type takes in a descriptors object of a certain Host (including an `unknown` host)
949
- * and returns an object with the same structure, but with all descriptors replaced with their API.
950
- * Any non-descriptor properties are removed from the returned object, including descriptors that
951
- * do not match the given host (as they will not work with the given host).
952
- */
953
- type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
954
- done: T;
955
- recurse: T extends {
956
- __type: typeof SERVICE_PLUGIN_ERROR_TYPE;
957
- } ? 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<{
958
- [Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
959
- -1,
960
- 0,
961
- 1,
962
- 2,
963
- 3,
964
- 4,
965
- 5
966
- ][Depth]> : never;
967
- }, EmptyObject>;
968
- }[Depth extends -1 ? 'done' : 'recurse'];
969
- type PublicMetadata = {
970
- PACKAGE_NAME?: string;
971
- };
972
-
973
- declare global {
974
- interface ContextualClient {
975
- }
976
- }
977
- /**
978
- * A type used to create concerete types from SDK descriptors in
979
- * case a contextual client is available.
980
- */
981
- type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
982
- host: Host;
983
- } ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
984
-
985
557
  interface Notification {
986
558
  /** The id of the notification */
987
559
  _id?: string;