import { IsDateString, IsNumber, IsOptional } from 'class-validator';
import { JSONSchema } from 'class-validator-jsonschema';
export class BasicEntity {
@IsNumber()
id: number;
@JSONSchema({
description: '是否删除',
})
@IsNumber()
is_del: number;
@JSONSchema({
description: '组织id',
})
@IsNumber()
organization_id: number;
@JSONSchema({
description: '创建时间',
})
@IsDateString()
create_time: Date;
@JSONSchema({
description: '更新时间',
})
@IsDateString()
update_time: Date;
@JSONSchema({
description: 'guid',
})
guid: string;
}
export type OmitBasicEntity<T> = Omit<T, keyof BasicEntity>;
export interface FlowEntity {
id: number;
status: number;
data: FlowData;
create_time: string;
update_time: string;
user_id: number;
name: string;
key: string;
flow_type: string;
uuid: string;
organization_id: number;
is_del: number;
}
interface FlowData {
periods: string[];
nodes: FlowNode[];
meta: FlowMeta;
}
interface ObjectEvent {
name: string;
object_type: 'flow' | 'group' | 'user';
object_model: string;
object_event: 'step_active' | 'save_step_form' | 'user_update_form' | 'create_project';
action_type: string;
params_script: string;
mapping_script: string;
}
export interface FlowMeta {
form_template: number;
table_list_template: number;
table_filter_template: number;
condational_jump: Condationaljump[];
order: number;
lambda_step_visible: string;
isMeta: boolean;
public_create: boolean;
public_create_domain: string;
cold_data_handler: any;
use_template_project_name: boolean;
project_name_template: string;
task_project_name_template: string;
computed_fields: Computedfield[];
computed_fields_with_forms: boolean;
ignorePause: boolean;
plan_end_time_type: string;
name: string;
hide_fields: any[];
attachment_required: any[];
arrange_steps_owner: Arrangestepsowner[];
hook: Hook;
service_hook_url: string;
/* 子流程定时任务 */
/** 项目创建规则和数据映射 */
interval_auto_replay_create_rule: string;
/** 是否激活子流程定时任务创建规则 */
interval_auto_replay_create_rule_enable: boolean;
object_events: ObjectEvent[];
// 允许废弃项目的环节
abandon_steps: string[];
abandon_script: string;
// 允许撤销项目的环节
withdraw_steps: string[];
}
interface Hook {
[key: string]: Hookmetaprojectcreate;
}
interface Hookmetaprojectcreate {
config: Config;
key: string;
organization_id: number;
enable: boolean;
name: string;
type: string;
}
interface Config {
flow_type: string;
flow_key?: any;
}
interface Computedfield {
name: string;
value: string;
fieldType: string;
type: string;
filter: string;
__uniqueId: string;
}
interface Condationaljump {
i: number;
name: string;
result: string;
condition: string;
__uniqueId: string;
}
export interface FlowNode {
id: string;
name: string;
period: string;
start_step: boolean;
approve_to_step: string;
approve_fail: string;
approve_actions: string[];
approve_fail_actions: any[];
condational_nodes?: Condationalnode[];
auto_trigger_flows: Auto_trigger_flow;
approve_count_required: number;
arrange_owner_steps: any[];
arrange_self_steps: string[];
arrange_steps_owner: any[];
attachment_required: any[];
auto_end_by_subflow: boolean;
auto_fail_by_subflow: boolean;
auto_range_type: string;
auto_range_by_role: boolean;
bind_by_subflow: boolean;
bind_subflow_add_btn_text: string;
bind_subflow_title: string;
bind_subflow: string;
canExpand: boolean;
cc_type: string;
cc_user_role: any[];
cc_user_by_script: string;
cc_message_template: string;
cc_user: any[];
create_step: boolean;
description: string;
done_count_required: number;
end_action_by_subflow: string;
expand: boolean;
fail_action_by_subflow: string;
form_template?: any;
hide_step_detail: boolean;
hook: Hook;
multiple_actions: boolean;
need_confirm: boolean;
object_events: any[];
owner_is_creater: boolean;
owner_roles: any[];
plan_end_time: boolean;
plan_start_time: boolean;
public: boolean;
report_actions: any[];
role_logic: string;
seperate_content: boolean;
set_step_owner_time_limit: boolean;
show_on_pending: boolean;
start_time: boolean;
step_detail_id?: any;
message_template: string;
step_transform: string;
sub_flow_actions: string[];
plugin_urgent_reminder: Plugin_urgent_reminder;
plugin_create_feishu_chat: Plugin_create_feishu_chat;
cc_delay_time?: any;
cc_matrix: Cc_matrix;
matrix_owner: Matrix_owner;
enable_relate_project_form: boolean;
plugin_plugin_step_agent: Plugin_plugin_step_agent;
plugin_step_agent_tip: Plugin_step_agent_tip;
plugin_feishu_feed_card: Plugin_feishu_feed_card;
plugin_feishu_task: Plugin_feishu_task;
plugin_plugin_logical_nodes: Plugin_plugin_logical_node;
plugin_rejection_control: Plugin_rejection_control;
}
interface Flow {
flow: string;
create_rule: string;
__uniqueId: string;
}
interface Auto_trigger_flow {
flows: Flow[];
create_again: boolean;
manual_end: boolean;
all_finish_action: string;
fail_action: string;
}
interface Plugin_urgent_reminder {
enabled: boolean;
auto: boolean;
auto_action: string;
auto_action_time: string;
auto_action_deplay: string;
auto_remind_delay: string;
freq_control: string;
urgent: boolean;
chat_flow: string;
template: string;
flows: any[];
}
interface Plugin_create_feishu_chat {
type: string;
enabled: boolean;
chatName: string;
autoSendMessage: boolean;
autoSendCard: boolean;
subFlow: boolean;
advancedTaskCard: boolean;
platform_id: string;
member_script: string;
enable_update: boolean;
update_chat_configs: any[];
triggerMode: string;
chatRange: string;
chatOwner: string;
}
interface Cc_matrix {}
interface Matrix_owner {}
interface Plugin_plugin_step_agent {
enabled: boolean;
type: string;
prompt: string;
team_prompt: string;
action: string;
agent_id: string;
agent_key: string;
agent_team_id: string;
human_cost: number;
}
interface Plugin_step_agent_tip {
enabled: boolean;
prompt: string;
action: string;
agent_id: string;
agent_key: string;
}
interface Plugin_feishu_feed_card {
type: string;
enabled: boolean;
card_template: string;
platform_id: string;
enable_update: boolean;
update_card_configs: any[];
}
interface Plugin_feishu_task {
enabled: boolean;
mapping_function: string;
platform_id: string;
}
interface Plugin_plugin_logical_node {
enabled: boolean;
}
interface Plugin_rejection_control {
enabled: boolean;
button_text: string;
disabled_form_validate: boolean;
}
interface Arrangestepsowner {
i: number;
name: string;
steps: string[];
condition: string;
}
interface Condationalnode {
i: number;
name: string;
result: string[];
condition: string;
}
import { IsNotEmpty, IsOptional, IsNumber } from 'class-validator';
import { JSONSchema } from 'class-validator-jsonschema';
import { BasicEntity } from '../BasicEntity';
@think.Entity()
@JSONSchema({
title: '项目实体',
})
export class ProjectEntity extends BasicEntity implements Data2 {
@IsNotEmpty()
id: number;
@JSONSchema({
description: '项目名称',
})
@IsOptional()
name?: any;
customer_name?: any;
@JSONSchema({
description: '项目简介',
})
@IsOptional()
brief: string;
qualification: string;
project_type_ids: string;
address?: any;
@JSONSchema({
description: '0 未开始 1 进行中 2 完结 3 延期 4 失败, 5 暂停',
})
@IsNumber()
@IsNotEmpty()
status: number;
@JSONSchema({
description: '结束流程环节id',
})
@IsNumber()
end_flow_step_id: number;
@JSONSchema({
description: '结束环节id',
})
@IsNumber()
end_step_id: number;
@JSONSchema({
description: '计算字段',
})
@IsOptional()
computed?: any;
@JSONSchema({
description: '延期程度: 0 未延期 1 延期预期 2 已延期',
})
@IsOptional()
delay_level: number;
@JSONSchema({
description: '计划结束时间',
})
@IsOptional()
plan_end_time?: any;
@JSONSchema({
description: '项目创建人',
})
@IsOptional()
user_id: number;
project_id: number;
step_id: number;
app_id: number;
key: string;
flow_type: string;
contract_id: string;
customer_id: number;
path: string;
@JSONSchema({
description: '项目负责人,默认为项目创建人',
})
@IsOptional()
owner_id: number;
@JSONSchema({
description: '流程id',
})
@IsOptional()
flow_id: number;
archive_time?: any;
time_cost: any[];
@JSONSchema({
description: '项目负责人',
})
@IsOptional()
owner: Owner;
@JSONSchema({
description: '项目附件列表',
})
@IsOptional()
attachments: Attachment[];
@JSONSchema({
description: '项目创建表单',
})
@IsOptional()
metaForm: MetaForm;
@JSONSchema({
description: '项目环节负责人列表',
})
@IsOptional()
step_owner_list: Stepownerlist[];
@IsOptional()
ext_config: Extconfig;
}
interface Data2 {
id: number;
name?: any;
customer_name?: any;
brief: string;
qualification: string;
project_type_ids: string;
address?: any;
status: number;
computed?: any;
delay_level: number;
create_time: string;
update_time: string;
plan_end_time?: any;
user_id: number;
project_id: number;
step_id: number;
app_id: number;
key: string;
flow_type: string;
contract_id: string;
customer_id: number;
owner_id: number;
flow_id: number;
organization_id: number;
is_del: number;
archive_time?: any;
time_cost: any[];
owner: Owner;
attachments: Attachment[];
metaForm: MetaForm;
step_owner_list: Stepownerlist[];
}
interface Stepownerlist {
id: number;
name: string;
avatar: string;
status: number;
step_id: number;
limit_start_time?: any;
limit_end_time?: any;
attr: string;
organization_id: number;
flow_step_id: string;
project_id: number;
role: Role[];
}
interface MetaForm {
id: number;
project_id: number;
form_id?: any;
step_id: number;
name?: any;
desc?: any;
create_time: string;
update_time: string;
is_del: number;
template_id: number;
user_id: number;
organization_id: number;
value: Value2[];
form_template: Formtemplate;
}
interface Formtemplate {
id: number;
rule: Rule[][];
name: string;
option: Option3;
update_time: string;
origin_template_id: number;
}
interface Option3 {
form: Form;
submitBtn: boolean;
isTemplate: boolean;
isPreview: boolean;
}
interface Form {
inline: boolean;
hideRequiredAsterisk: boolean;
labelPosition: string;
size: string;
labelWidth: string;
}
interface Rule {
prefix: Prefix;
info: Info;
lambda_version: string;
lambda: string;
lambdaFields: string[];
type: string;
name?: string;
field: string;
title: string;
defaultValueType?: string;
props: Props3;
style?: Style;
effect: Effect;
_fc_drag_tag: string;
value?: null[] | any[];
hidden: boolean;
display: boolean;
options: Option2[];
children: any[];
quickValue?: boolean;
shouldLimit?: boolean;
}
interface Option2 {
label: string;
value: string;
}
interface Effect {
_fc: boolean;
fetch?: string;
}
interface Style {
width: string;
}
interface Props3 {
maxlength?: number;
placeholder?: string;
clearable?: boolean;
COMPLETE?: boolean;
multiple?: boolean;
props?: Props2;
options?: Option[];
showDetailAddress?: boolean;
priorProvince?: string;
action?: string;
data?: Data;
accept?: string;
uploadType?: string;
allowRemove?: boolean;
disabled?: boolean;
}
interface Data {
}
interface Option {
label: string;
workload?: Workload2;
children?: Child[];
}
interface Child {
label: string;
workload: Workload3;
}
interface Workload3 {
unit: string;
total: number;
computed: (Computed | Computed)[];
}
interface Workload2 {
unit: string;
total: number;
computed: Computed[];
}
interface Props2 {
multiple: boolean;
value: string;
}
interface Info {
info: string;
align: string;
class: string;
}
interface Prefix {
type: string;
props: Props;
}
interface Props {
value: string;
}
interface Value2 {
id: number;
field: string;
form_id: number;
title: string;
validateMap: ValidateMap;
value: Value;
search_value: string;
create_time: string;
update_time: string;
is_del: number;
template_id: number;
field_type: string;
}
interface Value {
value?: any[] | string[][] | (null | string)[];
type: string;
checkedDatas?: CheckedData[];
}
interface CheckedData {
label: string;
workload: Workload;
}
interface Workload {
unit: string;
total: number;
computed: Computed[];
}
interface Computed {
name: string;
period: string;
workload: number;
computed_type: string;
}
interface ValidateMap {
required: boolean;
}
interface Attachment {
id: number;
url: string;
name: string;
create_time: string;
update_time: string;
step_id: number;
project_id: number;
user_id: number;
organization_id: number;
is_del: number;
}
interface Owner {
id: number;
name: string;
avatar: string;
phone: string;
extra?: any;
role: Role[];
}
interface Role {
name: string;
key: string;
user_id: number;
}
import { IsNumber, IsString, IsArray, IsObject } from 'class-validator';
import { BasicEntity } from '../BasicEntity';
import { JSONSchema } from 'class-validator-jsonschema';
@think.Entity()
@JSONSchema({
description: '环节实体'
})
export class StepEntity extends BasicEntity {
@JSONSchema({
description: '环节名称,同流程环节名称'
})
@IsString()
name: string;
version: any[];
@JSONSchema({
description: '环节阶段'
})
@IsString()
period: string;
plan_time_cost: number;
@JSONSchema({
description: '来源流程节点id'
})
@IsNumber()
from_flow_step_id?: any;
@JSONSchema({
description: '流程节点id'
})
@IsNumber()
flow_step_id: string;
order: number;
accept_start_time?: any;
@JSONSchema({
description: '实际开始时间'
})
@IsString()
real_start_time: string;
step_alive_time?: any;
@JSONSchema({
description: '计划开始时间'
})
@IsString()
plan_start_time?: any;
@JSONSchema({
description: '实际结束时间'
})
@IsString()
real_end_time?: any;
@JSONSchema({
description: '计划结束时间'
})
@IsString()
plan_end_time?: any;
brief?: any;
@JSONSchema({
description: '0 未开始 1 进行中 2 完结 3 延期 4 失败, 5 暂停',
})
@IsNumber()
status: number;
is_public: number;
show_on_pending: number;
delay_level: number;
user_id: number;
flow_id: number;
organization_id: number;
project_id: number;
is_del: number;
seperate_content: number;
form_template_id: number;
reference_attachments: any[];
attachments: any[];
@JSONSchema({
description: '环节表单'
})
@IsObject()
formList: any[];
@JSONSchema({
description: '环节表单模板'
})
@IsObject()
form_template: Form_template;
@JSONSchema({
description: '环节负责人列表'
})
@IsArray()
owner: Owner[];
}
interface FormValue {
value: string;
type: string;
}
interface ValidateMap {
required: boolean;
}
interface Value {
field: string;
title: string;
template_id: number;
field_type: string;
value: FormValue;
validateMap: ValidateMap;
}
interface Step_form {
value: Value[];
title_to_value?: Record<string, any>;
field_to_value?: Record<string, any>;
}
interface Raw {
uid: number;
}
interface Attachment {
status: string;
name: string;
size: number;
percentage: number;
uid: number;
raw: Raw;
response: string;
url: string;
}
interface User_list {
type: string;
user_id: number;
}
export interface NextStep {
step_form: Step_form;
real_start_time: string;
brief?: any;
attachments: Attachment[];
attachment_reference: any[];
self_steps: string[];
description: string;
step_id?: number;
project_id: number;
flow_step_id?: number;
user_list: User_list[];
action: 'approve' | 'accept' | 'manualUpload' | 'refuse';
// 自定义条件节点name
condition_name: string;
// 要跳转的流程环节id, 如果不传则走默认流程
// 当action = 'approve' 且 当前环节有条件节点并且不存在condition_name时会调用第一个自定义条件节点脚本
target_step?: string;
}
interface Form {
size: string;
inline: boolean;
labelWidth: string;
labelPosition: string;
hideRequiredAsterisk: boolean;
}
interface Option {
form: Form;
submitBtn: boolean;
}
interface Form_template {
id: number;
name: string;
desc?: any;
option: Option;
rule: any[][];
value: Value[];
create_time: string;
update_time: string;
is_del: number;
origin_template_id: number;
user_id: number;
organization_id: number;
}
interface Role {
name: string;
key: string;
user_id: number;
}
interface Owner {
id: number;
name: string;
avatar: string;
status: number;
step_id: number;
limit_start_time?: any;
limit_end_time?: any;
attr?: any;
role: Role[];
}
// type GroupEntity = {
// children?: GroupEntity[];
// type: EntityType;
// parent_id: number;
// level: number;
// path: string;
// permission: GroupPermission;
// sub_entitys: EntityType[]
// groupModel: GroupModelEntity;
// [p: string]: any;
// };
import { JSONSchema } from 'class-validator-jsonschema';
import { BasicEntity } from '../BasicEntity';
import { Type } from 'class-transformer';
import { IsNumber, IsOptional, IsString } from 'class-validator';
import { GroupModelEntity } from './GroupModelEntity';
export enum EntityType {
user = 'user',
group = 'group'
}
export type GroupPermission = {
value: string;
config: any;
};
@think.Entity()
@JSONSchema({
title: '重复项目',
})
export class GroupEntity extends BasicEntity {
name: string;
user_id: number;
partner_id: string;
@IsOptional()
@Type(() => GroupEntity)
children?: GroupEntity[];
@IsString()
_type: EntityType
@IsString()
parent_id: number;
@IsNumber()
level: number;
@IsString()
path: string;
@IsOptional()
model_id: number;
@IsOptional()
meta_form: any;
permission: GroupPermission;
sub_entitys: EntityType[];
model?: GroupModelEntity;
platform_feishu_department_id?: string;
meta_form_id: number;
}
import { Type } from 'class-transformer';
import { IsEnum, IsNotEmpty, ValidateNested } from 'class-validator';
import { JSONSchema, } from 'class-validator-jsonschema';
import { ProjectEntity } from './ProjectEntity';
import { StepEntity } from './StepEntity';
@think.Entity()
@JSONSchema({
description: '流程事件回调携带数据',
})
export class HookCallbackEntity {
@JSONSchema({
description: '事件类型',
enum: [ 'PROJECT_CREATE (项目创建)', 'PROJECT_END (项目结束)', 'STEP_ACTIVE (环节开始)', 'STEP_FINISH (环节结束)']
})
@IsNotEmpty()
action: string;
@JSONSchema({
description: '事件数据3',
oneOf: [
{
$ref: '#/components/schemas/ProjectEntity',
title: '项目数据',
},
{
$ref: '#/components/schemas/StepEntity',
title: '环节数据'
}
]
})
@Type(() => Object, {
keepDiscriminatorProperty: true,
discriminator: {
property: 'type',
subTypes: [
{
value: ProjectEntity,
name: 'project'
},
{
value: StepEntity,
name: 'step'
}
]
}
})
@ValidateNested({ each: true })
@IsNotEmpty()
data: ProjectEntity | StepEntity;
}