@skychameleon/workflow 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +0 -0
- package/package.json +19 -0
- package/workflow/blocks/base.schema.d.ts +19 -0
- package/workflow/blocks/chat_bot/input-file.schema.ts +16 -0
- package/workflow/blocks/chat_bot/input-text.schema.ts +35 -0
- package/workflow/blocks/chat_bot/send-file.schema.ts +19 -0
- package/workflow/blocks/chat_bot/send-msg.schema.d.ts +11 -0
- package/workflow/blocks/general/run-code.schema.d.ts +8 -0
- package/workflow/blocks/general/start.schema.d.ts +10 -0
- package/workflow/blocks/general/var-set.schema.d.ts +25 -0
- package/workflow/blocks/registry.ts +18 -0
- package/workflow/blocks/shared/general.types.d.ts +63 -0
- package/workflow/edges/base.schema.d.ts +9 -0
- package/workflow/edges/query-rule.schema.d.ts +38 -0
- package/workflow/workflow.schema.d.ts +18 -0
package/index.ts
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@skychameleon/workflow",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Everything about workflow",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"format": "npx prettier --write ."
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@skychameleon/core": "^1.0.3"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
"./workflow.schema": "./workflow/workflow.schema.d.ts"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { EntranceHandler, ExitHandler } from "./shared/general.types";
|
|
2
|
+
|
|
3
|
+
type ChatBotBlockTypes = "send_file" | "send_msg" | "input-text" | "input-file";
|
|
4
|
+
|
|
5
|
+
type MainBlockTypes = "start" | "var_set" | "run_code";
|
|
6
|
+
|
|
7
|
+
type BlockTypes = MainBlockTypes | ChatBotBlockTypes;
|
|
8
|
+
|
|
9
|
+
export interface BaseBlockSchema<T extends BlockTypes> {
|
|
10
|
+
_id: string;
|
|
11
|
+
type: T;
|
|
12
|
+
label: string;
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
entrance: EntranceHandler;
|
|
18
|
+
exit: ExitHandler;
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BaseBlockSchema } from "../base.schema";
|
|
2
|
+
import type { VarSetBlockSchema } from "../general/var-set.schema";
|
|
3
|
+
import type {
|
|
4
|
+
AdditionalOptions,
|
|
5
|
+
InputVarChatBotType,
|
|
6
|
+
SendText,
|
|
7
|
+
} from "../shared/general.types";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Блок отвечающий за получения файла
|
|
11
|
+
*/
|
|
12
|
+
export interface InputFileChatBotBlockSchema extends BaseBlockSchema<"input-file"> {
|
|
13
|
+
sendText: SendText;
|
|
14
|
+
varSet: Omit<VarSetBlockSchema<InputVarChatBotType>, "code">;
|
|
15
|
+
additionalOptions: Pick<AdditionalOptions, "back_button" | "skip_button">;
|
|
16
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { BaseBlockSchema } from "../base.schema";
|
|
2
|
+
import type { VarSetBlockSchema } from "../general/var-set.schema";
|
|
3
|
+
import type {
|
|
4
|
+
AdditionalOptions,
|
|
5
|
+
CodeExpression,
|
|
6
|
+
InputVarChatBotType,
|
|
7
|
+
SendText,
|
|
8
|
+
} from "../shared/general.types";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Типы для составления клавиатуры
|
|
12
|
+
* Если создается кодом - KeyboardCode, то он должен вернуть объекта типа KeyboardConstructor
|
|
13
|
+
*/
|
|
14
|
+
export type KeyboardCode = CodeExpression;
|
|
15
|
+
export type KeyboardConstructor = {
|
|
16
|
+
text:
|
|
17
|
+
| string
|
|
18
|
+
| {
|
|
19
|
+
useCodeExpression: boolean;
|
|
20
|
+
code: CodeExpression;
|
|
21
|
+
};
|
|
22
|
+
callback_data: string;
|
|
23
|
+
}[];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Блок отвечающий за получения текстового сообщения
|
|
27
|
+
*/
|
|
28
|
+
export interface InputTextChatBotBlockSchema extends BaseBlockSchema<"input-text"> {
|
|
29
|
+
sendText: SendText;
|
|
30
|
+
validator: false | CodeExpression; // валидирует полученное сообщение, в случае не сопаставление можно выдать ошибку
|
|
31
|
+
convertor: false | CodeExpression; // конвертирует полученное сообщение в другое значение&тип
|
|
32
|
+
varSet: Omit<VarSetBlockSchema<InputVarChatBotType>, "code">;
|
|
33
|
+
keyboard: false | KeyboardConstructor | KeyboardCode;
|
|
34
|
+
additionalOptions: Pick<AdditionalOptions, "back_button" | "skip_button">;
|
|
35
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BaseBlockSchema } from "../base.schema";
|
|
2
|
+
import type { VarSetBlockSchema } from "../general/var-set.schema";
|
|
3
|
+
import type {
|
|
4
|
+
AdditionalOptions,
|
|
5
|
+
CodeExpression,
|
|
6
|
+
VarType,
|
|
7
|
+
SendText,
|
|
8
|
+
} from "../shared/general.types";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Блок отвечающий за отправление файлов
|
|
12
|
+
*/
|
|
13
|
+
export interface SendFileChatBotBlockSchema extends BaseBlockSchema<"send_file"> {
|
|
14
|
+
several: boolean;
|
|
15
|
+
sendText: SendText;
|
|
16
|
+
varSet: Omit<VarSetBlockSchema<VarType.BOOLEAN>, "code">;
|
|
17
|
+
errorText: string;
|
|
18
|
+
additionalOptions: Pick<AdditionalOptions, "send_other_chat">;
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BaseBlockSchema } from "../base.schema";
|
|
2
|
+
import type { AdditionalOptions, SendText } from "../shared/general.types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Блок отвечающий за отправление текстового сообщения
|
|
6
|
+
*/
|
|
7
|
+
export interface SendMsgChatBotBlockSchema extends BaseBlockSchema<"send_msg"> {
|
|
8
|
+
markdown: boolean;
|
|
9
|
+
sendText: SendText;
|
|
10
|
+
additionalOptions: Pick<AdditionalOptions, "send_other_chat">;
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BaseBlockSchema } from "../base.schema";
|
|
2
|
+
import type { VarType } from "../shared/general.types";
|
|
3
|
+
import type { VarSetBlockSchema } from "./var-set.schema";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Блок отвечающий за запуск сценария и содержащий все необходимые переменные для работы
|
|
7
|
+
*/
|
|
8
|
+
export interface StartBlockSchema extends BaseBlockSchema<"start"> {
|
|
9
|
+
vars: VarSetBlockSchema<VarType>[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { BaseBlockSchema } from "../base.schema";
|
|
2
|
+
import type { VarType, InputVarChatBotType } from "../shared/general.types";
|
|
3
|
+
|
|
4
|
+
type CompletionTypes = `function` | `variable`;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Блок отвечающий за создание переменной в контексте клиента
|
|
8
|
+
*/
|
|
9
|
+
export interface VarSetBlockSchema<
|
|
10
|
+
Type extends VarType | InputVarChatBotType,
|
|
11
|
+
> extends BaseBlockSchema<"var_set"> {
|
|
12
|
+
name: string;
|
|
13
|
+
varType: Type;
|
|
14
|
+
code: string;
|
|
15
|
+
completion:
|
|
16
|
+
| false
|
|
17
|
+
| {
|
|
18
|
+
// для подсказки в редакторе-codemirror
|
|
19
|
+
label?: string;
|
|
20
|
+
type?: CompletionTypes;
|
|
21
|
+
detail?: string;
|
|
22
|
+
info?: string;
|
|
23
|
+
apply?: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RunCodeBlockSchema } from "./general/run-code.schema.d.ts";
|
|
2
|
+
import type { StartBlockSchema } from "./general/start.schema.d.ts";
|
|
3
|
+
import type { VarSetBlockSchema } from "./general/var-set.schema.d.ts";
|
|
4
|
+
import type { InputVarChatBotType, VarType } from "./shared/general.types.d.ts";
|
|
5
|
+
import type { SendMsgChatBotBlockSchema } from "./chat_bot/send-msg.schema.d.ts";
|
|
6
|
+
import type { SendFileChatBotBlockSchema } from "./chat_bot/send-file.schema.d.ts";
|
|
7
|
+
import type { InputTextChatBotBlockSchema } from "./chat_bot/input-text.schema.d.ts";
|
|
8
|
+
import type { InputFileChatBotBlockSchema } from "./chat_bot/input-file.schema.d.ts";
|
|
9
|
+
|
|
10
|
+
export type GeneralBlockSchema =
|
|
11
|
+
| StartBlockSchema
|
|
12
|
+
| VarSetBlockSchema<VarType | InputVarChatBotType>
|
|
13
|
+
| RunCodeBlockSchema;
|
|
14
|
+
export type ChatBotBlockSchema =
|
|
15
|
+
| SendMsgChatBotBlockSchema
|
|
16
|
+
| SendFileChatBotBlockSchema
|
|
17
|
+
| InputTextChatBotBlockSchema
|
|
18
|
+
| InputFileChatBotBlockSchema;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export type CodeExpression = string;
|
|
2
|
+
/**
|
|
3
|
+
* Обработчик блока после выхода из основной логики бота
|
|
4
|
+
*/
|
|
5
|
+
export type ExitHandler =
|
|
6
|
+
| false
|
|
7
|
+
| {
|
|
8
|
+
code: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Обработчик блока перед входом в основную логику бота
|
|
12
|
+
*/
|
|
13
|
+
export type EntranceHandler =
|
|
14
|
+
| false
|
|
15
|
+
| {
|
|
16
|
+
code: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
interface DynamicText {
|
|
20
|
+
useCodeExpression: boolean;
|
|
21
|
+
code: CodeExpression;
|
|
22
|
+
}
|
|
23
|
+
export type SendText = string | DynamicText;
|
|
24
|
+
export type ChatID = number;
|
|
25
|
+
/**
|
|
26
|
+
* Дополнительные опции для чат-ботов
|
|
27
|
+
*/
|
|
28
|
+
export type AdditionalOptions = {
|
|
29
|
+
back_button:
|
|
30
|
+
| false
|
|
31
|
+
| string
|
|
32
|
+
| {
|
|
33
|
+
useCodeExpression: boolean;
|
|
34
|
+
code: CodeExpression;
|
|
35
|
+
};
|
|
36
|
+
skip_button:
|
|
37
|
+
| false
|
|
38
|
+
| string
|
|
39
|
+
| {
|
|
40
|
+
useCodeExpression: boolean;
|
|
41
|
+
code: CodeExpression;
|
|
42
|
+
};
|
|
43
|
+
send_other_chat: false | ChatID;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Типы переменных
|
|
48
|
+
*
|
|
49
|
+
* Типы для полученных сообщений из чат-ботов
|
|
50
|
+
* Общие типы
|
|
51
|
+
*/
|
|
52
|
+
export enum InputVarChatBotType {
|
|
53
|
+
FILE = "file",
|
|
54
|
+
}
|
|
55
|
+
export enum VarType {
|
|
56
|
+
STRING = "string",
|
|
57
|
+
NUMBER = "number",
|
|
58
|
+
BOOLEAN = "boolean",
|
|
59
|
+
OBJECT = "object",
|
|
60
|
+
ARRAY = "array",
|
|
61
|
+
FUNCTION = "function",
|
|
62
|
+
ANY = "any",
|
|
63
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { VarType } from "../blocks/shared/general.types";
|
|
2
|
+
import type { BaseEdgeSchema } from "./base.schema";
|
|
3
|
+
|
|
4
|
+
export enum LogicOperator {
|
|
5
|
+
AND = "and",
|
|
6
|
+
OR = "or",
|
|
7
|
+
}
|
|
8
|
+
export enum ConditionList {
|
|
9
|
+
EMPTY = "empty",
|
|
10
|
+
NOT_EMPTY = "not_empty",
|
|
11
|
+
EQUAL = "equal",
|
|
12
|
+
NOT_EQUAL = "not_equal",
|
|
13
|
+
LESS = "less",
|
|
14
|
+
LESS_OR_EQUAL = "less_or_equal",
|
|
15
|
+
GREATER = "greater",
|
|
16
|
+
GREATER_OR_EQUAL = "greater_or_equal",
|
|
17
|
+
IS_NULL = "is_null",
|
|
18
|
+
IS_NOT_NULL = "is_not_null",
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface SingleRuleGuard {
|
|
22
|
+
var: string;
|
|
23
|
+
typeVar: VarType;
|
|
24
|
+
/*--*/
|
|
25
|
+
condition: ConditionList;
|
|
26
|
+
/*--*/
|
|
27
|
+
valueMode: {
|
|
28
|
+
mode: "value" | "variable" | "expression";
|
|
29
|
+
value: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface RuleGuardGroup {
|
|
34
|
+
operator: LogicOperator;
|
|
35
|
+
guards: (SingleRuleGuard | RuleGuardGroup)[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type QueryRuleEdgeSchema = BaseEdgeSchema<"query-rule", RuleGuardGroup>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ChatBotBlockSchema, GeneralBlockSchema } from "./blocks/registry";
|
|
2
|
+
import type { QueryRuleEdgeSchema } from "./edges/query-rule.schema";
|
|
3
|
+
|
|
4
|
+
export interface Metadata {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
exportedAt: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface WorkflowSchema {
|
|
11
|
+
states: {
|
|
12
|
+
blocks: (GeneralBlockSchema | ChatBotBlockSchema)[];
|
|
13
|
+
edges: QueryRuleEdgeSchema[];
|
|
14
|
+
};
|
|
15
|
+
metadata: Metadata;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default WorkflowSchema;
|