mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 23:10:29 +00:00
[@types/node-notifier] Update typings (#33419)
* Update node-notifier typings * Add typings for NotificationCallback
This commit is contained in:
committed by
Wesley Wigham
parent
3db0bee205
commit
d959efd3fe
Vendored
+87
-24
@@ -1,6 +1,7 @@
|
||||
// Type definitions for node-notifier
|
||||
// Type definitions for node-notifier 5.4.0
|
||||
// Project: https://github.com/mikaelbr/node-notifier
|
||||
// Definitions by: Qubo <https://github.com/tkQubo>
|
||||
// Lorenzo Rapetti <https://github.com/loryman>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
@@ -14,12 +15,30 @@ declare module "node-notifier" {
|
||||
|
||||
namespace nodeNotifier {
|
||||
interface NodeNotifier extends NodeJS.EventEmitter {
|
||||
notify(
|
||||
notification?: NotificationCenter.Notification,
|
||||
callback?: NotificationCallback
|
||||
): NotificationCenter;
|
||||
notify(
|
||||
notification?: WindowsToaster.Notification,
|
||||
callback?: NotificationCallback
|
||||
): WindowsToaster;
|
||||
notify(
|
||||
notification?: WindowsBalloon.Notification,
|
||||
callback?: NotificationCallback
|
||||
): WindowsBalloon;
|
||||
notify(
|
||||
notification?: NotifySend.Notification,
|
||||
callback?: NotificationCallback
|
||||
): NotifySend;
|
||||
notify(notification?: Growl.Notification, callback?: NotificationCallback): Growl;
|
||||
notify(notification?: Notification, callback?: NotificationCallback): NodeNotifier;
|
||||
NotificationCenter: NotificationCenter;
|
||||
NotifySend: NotifySend;
|
||||
WindowsToaster: WindowsToaster;
|
||||
WindowsBalloon: WindowsBalloon;
|
||||
Growl: Growl;
|
||||
notify(notification?: string, callback?: NotificationCallback): NodeNotifier;
|
||||
NotificationCenter: typeof NotificationCenter;
|
||||
NotifySend: typeof NotifySend;
|
||||
WindowsToaster: typeof WindowsToaster;
|
||||
WindowsBalloon: typeof WindowsBalloon;
|
||||
Growl: typeof Growl;
|
||||
}
|
||||
|
||||
interface Notification {
|
||||
@@ -27,15 +46,25 @@ declare module "node-notifier" {
|
||||
message?: string;
|
||||
/** Absolute path (not balloons) */
|
||||
icon?: string;
|
||||
/** Only Notification Center or Windows Toasters */
|
||||
sound?: boolean;
|
||||
/** Wait with callback until user action is taken on notification */
|
||||
wait?: boolean;
|
||||
}
|
||||
|
||||
interface NotificationCallback {
|
||||
(err: any, response: any): any;
|
||||
}
|
||||
interface NotificationMetadata {
|
||||
activationType?: string;
|
||||
activationAt?: string;
|
||||
deliveredAt?: string;
|
||||
activationValue?: string;
|
||||
activationValueIndex?: string;
|
||||
}
|
||||
|
||||
interface NotificationCallback {
|
||||
(
|
||||
err: Error | null,
|
||||
response: string,
|
||||
metadata?: NotificationMetadata,
|
||||
): void;
|
||||
}
|
||||
|
||||
interface Option {
|
||||
withFallback?: boolean;
|
||||
@@ -58,11 +87,31 @@ declare module "node-notifier/notifiers/notificationcenter" {
|
||||
|
||||
namespace NotificationCenter {
|
||||
interface Notification extends notifier.Notification {
|
||||
/**
|
||||
* Case Sensitive string for location of sound file, or use one of macOS' native sounds.
|
||||
*/
|
||||
sound?: boolean | string;
|
||||
subtitle?: string;
|
||||
/** Attach image? (Absolute path) */
|
||||
contentImage?: string;
|
||||
/** URL to open on click */
|
||||
open?: string;
|
||||
/**
|
||||
* The amount of seconds before the notification closes.
|
||||
* Takes precedence over wait if both are defined.
|
||||
*/
|
||||
timeout?: number;
|
||||
/** Label for cancel button */
|
||||
closeLabel?: string;
|
||||
/** Action label or list of labels in case of dropdown. */
|
||||
actions?: string | string[];
|
||||
/** Label to be used if there are multiple actions */
|
||||
dropdownLabel?: string;
|
||||
/**
|
||||
* If notification should take input.
|
||||
* Value passed as third argument in callback and event emitter.
|
||||
*/
|
||||
reply?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +150,27 @@ declare module "node-notifier/notifiers/toaster" {
|
||||
|
||||
class WindowsToaster {
|
||||
constructor(option?: notifier.Option);
|
||||
notify(notification?: notifier.Notification, callback?: notifier.NotificationCallback): WindowsToaster;
|
||||
notify(notification?: WindowsToaster.Notification, callback?: notifier.NotificationCallback): WindowsToaster;
|
||||
}
|
||||
|
||||
namespace WindowsToaster {
|
||||
interface Notification extends notifier.Notification {
|
||||
/**
|
||||
* Defined by http://msdn.microsoft.com/en-us/library/windows/apps/hh761492.aspx
|
||||
*/
|
||||
sound?: boolean | string;
|
||||
/** ID to use for closing notification. */
|
||||
id?: number;
|
||||
/** App.ID and app Name. Defaults to no value, causing SnoreToast text to be visible. */
|
||||
appID?: string;
|
||||
/** Refer to previously created notification to close. */
|
||||
remove?: number;
|
||||
/**
|
||||
* Creates a shortcut <path> in the start menu which point to the
|
||||
* executable <application>, appID used for the notifications.
|
||||
*/
|
||||
install?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export = WindowsToaster;
|
||||
@@ -122,19 +191,13 @@ declare module "node-notifier/notifiers/growl" {
|
||||
port?: number;
|
||||
}
|
||||
|
||||
interface Notification {
|
||||
title?: string;
|
||||
message?: string;
|
||||
/** Absolute path (not balloons) */
|
||||
icon?: string;
|
||||
/** Wait with callback until user action is taken on notification */
|
||||
wait?: boolean;
|
||||
interface Notification extends notifier.Notification {
|
||||
/** whether or not to sticky the notification (defaults to false) */
|
||||
sticky?: boolean;
|
||||
sticky?: boolean;
|
||||
/** type of notification to use (defaults to the first registered type) */
|
||||
label: string;
|
||||
label?: string;
|
||||
/** the priority of the notification from lowest (-2) to highest (2) */
|
||||
priority: number;
|
||||
priority?: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,12 +216,12 @@ declare module "node-notifier/notifiers/balloon" {
|
||||
interface Notification {
|
||||
title?: string;
|
||||
message?: string;
|
||||
/** Only Notification Center or Windows Toasters */
|
||||
sound?: boolean;
|
||||
/** How long to show balloons in ms */
|
||||
time?: number;
|
||||
/** Wait with callback until user action is taken on notification */
|
||||
wait?: boolean;
|
||||
/** The notification type */
|
||||
type?: 'info' | 'warn' | 'error';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
import notifier = require('node-notifier');
|
||||
import * as path from 'path';
|
||||
|
||||
notifier.notify();
|
||||
notifier.notify('Hello there');
|
||||
notifier.notify({
|
||||
title: 'My awesome title',
|
||||
message: 'Hello from node, Mr. User!',
|
||||
@@ -22,8 +24,8 @@ notifier.on('timeout', function (notifierObject: any, options: any) {
|
||||
// Happens if `wait: true` and notification closes
|
||||
});
|
||||
|
||||
const options = { };
|
||||
|
||||
const options = { };
|
||||
|
||||
import NotificationCenter = require('node-notifier/notifiers/notificationcenter');
|
||||
new NotificationCenter(options).notify();
|
||||
@@ -41,35 +43,38 @@ import WindowsBalloon = require('node-notifier/notifiers/balloon');
|
||||
new WindowsBalloon(options).notify();
|
||||
|
||||
|
||||
var nn = require('node-notifier');
|
||||
|
||||
new nn.NotificationCenter(options).notify();
|
||||
new nn.NotifySend(options).notify();
|
||||
new nn.WindowsToaster(options).notify(options);
|
||||
new nn.WindowsBalloon(options).notify(options);
|
||||
new nn.Growl(options).notify(options);
|
||||
new notifier.NotificationCenter(options).notify();
|
||||
new notifier.NotifySend(options).notify();
|
||||
new notifier.WindowsToaster(options).notify(options);
|
||||
new notifier.WindowsBalloon(options).notify(options);
|
||||
new notifier.Growl(options).notify(options);
|
||||
|
||||
|
||||
//
|
||||
// All notification options with their defaults:
|
||||
//
|
||||
|
||||
var NotificationCenter2 = require('node-notifier').NotificationCenter;
|
||||
const NotificationCenter2 = notifier.NotificationCenter;
|
||||
|
||||
var notifier2 = new NotificationCenter2({
|
||||
const notifier2 = new NotificationCenter2({
|
||||
withFallback: false, // use Growl if <= 10.8?
|
||||
customPath: void 0 // Relative path if you want to use your fork of terminal-notifier
|
||||
});
|
||||
|
||||
notifier2.notify({
|
||||
'title': void 0,
|
||||
'subtitle': void 0,
|
||||
'message': void 0,
|
||||
'sound': false, // Case Sensitive string of sound file (see below)
|
||||
'icon': 'Terminal Icon', // Set icon? (Absolute path to image)
|
||||
'contentImage': void 0, // Attach image? (Absolute path)
|
||||
'open': void 0, // URL to open on click
|
||||
'wait': false // if wait for notification to end
|
||||
title: void 0,
|
||||
subtitle: void 0,
|
||||
message: void 0,
|
||||
sound: false, // Case Sensitive string of sound file (see below)
|
||||
icon: 'Terminal Icon', // Set icon? (Absolute path to image)
|
||||
contentImage: void 0, // Attach image? (Absolute path)
|
||||
open: void 0, // URL to open on click
|
||||
wait: false, // if wait for notification to end
|
||||
actions: ['Action 1', 'Action 2'],
|
||||
closeLabel: 'Close',
|
||||
dropdownLabel: 'Dropdown',
|
||||
reply: true,
|
||||
timeout: 10
|
||||
}, function(error: any, response: any) {
|
||||
console.log(response);
|
||||
});
|
||||
@@ -78,9 +83,9 @@ notifier2.notify({
|
||||
// Usage WindowsToaster
|
||||
//
|
||||
|
||||
var WindowsToaster2 = require('node-notifier').WindowsToaster;
|
||||
const WindowsToaster2 = notifier.WindowsToaster;
|
||||
|
||||
var notifier3 = new WindowsToaster2({
|
||||
const notifier3 = new WindowsToaster2({
|
||||
withFallback: false, // Fallback to Growl or Balloons?
|
||||
customPath: void 0 // Relative path if you want to use your fork of toast.exe
|
||||
});
|
||||
@@ -91,6 +96,10 @@ notifier3.notify({
|
||||
icon: void 0, // absolute path to an icon
|
||||
sound: false, // true | false.
|
||||
wait: false, // if wait for notification to end
|
||||
appID: '',
|
||||
id: 1,
|
||||
install: '/',
|
||||
remove: 1
|
||||
}, function(error: any, response: any) {
|
||||
console.log(response);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user