Skip to content
Open
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
53 changes: 48 additions & 5 deletions src/modules/Resources/actions.types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { GenericID, Conditionals, TagsObj, Query, ExpireTimeOption } from "../../common/common.types";
import { Conditionals, ExpireTimeOption, GenericID, Query, TagsObj } from "../../common/common.types";

type ActionType = "condition" | "resource" | "interval" | "schedule" | "mqtt_topic";

type ActionTypeParams =
| {
script: GenericID[];
script: GenericID | GenericID[];
type: "script";
}
| {
Expand Down Expand Up @@ -34,17 +34,41 @@ type ActionTypeParams =
payload: string;
topic: string;
type: "mqtt";
qos?: 1 | 2 | 3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
qos?: 1 | 2 | 3;
qos?: 0 | 1 | 2;

retain?: boolean;
}
| {
headers: {};
headers: Record<string, string>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
headers: Record<string, string>;
headers?: Record<string, string>;

fallback_token?: string;
type: "post";
url: string;
}
| {
type: "insert_bucket";
}
| {
type: "tcore";
tcore_id: GenericID;
device_token: string;
}
| {
type: "tcore";
device_token: string;
tcore_cluster_id: string;
};

type ActionTriggerType =
| {
resource: "device" | "bucket" | "file" | "analysis" | "action" | "am" | "user" | "financial" | "profile";
when: "create" | "update" | "delete";
when:
| "create"
| "update"
| "delete"
| "mqtt_connect"
| "mqtt_disconnect"
| "login_success"
| "login_fail"
| "chunk_copied";
tag_key: string;
tag_value: string;
}
Expand All @@ -63,6 +87,25 @@ type ActionTriggerType =
second_value?: string;
value_type: "string" | "number" | "boolean" | "*";
unlock?: boolean;
}
| {
variable: string;
is: Conditionals;
value: string;
second_value?: string;
value_type: "string" | "number" | "boolean" | "*";
unlock?: boolean;
tag_key: string;
tag_value: string;
}
| {
device: string;
topic: string;
}
| {
tag_key: string;
tag_value: string;
topic: string;
};

interface ActionCreateInfo {
Expand All @@ -85,7 +128,7 @@ interface ActionCreateInfo {
/**
* Description of the action.
*/
description?: string | null;
description?: string;
lock?: boolean;
/**
* Type of action
Expand Down