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

Improve the interface of the Actions class #98

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 2 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
51 changes: 47 additions & 4 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: string | string[];
type: "script";
mateuscardosodeveloper marked this conversation as resolved.
Show resolved Hide resolved
}
| {
Expand Down Expand Up @@ -34,17 +34,41 @@ type ActionTypeParams =
payload: string;
topic: string;
type: "mqtt";
qos?: number;
retain?: boolean;
mateuscardosodeveloper marked this conversation as resolved.
Show resolved Hide resolved
}
| {
headers: {};
fallback_token?: string | null | undefined;
mateuscardosodeveloper marked this conversation as resolved.
Show resolved Hide resolved
type: "post";
mateuscardosodeveloper marked this conversation as resolved.
Show resolved Hide resolved
url: string;
}
| {
type: "insert_bucket";
}
| {
type: "tcore";
tcore_id: string;
device_token: string;
mateuscardosodeveloper marked this conversation as resolved.
Show resolved Hide resolved
}
| {
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 | null | undefined;
lock?: boolean;
mateuscardosodeveloper marked this conversation as resolved.
Show resolved Hide resolved
/**
* Type of action
Expand Down
Loading