Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add missing action options and better naming #61

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/dynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
/* 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 @@
* > 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 @@
* > 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
Loading