Skip to content

Commit

Permalink
add missing action options and better naming
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdrackett committed Aug 15, 2024
1 parent 50c65e4 commit 2b0772f
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 32 deletions.
14 changes: 7 additions & 7 deletions src/dynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
/* eslint-disable @typescript-eslint/ban-types */
// @ts-nocheck
import {

Check warning on line 7 in src/dynamic.ts

View workflow job for this annotation

GitHub Actions / lint-and-build

Run autofix to sort these imports!
ActionableNotification,
AndroidActionableNotification,
AppleActionableNotification,
NotificationData,
AndroidNotificationData,
AppleNotificationData,
PICK_ENTITY,
} from "./helpers";

Expand Down Expand Up @@ -2691,8 +2691,8 @@ export type iCallService = {
* > object: null
* > ```
*/
data?: ActionableNotification &
(AndroidActionableNotification | AppleActionableNotification);
data?: NotificationData &
(AndroidNotificationData | AppleNotificationData);

Check failure on line 2695 in src/dynamic.ts

View workflow job for this annotation

GitHub Actions / lint-and-build

Insert `··`
/**
* ## message
*
Expand Down Expand Up @@ -2761,8 +2761,8 @@ export type iCallService = {
* > object: null
* > ```
*/
data?: ActionableNotification &
(AndroidActionableNotification | AppleActionableNotification);
data?: NotificationData &
(AndroidNotificationData | AppleNotificationData);

Check failure on line 2765 in src/dynamic.ts

View workflow job for this annotation

GitHub Actions / lint-and-build

Insert `··`
/**
* ## Message
*
Expand Down
105 changes: 80 additions & 25 deletions src/helpers/notify.helper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type AppleActionableNotificationPush = {
export type AppleNotificationPush = {
/**
* **iOS | MacOS**
*
Expand Down Expand Up @@ -32,7 +32,73 @@ export type AppleActionableNotificationPush = {
presentation_options?: ["alert" | "badge" | "sound"];
};

export type AppleActionableNotification = {
export type NotificationAction = {
/**
* Key passed back in events.
* When set to `REPLY`, you will be prompted for text to send with the event.
*/
action: "REPLY" | "URI" | string;
/**
* Shown on the action button to the user.
*/
title: string;
/**
* The URI to open when selected.
* Android requires setting the action string to `URI` to use this key. [More Info](https://companion.home-assistant.io/docs/notifications/actionable-notifications/#uri-values).
*/
uri?: string;
};

export type AndroidNotificationActionOptions = {};

export type AppleNotificationActionOptions = {
/**
* **iOS | MacOS**
*
* Set to `foreground` to launch the app when tapped. Defaults to background which just fires the event.
* This is automatically set to foreground when providing a uri.
*/
activationMode?: "foreground" | "background";
/**
* **iOS | MacOS**
*
* Set to `true` to require a password to fire the event.
*/
authenticationRequired?: boolean;
/**
* **iOS | MacOS**
*
* Set to `true` to color the actions title red.
*/
destructive?: boolean;
/**
* **iOS | MacOS**
*
* Set to `textInput` to prompt for text to return with the event. This also occurs when setting the action to `REPLY`.
*/
behavior?: "textInput";
/**
* **iOS | MacOS**
*
* Title to use for text input for actions that prompt.
*/
textInputButtonTitle?: string;
/**
* **iOS | MacOS**
*
* Placeholder to use for text input for actions that prompt.
*/
textInputPlaceholder?: string;
/**
* **iOS | MacOS**
*
* The icon to use for the notification.
* * [More info](https://companion.home-assistant.io/docs/notifications/actionable-notifications#icon-values)
*/
icon?: string;
}

export type AppleNotificationData = {
/**
* **iOS | MacOS**
*
Expand All @@ -48,10 +114,14 @@ export type AppleActionableNotification = {
* [More info](https://companion.home-assistant.io/docs/notifications/notifications-basic#subtitle--subject)
*/
subtitle?: string;
push?: AppleActionableNotificationPush;
push?: AppleNotificationPush;
/**
* iOS Suports ~10 actions.
*/
actions: Array<NotificationAction & AppleNotificationActionOptions>;
};

export type AndroidActionableNotification = {
export type AndroidNotificationData = {
/**
* **Android**
*
Expand Down Expand Up @@ -202,29 +272,14 @@ export type AndroidActionableNotification = {
* [More info](https://companion.home-assistant.io/docs/notifications/notifications-basic#android-auto-visibility)
*/
car_ui?: boolean;

/**
* Android Suports 3 actions.
*/
actions: Array<NotificationAction & AndroidNotificationActionOptions>;
};

export type ActionableNotification = {
/**
* Android allows 3 actions.
* iOS allows around 10 actions.
*/
actions?: {
/**
* Key passed back in events.
* When set to `REPLY`, you will be prompted for text to send with the event.
*/
action: "REPLY" | "URI" | string;
/**
* Shown on the action button to the user.
*/
title: string;
/**
* The URI to open when selected.
* Android requires setting the action string to `URI` to use this key. [More Info](https://companion.home-assistant.io/docs/notifications/actionable-notifications/#uri-values).
*/
uri?: string;
}[];
export type NotificationData = {
/**
* The group to which the notification belongs.
* [More info](https://companion.home-assistant.io/docs/notifications/notifications-basic#grouping)
Expand Down

0 comments on commit 2b0772f

Please sign in to comment.