@contractspec/example.workflow-system 3.7.5 → 3.7.7
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/README.md +69 -119
- package/dist/approval/approval.event.js +1 -1
- package/dist/approval/approval.handler.d.ts +1 -1
- package/dist/approval/index.d.ts +4 -4
- package/dist/approval/index.js +1 -1
- package/dist/browser/approval/approval.event.js +1 -1
- package/dist/browser/approval/index.js +1 -1
- package/dist/browser/entities/index.js +166 -166
- package/dist/browser/index.js +1800 -1802
- package/dist/browser/instance/index.js +210 -210
- package/dist/browser/instance/instance.event.js +1 -1
- package/dist/browser/ui/hooks/index.js +1 -1
- package/dist/browser/ui/hooks/useWorkflowList.js +1 -1
- package/dist/browser/ui/index.js +1 -1
- package/dist/entities/index.d.ts +53 -53
- package/dist/entities/index.js +166 -166
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1800 -1802
- package/dist/instance/index.d.ts +3 -3
- package/dist/instance/index.js +210 -210
- package/dist/instance/instance.event.js +1 -1
- package/dist/instance/instance.handler.d.ts +1 -1
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/mock-data.d.ts +1 -1
- package/dist/ui/hooks/index.js +1 -1
- package/dist/ui/hooks/useWorkflowList.js +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/workflow/index.d.ts +4 -4
- package/dist/workflow/workflow.handler.d.ts +1 -1
- package/package.json +10 -10
package/dist/browser/index.js
CHANGED
|
@@ -19,7 +19,7 @@ var ApprovalDecisionEnum = defineEnum("ApprovalDecision", [
|
|
|
19
19
|
|
|
20
20
|
// src/approval/approval.event.ts
|
|
21
21
|
import { defineEvent } from "@contractspec/lib.contracts-spec";
|
|
22
|
-
import {
|
|
22
|
+
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
23
23
|
var ApprovalRequestedPayload = defineSchemaModel({
|
|
24
24
|
name: "ApprovalRequestedEventPayload",
|
|
25
25
|
description: "Payload when approval is requested",
|
|
@@ -910,398 +910,596 @@ function createWorkflowHandlers(db) {
|
|
|
910
910
|
};
|
|
911
911
|
}
|
|
912
912
|
|
|
913
|
-
// src/
|
|
913
|
+
// src/instance/instance.enum.ts
|
|
914
914
|
import { defineEnum as defineEnum2 } from "@contractspec/lib.schema";
|
|
915
|
-
var
|
|
916
|
-
"
|
|
917
|
-
"
|
|
918
|
-
"
|
|
919
|
-
"
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
"
|
|
923
|
-
"
|
|
924
|
-
"SCHEDULED",
|
|
925
|
-
"API"
|
|
926
|
-
]);
|
|
927
|
-
var StepTypeEnum = defineEnum2("StepType", [
|
|
928
|
-
"START",
|
|
929
|
-
"APPROVAL",
|
|
930
|
-
"TASK",
|
|
931
|
-
"CONDITION",
|
|
932
|
-
"PARALLEL",
|
|
933
|
-
"WAIT",
|
|
934
|
-
"ACTION",
|
|
935
|
-
"END"
|
|
936
|
-
]);
|
|
937
|
-
var ApprovalModeEnum = defineEnum2("ApprovalMode", [
|
|
938
|
-
"ANY",
|
|
939
|
-
"ALL",
|
|
940
|
-
"MAJORITY",
|
|
941
|
-
"SEQUENTIAL"
|
|
915
|
+
var InstanceStatusEnum = defineEnum2("InstanceStatus", [
|
|
916
|
+
"PENDING",
|
|
917
|
+
"RUNNING",
|
|
918
|
+
"WAITING",
|
|
919
|
+
"PAUSED",
|
|
920
|
+
"COMPLETED",
|
|
921
|
+
"CANCELLED",
|
|
922
|
+
"FAILED",
|
|
923
|
+
"TIMEOUT"
|
|
942
924
|
]);
|
|
943
925
|
|
|
944
|
-
// src/
|
|
926
|
+
// src/instance/instance.event.ts
|
|
927
|
+
import { defineEvent as defineEvent2 } from "@contractspec/lib.contracts-spec";
|
|
945
928
|
import { defineSchemaModel as defineSchemaModel4, ScalarTypeEnum as ScalarTypeEnum4 } from "@contractspec/lib.schema";
|
|
946
|
-
var
|
|
947
|
-
name: "
|
|
948
|
-
description: "
|
|
949
|
-
fields: {
|
|
950
|
-
id: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
|
|
951
|
-
key: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
|
|
952
|
-
name: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
|
|
953
|
-
description: { type: ScalarTypeEnum4.String_unsecure(), isOptional: true },
|
|
954
|
-
type: { type: StepTypeEnum, isOptional: false },
|
|
955
|
-
position: { type: ScalarTypeEnum4.Int_unsecure(), isOptional: false },
|
|
956
|
-
transitions: { type: ScalarTypeEnum4.JSON(), isOptional: false },
|
|
957
|
-
approvalMode: { type: ApprovalModeEnum, isOptional: true },
|
|
958
|
-
approverRoles: {
|
|
959
|
-
type: ScalarTypeEnum4.String_unsecure(),
|
|
960
|
-
isArray: true,
|
|
961
|
-
isOptional: true
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
});
|
|
965
|
-
var WorkflowDefinitionModel = defineSchemaModel4({
|
|
966
|
-
name: "WorkflowDefinitionModel",
|
|
967
|
-
description: "A workflow definition",
|
|
929
|
+
var InstanceEventPayload = defineSchemaModel4({
|
|
930
|
+
name: "InstanceEventPayload",
|
|
931
|
+
description: "Base payload for instance events",
|
|
968
932
|
fields: {
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
triggerType: { type: TriggerTypeEnum, isOptional: false },
|
|
976
|
-
initialStepId: {
|
|
977
|
-
type: ScalarTypeEnum4.String_unsecure(),
|
|
978
|
-
isOptional: true
|
|
979
|
-
},
|
|
980
|
-
featureFlagKey: {
|
|
933
|
+
instanceId: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
|
|
934
|
+
workflowId: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
|
|
935
|
+
workflowKey: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
|
|
936
|
+
status: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
|
|
937
|
+
referenceId: { type: ScalarTypeEnum4.String_unsecure(), isOptional: true },
|
|
938
|
+
referenceType: {
|
|
981
939
|
type: ScalarTypeEnum4.String_unsecure(),
|
|
982
940
|
isOptional: true
|
|
983
941
|
},
|
|
942
|
+
triggeredBy: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
|
|
984
943
|
organizationId: {
|
|
985
944
|
type: ScalarTypeEnum4.String_unsecure(),
|
|
986
945
|
isOptional: false
|
|
987
946
|
},
|
|
988
|
-
|
|
989
|
-
updatedAt: { type: ScalarTypeEnum4.DateTime(), isOptional: false },
|
|
990
|
-
steps: { type: WorkflowStepModel, isArray: true, isOptional: true }
|
|
947
|
+
timestamp: { type: ScalarTypeEnum4.DateTime(), isOptional: false }
|
|
991
948
|
}
|
|
992
949
|
});
|
|
993
|
-
var
|
|
994
|
-
name: "
|
|
995
|
-
description: "
|
|
950
|
+
var StepTransitionPayload = defineSchemaModel4({
|
|
951
|
+
name: "StepTransitionEventPayload",
|
|
952
|
+
description: "Payload for step transition events",
|
|
996
953
|
fields: {
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
954
|
+
instanceId: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
|
|
955
|
+
workflowId: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
|
|
956
|
+
fromStepKey: { type: ScalarTypeEnum4.String_unsecure(), isOptional: true },
|
|
957
|
+
toStepKey: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
|
|
958
|
+
action: { type: ScalarTypeEnum4.String_unsecure(), isOptional: true },
|
|
959
|
+
executedBy: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
|
|
960
|
+
timestamp: { type: ScalarTypeEnum4.DateTime(), isOptional: false }
|
|
961
|
+
}
|
|
962
|
+
});
|
|
963
|
+
var InstanceCompletedPayload = defineSchemaModel4({
|
|
964
|
+
name: "InstanceCompletedEventPayload",
|
|
965
|
+
description: "Payload when instance completes",
|
|
966
|
+
fields: {
|
|
967
|
+
instanceId: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
|
|
968
|
+
workflowId: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
|
|
969
|
+
workflowKey: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
|
|
970
|
+
outcome: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
|
|
971
|
+
referenceId: { type: ScalarTypeEnum4.String_unsecure(), isOptional: true },
|
|
972
|
+
referenceType: {
|
|
1003
973
|
type: ScalarTypeEnum4.String_unsecure(),
|
|
1004
974
|
isOptional: true
|
|
1005
975
|
},
|
|
1006
|
-
|
|
976
|
+
duration: { type: ScalarTypeEnum4.Int_unsecure(), isOptional: false },
|
|
977
|
+
timestamp: { type: ScalarTypeEnum4.DateTime(), isOptional: false }
|
|
1007
978
|
}
|
|
1008
979
|
});
|
|
1009
|
-
var
|
|
1010
|
-
|
|
1011
|
-
|
|
980
|
+
var InstanceStartedEvent = defineEvent2({
|
|
981
|
+
meta: {
|
|
982
|
+
key: "workflow.instance.started",
|
|
983
|
+
version: "1.0.0",
|
|
984
|
+
description: "A new workflow instance has been started.",
|
|
985
|
+
stability: "stable",
|
|
986
|
+
owners: ["@workflow-team"],
|
|
987
|
+
tags: ["workflow", "instance", "started"]
|
|
988
|
+
},
|
|
989
|
+
payload: InstanceEventPayload
|
|
990
|
+
});
|
|
991
|
+
var StepEnteredEvent = defineEvent2({
|
|
992
|
+
meta: {
|
|
993
|
+
key: "workflow.step.entered",
|
|
994
|
+
version: "1.0.0",
|
|
995
|
+
description: "A workflow instance has entered a new step.",
|
|
996
|
+
stability: "stable",
|
|
997
|
+
owners: ["@workflow-team"],
|
|
998
|
+
tags: ["workflow", "step", "entered"]
|
|
999
|
+
},
|
|
1000
|
+
payload: StepTransitionPayload
|
|
1001
|
+
});
|
|
1002
|
+
var StepExitedEvent = defineEvent2({
|
|
1003
|
+
meta: {
|
|
1004
|
+
key: "workflow.step.exited",
|
|
1005
|
+
version: "1.0.0",
|
|
1006
|
+
description: "A workflow instance has exited a step.",
|
|
1007
|
+
stability: "stable",
|
|
1008
|
+
owners: ["@workflow-team"],
|
|
1009
|
+
tags: ["workflow", "step", "exited"]
|
|
1010
|
+
},
|
|
1011
|
+
payload: StepTransitionPayload
|
|
1012
|
+
});
|
|
1013
|
+
var InstanceCompletedEvent = defineEvent2({
|
|
1014
|
+
meta: {
|
|
1015
|
+
key: "workflow.instance.completed",
|
|
1016
|
+
version: "1.0.0",
|
|
1017
|
+
description: "A workflow instance has completed.",
|
|
1018
|
+
stability: "stable",
|
|
1019
|
+
owners: ["@workflow-team"],
|
|
1020
|
+
tags: ["workflow", "instance", "completed"]
|
|
1021
|
+
},
|
|
1022
|
+
payload: InstanceCompletedPayload
|
|
1023
|
+
});
|
|
1024
|
+
var InstanceCancelledEvent = defineEvent2({
|
|
1025
|
+
meta: {
|
|
1026
|
+
key: "workflow.instance.cancelled",
|
|
1027
|
+
version: "1.0.0",
|
|
1028
|
+
description: "A workflow instance has been cancelled.",
|
|
1029
|
+
stability: "stable",
|
|
1030
|
+
owners: ["@workflow-team"],
|
|
1031
|
+
tags: ["workflow", "instance", "cancelled"]
|
|
1032
|
+
},
|
|
1033
|
+
payload: InstanceEventPayload
|
|
1034
|
+
});
|
|
1035
|
+
var InstancePausedEvent = defineEvent2({
|
|
1036
|
+
meta: {
|
|
1037
|
+
key: "workflow.instance.paused",
|
|
1038
|
+
version: "1.0.0",
|
|
1039
|
+
description: "A workflow instance has been paused.",
|
|
1040
|
+
stability: "stable",
|
|
1041
|
+
owners: ["@workflow-team"],
|
|
1042
|
+
tags: ["workflow", "instance", "paused"]
|
|
1043
|
+
},
|
|
1044
|
+
payload: InstanceEventPayload
|
|
1045
|
+
});
|
|
1046
|
+
var InstanceResumedEvent = defineEvent2({
|
|
1047
|
+
meta: {
|
|
1048
|
+
key: "workflow.instance.resumed",
|
|
1049
|
+
version: "1.0.0",
|
|
1050
|
+
description: "A workflow instance has been resumed.",
|
|
1051
|
+
stability: "stable",
|
|
1052
|
+
owners: ["@workflow-team"],
|
|
1053
|
+
tags: ["workflow", "instance", "resumed"]
|
|
1054
|
+
},
|
|
1055
|
+
payload: InstanceEventPayload
|
|
1056
|
+
});
|
|
1057
|
+
var InstanceFailedEvent = defineEvent2({
|
|
1058
|
+
meta: {
|
|
1059
|
+
key: "workflow.instance.failed",
|
|
1060
|
+
version: "1.0.0",
|
|
1061
|
+
description: "A workflow instance has failed.",
|
|
1062
|
+
stability: "stable",
|
|
1063
|
+
owners: ["@workflow-team"],
|
|
1064
|
+
tags: ["workflow", "instance", "failed"]
|
|
1065
|
+
},
|
|
1066
|
+
payload: InstanceEventPayload
|
|
1067
|
+
});
|
|
1068
|
+
var InstanceTimedOutEvent = defineEvent2({
|
|
1069
|
+
meta: {
|
|
1070
|
+
key: "workflow.instance.timedOut",
|
|
1071
|
+
version: "1.0.0",
|
|
1072
|
+
description: "A workflow instance has timed out.",
|
|
1073
|
+
stability: "stable",
|
|
1074
|
+
owners: ["@workflow-team"],
|
|
1075
|
+
tags: ["workflow", "instance", "timeout"]
|
|
1076
|
+
},
|
|
1077
|
+
payload: InstanceEventPayload
|
|
1078
|
+
});
|
|
1079
|
+
|
|
1080
|
+
// src/instance/instance.schema.ts
|
|
1081
|
+
import { defineSchemaModel as defineSchemaModel5, ScalarTypeEnum as ScalarTypeEnum5 } from "@contractspec/lib.schema";
|
|
1082
|
+
var WorkflowInstanceModel = defineSchemaModel5({
|
|
1083
|
+
name: "WorkflowInstanceModel",
|
|
1084
|
+
description: "A running workflow instance",
|
|
1012
1085
|
fields: {
|
|
1013
|
-
|
|
1014
|
-
|
|
1086
|
+
id: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
|
|
1087
|
+
workflowDefinitionId: {
|
|
1088
|
+
type: ScalarTypeEnum5.String_unsecure(),
|
|
1015
1089
|
isOptional: false
|
|
1016
1090
|
},
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1091
|
+
referenceId: { type: ScalarTypeEnum5.String_unsecure(), isOptional: true },
|
|
1092
|
+
referenceType: {
|
|
1093
|
+
type: ScalarTypeEnum5.String_unsecure(),
|
|
1094
|
+
isOptional: true
|
|
1095
|
+
},
|
|
1096
|
+
status: { type: InstanceStatusEnum, isOptional: false },
|
|
1097
|
+
currentStepId: {
|
|
1098
|
+
type: ScalarTypeEnum5.String_unsecure(),
|
|
1099
|
+
isOptional: true
|
|
1100
|
+
},
|
|
1101
|
+
contextData: { type: ScalarTypeEnum5.JSON(), isOptional: true },
|
|
1102
|
+
triggeredBy: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
|
|
1103
|
+
organizationId: {
|
|
1104
|
+
type: ScalarTypeEnum5.String_unsecure(),
|
|
1105
|
+
isOptional: false
|
|
1106
|
+
},
|
|
1107
|
+
priority: { type: ScalarTypeEnum5.Int_unsecure(), isOptional: false },
|
|
1108
|
+
dueAt: { type: ScalarTypeEnum5.DateTime(), isOptional: true },
|
|
1109
|
+
outcome: { type: ScalarTypeEnum5.String_unsecure(), isOptional: true },
|
|
1110
|
+
resultData: { type: ScalarTypeEnum5.JSON(), isOptional: true },
|
|
1111
|
+
errorMessage: {
|
|
1112
|
+
type: ScalarTypeEnum5.String_unsecure(),
|
|
1023
1113
|
isOptional: true
|
|
1024
1114
|
},
|
|
1025
|
-
|
|
1115
|
+
createdAt: { type: ScalarTypeEnum5.DateTime(), isOptional: false },
|
|
1116
|
+
startedAt: { type: ScalarTypeEnum5.DateTime(), isOptional: true },
|
|
1117
|
+
completedAt: { type: ScalarTypeEnum5.DateTime(), isOptional: true }
|
|
1026
1118
|
}
|
|
1027
1119
|
});
|
|
1028
|
-
var
|
|
1029
|
-
name: "
|
|
1030
|
-
description: "Input for
|
|
1120
|
+
var StartWorkflowInputModel = defineSchemaModel5({
|
|
1121
|
+
name: "StartWorkflowInput",
|
|
1122
|
+
description: "Input for starting a workflow",
|
|
1031
1123
|
fields: {
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1124
|
+
workflowKey: { type: ScalarTypeEnum5.NonEmptyString(), isOptional: false },
|
|
1125
|
+
contextData: { type: ScalarTypeEnum5.JSON(), isOptional: true },
|
|
1126
|
+
referenceId: { type: ScalarTypeEnum5.String_unsecure(), isOptional: true },
|
|
1127
|
+
referenceType: {
|
|
1128
|
+
type: ScalarTypeEnum5.String_unsecure(),
|
|
1129
|
+
isOptional: true
|
|
1035
1130
|
},
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1131
|
+
priority: { type: ScalarTypeEnum5.Int_unsecure(), isOptional: true },
|
|
1132
|
+
dueAt: { type: ScalarTypeEnum5.DateTime(), isOptional: true }
|
|
1133
|
+
}
|
|
1134
|
+
});
|
|
1135
|
+
var TransitionInputModel = defineSchemaModel5({
|
|
1136
|
+
name: "TransitionInput",
|
|
1137
|
+
description: "Input for transitioning a workflow",
|
|
1138
|
+
fields: {
|
|
1139
|
+
instanceId: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
|
|
1140
|
+
action: { type: ScalarTypeEnum5.NonEmptyString(), isOptional: false },
|
|
1141
|
+
data: { type: ScalarTypeEnum5.JSON(), isOptional: true },
|
|
1142
|
+
comment: { type: ScalarTypeEnum5.String_unsecure(), isOptional: true }
|
|
1143
|
+
}
|
|
1144
|
+
});
|
|
1145
|
+
var TransitionResultModel = defineSchemaModel5({
|
|
1146
|
+
name: "TransitionResult",
|
|
1147
|
+
description: "Result of a workflow transition",
|
|
1148
|
+
fields: {
|
|
1149
|
+
success: { type: ScalarTypeEnum5.Boolean(), isOptional: false },
|
|
1150
|
+
instance: { type: WorkflowInstanceModel, isOptional: false },
|
|
1151
|
+
previousStepKey: {
|
|
1152
|
+
type: ScalarTypeEnum5.String_unsecure(),
|
|
1046
1153
|
isOptional: true
|
|
1047
1154
|
},
|
|
1048
|
-
|
|
1049
|
-
type:
|
|
1050
|
-
isArray: true,
|
|
1155
|
+
currentStepKey: {
|
|
1156
|
+
type: ScalarTypeEnum5.String_unsecure(),
|
|
1051
1157
|
isOptional: true
|
|
1052
1158
|
},
|
|
1053
|
-
|
|
1054
|
-
slaSeconds: { type: ScalarTypeEnum4.Int_unsecure(), isOptional: true }
|
|
1159
|
+
message: { type: ScalarTypeEnum5.String_unsecure(), isOptional: true }
|
|
1055
1160
|
}
|
|
1056
1161
|
});
|
|
1057
1162
|
|
|
1058
|
-
// src/
|
|
1163
|
+
// src/instance/instance.operations.ts
|
|
1059
1164
|
import {
|
|
1060
1165
|
defineCommand as defineCommand2,
|
|
1061
1166
|
defineQuery as defineQuery2
|
|
1062
1167
|
} from "@contractspec/lib.contracts-spec/operations";
|
|
1063
|
-
import { defineSchemaModel as
|
|
1168
|
+
import { defineSchemaModel as defineSchemaModel6, ScalarTypeEnum as ScalarTypeEnum6 } from "@contractspec/lib.schema";
|
|
1064
1169
|
var OWNERS2 = ["@example.workflow-system"];
|
|
1065
|
-
var
|
|
1170
|
+
var StartWorkflowContract = defineCommand2({
|
|
1066
1171
|
meta: {
|
|
1067
|
-
key: "workflow.
|
|
1172
|
+
key: "workflow.instance.start",
|
|
1068
1173
|
version: "1.0.0",
|
|
1069
1174
|
stability: "stable",
|
|
1070
1175
|
owners: [...OWNERS2],
|
|
1071
|
-
tags: ["workflow", "
|
|
1072
|
-
description: "
|
|
1073
|
-
goal: "
|
|
1074
|
-
context: "
|
|
1176
|
+
tags: ["workflow", "instance", "start"],
|
|
1177
|
+
description: "Start a new workflow instance.",
|
|
1178
|
+
goal: "Initiate a workflow for a business process.",
|
|
1179
|
+
context: "Order creation, request submission, etc."
|
|
1075
1180
|
},
|
|
1076
1181
|
io: {
|
|
1077
|
-
input:
|
|
1078
|
-
output:
|
|
1182
|
+
input: StartWorkflowInputModel,
|
|
1183
|
+
output: WorkflowInstanceModel
|
|
1079
1184
|
},
|
|
1080
1185
|
policy: { auth: "user" },
|
|
1081
1186
|
sideEffects: {
|
|
1082
1187
|
emits: [
|
|
1083
1188
|
{
|
|
1084
|
-
key: "workflow.
|
|
1189
|
+
key: "workflow.instance.started",
|
|
1085
1190
|
version: "1.0.0",
|
|
1086
|
-
when: "Workflow
|
|
1087
|
-
payload:
|
|
1191
|
+
when: "Workflow starts",
|
|
1192
|
+
payload: WorkflowInstanceModel
|
|
1193
|
+
},
|
|
1194
|
+
{
|
|
1195
|
+
key: "workflow.step.entered",
|
|
1196
|
+
version: "1.0.0",
|
|
1197
|
+
when: "First step entered",
|
|
1198
|
+
payload: WorkflowInstanceModel
|
|
1088
1199
|
}
|
|
1089
1200
|
],
|
|
1090
|
-
audit: ["workflow.
|
|
1201
|
+
audit: ["workflow.instance.started"]
|
|
1091
1202
|
},
|
|
1092
1203
|
acceptance: {
|
|
1093
1204
|
scenarios: [
|
|
1094
1205
|
{
|
|
1095
|
-
key: "
|
|
1096
|
-
given: ["
|
|
1097
|
-
when: ["User
|
|
1098
|
-
then: [
|
|
1099
|
-
|
|
1100
|
-
"WorkflowDefinitionCreated event is emitted"
|
|
1101
|
-
]
|
|
1102
|
-
}
|
|
1206
|
+
key: "start-workflow-happy-path",
|
|
1207
|
+
given: ["Workflow definition exists"],
|
|
1208
|
+
when: ["User starts workflow"],
|
|
1209
|
+
then: ["Instance is created and started"]
|
|
1210
|
+
}
|
|
1103
1211
|
],
|
|
1104
1212
|
examples: [
|
|
1105
1213
|
{
|
|
1106
|
-
key: "
|
|
1214
|
+
key: "start-onboarding",
|
|
1107
1215
|
input: {
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
version: "1.0.0"
|
|
1216
|
+
workflowKey: "onboarding-v1",
|
|
1217
|
+
context: { employeeId: "emp-123" }
|
|
1111
1218
|
},
|
|
1112
|
-
output: { id: "
|
|
1219
|
+
output: { id: "inst-456", status: "running" }
|
|
1113
1220
|
}
|
|
1114
1221
|
]
|
|
1115
1222
|
}
|
|
1116
1223
|
});
|
|
1117
|
-
var
|
|
1224
|
+
var TransitionWorkflowContract = defineCommand2({
|
|
1118
1225
|
meta: {
|
|
1119
|
-
key: "workflow.
|
|
1226
|
+
key: "workflow.instance.transition",
|
|
1120
1227
|
version: "1.0.0",
|
|
1121
1228
|
stability: "stable",
|
|
1122
1229
|
owners: [...OWNERS2],
|
|
1123
|
-
tags: ["workflow", "
|
|
1124
|
-
description: "
|
|
1125
|
-
goal: "
|
|
1126
|
-
context: "
|
|
1230
|
+
tags: ["workflow", "instance", "transition", "state-machine"],
|
|
1231
|
+
description: "Transition a workflow instance to the next step.",
|
|
1232
|
+
goal: "Move workflow forward based on action.",
|
|
1233
|
+
context: "Task completion, approval decisions."
|
|
1127
1234
|
},
|
|
1128
1235
|
io: {
|
|
1129
|
-
input:
|
|
1130
|
-
output:
|
|
1236
|
+
input: TransitionInputModel,
|
|
1237
|
+
output: TransitionResultModel
|
|
1131
1238
|
},
|
|
1132
1239
|
policy: { auth: "user" },
|
|
1133
1240
|
sideEffects: {
|
|
1134
1241
|
emits: [
|
|
1135
1242
|
{
|
|
1136
|
-
key: "workflow.
|
|
1243
|
+
key: "workflow.step.exited",
|
|
1137
1244
|
version: "1.0.0",
|
|
1138
|
-
when: "
|
|
1139
|
-
payload:
|
|
1245
|
+
when: "Step is exited",
|
|
1246
|
+
payload: WorkflowInstanceModel
|
|
1247
|
+
},
|
|
1248
|
+
{
|
|
1249
|
+
key: "workflow.step.entered",
|
|
1250
|
+
version: "1.0.0",
|
|
1251
|
+
when: "New step is entered",
|
|
1252
|
+
payload: WorkflowInstanceModel
|
|
1253
|
+
},
|
|
1254
|
+
{
|
|
1255
|
+
key: "workflow.instance.completed",
|
|
1256
|
+
version: "1.0.0",
|
|
1257
|
+
when: "Workflow reaches end",
|
|
1258
|
+
payload: WorkflowInstanceModel
|
|
1140
1259
|
}
|
|
1141
1260
|
],
|
|
1142
|
-
audit: ["workflow.
|
|
1261
|
+
audit: ["workflow.instance.transitioned"]
|
|
1143
1262
|
},
|
|
1144
1263
|
acceptance: {
|
|
1145
1264
|
scenarios: [
|
|
1146
1265
|
{
|
|
1147
|
-
key: "
|
|
1148
|
-
given: ["Workflow
|
|
1149
|
-
when: ["User
|
|
1150
|
-
then: [
|
|
1151
|
-
"Definition is updated",
|
|
1152
|
-
"WorkflowDefinitionUpdated event is emitted"
|
|
1153
|
-
]
|
|
1266
|
+
key: "transition-workflow-happy-path",
|
|
1267
|
+
given: ["Workflow instance is waiting at step"],
|
|
1268
|
+
when: ["User provides input"],
|
|
1269
|
+
then: ["Instance moves to next step"]
|
|
1154
1270
|
}
|
|
1155
1271
|
],
|
|
1156
1272
|
examples: [
|
|
1157
1273
|
{
|
|
1158
|
-
key: "
|
|
1159
|
-
input: {
|
|
1160
|
-
|
|
1274
|
+
key: "complete-task",
|
|
1275
|
+
input: {
|
|
1276
|
+
instanceId: "inst-456",
|
|
1277
|
+
action: "complete",
|
|
1278
|
+
data: { approved: true }
|
|
1279
|
+
},
|
|
1280
|
+
output: { success: true, nextStep: "notify-hr" }
|
|
1161
1281
|
}
|
|
1162
1282
|
]
|
|
1163
1283
|
}
|
|
1164
1284
|
});
|
|
1165
|
-
var
|
|
1285
|
+
var PauseWorkflowContract = defineCommand2({
|
|
1166
1286
|
meta: {
|
|
1167
|
-
key: "workflow.
|
|
1287
|
+
key: "workflow.instance.pause",
|
|
1168
1288
|
version: "1.0.0",
|
|
1169
1289
|
stability: "stable",
|
|
1170
1290
|
owners: [...OWNERS2],
|
|
1171
|
-
tags: ["workflow", "
|
|
1172
|
-
description: "
|
|
1173
|
-
goal: "
|
|
1174
|
-
context: "
|
|
1291
|
+
tags: ["workflow", "instance", "pause"],
|
|
1292
|
+
description: "Pause a running workflow instance.",
|
|
1293
|
+
goal: "Temporarily halt workflow execution.",
|
|
1294
|
+
context: "Administrative action, emergency stop."
|
|
1175
1295
|
},
|
|
1176
1296
|
io: {
|
|
1177
|
-
input:
|
|
1178
|
-
|
|
1297
|
+
input: defineSchemaModel6({
|
|
1298
|
+
name: "PauseResumeInput",
|
|
1299
|
+
fields: {
|
|
1300
|
+
instanceId: {
|
|
1301
|
+
type: ScalarTypeEnum6.String_unsecure(),
|
|
1302
|
+
isOptional: false
|
|
1303
|
+
},
|
|
1304
|
+
reason: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true }
|
|
1305
|
+
}
|
|
1306
|
+
}),
|
|
1307
|
+
output: WorkflowInstanceModel
|
|
1179
1308
|
},
|
|
1180
1309
|
policy: { auth: "user" },
|
|
1181
1310
|
sideEffects: {
|
|
1182
1311
|
emits: [
|
|
1183
1312
|
{
|
|
1184
|
-
key: "workflow.
|
|
1313
|
+
key: "workflow.instance.paused",
|
|
1185
1314
|
version: "1.0.0",
|
|
1186
|
-
when: "
|
|
1187
|
-
payload:
|
|
1315
|
+
when: "Workflow is paused",
|
|
1316
|
+
payload: WorkflowInstanceModel
|
|
1188
1317
|
}
|
|
1189
1318
|
],
|
|
1190
|
-
audit: ["workflow.
|
|
1319
|
+
audit: ["workflow.instance.paused"]
|
|
1191
1320
|
},
|
|
1192
1321
|
acceptance: {
|
|
1193
1322
|
scenarios: [
|
|
1194
1323
|
{
|
|
1195
|
-
key: "
|
|
1196
|
-
given: ["Workflow
|
|
1197
|
-
when: ["
|
|
1198
|
-
then: ["
|
|
1324
|
+
key: "pause-workflow-happy-path",
|
|
1325
|
+
given: ["Workflow is running"],
|
|
1326
|
+
when: ["Admin pauses workflow"],
|
|
1327
|
+
then: ["Instance status becomes PAUSED"]
|
|
1199
1328
|
}
|
|
1200
1329
|
],
|
|
1201
1330
|
examples: [
|
|
1202
1331
|
{
|
|
1203
|
-
key: "
|
|
1204
|
-
input: {
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1332
|
+
key: "pause-maintenance",
|
|
1333
|
+
input: { instanceId: "inst-456", reason: "System maintenance" },
|
|
1334
|
+
output: { id: "inst-456", status: "paused" }
|
|
1335
|
+
}
|
|
1336
|
+
]
|
|
1337
|
+
}
|
|
1338
|
+
});
|
|
1339
|
+
var ResumeWorkflowContract = defineCommand2({
|
|
1340
|
+
meta: {
|
|
1341
|
+
key: "workflow.instance.resume",
|
|
1342
|
+
version: "1.0.0",
|
|
1343
|
+
stability: "stable",
|
|
1344
|
+
owners: [...OWNERS2],
|
|
1345
|
+
tags: ["workflow", "instance", "resume"],
|
|
1346
|
+
description: "Resume a paused workflow instance.",
|
|
1347
|
+
goal: "Continue workflow execution.",
|
|
1348
|
+
context: "Administrative action."
|
|
1349
|
+
},
|
|
1350
|
+
io: {
|
|
1351
|
+
input: defineSchemaModel6({
|
|
1352
|
+
name: "PauseResumeInput",
|
|
1353
|
+
fields: {
|
|
1354
|
+
instanceId: {
|
|
1355
|
+
type: ScalarTypeEnum6.String_unsecure(),
|
|
1356
|
+
isOptional: false
|
|
1208
1357
|
},
|
|
1209
|
-
|
|
1358
|
+
reason: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true }
|
|
1359
|
+
}
|
|
1360
|
+
}),
|
|
1361
|
+
output: WorkflowInstanceModel
|
|
1362
|
+
},
|
|
1363
|
+
policy: { auth: "user" },
|
|
1364
|
+
sideEffects: {
|
|
1365
|
+
emits: [
|
|
1366
|
+
{
|
|
1367
|
+
key: "workflow.instance.resumed",
|
|
1368
|
+
version: "1.0.0",
|
|
1369
|
+
when: "Workflow is resumed",
|
|
1370
|
+
payload: WorkflowInstanceModel
|
|
1371
|
+
}
|
|
1372
|
+
],
|
|
1373
|
+
audit: ["workflow.instance.resumed"]
|
|
1374
|
+
},
|
|
1375
|
+
acceptance: {
|
|
1376
|
+
scenarios: [
|
|
1377
|
+
{
|
|
1378
|
+
key: "resume-workflow-happy-path",
|
|
1379
|
+
given: ["Workflow is paused"],
|
|
1380
|
+
when: ["Admin resumes workflow"],
|
|
1381
|
+
then: ["Instance status becomes RUNNING"]
|
|
1382
|
+
}
|
|
1383
|
+
],
|
|
1384
|
+
examples: [
|
|
1385
|
+
{
|
|
1386
|
+
key: "resume-normal",
|
|
1387
|
+
input: { instanceId: "inst-456", reason: "Issue resolved" },
|
|
1388
|
+
output: { id: "inst-456", status: "running" }
|
|
1210
1389
|
}
|
|
1211
1390
|
]
|
|
1212
1391
|
}
|
|
1213
1392
|
});
|
|
1214
|
-
var
|
|
1393
|
+
var CancelWorkflowContract = defineCommand2({
|
|
1215
1394
|
meta: {
|
|
1216
|
-
key: "workflow.
|
|
1395
|
+
key: "workflow.instance.cancel",
|
|
1217
1396
|
version: "1.0.0",
|
|
1218
1397
|
stability: "stable",
|
|
1219
1398
|
owners: [...OWNERS2],
|
|
1220
|
-
tags: ["workflow", "
|
|
1221
|
-
description: "
|
|
1222
|
-
goal: "
|
|
1223
|
-
context: "
|
|
1399
|
+
tags: ["workflow", "instance", "cancel"],
|
|
1400
|
+
description: "Cancel a workflow instance.",
|
|
1401
|
+
goal: "Terminate workflow without completion.",
|
|
1402
|
+
context: "User request, system cancellation."
|
|
1224
1403
|
},
|
|
1225
1404
|
io: {
|
|
1226
|
-
input:
|
|
1227
|
-
name: "
|
|
1405
|
+
input: defineSchemaModel6({
|
|
1406
|
+
name: "CancelWorkflowInput",
|
|
1228
1407
|
fields: {
|
|
1229
|
-
|
|
1230
|
-
type:
|
|
1408
|
+
instanceId: {
|
|
1409
|
+
type: ScalarTypeEnum6.String_unsecure(),
|
|
1410
|
+
isOptional: false
|
|
1411
|
+
},
|
|
1412
|
+
reason: {
|
|
1413
|
+
type: ScalarTypeEnum6.String_unsecure(),
|
|
1231
1414
|
isOptional: false
|
|
1232
1415
|
}
|
|
1233
1416
|
}
|
|
1234
1417
|
}),
|
|
1235
|
-
output:
|
|
1418
|
+
output: WorkflowInstanceModel
|
|
1236
1419
|
},
|
|
1237
1420
|
policy: { auth: "user" },
|
|
1238
1421
|
sideEffects: {
|
|
1239
1422
|
emits: [
|
|
1240
1423
|
{
|
|
1241
|
-
key: "workflow.
|
|
1424
|
+
key: "workflow.instance.cancelled",
|
|
1242
1425
|
version: "1.0.0",
|
|
1243
|
-
when: "Workflow is
|
|
1244
|
-
payload:
|
|
1426
|
+
when: "Workflow is cancelled",
|
|
1427
|
+
payload: WorkflowInstanceModel
|
|
1245
1428
|
}
|
|
1246
1429
|
],
|
|
1247
|
-
audit: ["workflow.
|
|
1430
|
+
audit: ["workflow.instance.cancelled"]
|
|
1248
1431
|
},
|
|
1249
1432
|
acceptance: {
|
|
1250
1433
|
scenarios: [
|
|
1251
1434
|
{
|
|
1252
|
-
key: "
|
|
1253
|
-
given: ["Workflow
|
|
1254
|
-
when: ["User
|
|
1255
|
-
then: ["
|
|
1435
|
+
key: "cancel-workflow-happy-path",
|
|
1436
|
+
given: ["Workflow is running"],
|
|
1437
|
+
when: ["User cancels workflow"],
|
|
1438
|
+
then: ["Instance status becomes CANCELLED"]
|
|
1256
1439
|
}
|
|
1257
1440
|
],
|
|
1258
1441
|
examples: [
|
|
1259
1442
|
{
|
|
1260
|
-
key: "
|
|
1261
|
-
input: {
|
|
1262
|
-
output: { id: "
|
|
1443
|
+
key: "cancel-mistake",
|
|
1444
|
+
input: { instanceId: "inst-456", reason: "Created by mistake" },
|
|
1445
|
+
output: { id: "inst-456", status: "cancelled" }
|
|
1263
1446
|
}
|
|
1264
1447
|
]
|
|
1265
1448
|
}
|
|
1266
1449
|
});
|
|
1267
|
-
var
|
|
1450
|
+
var ListInstancesContract = defineQuery2({
|
|
1268
1451
|
meta: {
|
|
1269
|
-
key: "workflow.
|
|
1452
|
+
key: "workflow.instance.list",
|
|
1270
1453
|
version: "1.0.0",
|
|
1271
1454
|
stability: "stable",
|
|
1272
1455
|
owners: [...OWNERS2],
|
|
1273
|
-
tags: ["workflow", "
|
|
1274
|
-
description: "List workflow
|
|
1275
|
-
goal: "Browse and search
|
|
1276
|
-
context: "
|
|
1456
|
+
tags: ["workflow", "instance", "list"],
|
|
1457
|
+
description: "List workflow instances with filtering.",
|
|
1458
|
+
goal: "Browse and search running workflows.",
|
|
1459
|
+
context: "Dashboard, monitoring."
|
|
1277
1460
|
},
|
|
1278
1461
|
io: {
|
|
1279
|
-
input:
|
|
1280
|
-
name: "
|
|
1462
|
+
input: defineSchemaModel6({
|
|
1463
|
+
name: "ListInstancesInput",
|
|
1281
1464
|
fields: {
|
|
1282
|
-
|
|
1283
|
-
|
|
1465
|
+
workflowKey: {
|
|
1466
|
+
type: ScalarTypeEnum6.String_unsecure(),
|
|
1467
|
+
isOptional: true
|
|
1468
|
+
},
|
|
1469
|
+
status: { type: InstanceStatusEnum, isOptional: true },
|
|
1470
|
+
referenceType: {
|
|
1471
|
+
type: ScalarTypeEnum6.String_unsecure(),
|
|
1472
|
+
isOptional: true
|
|
1473
|
+
},
|
|
1474
|
+
referenceId: {
|
|
1475
|
+
type: ScalarTypeEnum6.String_unsecure(),
|
|
1476
|
+
isOptional: true
|
|
1477
|
+
},
|
|
1478
|
+
triggeredBy: {
|
|
1479
|
+
type: ScalarTypeEnum6.String_unsecure(),
|
|
1480
|
+
isOptional: true
|
|
1481
|
+
},
|
|
1284
1482
|
limit: {
|
|
1285
|
-
type:
|
|
1483
|
+
type: ScalarTypeEnum6.Int_unsecure(),
|
|
1286
1484
|
isOptional: true,
|
|
1287
1485
|
defaultValue: 20
|
|
1288
1486
|
},
|
|
1289
1487
|
offset: {
|
|
1290
|
-
type:
|
|
1488
|
+
type: ScalarTypeEnum6.Int_unsecure(),
|
|
1291
1489
|
isOptional: true,
|
|
1292
1490
|
defaultValue: 0
|
|
1293
1491
|
}
|
|
1294
1492
|
}
|
|
1295
1493
|
}),
|
|
1296
|
-
output:
|
|
1297
|
-
name: "
|
|
1494
|
+
output: defineSchemaModel6({
|
|
1495
|
+
name: "ListInstancesOutput",
|
|
1298
1496
|
fields: {
|
|
1299
|
-
|
|
1300
|
-
type:
|
|
1497
|
+
instances: {
|
|
1498
|
+
type: WorkflowInstanceModel,
|
|
1301
1499
|
isArray: true,
|
|
1302
1500
|
isOptional: false
|
|
1303
1501
|
},
|
|
1304
|
-
total: { type:
|
|
1502
|
+
total: { type: ScalarTypeEnum6.Int_unsecure(), isOptional: false }
|
|
1305
1503
|
}
|
|
1306
1504
|
})
|
|
1307
1505
|
},
|
|
@@ -1309,1753 +1507,1553 @@ var ListWorkflowsContract = defineQuery2({
|
|
|
1309
1507
|
acceptance: {
|
|
1310
1508
|
scenarios: [
|
|
1311
1509
|
{
|
|
1312
|
-
key: "list-
|
|
1313
|
-
given: ["Workflow
|
|
1314
|
-
when: ["User lists
|
|
1315
|
-
then: ["List of
|
|
1510
|
+
key: "list-instances-happy-path",
|
|
1511
|
+
given: ["Workflow instances exist"],
|
|
1512
|
+
when: ["User lists instances"],
|
|
1513
|
+
then: ["List of instances is returned"]
|
|
1316
1514
|
}
|
|
1317
1515
|
],
|
|
1318
1516
|
examples: [
|
|
1319
1517
|
{
|
|
1320
|
-
key: "list-
|
|
1321
|
-
input: { limit: 10 },
|
|
1322
|
-
output: {
|
|
1518
|
+
key: "list-running",
|
|
1519
|
+
input: { status: "running", limit: 10 },
|
|
1520
|
+
output: { instances: [], total: 5 }
|
|
1323
1521
|
}
|
|
1324
1522
|
]
|
|
1325
1523
|
}
|
|
1326
1524
|
});
|
|
1327
|
-
var
|
|
1525
|
+
var GetInstanceContract = defineQuery2({
|
|
1328
1526
|
meta: {
|
|
1329
|
-
key: "workflow.
|
|
1527
|
+
key: "workflow.instance.get",
|
|
1330
1528
|
version: "1.0.0",
|
|
1331
1529
|
stability: "stable",
|
|
1332
1530
|
owners: [...OWNERS2],
|
|
1333
|
-
tags: ["workflow", "
|
|
1334
|
-
description: "Get a workflow
|
|
1335
|
-
goal: "View workflow details.",
|
|
1336
|
-
context: "
|
|
1531
|
+
tags: ["workflow", "instance", "get"],
|
|
1532
|
+
description: "Get a workflow instance with details.",
|
|
1533
|
+
goal: "View workflow instance details.",
|
|
1534
|
+
context: "Instance detail view."
|
|
1337
1535
|
},
|
|
1338
1536
|
io: {
|
|
1339
|
-
input:
|
|
1340
|
-
name: "
|
|
1537
|
+
input: defineSchemaModel6({
|
|
1538
|
+
name: "GetInstanceInput",
|
|
1341
1539
|
fields: {
|
|
1342
|
-
|
|
1343
|
-
type:
|
|
1540
|
+
instanceId: {
|
|
1541
|
+
type: ScalarTypeEnum6.String_unsecure(),
|
|
1344
1542
|
isOptional: false
|
|
1345
1543
|
}
|
|
1346
1544
|
}
|
|
1347
1545
|
}),
|
|
1348
|
-
output:
|
|
1546
|
+
output: WorkflowInstanceModel
|
|
1349
1547
|
},
|
|
1350
1548
|
policy: { auth: "user" },
|
|
1351
1549
|
acceptance: {
|
|
1352
1550
|
scenarios: [
|
|
1353
1551
|
{
|
|
1354
|
-
key: "get-
|
|
1355
|
-
given: ["
|
|
1356
|
-
when: ["User requests
|
|
1357
|
-
then: ["
|
|
1552
|
+
key: "get-instance-happy-path",
|
|
1553
|
+
given: ["Instance exists"],
|
|
1554
|
+
when: ["User requests instance details"],
|
|
1555
|
+
then: ["Instance details are returned"]
|
|
1358
1556
|
}
|
|
1359
1557
|
],
|
|
1360
1558
|
examples: [
|
|
1361
1559
|
{
|
|
1362
1560
|
key: "get-details",
|
|
1363
|
-
input: {
|
|
1364
|
-
output: { id: "
|
|
1561
|
+
input: { instanceId: "inst-456" },
|
|
1562
|
+
output: { id: "inst-456", workflowKey: "onboarding-v1" }
|
|
1365
1563
|
}
|
|
1366
1564
|
]
|
|
1367
1565
|
}
|
|
1368
1566
|
});
|
|
1369
|
-
|
|
1370
|
-
// src/workflow/workflow.event.ts
|
|
1371
|
-
import { defineEvent as defineEvent2 } from "@contractspec/lib.contracts-spec";
|
|
1372
|
-
import { ScalarTypeEnum as ScalarTypeEnum6, defineSchemaModel as defineSchemaModel6 } from "@contractspec/lib.schema";
|
|
1373
|
-
var WorkflowDefinitionPayload = defineSchemaModel6({
|
|
1374
|
-
name: "WorkflowDefinitionEventPayload",
|
|
1375
|
-
description: "Payload for workflow definition events",
|
|
1376
|
-
fields: {
|
|
1377
|
-
workflowId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
|
|
1378
|
-
key: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
|
|
1379
|
-
name: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
|
|
1380
|
-
version: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
|
|
1381
|
-
organizationId: {
|
|
1382
|
-
type: ScalarTypeEnum6.String_unsecure(),
|
|
1383
|
-
isOptional: false
|
|
1384
|
-
},
|
|
1385
|
-
createdBy: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
|
|
1386
|
-
timestamp: { type: ScalarTypeEnum6.DateTime(), isOptional: false }
|
|
1387
|
-
}
|
|
1388
|
-
});
|
|
1389
|
-
var StepAddedPayload = defineSchemaModel6({
|
|
1390
|
-
name: "StepAddedEventPayload",
|
|
1391
|
-
description: "Payload when a step is added",
|
|
1392
|
-
fields: {
|
|
1393
|
-
stepId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
|
|
1394
|
-
workflowId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
|
|
1395
|
-
stepKey: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
|
|
1396
|
-
stepType: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
|
|
1397
|
-
position: { type: ScalarTypeEnum6.Int_unsecure(), isOptional: false },
|
|
1398
|
-
timestamp: { type: ScalarTypeEnum6.DateTime(), isOptional: false }
|
|
1399
|
-
}
|
|
1400
|
-
});
|
|
1401
|
-
var WorkflowCreatedEvent = defineEvent2({
|
|
1402
|
-
meta: {
|
|
1403
|
-
key: "workflow.definition.created",
|
|
1404
|
-
version: "1.0.0",
|
|
1405
|
-
description: "A new workflow definition has been created.",
|
|
1406
|
-
stability: "stable",
|
|
1407
|
-
owners: ["@workflow-team"],
|
|
1408
|
-
tags: ["workflow", "definition", "created"]
|
|
1409
|
-
},
|
|
1410
|
-
payload: WorkflowDefinitionPayload
|
|
1411
|
-
});
|
|
1412
|
-
var WorkflowUpdatedEvent = defineEvent2({
|
|
1413
|
-
meta: {
|
|
1414
|
-
key: "workflow.definition.updated",
|
|
1415
|
-
version: "1.0.0",
|
|
1416
|
-
description: "A workflow definition has been updated.",
|
|
1417
|
-
stability: "stable",
|
|
1418
|
-
owners: ["@workflow-team"],
|
|
1419
|
-
tags: ["workflow", "definition", "updated"]
|
|
1420
|
-
},
|
|
1421
|
-
payload: WorkflowDefinitionPayload
|
|
1422
|
-
});
|
|
1423
|
-
var WorkflowPublishedEvent = defineEvent2({
|
|
1424
|
-
meta: {
|
|
1425
|
-
key: "workflow.definition.published",
|
|
1426
|
-
version: "1.0.0",
|
|
1427
|
-
description: "A workflow definition has been published and is now active.",
|
|
1428
|
-
stability: "stable",
|
|
1429
|
-
owners: ["@workflow-team"],
|
|
1430
|
-
tags: ["workflow", "definition", "published"]
|
|
1431
|
-
},
|
|
1432
|
-
payload: WorkflowDefinitionPayload
|
|
1433
|
-
});
|
|
1434
|
-
var StepAddedEvent = defineEvent2({
|
|
1435
|
-
meta: {
|
|
1436
|
-
key: "workflow.step.added",
|
|
1437
|
-
version: "1.0.0",
|
|
1438
|
-
description: "A step has been added to a workflow definition.",
|
|
1439
|
-
stability: "stable",
|
|
1440
|
-
owners: ["@workflow-team"],
|
|
1441
|
-
tags: ["workflow", "step", "added"]
|
|
1442
|
-
},
|
|
1443
|
-
payload: StepAddedPayload
|
|
1444
|
-
});
|
|
1445
|
-
// src/instance/instance.enum.ts
|
|
1567
|
+
// src/workflow/workflow.enum.ts
|
|
1446
1568
|
import { defineEnum as defineEnum3 } from "@contractspec/lib.schema";
|
|
1447
|
-
var
|
|
1448
|
-
"
|
|
1449
|
-
"
|
|
1450
|
-
"
|
|
1451
|
-
"
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
"
|
|
1455
|
-
"
|
|
1569
|
+
var WorkflowStatusEnum = defineEnum3("WorkflowStatus", [
|
|
1570
|
+
"DRAFT",
|
|
1571
|
+
"ACTIVE",
|
|
1572
|
+
"DEPRECATED",
|
|
1573
|
+
"ARCHIVED"
|
|
1574
|
+
]);
|
|
1575
|
+
var TriggerTypeEnum = defineEnum3("WorkflowTriggerType", [
|
|
1576
|
+
"MANUAL",
|
|
1577
|
+
"EVENT",
|
|
1578
|
+
"SCHEDULED",
|
|
1579
|
+
"API"
|
|
1580
|
+
]);
|
|
1581
|
+
var StepTypeEnum = defineEnum3("StepType", [
|
|
1582
|
+
"START",
|
|
1583
|
+
"APPROVAL",
|
|
1584
|
+
"TASK",
|
|
1585
|
+
"CONDITION",
|
|
1586
|
+
"PARALLEL",
|
|
1587
|
+
"WAIT",
|
|
1588
|
+
"ACTION",
|
|
1589
|
+
"END"
|
|
1590
|
+
]);
|
|
1591
|
+
var ApprovalModeEnum = defineEnum3("ApprovalMode", [
|
|
1592
|
+
"ANY",
|
|
1593
|
+
"ALL",
|
|
1594
|
+
"MAJORITY",
|
|
1595
|
+
"SEQUENTIAL"
|
|
1456
1596
|
]);
|
|
1457
1597
|
|
|
1458
|
-
// src/
|
|
1598
|
+
// src/workflow/workflow.schema.ts
|
|
1459
1599
|
import { defineSchemaModel as defineSchemaModel7, ScalarTypeEnum as ScalarTypeEnum7 } from "@contractspec/lib.schema";
|
|
1460
|
-
var
|
|
1461
|
-
name: "
|
|
1462
|
-
description: "A
|
|
1600
|
+
var WorkflowStepModel = defineSchemaModel7({
|
|
1601
|
+
name: "WorkflowStepModel",
|
|
1602
|
+
description: "A step in a workflow definition",
|
|
1463
1603
|
fields: {
|
|
1464
1604
|
id: { type: ScalarTypeEnum7.String_unsecure(), isOptional: false },
|
|
1465
|
-
|
|
1605
|
+
key: { type: ScalarTypeEnum7.String_unsecure(), isOptional: false },
|
|
1606
|
+
name: { type: ScalarTypeEnum7.String_unsecure(), isOptional: false },
|
|
1607
|
+
description: { type: ScalarTypeEnum7.String_unsecure(), isOptional: true },
|
|
1608
|
+
type: { type: StepTypeEnum, isOptional: false },
|
|
1609
|
+
position: { type: ScalarTypeEnum7.Int_unsecure(), isOptional: false },
|
|
1610
|
+
transitions: { type: ScalarTypeEnum7.JSON(), isOptional: false },
|
|
1611
|
+
approvalMode: { type: ApprovalModeEnum, isOptional: true },
|
|
1612
|
+
approverRoles: {
|
|
1466
1613
|
type: ScalarTypeEnum7.String_unsecure(),
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1614
|
+
isArray: true,
|
|
1615
|
+
isOptional: true
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
});
|
|
1619
|
+
var WorkflowDefinitionModel = defineSchemaModel7({
|
|
1620
|
+
name: "WorkflowDefinitionModel",
|
|
1621
|
+
description: "A workflow definition",
|
|
1622
|
+
fields: {
|
|
1623
|
+
id: { type: ScalarTypeEnum7.String_unsecure(), isOptional: false },
|
|
1624
|
+
name: { type: ScalarTypeEnum7.String_unsecure(), isOptional: false },
|
|
1625
|
+
key: { type: ScalarTypeEnum7.String_unsecure(), isOptional: false },
|
|
1626
|
+
description: { type: ScalarTypeEnum7.String_unsecure(), isOptional: true },
|
|
1627
|
+
version: { type: ScalarTypeEnum7.String_unsecure(), isOptional: false },
|
|
1628
|
+
status: { type: WorkflowStatusEnum, isOptional: false },
|
|
1629
|
+
triggerType: { type: TriggerTypeEnum, isOptional: false },
|
|
1630
|
+
initialStepId: {
|
|
1471
1631
|
type: ScalarTypeEnum7.String_unsecure(),
|
|
1472
1632
|
isOptional: true
|
|
1473
1633
|
},
|
|
1474
|
-
|
|
1475
|
-
currentStepId: {
|
|
1634
|
+
featureFlagKey: {
|
|
1476
1635
|
type: ScalarTypeEnum7.String_unsecure(),
|
|
1477
1636
|
isOptional: true
|
|
1478
1637
|
},
|
|
1479
|
-
contextData: { type: ScalarTypeEnum7.JSON(), isOptional: true },
|
|
1480
|
-
triggeredBy: { type: ScalarTypeEnum7.String_unsecure(), isOptional: false },
|
|
1481
1638
|
organizationId: {
|
|
1482
1639
|
type: ScalarTypeEnum7.String_unsecure(),
|
|
1483
1640
|
isOptional: false
|
|
1484
1641
|
},
|
|
1485
|
-
priority: { type: ScalarTypeEnum7.Int_unsecure(), isOptional: false },
|
|
1486
|
-
dueAt: { type: ScalarTypeEnum7.DateTime(), isOptional: true },
|
|
1487
|
-
outcome: { type: ScalarTypeEnum7.String_unsecure(), isOptional: true },
|
|
1488
|
-
resultData: { type: ScalarTypeEnum7.JSON(), isOptional: true },
|
|
1489
|
-
errorMessage: {
|
|
1490
|
-
type: ScalarTypeEnum7.String_unsecure(),
|
|
1491
|
-
isOptional: true
|
|
1492
|
-
},
|
|
1493
1642
|
createdAt: { type: ScalarTypeEnum7.DateTime(), isOptional: false },
|
|
1494
|
-
|
|
1495
|
-
|
|
1643
|
+
updatedAt: { type: ScalarTypeEnum7.DateTime(), isOptional: false },
|
|
1644
|
+
steps: { type: WorkflowStepModel, isArray: true, isOptional: true }
|
|
1496
1645
|
}
|
|
1497
1646
|
});
|
|
1498
|
-
var
|
|
1499
|
-
name: "
|
|
1500
|
-
description: "Input for
|
|
1647
|
+
var CreateWorkflowInputModel = defineSchemaModel7({
|
|
1648
|
+
name: "CreateWorkflowInput",
|
|
1649
|
+
description: "Input for creating a workflow definition",
|
|
1501
1650
|
fields: {
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1651
|
+
name: { type: ScalarTypeEnum7.NonEmptyString(), isOptional: false },
|
|
1652
|
+
key: { type: ScalarTypeEnum7.NonEmptyString(), isOptional: false },
|
|
1653
|
+
description: { type: ScalarTypeEnum7.String_unsecure(), isOptional: true },
|
|
1654
|
+
triggerType: { type: TriggerTypeEnum, isOptional: true },
|
|
1655
|
+
triggerConfig: { type: ScalarTypeEnum7.JSON(), isOptional: true },
|
|
1656
|
+
featureFlagKey: {
|
|
1506
1657
|
type: ScalarTypeEnum7.String_unsecure(),
|
|
1507
1658
|
isOptional: true
|
|
1508
1659
|
},
|
|
1509
|
-
|
|
1510
|
-
dueAt: { type: ScalarTypeEnum7.DateTime(), isOptional: true }
|
|
1660
|
+
settings: { type: ScalarTypeEnum7.JSON(), isOptional: true }
|
|
1511
1661
|
}
|
|
1512
1662
|
});
|
|
1513
|
-
var
|
|
1514
|
-
name: "
|
|
1515
|
-
description: "Input for
|
|
1663
|
+
var UpdateWorkflowInputModel = defineSchemaModel7({
|
|
1664
|
+
name: "UpdateWorkflowInput",
|
|
1665
|
+
description: "Input for updating a workflow definition",
|
|
1516
1666
|
fields: {
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1667
|
+
workflowId: {
|
|
1668
|
+
type: ScalarTypeEnum7.String_unsecure(),
|
|
1669
|
+
isOptional: false
|
|
1670
|
+
},
|
|
1671
|
+
name: { type: ScalarTypeEnum7.String_unsecure(), isOptional: true },
|
|
1672
|
+
description: { type: ScalarTypeEnum7.String_unsecure(), isOptional: true },
|
|
1673
|
+
triggerType: { type: TriggerTypeEnum, isOptional: true },
|
|
1674
|
+
triggerConfig: { type: ScalarTypeEnum7.JSON(), isOptional: true },
|
|
1675
|
+
featureFlagKey: {
|
|
1676
|
+
type: ScalarTypeEnum7.String_unsecure(),
|
|
1677
|
+
isOptional: true
|
|
1678
|
+
},
|
|
1679
|
+
settings: { type: ScalarTypeEnum7.JSON(), isOptional: true }
|
|
1521
1680
|
}
|
|
1522
1681
|
});
|
|
1523
|
-
var
|
|
1524
|
-
name: "
|
|
1525
|
-
description: "
|
|
1682
|
+
var AddStepInputModel = defineSchemaModel7({
|
|
1683
|
+
name: "AddStepInput",
|
|
1684
|
+
description: "Input for adding a step to a workflow",
|
|
1526
1685
|
fields: {
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1686
|
+
workflowId: {
|
|
1687
|
+
type: ScalarTypeEnum7.String_unsecure(),
|
|
1688
|
+
isOptional: false
|
|
1689
|
+
},
|
|
1690
|
+
key: { type: ScalarTypeEnum7.NonEmptyString(), isOptional: false },
|
|
1691
|
+
name: { type: ScalarTypeEnum7.NonEmptyString(), isOptional: false },
|
|
1692
|
+
description: { type: ScalarTypeEnum7.String_unsecure(), isOptional: true },
|
|
1693
|
+
type: { type: StepTypeEnum, isOptional: false },
|
|
1694
|
+
position: { type: ScalarTypeEnum7.Int_unsecure(), isOptional: true },
|
|
1695
|
+
transitions: { type: ScalarTypeEnum7.JSON(), isOptional: false },
|
|
1696
|
+
approvalMode: { type: ApprovalModeEnum, isOptional: true },
|
|
1697
|
+
approverRoles: {
|
|
1530
1698
|
type: ScalarTypeEnum7.String_unsecure(),
|
|
1699
|
+
isArray: true,
|
|
1531
1700
|
isOptional: true
|
|
1532
1701
|
},
|
|
1533
|
-
|
|
1702
|
+
approverUserIds: {
|
|
1534
1703
|
type: ScalarTypeEnum7.String_unsecure(),
|
|
1704
|
+
isArray: true,
|
|
1535
1705
|
isOptional: true
|
|
1536
1706
|
},
|
|
1537
|
-
|
|
1707
|
+
timeoutSeconds: { type: ScalarTypeEnum7.Int_unsecure(), isOptional: true },
|
|
1708
|
+
slaSeconds: { type: ScalarTypeEnum7.Int_unsecure(), isOptional: true }
|
|
1538
1709
|
}
|
|
1539
1710
|
});
|
|
1540
1711
|
|
|
1541
|
-
// src/
|
|
1712
|
+
// src/presentations/index.ts
|
|
1542
1713
|
import {
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
} from "@contractspec/lib.contracts-spec
|
|
1546
|
-
|
|
1547
|
-
var OWNERS3 = ["@example.workflow-system"];
|
|
1548
|
-
var StartWorkflowContract = defineCommand3({
|
|
1714
|
+
definePresentation,
|
|
1715
|
+
StabilityEnum
|
|
1716
|
+
} from "@contractspec/lib.contracts-spec";
|
|
1717
|
+
var WorkflowDesignerPresentation = definePresentation({
|
|
1549
1718
|
meta: {
|
|
1550
|
-
key: "workflow.
|
|
1719
|
+
key: "workflow.designer",
|
|
1551
1720
|
version: "1.0.0",
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
input: StartWorkflowInputModel,
|
|
1561
|
-
output: WorkflowInstanceModel
|
|
1721
|
+
title: "Workflow Designer",
|
|
1722
|
+
description: "Visual workflow designer with drag-and-drop steps",
|
|
1723
|
+
domain: "workflow-system",
|
|
1724
|
+
owners: ["@workflow-team"],
|
|
1725
|
+
tags: ["workflow", "designer", "admin"],
|
|
1726
|
+
stability: StabilityEnum.Experimental,
|
|
1727
|
+
goal: "Building and modifying workflow definitions",
|
|
1728
|
+
context: "Workflow administration and setup"
|
|
1562
1729
|
},
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
version: "1.0.0",
|
|
1569
|
-
when: "Workflow starts",
|
|
1570
|
-
payload: WorkflowInstanceModel
|
|
1571
|
-
},
|
|
1572
|
-
{
|
|
1573
|
-
key: "workflow.step.entered",
|
|
1574
|
-
version: "1.0.0",
|
|
1575
|
-
when: "First step entered",
|
|
1576
|
-
payload: WorkflowInstanceModel
|
|
1577
|
-
}
|
|
1578
|
-
],
|
|
1579
|
-
audit: ["workflow.instance.started"]
|
|
1730
|
+
source: {
|
|
1731
|
+
type: "component",
|
|
1732
|
+
framework: "react",
|
|
1733
|
+
componentKey: "WorkflowDesigner",
|
|
1734
|
+
props: WorkflowDefinitionModel
|
|
1580
1735
|
},
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
key: "start-workflow-happy-path",
|
|
1585
|
-
given: ["Workflow definition exists"],
|
|
1586
|
-
when: ["User starts workflow"],
|
|
1587
|
-
then: ["Instance is created and started"]
|
|
1588
|
-
}
|
|
1589
|
-
],
|
|
1590
|
-
examples: [
|
|
1591
|
-
{
|
|
1592
|
-
key: "start-onboarding",
|
|
1593
|
-
input: {
|
|
1594
|
-
workflowKey: "onboarding-v1",
|
|
1595
|
-
context: { employeeId: "emp-123" }
|
|
1596
|
-
},
|
|
1597
|
-
output: { id: "inst-456", status: "running" }
|
|
1598
|
-
}
|
|
1599
|
-
]
|
|
1736
|
+
targets: ["react"],
|
|
1737
|
+
policy: {
|
|
1738
|
+
flags: ["workflow.designer.enabled"]
|
|
1600
1739
|
}
|
|
1601
1740
|
});
|
|
1602
|
-
var
|
|
1741
|
+
var WorkflowListPresentation = definePresentation({
|
|
1603
1742
|
meta: {
|
|
1604
|
-
key: "workflow.
|
|
1743
|
+
key: "workflow.definition.viewList",
|
|
1605
1744
|
version: "1.0.0",
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
input: TransitionInputModel,
|
|
1615
|
-
output: TransitionResultModel
|
|
1745
|
+
title: "Workflow List",
|
|
1746
|
+
description: "List of workflow definitions with status and actions",
|
|
1747
|
+
domain: "workflow-system",
|
|
1748
|
+
owners: ["@workflow-team"],
|
|
1749
|
+
tags: ["workflow", "list", "admin"],
|
|
1750
|
+
stability: StabilityEnum.Experimental,
|
|
1751
|
+
goal: "Overview of all defined workflows",
|
|
1752
|
+
context: "Workflow management dashboard"
|
|
1616
1753
|
},
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
version: "1.0.0",
|
|
1623
|
-
when: "Step is exited",
|
|
1624
|
-
payload: WorkflowInstanceModel
|
|
1625
|
-
},
|
|
1626
|
-
{
|
|
1627
|
-
key: "workflow.step.entered",
|
|
1628
|
-
version: "1.0.0",
|
|
1629
|
-
when: "New step is entered",
|
|
1630
|
-
payload: WorkflowInstanceModel
|
|
1631
|
-
},
|
|
1632
|
-
{
|
|
1633
|
-
key: "workflow.instance.completed",
|
|
1634
|
-
version: "1.0.0",
|
|
1635
|
-
when: "Workflow reaches end",
|
|
1636
|
-
payload: WorkflowInstanceModel
|
|
1637
|
-
}
|
|
1638
|
-
],
|
|
1639
|
-
audit: ["workflow.instance.transitioned"]
|
|
1754
|
+
source: {
|
|
1755
|
+
type: "component",
|
|
1756
|
+
framework: "react",
|
|
1757
|
+
componentKey: "WorkflowDefinitionList",
|
|
1758
|
+
props: WorkflowDefinitionModel
|
|
1640
1759
|
},
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
key: "transition-workflow-happy-path",
|
|
1645
|
-
given: ["Workflow instance is waiting at step"],
|
|
1646
|
-
when: ["User provides input"],
|
|
1647
|
-
then: ["Instance moves to next step"]
|
|
1648
|
-
}
|
|
1649
|
-
],
|
|
1650
|
-
examples: [
|
|
1651
|
-
{
|
|
1652
|
-
key: "complete-task",
|
|
1653
|
-
input: {
|
|
1654
|
-
instanceId: "inst-456",
|
|
1655
|
-
action: "complete",
|
|
1656
|
-
data: { approved: true }
|
|
1657
|
-
},
|
|
1658
|
-
output: { success: true, nextStep: "notify-hr" }
|
|
1659
|
-
}
|
|
1660
|
-
]
|
|
1760
|
+
targets: ["react", "markdown"],
|
|
1761
|
+
policy: {
|
|
1762
|
+
flags: ["workflow.enabled"]
|
|
1661
1763
|
}
|
|
1662
1764
|
});
|
|
1663
|
-
var
|
|
1765
|
+
var WorkflowDetailPresentation = definePresentation({
|
|
1664
1766
|
meta: {
|
|
1665
|
-
key: "workflow.
|
|
1767
|
+
key: "workflow.definition.detail",
|
|
1666
1768
|
version: "1.0.0",
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
input: defineSchemaModel8({
|
|
1676
|
-
name: "PauseResumeInput",
|
|
1677
|
-
fields: {
|
|
1678
|
-
instanceId: {
|
|
1679
|
-
type: ScalarTypeEnum8.String_unsecure(),
|
|
1680
|
-
isOptional: false
|
|
1681
|
-
},
|
|
1682
|
-
reason: { type: ScalarTypeEnum8.String_unsecure(), isOptional: true }
|
|
1683
|
-
}
|
|
1684
|
-
}),
|
|
1685
|
-
output: WorkflowInstanceModel
|
|
1769
|
+
title: "Workflow Details",
|
|
1770
|
+
description: "Detailed view of a workflow definition with steps",
|
|
1771
|
+
domain: "workflow-system",
|
|
1772
|
+
owners: ["@workflow-team"],
|
|
1773
|
+
tags: ["workflow", "detail"],
|
|
1774
|
+
stability: StabilityEnum.Experimental,
|
|
1775
|
+
goal: "Viewing technical details of a workflow definition",
|
|
1776
|
+
context: "Workflow inspection and debugging"
|
|
1686
1777
|
},
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
version: "1.0.0",
|
|
1693
|
-
when: "Workflow is paused",
|
|
1694
|
-
payload: WorkflowInstanceModel
|
|
1695
|
-
}
|
|
1696
|
-
],
|
|
1697
|
-
audit: ["workflow.instance.paused"]
|
|
1778
|
+
source: {
|
|
1779
|
+
type: "component",
|
|
1780
|
+
framework: "react",
|
|
1781
|
+
componentKey: "WorkflowDefinitionDetail",
|
|
1782
|
+
props: WorkflowDefinitionModel
|
|
1698
1783
|
},
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
key: "pause-workflow-happy-path",
|
|
1703
|
-
given: ["Workflow is running"],
|
|
1704
|
-
when: ["Admin pauses workflow"],
|
|
1705
|
-
then: ["Instance status becomes PAUSED"]
|
|
1706
|
-
}
|
|
1707
|
-
],
|
|
1708
|
-
examples: [
|
|
1709
|
-
{
|
|
1710
|
-
key: "pause-maintenance",
|
|
1711
|
-
input: { instanceId: "inst-456", reason: "System maintenance" },
|
|
1712
|
-
output: { id: "inst-456", status: "paused" }
|
|
1713
|
-
}
|
|
1714
|
-
]
|
|
1784
|
+
targets: ["react", "markdown"],
|
|
1785
|
+
policy: {
|
|
1786
|
+
flags: ["workflow.enabled"]
|
|
1715
1787
|
}
|
|
1716
1788
|
});
|
|
1717
|
-
var
|
|
1789
|
+
var InstanceListPresentation = definePresentation({
|
|
1718
1790
|
meta: {
|
|
1719
|
-
key: "workflow.instance.
|
|
1791
|
+
key: "workflow.instance.viewList",
|
|
1720
1792
|
version: "1.0.0",
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1793
|
+
title: "Instance List",
|
|
1794
|
+
description: "List of workflow instances with status and progress",
|
|
1795
|
+
domain: "workflow-system",
|
|
1796
|
+
owners: ["@workflow-team"],
|
|
1797
|
+
tags: ["workflow", "instance", "list"],
|
|
1798
|
+
stability: StabilityEnum.Experimental,
|
|
1799
|
+
goal: "Monitoring active and past workflow executions",
|
|
1800
|
+
context: "Operations monitoring"
|
|
1727
1801
|
},
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
type: ScalarTypeEnum8.String_unsecure(),
|
|
1734
|
-
isOptional: false
|
|
1735
|
-
},
|
|
1736
|
-
reason: { type: ScalarTypeEnum8.String_unsecure(), isOptional: true }
|
|
1737
|
-
}
|
|
1738
|
-
}),
|
|
1739
|
-
output: WorkflowInstanceModel
|
|
1802
|
+
source: {
|
|
1803
|
+
type: "component",
|
|
1804
|
+
framework: "react",
|
|
1805
|
+
componentKey: "WorkflowInstanceList",
|
|
1806
|
+
props: WorkflowInstanceModel
|
|
1740
1807
|
},
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1808
|
+
targets: ["react", "markdown"],
|
|
1809
|
+
policy: {
|
|
1810
|
+
flags: ["workflow.enabled"]
|
|
1811
|
+
}
|
|
1812
|
+
});
|
|
1813
|
+
var InstanceDetailPresentation = definePresentation({
|
|
1814
|
+
meta: {
|
|
1815
|
+
key: "workflow.instance.detail",
|
|
1816
|
+
version: "1.0.0",
|
|
1817
|
+
title: "Instance Details",
|
|
1818
|
+
description: "Detailed view of a workflow instance with step timeline",
|
|
1819
|
+
domain: "workflow-system",
|
|
1820
|
+
owners: ["@workflow-team"],
|
|
1821
|
+
tags: ["workflow", "instance", "detail", "timeline"],
|
|
1822
|
+
stability: StabilityEnum.Experimental,
|
|
1823
|
+
goal: "Detailed inspection of a specific workflow instance",
|
|
1824
|
+
context: "Case management and troubleshooting"
|
|
1752
1825
|
},
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
]
|
|
1762
|
-
examples: [
|
|
1763
|
-
{
|
|
1764
|
-
key: "resume-normal",
|
|
1765
|
-
input: { instanceId: "inst-456", reason: "Issue resolved" },
|
|
1766
|
-
output: { id: "inst-456", status: "running" }
|
|
1767
|
-
}
|
|
1768
|
-
]
|
|
1826
|
+
source: {
|
|
1827
|
+
type: "component",
|
|
1828
|
+
framework: "react",
|
|
1829
|
+
componentKey: "WorkflowInstanceDetail",
|
|
1830
|
+
props: WorkflowInstanceModel
|
|
1831
|
+
},
|
|
1832
|
+
targets: ["react", "markdown"],
|
|
1833
|
+
policy: {
|
|
1834
|
+
flags: ["workflow.enabled"]
|
|
1769
1835
|
}
|
|
1770
1836
|
});
|
|
1771
|
-
var
|
|
1837
|
+
var ProgressTrackerPresentation = definePresentation({
|
|
1772
1838
|
meta: {
|
|
1773
|
-
key: "workflow.instance.
|
|
1839
|
+
key: "workflow.instance.progress",
|
|
1774
1840
|
version: "1.0.0",
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1841
|
+
title: "Progress Tracker",
|
|
1842
|
+
description: "Visual progress tracker showing current step in workflow",
|
|
1843
|
+
domain: "workflow-system",
|
|
1844
|
+
owners: ["@workflow-team"],
|
|
1845
|
+
tags: ["workflow", "progress", "widget"],
|
|
1846
|
+
stability: StabilityEnum.Experimental,
|
|
1847
|
+
goal: "Quick view of current progress for a workflow",
|
|
1848
|
+
context: "Embedded progress indicator in entity views"
|
|
1781
1849
|
},
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
type: ScalarTypeEnum8.String_unsecure(),
|
|
1788
|
-
isOptional: false
|
|
1789
|
-
},
|
|
1790
|
-
reason: {
|
|
1791
|
-
type: ScalarTypeEnum8.String_unsecure(),
|
|
1792
|
-
isOptional: false
|
|
1793
|
-
}
|
|
1794
|
-
}
|
|
1795
|
-
}),
|
|
1796
|
-
output: WorkflowInstanceModel
|
|
1850
|
+
source: {
|
|
1851
|
+
type: "component",
|
|
1852
|
+
framework: "react",
|
|
1853
|
+
componentKey: "WorkflowProgressTracker",
|
|
1854
|
+
props: WorkflowInstanceModel
|
|
1797
1855
|
},
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
{
|
|
1802
|
-
key: "workflow.instance.cancelled",
|
|
1803
|
-
version: "1.0.0",
|
|
1804
|
-
when: "Workflow is cancelled",
|
|
1805
|
-
payload: WorkflowInstanceModel
|
|
1806
|
-
}
|
|
1807
|
-
],
|
|
1808
|
-
audit: ["workflow.instance.cancelled"]
|
|
1809
|
-
},
|
|
1810
|
-
acceptance: {
|
|
1811
|
-
scenarios: [
|
|
1812
|
-
{
|
|
1813
|
-
key: "cancel-workflow-happy-path",
|
|
1814
|
-
given: ["Workflow is running"],
|
|
1815
|
-
when: ["User cancels workflow"],
|
|
1816
|
-
then: ["Instance status becomes CANCELLED"]
|
|
1817
|
-
}
|
|
1818
|
-
],
|
|
1819
|
-
examples: [
|
|
1820
|
-
{
|
|
1821
|
-
key: "cancel-mistake",
|
|
1822
|
-
input: { instanceId: "inst-456", reason: "Created by mistake" },
|
|
1823
|
-
output: { id: "inst-456", status: "cancelled" }
|
|
1824
|
-
}
|
|
1825
|
-
]
|
|
1856
|
+
targets: ["react"],
|
|
1857
|
+
policy: {
|
|
1858
|
+
flags: ["workflow.enabled"]
|
|
1826
1859
|
}
|
|
1827
1860
|
});
|
|
1828
|
-
var
|
|
1861
|
+
var ApprovalInboxPresentation = definePresentation({
|
|
1829
1862
|
meta: {
|
|
1830
|
-
key: "workflow.
|
|
1863
|
+
key: "workflow.approval.inbox",
|
|
1831
1864
|
version: "1.0.0",
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1865
|
+
title: "Approval Inbox",
|
|
1866
|
+
description: "Inbox showing pending approval requests for current user",
|
|
1867
|
+
domain: "workflow-system",
|
|
1868
|
+
owners: ["@workflow-team"],
|
|
1869
|
+
tags: ["workflow", "approval", "inbox"],
|
|
1870
|
+
stability: StabilityEnum.Experimental,
|
|
1871
|
+
goal: "Managing personal workload of approval requests",
|
|
1872
|
+
context: "Personal task management"
|
|
1838
1873
|
},
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
type: ScalarTypeEnum8.String_unsecure(),
|
|
1845
|
-
isOptional: true
|
|
1846
|
-
},
|
|
1847
|
-
status: { type: InstanceStatusEnum, isOptional: true },
|
|
1848
|
-
referenceType: {
|
|
1849
|
-
type: ScalarTypeEnum8.String_unsecure(),
|
|
1850
|
-
isOptional: true
|
|
1851
|
-
},
|
|
1852
|
-
referenceId: {
|
|
1853
|
-
type: ScalarTypeEnum8.String_unsecure(),
|
|
1854
|
-
isOptional: true
|
|
1855
|
-
},
|
|
1856
|
-
triggeredBy: {
|
|
1857
|
-
type: ScalarTypeEnum8.String_unsecure(),
|
|
1858
|
-
isOptional: true
|
|
1859
|
-
},
|
|
1860
|
-
limit: {
|
|
1861
|
-
type: ScalarTypeEnum8.Int_unsecure(),
|
|
1862
|
-
isOptional: true,
|
|
1863
|
-
defaultValue: 20
|
|
1864
|
-
},
|
|
1865
|
-
offset: {
|
|
1866
|
-
type: ScalarTypeEnum8.Int_unsecure(),
|
|
1867
|
-
isOptional: true,
|
|
1868
|
-
defaultValue: 0
|
|
1869
|
-
}
|
|
1870
|
-
}
|
|
1871
|
-
}),
|
|
1872
|
-
output: defineSchemaModel8({
|
|
1873
|
-
name: "ListInstancesOutput",
|
|
1874
|
-
fields: {
|
|
1875
|
-
instances: {
|
|
1876
|
-
type: WorkflowInstanceModel,
|
|
1877
|
-
isArray: true,
|
|
1878
|
-
isOptional: false
|
|
1879
|
-
},
|
|
1880
|
-
total: { type: ScalarTypeEnum8.Int_unsecure(), isOptional: false }
|
|
1881
|
-
}
|
|
1882
|
-
})
|
|
1874
|
+
source: {
|
|
1875
|
+
type: "component",
|
|
1876
|
+
framework: "react",
|
|
1877
|
+
componentKey: "ApprovalInbox",
|
|
1878
|
+
props: ApprovalRequestModel
|
|
1883
1879
|
},
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
{
|
|
1888
|
-
key: "list-instances-happy-path",
|
|
1889
|
-
given: ["Workflow instances exist"],
|
|
1890
|
-
when: ["User lists instances"],
|
|
1891
|
-
then: ["List of instances is returned"]
|
|
1892
|
-
}
|
|
1893
|
-
],
|
|
1894
|
-
examples: [
|
|
1895
|
-
{
|
|
1896
|
-
key: "list-running",
|
|
1897
|
-
input: { status: "running", limit: 10 },
|
|
1898
|
-
output: { instances: [], total: 5 }
|
|
1899
|
-
}
|
|
1900
|
-
]
|
|
1880
|
+
targets: ["react", "markdown"],
|
|
1881
|
+
policy: {
|
|
1882
|
+
flags: ["workflow.approvals.enabled"]
|
|
1901
1883
|
}
|
|
1902
1884
|
});
|
|
1903
|
-
var
|
|
1885
|
+
var ApprovalDetailPresentation = definePresentation({
|
|
1904
1886
|
meta: {
|
|
1905
|
-
key: "workflow.
|
|
1887
|
+
key: "workflow.approval.detail",
|
|
1906
1888
|
version: "1.0.0",
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1889
|
+
title: "Approval Details",
|
|
1890
|
+
description: "Detailed approval request view with context and actions",
|
|
1891
|
+
domain: "workflow-system",
|
|
1892
|
+
owners: ["@workflow-team"],
|
|
1893
|
+
tags: ["workflow", "approval", "detail"],
|
|
1894
|
+
stability: StabilityEnum.Experimental,
|
|
1895
|
+
goal: "Decision support for an approval request",
|
|
1896
|
+
context: "Specific approval action"
|
|
1913
1897
|
},
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
type: ScalarTypeEnum8.String_unsecure(),
|
|
1920
|
-
isOptional: false
|
|
1921
|
-
}
|
|
1922
|
-
}
|
|
1923
|
-
}),
|
|
1924
|
-
output: WorkflowInstanceModel
|
|
1898
|
+
source: {
|
|
1899
|
+
type: "component",
|
|
1900
|
+
framework: "react",
|
|
1901
|
+
componentKey: "ApprovalRequestDetail",
|
|
1902
|
+
props: ApprovalRequestModel
|
|
1925
1903
|
},
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
{
|
|
1930
|
-
key: "get-instance-happy-path",
|
|
1931
|
-
given: ["Instance exists"],
|
|
1932
|
-
when: ["User requests instance details"],
|
|
1933
|
-
then: ["Instance details are returned"]
|
|
1934
|
-
}
|
|
1935
|
-
],
|
|
1936
|
-
examples: [
|
|
1937
|
-
{
|
|
1938
|
-
key: "get-details",
|
|
1939
|
-
input: { instanceId: "inst-456" },
|
|
1940
|
-
output: { id: "inst-456", workflowKey: "onboarding-v1" }
|
|
1941
|
-
}
|
|
1942
|
-
]
|
|
1943
|
-
}
|
|
1944
|
-
});
|
|
1945
|
-
|
|
1946
|
-
// src/instance/instance.event.ts
|
|
1947
|
-
import { defineEvent as defineEvent3 } from "@contractspec/lib.contracts-spec";
|
|
1948
|
-
import { ScalarTypeEnum as ScalarTypeEnum9, defineSchemaModel as defineSchemaModel9 } from "@contractspec/lib.schema";
|
|
1949
|
-
var InstanceEventPayload = defineSchemaModel9({
|
|
1950
|
-
name: "InstanceEventPayload",
|
|
1951
|
-
description: "Base payload for instance events",
|
|
1952
|
-
fields: {
|
|
1953
|
-
instanceId: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
|
|
1954
|
-
workflowId: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
|
|
1955
|
-
workflowKey: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
|
|
1956
|
-
status: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
|
|
1957
|
-
referenceId: { type: ScalarTypeEnum9.String_unsecure(), isOptional: true },
|
|
1958
|
-
referenceType: {
|
|
1959
|
-
type: ScalarTypeEnum9.String_unsecure(),
|
|
1960
|
-
isOptional: true
|
|
1961
|
-
},
|
|
1962
|
-
triggeredBy: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
|
|
1963
|
-
organizationId: {
|
|
1964
|
-
type: ScalarTypeEnum9.String_unsecure(),
|
|
1965
|
-
isOptional: false
|
|
1966
|
-
},
|
|
1967
|
-
timestamp: { type: ScalarTypeEnum9.DateTime(), isOptional: false }
|
|
1968
|
-
}
|
|
1969
|
-
});
|
|
1970
|
-
var StepTransitionPayload = defineSchemaModel9({
|
|
1971
|
-
name: "StepTransitionEventPayload",
|
|
1972
|
-
description: "Payload for step transition events",
|
|
1973
|
-
fields: {
|
|
1974
|
-
instanceId: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
|
|
1975
|
-
workflowId: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
|
|
1976
|
-
fromStepKey: { type: ScalarTypeEnum9.String_unsecure(), isOptional: true },
|
|
1977
|
-
toStepKey: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
|
|
1978
|
-
action: { type: ScalarTypeEnum9.String_unsecure(), isOptional: true },
|
|
1979
|
-
executedBy: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
|
|
1980
|
-
timestamp: { type: ScalarTypeEnum9.DateTime(), isOptional: false }
|
|
1981
|
-
}
|
|
1982
|
-
});
|
|
1983
|
-
var InstanceCompletedPayload = defineSchemaModel9({
|
|
1984
|
-
name: "InstanceCompletedEventPayload",
|
|
1985
|
-
description: "Payload when instance completes",
|
|
1986
|
-
fields: {
|
|
1987
|
-
instanceId: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
|
|
1988
|
-
workflowId: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
|
|
1989
|
-
workflowKey: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
|
|
1990
|
-
outcome: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
|
|
1991
|
-
referenceId: { type: ScalarTypeEnum9.String_unsecure(), isOptional: true },
|
|
1992
|
-
referenceType: {
|
|
1993
|
-
type: ScalarTypeEnum9.String_unsecure(),
|
|
1994
|
-
isOptional: true
|
|
1995
|
-
},
|
|
1996
|
-
duration: { type: ScalarTypeEnum9.Int_unsecure(), isOptional: false },
|
|
1997
|
-
timestamp: { type: ScalarTypeEnum9.DateTime(), isOptional: false }
|
|
1904
|
+
targets: ["react", "markdown"],
|
|
1905
|
+
policy: {
|
|
1906
|
+
flags: ["workflow.approvals.enabled"]
|
|
1998
1907
|
}
|
|
1999
1908
|
});
|
|
2000
|
-
var
|
|
1909
|
+
var ApprovalFormPresentation = definePresentation({
|
|
2001
1910
|
meta: {
|
|
2002
|
-
key: "workflow.
|
|
1911
|
+
key: "workflow.approval.form",
|
|
2003
1912
|
version: "1.0.0",
|
|
2004
|
-
|
|
2005
|
-
|
|
1913
|
+
title: "Approval Form",
|
|
1914
|
+
description: "Form for submitting approval decisions",
|
|
1915
|
+
domain: "workflow-system",
|
|
2006
1916
|
owners: ["@workflow-team"],
|
|
2007
|
-
tags: ["workflow", "
|
|
1917
|
+
tags: ["workflow", "approval", "form"],
|
|
1918
|
+
stability: StabilityEnum.Experimental,
|
|
1919
|
+
goal: "Submitting a decision on an approval request",
|
|
1920
|
+
context: "Approval decision dialog"
|
|
2008
1921
|
},
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
key: "workflow.step.entered",
|
|
2014
|
-
version: "1.0.0",
|
|
2015
|
-
description: "A workflow instance has entered a new step.",
|
|
2016
|
-
stability: "stable",
|
|
2017
|
-
owners: ["@workflow-team"],
|
|
2018
|
-
tags: ["workflow", "step", "entered"]
|
|
1922
|
+
source: {
|
|
1923
|
+
type: "component",
|
|
1924
|
+
framework: "react",
|
|
1925
|
+
componentKey: "ApprovalDecisionForm"
|
|
2019
1926
|
},
|
|
2020
|
-
|
|
1927
|
+
targets: ["react"],
|
|
1928
|
+
policy: {
|
|
1929
|
+
flags: ["workflow.approvals.enabled"]
|
|
1930
|
+
}
|
|
2021
1931
|
});
|
|
2022
|
-
var
|
|
1932
|
+
var PendingApprovalsBadgePresentation = definePresentation({
|
|
2023
1933
|
meta: {
|
|
2024
|
-
key: "workflow.
|
|
1934
|
+
key: "workflow.approval.badge",
|
|
2025
1935
|
version: "1.0.0",
|
|
2026
|
-
|
|
2027
|
-
|
|
1936
|
+
title: "Pending Approvals Badge",
|
|
1937
|
+
description: "Badge showing count of pending approvals",
|
|
1938
|
+
domain: "workflow-system",
|
|
2028
1939
|
owners: ["@workflow-team"],
|
|
2029
|
-
tags: ["workflow", "
|
|
1940
|
+
tags: ["workflow", "approval", "badge", "widget"],
|
|
1941
|
+
stability: StabilityEnum.Experimental,
|
|
1942
|
+
goal: "Visual notification of pending approvals",
|
|
1943
|
+
context: "Global navigation or sidebar"
|
|
2030
1944
|
},
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
key: "workflow.instance.completed",
|
|
2036
|
-
version: "1.0.0",
|
|
2037
|
-
description: "A workflow instance has completed.",
|
|
2038
|
-
stability: "stable",
|
|
2039
|
-
owners: ["@workflow-team"],
|
|
2040
|
-
tags: ["workflow", "instance", "completed"]
|
|
1945
|
+
source: {
|
|
1946
|
+
type: "component",
|
|
1947
|
+
framework: "react",
|
|
1948
|
+
componentKey: "PendingApprovalsBadge"
|
|
2041
1949
|
},
|
|
2042
|
-
|
|
1950
|
+
targets: ["react"],
|
|
1951
|
+
policy: {
|
|
1952
|
+
flags: ["workflow.approvals.enabled"]
|
|
1953
|
+
}
|
|
2043
1954
|
});
|
|
2044
|
-
var
|
|
1955
|
+
var WorkflowMetricsPresentation = definePresentation({
|
|
2045
1956
|
meta: {
|
|
2046
|
-
key: "workflow.
|
|
1957
|
+
key: "workflow.metrics",
|
|
2047
1958
|
version: "1.0.0",
|
|
2048
|
-
|
|
2049
|
-
|
|
1959
|
+
title: "Workflow Metrics",
|
|
1960
|
+
description: "Dashboard widget showing workflow metrics and statistics",
|
|
1961
|
+
domain: "workflow-system",
|
|
2050
1962
|
owners: ["@workflow-team"],
|
|
2051
|
-
tags: ["workflow", "
|
|
2052
|
-
},
|
|
2053
|
-
payload: InstanceEventPayload
|
|
2054
|
-
});
|
|
2055
|
-
var InstancePausedEvent = defineEvent3({
|
|
2056
|
-
meta: {
|
|
2057
|
-
key: "workflow.instance.paused",
|
|
2058
|
-
version: "1.0.0",
|
|
2059
|
-
description: "A workflow instance has been paused.",
|
|
2060
|
-
stability: "stable",
|
|
2061
|
-
owners: ["@workflow-team"],
|
|
2062
|
-
tags: ["workflow", "instance", "paused"]
|
|
2063
|
-
},
|
|
2064
|
-
payload: InstanceEventPayload
|
|
2065
|
-
});
|
|
2066
|
-
var InstanceResumedEvent = defineEvent3({
|
|
2067
|
-
meta: {
|
|
2068
|
-
key: "workflow.instance.resumed",
|
|
2069
|
-
version: "1.0.0",
|
|
2070
|
-
description: "A workflow instance has been resumed.",
|
|
2071
|
-
stability: "stable",
|
|
2072
|
-
owners: ["@workflow-team"],
|
|
2073
|
-
tags: ["workflow", "instance", "resumed"]
|
|
2074
|
-
},
|
|
2075
|
-
payload: InstanceEventPayload
|
|
2076
|
-
});
|
|
2077
|
-
var InstanceFailedEvent = defineEvent3({
|
|
2078
|
-
meta: {
|
|
2079
|
-
key: "workflow.instance.failed",
|
|
2080
|
-
version: "1.0.0",
|
|
2081
|
-
description: "A workflow instance has failed.",
|
|
2082
|
-
stability: "stable",
|
|
2083
|
-
owners: ["@workflow-team"],
|
|
2084
|
-
tags: ["workflow", "instance", "failed"]
|
|
2085
|
-
},
|
|
2086
|
-
payload: InstanceEventPayload
|
|
2087
|
-
});
|
|
2088
|
-
var InstanceTimedOutEvent = defineEvent3({
|
|
2089
|
-
meta: {
|
|
2090
|
-
key: "workflow.instance.timedOut",
|
|
2091
|
-
version: "1.0.0",
|
|
2092
|
-
description: "A workflow instance has timed out.",
|
|
2093
|
-
stability: "stable",
|
|
2094
|
-
owners: ["@workflow-team"],
|
|
2095
|
-
tags: ["workflow", "instance", "timeout"]
|
|
2096
|
-
},
|
|
2097
|
-
payload: InstanceEventPayload
|
|
2098
|
-
});
|
|
2099
|
-
// src/presentations/index.ts
|
|
2100
|
-
import {
|
|
2101
|
-
definePresentation,
|
|
2102
|
-
StabilityEnum
|
|
2103
|
-
} from "@contractspec/lib.contracts-spec";
|
|
2104
|
-
var WorkflowDesignerPresentation = definePresentation({
|
|
2105
|
-
meta: {
|
|
2106
|
-
key: "workflow.designer",
|
|
2107
|
-
version: "1.0.0",
|
|
2108
|
-
title: "Workflow Designer",
|
|
2109
|
-
description: "Visual workflow designer with drag-and-drop steps",
|
|
2110
|
-
domain: "workflow-system",
|
|
2111
|
-
owners: ["@workflow-team"],
|
|
2112
|
-
tags: ["workflow", "designer", "admin"],
|
|
2113
|
-
stability: StabilityEnum.Experimental,
|
|
2114
|
-
goal: "Building and modifying workflow definitions",
|
|
2115
|
-
context: "Workflow administration and setup"
|
|
2116
|
-
},
|
|
2117
|
-
source: {
|
|
2118
|
-
type: "component",
|
|
2119
|
-
framework: "react",
|
|
2120
|
-
componentKey: "WorkflowDesigner",
|
|
2121
|
-
props: WorkflowDefinitionModel
|
|
2122
|
-
},
|
|
2123
|
-
targets: ["react"],
|
|
2124
|
-
policy: {
|
|
2125
|
-
flags: ["workflow.designer.enabled"]
|
|
2126
|
-
}
|
|
2127
|
-
});
|
|
2128
|
-
var WorkflowListPresentation = definePresentation({
|
|
2129
|
-
meta: {
|
|
2130
|
-
key: "workflow.definition.viewList",
|
|
2131
|
-
version: "1.0.0",
|
|
2132
|
-
title: "Workflow List",
|
|
2133
|
-
description: "List of workflow definitions with status and actions",
|
|
2134
|
-
domain: "workflow-system",
|
|
2135
|
-
owners: ["@workflow-team"],
|
|
2136
|
-
tags: ["workflow", "list", "admin"],
|
|
1963
|
+
tags: ["workflow", "metrics", "dashboard"],
|
|
2137
1964
|
stability: StabilityEnum.Experimental,
|
|
2138
|
-
goal: "
|
|
2139
|
-
context: "
|
|
1965
|
+
goal: "Monitoring throughput and bottlenecks",
|
|
1966
|
+
context: "System performance dashboard"
|
|
2140
1967
|
},
|
|
2141
1968
|
source: {
|
|
2142
1969
|
type: "component",
|
|
2143
1970
|
framework: "react",
|
|
2144
|
-
componentKey: "
|
|
2145
|
-
props: WorkflowDefinitionModel
|
|
1971
|
+
componentKey: "WorkflowMetricsDashboard"
|
|
2146
1972
|
},
|
|
2147
1973
|
targets: ["react", "markdown"],
|
|
2148
1974
|
policy: {
|
|
2149
|
-
flags: ["workflow.enabled"]
|
|
1975
|
+
flags: ["workflow.metrics.enabled"]
|
|
2150
1976
|
}
|
|
2151
1977
|
});
|
|
2152
|
-
var
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
1978
|
+
var WorkflowSystemPresentations = {
|
|
1979
|
+
WorkflowDesignerPresentation,
|
|
1980
|
+
WorkflowListPresentation,
|
|
1981
|
+
WorkflowDetailPresentation,
|
|
1982
|
+
InstanceListPresentation,
|
|
1983
|
+
InstanceDetailPresentation,
|
|
1984
|
+
ProgressTrackerPresentation,
|
|
1985
|
+
ApprovalInboxPresentation,
|
|
1986
|
+
ApprovalDetailPresentation,
|
|
1987
|
+
ApprovalFormPresentation,
|
|
1988
|
+
PendingApprovalsBadgePresentation,
|
|
1989
|
+
WorkflowMetricsPresentation
|
|
1990
|
+
};
|
|
1991
|
+
// src/ui/hooks/useWorkflowList.ts
|
|
1992
|
+
import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
|
|
1993
|
+
import { useCallback, useEffect, useState } from "react";
|
|
1994
|
+
"use client";
|
|
1995
|
+
function useWorkflowList(projectId = "local-project") {
|
|
1996
|
+
const { handlers } = useTemplateRuntime();
|
|
1997
|
+
const workflow = handlers.workflow;
|
|
1998
|
+
const [definitions, setDefinitions] = useState([]);
|
|
1999
|
+
const [instances, setInstances] = useState([]);
|
|
2000
|
+
const [loading, setLoading] = useState(true);
|
|
2001
|
+
const [error, setError] = useState(null);
|
|
2002
|
+
const fetchData = useCallback(async () => {
|
|
2003
|
+
try {
|
|
2004
|
+
setLoading(true);
|
|
2005
|
+
setError(null);
|
|
2006
|
+
const [defResult, instResult] = await Promise.all([
|
|
2007
|
+
workflow.listDefinitions({ projectId, limit: 100 }),
|
|
2008
|
+
workflow.listInstances({ projectId, limit: 100 })
|
|
2009
|
+
]);
|
|
2010
|
+
setDefinitions(defResult.definitions);
|
|
2011
|
+
setInstances(instResult.instances);
|
|
2012
|
+
} catch (err) {
|
|
2013
|
+
setError(err instanceof Error ? err : new Error("Failed to load workflows"));
|
|
2014
|
+
} finally {
|
|
2015
|
+
setLoading(false);
|
|
2016
|
+
}
|
|
2017
|
+
}, [handlers, projectId]);
|
|
2018
|
+
useEffect(() => {
|
|
2019
|
+
fetchData();
|
|
2020
|
+
}, [fetchData]);
|
|
2021
|
+
const stats = {
|
|
2022
|
+
totalDefinitions: definitions.length,
|
|
2023
|
+
activeDefinitions: definitions.filter((d) => d.status === "ACTIVE").length,
|
|
2024
|
+
totalInstances: instances.length,
|
|
2025
|
+
pendingInstances: instances.filter((i) => i.status === "PENDING").length,
|
|
2026
|
+
completedInstances: instances.filter((i) => i.status === "COMPLETED").length,
|
|
2027
|
+
rejectedInstances: instances.filter((i) => i.status === "REJECTED").length
|
|
2028
|
+
};
|
|
2029
|
+
return {
|
|
2030
|
+
definitions,
|
|
2031
|
+
instances,
|
|
2032
|
+
loading,
|
|
2033
|
+
error,
|
|
2034
|
+
stats,
|
|
2035
|
+
refetch: fetchData
|
|
2036
|
+
};
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
// src/ui/hooks/index.ts
|
|
2040
|
+
"use client";
|
|
2041
|
+
|
|
2042
|
+
// src/ui/renderers/workflow.markdown.ts
|
|
2043
|
+
var mockWorkflowDefinitions = [
|
|
2044
|
+
{
|
|
2045
|
+
id: "wf-1",
|
|
2046
|
+
name: "Purchase Approval",
|
|
2047
|
+
type: "APPROVAL",
|
|
2048
|
+
steps: [
|
|
2049
|
+
{
|
|
2050
|
+
id: "s1",
|
|
2051
|
+
name: "Manager Review",
|
|
2052
|
+
order: 1,
|
|
2053
|
+
requiredRoles: ["manager"]
|
|
2054
|
+
},
|
|
2055
|
+
{
|
|
2056
|
+
id: "s2",
|
|
2057
|
+
name: "Finance Review",
|
|
2058
|
+
order: 2,
|
|
2059
|
+
requiredRoles: ["finance"]
|
|
2060
|
+
},
|
|
2061
|
+
{ id: "s3", name: "Final Approval", order: 3, requiredRoles: ["admin"] }
|
|
2062
|
+
],
|
|
2063
|
+
status: "ACTIVE"
|
|
2164
2064
|
},
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2065
|
+
{
|
|
2066
|
+
id: "wf-2",
|
|
2067
|
+
name: "Leave Request",
|
|
2068
|
+
type: "APPROVAL",
|
|
2069
|
+
steps: [
|
|
2070
|
+
{
|
|
2071
|
+
id: "s1",
|
|
2072
|
+
name: "Supervisor Approval",
|
|
2073
|
+
order: 1,
|
|
2074
|
+
requiredRoles: ["supervisor"]
|
|
2075
|
+
},
|
|
2076
|
+
{ id: "s2", name: "HR Review", order: 2, requiredRoles: ["hr"] }
|
|
2077
|
+
],
|
|
2078
|
+
status: "ACTIVE"
|
|
2170
2079
|
},
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2080
|
+
{
|
|
2081
|
+
id: "wf-3",
|
|
2082
|
+
name: "Document Review",
|
|
2083
|
+
type: "SEQUENTIAL",
|
|
2084
|
+
steps: [
|
|
2085
|
+
{ id: "s1", name: "Author Review", order: 1, requiredRoles: ["author"] },
|
|
2086
|
+
{ id: "s2", name: "Peer Review", order: 2, requiredRoles: ["reviewer"] },
|
|
2087
|
+
{ id: "s3", name: "Publish", order: 3, requiredRoles: ["publisher"] }
|
|
2088
|
+
],
|
|
2089
|
+
status: "DRAFT"
|
|
2174
2090
|
}
|
|
2175
|
-
|
|
2176
|
-
var
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
stability: StabilityEnum.Experimental,
|
|
2186
|
-
goal: "Monitoring active and past workflow executions",
|
|
2187
|
-
context: "Operations monitoring"
|
|
2091
|
+
];
|
|
2092
|
+
var mockWorkflowInstances = [
|
|
2093
|
+
{
|
|
2094
|
+
id: "inst-1",
|
|
2095
|
+
definitionId: "wf-1",
|
|
2096
|
+
definitionName: "Purchase Approval",
|
|
2097
|
+
status: "IN_PROGRESS",
|
|
2098
|
+
currentStepId: "s2",
|
|
2099
|
+
startedAt: "2024-01-15T10:00:00Z",
|
|
2100
|
+
requestedBy: "John Doe"
|
|
2188
2101
|
},
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2102
|
+
{
|
|
2103
|
+
id: "inst-2",
|
|
2104
|
+
definitionId: "wf-1",
|
|
2105
|
+
definitionName: "Purchase Approval",
|
|
2106
|
+
status: "COMPLETED",
|
|
2107
|
+
currentStepId: null,
|
|
2108
|
+
startedAt: "2024-01-10T09:00:00Z",
|
|
2109
|
+
completedAt: "2024-01-12T14:00:00Z",
|
|
2110
|
+
requestedBy: "Jane Smith"
|
|
2194
2111
|
},
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
version: "1.0.0",
|
|
2204
|
-
title: "Instance Details",
|
|
2205
|
-
description: "Detailed view of a workflow instance with step timeline",
|
|
2206
|
-
domain: "workflow-system",
|
|
2207
|
-
owners: ["@workflow-team"],
|
|
2208
|
-
tags: ["workflow", "instance", "detail", "timeline"],
|
|
2209
|
-
stability: StabilityEnum.Experimental,
|
|
2210
|
-
goal: "Detailed inspection of a specific workflow instance",
|
|
2211
|
-
context: "Case management and troubleshooting"
|
|
2212
|
-
},
|
|
2213
|
-
source: {
|
|
2214
|
-
type: "component",
|
|
2215
|
-
framework: "react",
|
|
2216
|
-
componentKey: "WorkflowInstanceDetail",
|
|
2217
|
-
props: WorkflowInstanceModel
|
|
2218
|
-
},
|
|
2219
|
-
targets: ["react", "markdown"],
|
|
2220
|
-
policy: {
|
|
2221
|
-
flags: ["workflow.enabled"]
|
|
2112
|
+
{
|
|
2113
|
+
id: "inst-3",
|
|
2114
|
+
definitionId: "wf-2",
|
|
2115
|
+
definitionName: "Leave Request",
|
|
2116
|
+
status: "PENDING",
|
|
2117
|
+
currentStepId: "s1",
|
|
2118
|
+
startedAt: "2024-01-16T08:00:00Z",
|
|
2119
|
+
requestedBy: "Bob Wilson"
|
|
2222
2120
|
}
|
|
2223
|
-
|
|
2224
|
-
var
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2121
|
+
];
|
|
2122
|
+
var workflowDashboardMarkdownRenderer = {
|
|
2123
|
+
target: "markdown",
|
|
2124
|
+
render: async (desc) => {
|
|
2125
|
+
if (desc.source.type !== "component" || desc.source.componentKey !== "WorkflowDashboard") {
|
|
2126
|
+
throw new Error("workflowDashboardMarkdownRenderer: not WorkflowDashboard");
|
|
2127
|
+
}
|
|
2128
|
+
const definitions = mockWorkflowDefinitions;
|
|
2129
|
+
const instances = mockWorkflowInstances;
|
|
2130
|
+
const activeDefinitions = definitions.filter((d) => d.status === "ACTIVE");
|
|
2131
|
+
const pendingInstances = instances.filter((i) => i.status === "PENDING");
|
|
2132
|
+
const inProgressInstances = instances.filter((i) => i.status === "IN_PROGRESS");
|
|
2133
|
+
const completedInstances = instances.filter((i) => i.status === "COMPLETED");
|
|
2134
|
+
const lines = [
|
|
2135
|
+
"# Workflow Dashboard",
|
|
2136
|
+
"",
|
|
2137
|
+
"> Workflow and approval management overview",
|
|
2138
|
+
"",
|
|
2139
|
+
"## Summary",
|
|
2140
|
+
"",
|
|
2141
|
+
"| Metric | Value |",
|
|
2142
|
+
"|--------|-------|",
|
|
2143
|
+
`| Active Workflows | ${activeDefinitions.length} |`,
|
|
2144
|
+
`| Pending Approvals | ${pendingInstances.length} |`,
|
|
2145
|
+
`| In Progress | ${inProgressInstances.length} |`,
|
|
2146
|
+
`| Completed | ${completedInstances.length} |`,
|
|
2147
|
+
"",
|
|
2148
|
+
"## Active Workflow Definitions",
|
|
2149
|
+
""
|
|
2150
|
+
];
|
|
2151
|
+
if (activeDefinitions.length === 0) {
|
|
2152
|
+
lines.push("_No active workflow definitions._");
|
|
2153
|
+
} else {
|
|
2154
|
+
lines.push("| Name | Type | Steps | Status |");
|
|
2155
|
+
lines.push("|------|------|-------|--------|");
|
|
2156
|
+
for (const def of activeDefinitions) {
|
|
2157
|
+
lines.push(`| ${def.name} | ${def.type} | ${def.steps.length} | ${def.status} |`);
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
lines.push("");
|
|
2161
|
+
lines.push("## Recent Instances");
|
|
2162
|
+
lines.push("");
|
|
2163
|
+
if (instances.length === 0) {
|
|
2164
|
+
lines.push("_No workflow instances._");
|
|
2165
|
+
} else {
|
|
2166
|
+
lines.push("| Workflow | Requested By | Status | Started |");
|
|
2167
|
+
lines.push("|----------|--------------|--------|---------|");
|
|
2168
|
+
for (const inst of instances.slice(0, 10)) {
|
|
2169
|
+
const startedDate = new Date(inst.startedAt).toLocaleDateString();
|
|
2170
|
+
lines.push(`| ${inst.definitionName} | ${inst.requestedBy} | ${inst.status} | ${startedDate} |`);
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
return {
|
|
2174
|
+
mimeType: "text/markdown",
|
|
2175
|
+
body: lines.join(`
|
|
2176
|
+
`)
|
|
2177
|
+
};
|
|
2246
2178
|
}
|
|
2247
|
-
}
|
|
2248
|
-
var
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2179
|
+
};
|
|
2180
|
+
var workflowDefinitionListMarkdownRenderer = {
|
|
2181
|
+
target: "markdown",
|
|
2182
|
+
render: async (desc) => {
|
|
2183
|
+
if (desc.source.type !== "component" || desc.source.componentKey !== "WorkflowDefinitionList") {
|
|
2184
|
+
throw new Error("workflowDefinitionListMarkdownRenderer: not WorkflowDefinitionList");
|
|
2185
|
+
}
|
|
2186
|
+
const definitions = mockWorkflowDefinitions;
|
|
2187
|
+
const lines = [
|
|
2188
|
+
"# Workflow Definitions",
|
|
2189
|
+
"",
|
|
2190
|
+
"> Configure automated approval and process workflows",
|
|
2191
|
+
""
|
|
2192
|
+
];
|
|
2193
|
+
for (const def of definitions) {
|
|
2194
|
+
lines.push(`## ${def.name}`);
|
|
2195
|
+
lines.push("");
|
|
2196
|
+
lines.push(`**Type:** ${def.type} | **Status:** ${def.status}`);
|
|
2197
|
+
lines.push("");
|
|
2198
|
+
lines.push("### Steps");
|
|
2199
|
+
lines.push("");
|
|
2200
|
+
for (const step of def.steps) {
|
|
2201
|
+
lines.push(`${step.order}. **${step.name}** - Roles: ${step.requiredRoles.join(", ")}`);
|
|
2202
|
+
}
|
|
2203
|
+
lines.push("");
|
|
2204
|
+
}
|
|
2205
|
+
return {
|
|
2206
|
+
mimeType: "text/markdown",
|
|
2207
|
+
body: lines.join(`
|
|
2208
|
+
`)
|
|
2209
|
+
};
|
|
2270
2210
|
}
|
|
2271
|
-
}
|
|
2272
|
-
var
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2211
|
+
};
|
|
2212
|
+
var workflowInstanceDetailMarkdownRenderer = {
|
|
2213
|
+
target: "markdown",
|
|
2214
|
+
render: async (desc) => {
|
|
2215
|
+
if (desc.source.type !== "component" || desc.source.componentKey !== "WorkflowInstanceDetail") {
|
|
2216
|
+
throw new Error("workflowInstanceDetailMarkdownRenderer: not WorkflowInstanceDetail");
|
|
2217
|
+
}
|
|
2218
|
+
const instance = mockWorkflowInstances[0];
|
|
2219
|
+
if (!instance) {
|
|
2220
|
+
return {
|
|
2221
|
+
mimeType: "text/markdown",
|
|
2222
|
+
body: `# No Workflow Instances
|
|
2223
|
+
|
|
2224
|
+
No workflow instances available.`
|
|
2225
|
+
};
|
|
2226
|
+
}
|
|
2227
|
+
const definition = mockWorkflowDefinitions.find((d) => d.id === instance.definitionId);
|
|
2228
|
+
const lines = [
|
|
2229
|
+
`# Workflow: ${instance.definitionName}`,
|
|
2230
|
+
"",
|
|
2231
|
+
`**Instance ID:** ${instance.id}`,
|
|
2232
|
+
`**Status:** ${instance.status}`,
|
|
2233
|
+
`**Requested By:** ${instance.requestedBy}`,
|
|
2234
|
+
`**Started:** ${new Date(instance.startedAt).toLocaleString()}`,
|
|
2235
|
+
"",
|
|
2236
|
+
"## Steps Progress",
|
|
2237
|
+
""
|
|
2238
|
+
];
|
|
2239
|
+
if (definition) {
|
|
2240
|
+
for (const step of definition.steps) {
|
|
2241
|
+
const isCurrent = step.id === instance.currentStepId;
|
|
2242
|
+
const isCompleted = definition.steps.indexOf(step) < definition.steps.findIndex((s) => s.id === instance.currentStepId);
|
|
2243
|
+
let status = "⬜ Pending";
|
|
2244
|
+
if (isCompleted)
|
|
2245
|
+
status = "✅ Completed";
|
|
2246
|
+
if (isCurrent)
|
|
2247
|
+
status = "\uD83D\uDD04 In Progress";
|
|
2248
|
+
lines.push(`- ${status} **${step.name}**`);
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
lines.push("");
|
|
2252
|
+
lines.push("## Actions");
|
|
2253
|
+
lines.push("");
|
|
2254
|
+
lines.push("- **Approve** - Move to next step");
|
|
2255
|
+
lines.push("- **Reject** - Reject and return");
|
|
2256
|
+
lines.push("- **Delegate** - Assign to another approver");
|
|
2257
|
+
return {
|
|
2258
|
+
mimeType: "text/markdown",
|
|
2259
|
+
body: lines.join(`
|
|
2260
|
+
`)
|
|
2261
|
+
};
|
|
2294
2262
|
}
|
|
2295
|
-
}
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
stability: StabilityEnum.Experimental,
|
|
2329
|
-
goal: "Visual notification of pending approvals",
|
|
2330
|
-
context: "Global navigation or sidebar"
|
|
2331
|
-
},
|
|
2332
|
-
source: {
|
|
2333
|
-
type: "component",
|
|
2334
|
-
framework: "react",
|
|
2335
|
-
componentKey: "PendingApprovalsBadge"
|
|
2336
|
-
},
|
|
2337
|
-
targets: ["react"],
|
|
2338
|
-
policy: {
|
|
2339
|
-
flags: ["workflow.approvals.enabled"]
|
|
2263
|
+
};
|
|
2264
|
+
// src/ui/WorkflowDashboard.tsx
|
|
2265
|
+
import {
|
|
2266
|
+
Button,
|
|
2267
|
+
ErrorState,
|
|
2268
|
+
LoaderBlock,
|
|
2269
|
+
StatCard,
|
|
2270
|
+
StatCardGroup
|
|
2271
|
+
} from "@contractspec/lib.design-system";
|
|
2272
|
+
import { useState as useState2 } from "react";
|
|
2273
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2274
|
+
"use client";
|
|
2275
|
+
var STATUS_COLORS = {
|
|
2276
|
+
ACTIVE: "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",
|
|
2277
|
+
DRAFT: "bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",
|
|
2278
|
+
ARCHIVED: "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",
|
|
2279
|
+
PENDING: "bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",
|
|
2280
|
+
IN_PROGRESS: "bg-indigo-100 text-indigo-700 dark:bg-indigo-900/30 dark:text-indigo-400",
|
|
2281
|
+
COMPLETED: "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",
|
|
2282
|
+
REJECTED: "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",
|
|
2283
|
+
CANCELLED: "bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400"
|
|
2284
|
+
};
|
|
2285
|
+
function WorkflowDashboard() {
|
|
2286
|
+
const [activeTab, setActiveTab] = useState2("definitions");
|
|
2287
|
+
const { definitions, instances, loading, error, stats, refetch } = useWorkflowList();
|
|
2288
|
+
const tabs = [
|
|
2289
|
+
{ id: "definitions", label: "Definitions", icon: "\uD83D\uDCCB" },
|
|
2290
|
+
{ id: "instances", label: "Instances", icon: "\uD83D\uDD04" }
|
|
2291
|
+
];
|
|
2292
|
+
if (loading) {
|
|
2293
|
+
return /* @__PURE__ */ jsxDEV(LoaderBlock, {
|
|
2294
|
+
label: "Loading Workflows..."
|
|
2295
|
+
}, undefined, false, undefined, this);
|
|
2340
2296
|
}
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2297
|
+
if (error) {
|
|
2298
|
+
return /* @__PURE__ */ jsxDEV(ErrorState, {
|
|
2299
|
+
title: "Failed to load Workflows",
|
|
2300
|
+
description: error.message,
|
|
2301
|
+
onRetry: refetch,
|
|
2302
|
+
retryLabel: "Retry"
|
|
2303
|
+
}, undefined, false, undefined, this);
|
|
2304
|
+
}
|
|
2305
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
2306
|
+
className: "space-y-6",
|
|
2307
|
+
children: [
|
|
2308
|
+
/* @__PURE__ */ jsxDEV("div", {
|
|
2309
|
+
className: "flex items-center justify-between",
|
|
2310
|
+
children: [
|
|
2311
|
+
/* @__PURE__ */ jsxDEV("h2", {
|
|
2312
|
+
className: "font-bold text-2xl",
|
|
2313
|
+
children: "Workflow System"
|
|
2314
|
+
}, undefined, false, undefined, this),
|
|
2315
|
+
/* @__PURE__ */ jsxDEV(Button, {
|
|
2316
|
+
onClick: () => alert("Create workflow modal"),
|
|
2317
|
+
children: [
|
|
2318
|
+
/* @__PURE__ */ jsxDEV("span", {
|
|
2319
|
+
className: "mr-2",
|
|
2320
|
+
children: "+"
|
|
2321
|
+
}, undefined, false, undefined, this),
|
|
2322
|
+
" New Workflow"
|
|
2323
|
+
]
|
|
2324
|
+
}, undefined, true, undefined, this)
|
|
2325
|
+
]
|
|
2326
|
+
}, undefined, true, undefined, this),
|
|
2327
|
+
/* @__PURE__ */ jsxDEV(StatCardGroup, {
|
|
2328
|
+
children: [
|
|
2329
|
+
/* @__PURE__ */ jsxDEV(StatCard, {
|
|
2330
|
+
label: "Workflows",
|
|
2331
|
+
value: stats.totalDefinitions,
|
|
2332
|
+
hint: `${stats.activeDefinitions} active`
|
|
2333
|
+
}, undefined, false, undefined, this),
|
|
2334
|
+
/* @__PURE__ */ jsxDEV(StatCard, {
|
|
2335
|
+
label: "Instances",
|
|
2336
|
+
value: stats.totalInstances,
|
|
2337
|
+
hint: "total runs"
|
|
2338
|
+
}, undefined, false, undefined, this),
|
|
2339
|
+
/* @__PURE__ */ jsxDEV(StatCard, {
|
|
2340
|
+
label: "Pending",
|
|
2341
|
+
value: stats.pendingInstances,
|
|
2342
|
+
hint: "awaiting action"
|
|
2343
|
+
}, undefined, false, undefined, this),
|
|
2344
|
+
/* @__PURE__ */ jsxDEV(StatCard, {
|
|
2345
|
+
label: "Completed",
|
|
2346
|
+
value: stats.completedInstances,
|
|
2347
|
+
hint: "finished"
|
|
2348
|
+
}, undefined, false, undefined, this)
|
|
2349
|
+
]
|
|
2350
|
+
}, undefined, true, undefined, this),
|
|
2351
|
+
/* @__PURE__ */ jsxDEV("nav", {
|
|
2352
|
+
className: "flex gap-1 rounded-lg bg-muted p-1",
|
|
2353
|
+
role: "tablist",
|
|
2354
|
+
children: tabs.map((tab) => /* @__PURE__ */ jsxDEV(Button, {
|
|
2355
|
+
type: "button",
|
|
2356
|
+
role: "tab",
|
|
2357
|
+
"aria-selected": activeTab === tab.id,
|
|
2358
|
+
onClick: () => setActiveTab(tab.id),
|
|
2359
|
+
className: `flex flex-1 items-center justify-center gap-2 rounded-md px-4 py-2 font-medium text-sm transition-colors ${activeTab === tab.id ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"}`,
|
|
2360
|
+
children: [
|
|
2361
|
+
/* @__PURE__ */ jsxDEV("span", {
|
|
2362
|
+
children: tab.icon
|
|
2363
|
+
}, undefined, false, undefined, this),
|
|
2364
|
+
tab.label
|
|
2365
|
+
]
|
|
2366
|
+
}, tab.id, true, undefined, this))
|
|
2367
|
+
}, undefined, false, undefined, this),
|
|
2368
|
+
/* @__PURE__ */ jsxDEV("div", {
|
|
2369
|
+
className: "min-h-[400px]",
|
|
2370
|
+
role: "tabpanel",
|
|
2371
|
+
children: [
|
|
2372
|
+
activeTab === "definitions" && /* @__PURE__ */ jsxDEV("div", {
|
|
2373
|
+
className: "rounded-lg border border-border",
|
|
2374
|
+
children: /* @__PURE__ */ jsxDEV("table", {
|
|
2375
|
+
className: "w-full",
|
|
2376
|
+
children: [
|
|
2377
|
+
/* @__PURE__ */ jsxDEV("thead", {
|
|
2378
|
+
className: "border-border border-b bg-muted/30",
|
|
2379
|
+
children: /* @__PURE__ */ jsxDEV("tr", {
|
|
2380
|
+
children: [
|
|
2381
|
+
/* @__PURE__ */ jsxDEV("th", {
|
|
2382
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
2383
|
+
children: "Name"
|
|
2384
|
+
}, undefined, false, undefined, this),
|
|
2385
|
+
/* @__PURE__ */ jsxDEV("th", {
|
|
2386
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
2387
|
+
children: "Type"
|
|
2388
|
+
}, undefined, false, undefined, this),
|
|
2389
|
+
/* @__PURE__ */ jsxDEV("th", {
|
|
2390
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
2391
|
+
children: "Status"
|
|
2392
|
+
}, undefined, false, undefined, this),
|
|
2393
|
+
/* @__PURE__ */ jsxDEV("th", {
|
|
2394
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
2395
|
+
children: "Created"
|
|
2396
|
+
}, undefined, false, undefined, this)
|
|
2397
|
+
]
|
|
2398
|
+
}, undefined, true, undefined, this)
|
|
2399
|
+
}, undefined, false, undefined, this),
|
|
2400
|
+
/* @__PURE__ */ jsxDEV("tbody", {
|
|
2401
|
+
className: "divide-y divide-border",
|
|
2402
|
+
children: [
|
|
2403
|
+
definitions.map((def) => /* @__PURE__ */ jsxDEV("tr", {
|
|
2404
|
+
className: "hover:bg-muted/50",
|
|
2405
|
+
children: [
|
|
2406
|
+
/* @__PURE__ */ jsxDEV("td", {
|
|
2407
|
+
className: "px-4 py-3",
|
|
2408
|
+
children: [
|
|
2409
|
+
/* @__PURE__ */ jsxDEV("div", {
|
|
2410
|
+
className: "font-medium",
|
|
2411
|
+
children: def.name
|
|
2412
|
+
}, undefined, false, undefined, this),
|
|
2413
|
+
/* @__PURE__ */ jsxDEV("div", {
|
|
2414
|
+
className: "text-muted-foreground text-sm",
|
|
2415
|
+
children: def.description
|
|
2416
|
+
}, undefined, false, undefined, this)
|
|
2417
|
+
]
|
|
2418
|
+
}, undefined, true, undefined, this),
|
|
2419
|
+
/* @__PURE__ */ jsxDEV("td", {
|
|
2420
|
+
className: "px-4 py-3 font-mono text-sm",
|
|
2421
|
+
children: def.type
|
|
2422
|
+
}, undefined, false, undefined, this),
|
|
2423
|
+
/* @__PURE__ */ jsxDEV("td", {
|
|
2424
|
+
className: "px-4 py-3",
|
|
2425
|
+
children: /* @__PURE__ */ jsxDEV("span", {
|
|
2426
|
+
className: `inline-flex rounded-full px-2 py-0.5 font-medium text-xs ${STATUS_COLORS[def.status] ?? ""}`,
|
|
2427
|
+
children: def.status
|
|
2428
|
+
}, undefined, false, undefined, this)
|
|
2429
|
+
}, undefined, false, undefined, this),
|
|
2430
|
+
/* @__PURE__ */ jsxDEV("td", {
|
|
2431
|
+
className: "px-4 py-3 text-muted-foreground text-sm",
|
|
2432
|
+
children: def.createdAt.toLocaleDateString()
|
|
2433
|
+
}, undefined, false, undefined, this)
|
|
2434
|
+
]
|
|
2435
|
+
}, def.id, true, undefined, this)),
|
|
2436
|
+
definitions.length === 0 && /* @__PURE__ */ jsxDEV("tr", {
|
|
2437
|
+
children: /* @__PURE__ */ jsxDEV("td", {
|
|
2438
|
+
colSpan: 4,
|
|
2439
|
+
className: "px-4 py-8 text-center text-muted-foreground",
|
|
2440
|
+
children: "No workflow definitions found"
|
|
2441
|
+
}, undefined, false, undefined, this)
|
|
2442
|
+
}, undefined, false, undefined, this)
|
|
2443
|
+
]
|
|
2444
|
+
}, undefined, true, undefined, this)
|
|
2445
|
+
]
|
|
2446
|
+
}, undefined, true, undefined, this)
|
|
2447
|
+
}, undefined, false, undefined, this),
|
|
2448
|
+
activeTab === "instances" && /* @__PURE__ */ jsxDEV("div", {
|
|
2449
|
+
className: "rounded-lg border border-border",
|
|
2450
|
+
children: /* @__PURE__ */ jsxDEV("table", {
|
|
2451
|
+
className: "w-full",
|
|
2452
|
+
children: [
|
|
2453
|
+
/* @__PURE__ */ jsxDEV("thead", {
|
|
2454
|
+
className: "border-border border-b bg-muted/30",
|
|
2455
|
+
children: /* @__PURE__ */ jsxDEV("tr", {
|
|
2456
|
+
children: [
|
|
2457
|
+
/* @__PURE__ */ jsxDEV("th", {
|
|
2458
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
2459
|
+
children: "Instance ID"
|
|
2460
|
+
}, undefined, false, undefined, this),
|
|
2461
|
+
/* @__PURE__ */ jsxDEV("th", {
|
|
2462
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
2463
|
+
children: "Status"
|
|
2464
|
+
}, undefined, false, undefined, this),
|
|
2465
|
+
/* @__PURE__ */ jsxDEV("th", {
|
|
2466
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
2467
|
+
children: "Requested By"
|
|
2468
|
+
}, undefined, false, undefined, this),
|
|
2469
|
+
/* @__PURE__ */ jsxDEV("th", {
|
|
2470
|
+
className: "px-4 py-3 text-left font-medium text-sm",
|
|
2471
|
+
children: "Started"
|
|
2472
|
+
}, undefined, false, undefined, this)
|
|
2473
|
+
]
|
|
2474
|
+
}, undefined, true, undefined, this)
|
|
2475
|
+
}, undefined, false, undefined, this),
|
|
2476
|
+
/* @__PURE__ */ jsxDEV("tbody", {
|
|
2477
|
+
className: "divide-y divide-border",
|
|
2478
|
+
children: [
|
|
2479
|
+
instances.map((inst) => /* @__PURE__ */ jsxDEV("tr", {
|
|
2480
|
+
className: "hover:bg-muted/50",
|
|
2481
|
+
children: [
|
|
2482
|
+
/* @__PURE__ */ jsxDEV("td", {
|
|
2483
|
+
className: "px-4 py-3 font-mono text-sm",
|
|
2484
|
+
children: inst.id
|
|
2485
|
+
}, undefined, false, undefined, this),
|
|
2486
|
+
/* @__PURE__ */ jsxDEV("td", {
|
|
2487
|
+
className: "px-4 py-3",
|
|
2488
|
+
children: /* @__PURE__ */ jsxDEV("span", {
|
|
2489
|
+
className: `inline-flex rounded-full px-2 py-0.5 font-medium text-xs ${STATUS_COLORS[inst.status] ?? ""}`,
|
|
2490
|
+
children: inst.status
|
|
2491
|
+
}, undefined, false, undefined, this)
|
|
2492
|
+
}, undefined, false, undefined, this),
|
|
2493
|
+
/* @__PURE__ */ jsxDEV("td", {
|
|
2494
|
+
className: "px-4 py-3 text-sm",
|
|
2495
|
+
children: inst.requestedBy
|
|
2496
|
+
}, undefined, false, undefined, this),
|
|
2497
|
+
/* @__PURE__ */ jsxDEV("td", {
|
|
2498
|
+
className: "px-4 py-3 text-muted-foreground text-sm",
|
|
2499
|
+
children: inst.startedAt.toLocaleDateString()
|
|
2500
|
+
}, undefined, false, undefined, this)
|
|
2501
|
+
]
|
|
2502
|
+
}, inst.id, true, undefined, this)),
|
|
2503
|
+
instances.length === 0 && /* @__PURE__ */ jsxDEV("tr", {
|
|
2504
|
+
children: /* @__PURE__ */ jsxDEV("td", {
|
|
2505
|
+
colSpan: 4,
|
|
2506
|
+
className: "px-4 py-8 text-center text-muted-foreground",
|
|
2507
|
+
children: "No workflow instances found"
|
|
2508
|
+
}, undefined, false, undefined, this)
|
|
2509
|
+
}, undefined, false, undefined, this)
|
|
2510
|
+
]
|
|
2511
|
+
}, undefined, true, undefined, this)
|
|
2512
|
+
]
|
|
2513
|
+
}, undefined, true, undefined, this)
|
|
2514
|
+
}, undefined, false, undefined, this)
|
|
2515
|
+
]
|
|
2516
|
+
}, undefined, true, undefined, this)
|
|
2517
|
+
]
|
|
2518
|
+
}, undefined, true, undefined, this);
|
|
2519
|
+
}
|
|
2520
|
+
// src/workflow/workflow.event.ts
|
|
2521
|
+
import { defineEvent as defineEvent3 } from "@contractspec/lib.contracts-spec";
|
|
2522
|
+
import { defineSchemaModel as defineSchemaModel8, ScalarTypeEnum as ScalarTypeEnum8 } from "@contractspec/lib.schema";
|
|
2523
|
+
var WorkflowDefinitionPayload = defineSchemaModel8({
|
|
2524
|
+
name: "WorkflowDefinitionEventPayload",
|
|
2525
|
+
description: "Payload for workflow definition events",
|
|
2526
|
+
fields: {
|
|
2527
|
+
workflowId: { type: ScalarTypeEnum8.String_unsecure(), isOptional: false },
|
|
2528
|
+
key: { type: ScalarTypeEnum8.String_unsecure(), isOptional: false },
|
|
2529
|
+
name: { type: ScalarTypeEnum8.String_unsecure(), isOptional: false },
|
|
2530
|
+
version: { type: ScalarTypeEnum8.String_unsecure(), isOptional: false },
|
|
2531
|
+
organizationId: {
|
|
2532
|
+
type: ScalarTypeEnum8.String_unsecure(),
|
|
2533
|
+
isOptional: false
|
|
2534
|
+
},
|
|
2535
|
+
createdBy: { type: ScalarTypeEnum8.String_unsecure(), isOptional: false },
|
|
2536
|
+
timestamp: { type: ScalarTypeEnum8.DateTime(), isOptional: false }
|
|
2363
2537
|
}
|
|
2364
2538
|
});
|
|
2365
|
-
var
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
PendingApprovalsBadgePresentation,
|
|
2376
|
-
WorkflowMetricsPresentation
|
|
2377
|
-
};
|
|
2378
|
-
|
|
2379
|
-
// src/workflow-system.feature.ts
|
|
2380
|
-
import { defineFeature } from "@contractspec/lib.contracts-spec";
|
|
2381
|
-
var WorkflowSystemFeature = defineFeature({
|
|
2382
|
-
meta: {
|
|
2383
|
-
key: "workflow-system",
|
|
2384
|
-
title: "Workflow & Approval System",
|
|
2385
|
-
description: "State machine-based workflow engine with role-based approvals, delegation, and escalation",
|
|
2386
|
-
domain: "workflow",
|
|
2387
|
-
owners: ["@workflow-team"],
|
|
2388
|
-
tags: ["workflow", "approval", "state-machine", "automation"],
|
|
2389
|
-
stability: "experimental",
|
|
2390
|
-
version: "1.0.0"
|
|
2391
|
-
},
|
|
2392
|
-
operations: [
|
|
2393
|
-
{ key: "workflow.definition.create", version: "1.0.0" },
|
|
2394
|
-
{ key: "workflow.definition.update", version: "1.0.0" },
|
|
2395
|
-
{ key: "workflow.step.add", version: "1.0.0" },
|
|
2396
|
-
{ key: "workflow.definition.publish", version: "1.0.0" },
|
|
2397
|
-
{ key: "workflow.definition.list", version: "1.0.0" },
|
|
2398
|
-
{ key: "workflow.definition.get", version: "1.0.0" },
|
|
2399
|
-
{ key: "workflow.instance.start", version: "1.0.0" },
|
|
2400
|
-
{ key: "workflow.instance.transition", version: "1.0.0" },
|
|
2401
|
-
{ key: "workflow.instance.pause", version: "1.0.0" },
|
|
2402
|
-
{ key: "workflow.instance.resume", version: "1.0.0" },
|
|
2403
|
-
{ key: "workflow.instance.cancel", version: "1.0.0" },
|
|
2404
|
-
{ key: "workflow.instance.list", version: "1.0.0" },
|
|
2405
|
-
{ key: "workflow.instance.get", version: "1.0.0" },
|
|
2406
|
-
{ key: "workflow.approval.decide", version: "1.0.0" },
|
|
2407
|
-
{ key: "workflow.approval.delegate", version: "1.0.0" },
|
|
2408
|
-
{ key: "workflow.approval.comment.add", version: "1.0.0" },
|
|
2409
|
-
{ key: "workflow.approval.list.mine", version: "1.0.0" },
|
|
2410
|
-
{ key: "workflow.approval.get", version: "1.0.0" }
|
|
2411
|
-
],
|
|
2412
|
-
events: [
|
|
2413
|
-
{ key: "workflow.definition.created", version: "1.0.0" },
|
|
2414
|
-
{ key: "workflow.definition.updated", version: "1.0.0" },
|
|
2415
|
-
{ key: "workflow.definition.published", version: "1.0.0" },
|
|
2416
|
-
{ key: "workflow.step.added", version: "1.0.0" },
|
|
2417
|
-
{ key: "workflow.instance.started", version: "1.0.0" },
|
|
2418
|
-
{ key: "workflow.step.entered", version: "1.0.0" },
|
|
2419
|
-
{ key: "workflow.step.exited", version: "1.0.0" },
|
|
2420
|
-
{ key: "workflow.instance.completed", version: "1.0.0" },
|
|
2421
|
-
{ key: "workflow.instance.cancelled", version: "1.0.0" },
|
|
2422
|
-
{ key: "workflow.instance.paused", version: "1.0.0" },
|
|
2423
|
-
{ key: "workflow.instance.resumed", version: "1.0.0" },
|
|
2424
|
-
{ key: "workflow.instance.failed", version: "1.0.0" },
|
|
2425
|
-
{ key: "workflow.instance.timedOut", version: "1.0.0" },
|
|
2426
|
-
{ key: "workflow.approval.requested", version: "1.0.0" },
|
|
2427
|
-
{ key: "workflow.approval.decided", version: "1.0.0" },
|
|
2428
|
-
{ key: "workflow.approval.delegated", version: "1.0.0" },
|
|
2429
|
-
{ key: "workflow.approval.escalated", version: "1.0.0" }
|
|
2430
|
-
],
|
|
2431
|
-
presentations: [
|
|
2432
|
-
{ key: "workflow.designer", version: "1.0.0" },
|
|
2433
|
-
{ key: "workflow.definition.viewList", version: "1.0.0" },
|
|
2434
|
-
{ key: "workflow.definition.detail", version: "1.0.0" },
|
|
2435
|
-
{ key: "workflow.instance.viewList", version: "1.0.0" },
|
|
2436
|
-
{ key: "workflow.instance.detail", version: "1.0.0" },
|
|
2437
|
-
{ key: "workflow.instance.progress", version: "1.0.0" },
|
|
2438
|
-
{ key: "workflow.approval.inbox", version: "1.0.0" },
|
|
2439
|
-
{ key: "workflow.approval.detail", version: "1.0.0" },
|
|
2440
|
-
{ key: "workflow.approval.form", version: "1.0.0" },
|
|
2441
|
-
{ key: "workflow.approval.badge", version: "1.0.0" },
|
|
2442
|
-
{ key: "workflow.metrics", version: "1.0.0" }
|
|
2443
|
-
],
|
|
2444
|
-
opToPresentation: [
|
|
2445
|
-
{
|
|
2446
|
-
op: { key: "workflow.definition.list", version: "1.0.0" },
|
|
2447
|
-
pres: { key: "workflow.definition.viewList", version: "1.0.0" }
|
|
2448
|
-
},
|
|
2449
|
-
{
|
|
2450
|
-
op: { key: "workflow.instance.list", version: "1.0.0" },
|
|
2451
|
-
pres: { key: "workflow.instance.viewList", version: "1.0.0" }
|
|
2452
|
-
},
|
|
2453
|
-
{
|
|
2454
|
-
op: { key: "workflow.approval.list.mine", version: "1.0.0" },
|
|
2455
|
-
pres: { key: "workflow.approval.inbox", version: "1.0.0" }
|
|
2456
|
-
},
|
|
2457
|
-
{
|
|
2458
|
-
op: { key: "workflow.approval.decide", version: "1.0.0" },
|
|
2459
|
-
pres: { key: "workflow.approval.form", version: "1.0.0" }
|
|
2460
|
-
}
|
|
2461
|
-
],
|
|
2462
|
-
presentationsTargets: [
|
|
2463
|
-
{ key: "workflow.designer", version: "1.0.0", targets: ["react"] },
|
|
2464
|
-
{
|
|
2465
|
-
key: "workflow.definition.viewList",
|
|
2466
|
-
version: "1.0.0",
|
|
2467
|
-
targets: ["react", "markdown"]
|
|
2468
|
-
},
|
|
2469
|
-
{
|
|
2470
|
-
key: "workflow.definition.detail",
|
|
2471
|
-
version: "1.0.0",
|
|
2472
|
-
targets: ["react", "markdown"]
|
|
2473
|
-
},
|
|
2474
|
-
{
|
|
2475
|
-
key: "workflow.instance.viewList",
|
|
2476
|
-
version: "1.0.0",
|
|
2477
|
-
targets: ["react", "markdown"]
|
|
2478
|
-
},
|
|
2479
|
-
{
|
|
2480
|
-
key: "workflow.instance.detail",
|
|
2481
|
-
version: "1.0.0",
|
|
2482
|
-
targets: ["react", "markdown"]
|
|
2483
|
-
},
|
|
2484
|
-
{ key: "workflow.instance.progress", version: "1.0.0", targets: ["react"] },
|
|
2485
|
-
{
|
|
2486
|
-
key: "workflow.approval.inbox",
|
|
2487
|
-
version: "1.0.0",
|
|
2488
|
-
targets: ["react", "markdown"]
|
|
2489
|
-
},
|
|
2490
|
-
{
|
|
2491
|
-
key: "workflow.approval.detail",
|
|
2492
|
-
version: "1.0.0",
|
|
2493
|
-
targets: ["react", "markdown"]
|
|
2494
|
-
},
|
|
2495
|
-
{
|
|
2496
|
-
key: "workflow.metrics",
|
|
2497
|
-
version: "1.0.0",
|
|
2498
|
-
targets: ["react", "markdown"]
|
|
2499
|
-
}
|
|
2500
|
-
],
|
|
2501
|
-
capabilities: {
|
|
2502
|
-
requires: [
|
|
2503
|
-
{ key: "identity", version: "1.0.0" },
|
|
2504
|
-
{ key: "audit-trail", version: "1.0.0" },
|
|
2505
|
-
{ key: "notifications", version: "1.0.0" },
|
|
2506
|
-
{ key: "feature-flags", version: "1.0.0" }
|
|
2507
|
-
],
|
|
2508
|
-
provides: [
|
|
2509
|
-
{ key: "workflow", version: "1.0.0" },
|
|
2510
|
-
{ key: "approval", version: "1.0.0" },
|
|
2511
|
-
{ key: "state-machine", version: "1.0.0" }
|
|
2512
|
-
]
|
|
2513
|
-
},
|
|
2514
|
-
workflows: [
|
|
2515
|
-
{ key: "workflow-system.workflow.approval-chain", version: "1.0.0" }
|
|
2516
|
-
],
|
|
2517
|
-
telemetry: [{ key: "workflow-system.telemetry", version: "1.0.0" }],
|
|
2518
|
-
jobs: [
|
|
2519
|
-
{ key: "workflow-system.job.instance-timeout", version: "1.0.0" },
|
|
2520
|
-
{ key: "workflow-system.job.escalation", version: "1.0.0" }
|
|
2521
|
-
],
|
|
2522
|
-
docs: [
|
|
2523
|
-
"docs.examples.workflow-system",
|
|
2524
|
-
"docs.examples.workflow-system.goal",
|
|
2525
|
-
"docs.examples.workflow-system.usage",
|
|
2526
|
-
"docs.examples.workflow-system.constraints"
|
|
2527
|
-
]
|
|
2528
|
-
});
|
|
2529
|
-
|
|
2530
|
-
// src/ui/renderers/workflow.markdown.ts
|
|
2531
|
-
var mockWorkflowDefinitions = [
|
|
2532
|
-
{
|
|
2533
|
-
id: "wf-1",
|
|
2534
|
-
name: "Purchase Approval",
|
|
2535
|
-
type: "APPROVAL",
|
|
2536
|
-
steps: [
|
|
2537
|
-
{
|
|
2538
|
-
id: "s1",
|
|
2539
|
-
name: "Manager Review",
|
|
2540
|
-
order: 1,
|
|
2541
|
-
requiredRoles: ["manager"]
|
|
2542
|
-
},
|
|
2543
|
-
{
|
|
2544
|
-
id: "s2",
|
|
2545
|
-
name: "Finance Review",
|
|
2546
|
-
order: 2,
|
|
2547
|
-
requiredRoles: ["finance"]
|
|
2548
|
-
},
|
|
2549
|
-
{ id: "s3", name: "Final Approval", order: 3, requiredRoles: ["admin"] }
|
|
2550
|
-
],
|
|
2551
|
-
status: "ACTIVE"
|
|
2552
|
-
},
|
|
2553
|
-
{
|
|
2554
|
-
id: "wf-2",
|
|
2555
|
-
name: "Leave Request",
|
|
2556
|
-
type: "APPROVAL",
|
|
2557
|
-
steps: [
|
|
2558
|
-
{
|
|
2559
|
-
id: "s1",
|
|
2560
|
-
name: "Supervisor Approval",
|
|
2561
|
-
order: 1,
|
|
2562
|
-
requiredRoles: ["supervisor"]
|
|
2563
|
-
},
|
|
2564
|
-
{ id: "s2", name: "HR Review", order: 2, requiredRoles: ["hr"] }
|
|
2565
|
-
],
|
|
2566
|
-
status: "ACTIVE"
|
|
2567
|
-
},
|
|
2568
|
-
{
|
|
2569
|
-
id: "wf-3",
|
|
2570
|
-
name: "Document Review",
|
|
2571
|
-
type: "SEQUENTIAL",
|
|
2572
|
-
steps: [
|
|
2573
|
-
{ id: "s1", name: "Author Review", order: 1, requiredRoles: ["author"] },
|
|
2574
|
-
{ id: "s2", name: "Peer Review", order: 2, requiredRoles: ["reviewer"] },
|
|
2575
|
-
{ id: "s3", name: "Publish", order: 3, requiredRoles: ["publisher"] }
|
|
2576
|
-
],
|
|
2577
|
-
status: "DRAFT"
|
|
2539
|
+
var StepAddedPayload = defineSchemaModel8({
|
|
2540
|
+
name: "StepAddedEventPayload",
|
|
2541
|
+
description: "Payload when a step is added",
|
|
2542
|
+
fields: {
|
|
2543
|
+
stepId: { type: ScalarTypeEnum8.String_unsecure(), isOptional: false },
|
|
2544
|
+
workflowId: { type: ScalarTypeEnum8.String_unsecure(), isOptional: false },
|
|
2545
|
+
stepKey: { type: ScalarTypeEnum8.String_unsecure(), isOptional: false },
|
|
2546
|
+
stepType: { type: ScalarTypeEnum8.String_unsecure(), isOptional: false },
|
|
2547
|
+
position: { type: ScalarTypeEnum8.Int_unsecure(), isOptional: false },
|
|
2548
|
+
timestamp: { type: ScalarTypeEnum8.DateTime(), isOptional: false }
|
|
2578
2549
|
}
|
|
2579
|
-
|
|
2580
|
-
var
|
|
2581
|
-
{
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
requestedBy: "John Doe"
|
|
2550
|
+
});
|
|
2551
|
+
var WorkflowCreatedEvent = defineEvent3({
|
|
2552
|
+
meta: {
|
|
2553
|
+
key: "workflow.definition.created",
|
|
2554
|
+
version: "1.0.0",
|
|
2555
|
+
description: "A new workflow definition has been created.",
|
|
2556
|
+
stability: "stable",
|
|
2557
|
+
owners: ["@workflow-team"],
|
|
2558
|
+
tags: ["workflow", "definition", "created"]
|
|
2589
2559
|
},
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2560
|
+
payload: WorkflowDefinitionPayload
|
|
2561
|
+
});
|
|
2562
|
+
var WorkflowUpdatedEvent = defineEvent3({
|
|
2563
|
+
meta: {
|
|
2564
|
+
key: "workflow.definition.updated",
|
|
2565
|
+
version: "1.0.0",
|
|
2566
|
+
description: "A workflow definition has been updated.",
|
|
2567
|
+
stability: "stable",
|
|
2568
|
+
owners: ["@workflow-team"],
|
|
2569
|
+
tags: ["workflow", "definition", "updated"]
|
|
2599
2570
|
},
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
]
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
]
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2571
|
+
payload: WorkflowDefinitionPayload
|
|
2572
|
+
});
|
|
2573
|
+
var WorkflowPublishedEvent = defineEvent3({
|
|
2574
|
+
meta: {
|
|
2575
|
+
key: "workflow.definition.published",
|
|
2576
|
+
version: "1.0.0",
|
|
2577
|
+
description: "A workflow definition has been published and is now active.",
|
|
2578
|
+
stability: "stable",
|
|
2579
|
+
owners: ["@workflow-team"],
|
|
2580
|
+
tags: ["workflow", "definition", "published"]
|
|
2581
|
+
},
|
|
2582
|
+
payload: WorkflowDefinitionPayload
|
|
2583
|
+
});
|
|
2584
|
+
var StepAddedEvent = defineEvent3({
|
|
2585
|
+
meta: {
|
|
2586
|
+
key: "workflow.step.added",
|
|
2587
|
+
version: "1.0.0",
|
|
2588
|
+
description: "A step has been added to a workflow definition.",
|
|
2589
|
+
stability: "stable",
|
|
2590
|
+
owners: ["@workflow-team"],
|
|
2591
|
+
tags: ["workflow", "step", "added"]
|
|
2592
|
+
},
|
|
2593
|
+
payload: StepAddedPayload
|
|
2594
|
+
});
|
|
2595
|
+
|
|
2596
|
+
// src/workflow/workflow.operations.ts
|
|
2597
|
+
import {
|
|
2598
|
+
defineCommand as defineCommand3,
|
|
2599
|
+
defineQuery as defineQuery3
|
|
2600
|
+
} from "@contractspec/lib.contracts-spec/operations";
|
|
2601
|
+
import { defineSchemaModel as defineSchemaModel9, ScalarTypeEnum as ScalarTypeEnum9 } from "@contractspec/lib.schema";
|
|
2602
|
+
var OWNERS3 = ["@example.workflow-system"];
|
|
2603
|
+
var CreateWorkflowContract = defineCommand3({
|
|
2604
|
+
meta: {
|
|
2605
|
+
key: "workflow.definition.create",
|
|
2606
|
+
version: "1.0.0",
|
|
2607
|
+
stability: "stable",
|
|
2608
|
+
owners: [...OWNERS3],
|
|
2609
|
+
tags: ["workflow", "definition", "create"],
|
|
2610
|
+
description: "Create a new workflow definition.",
|
|
2611
|
+
goal: "Allow users to define new workflow blueprints.",
|
|
2612
|
+
context: "Workflow designer, admin panel."
|
|
2613
|
+
},
|
|
2614
|
+
io: {
|
|
2615
|
+
input: CreateWorkflowInputModel,
|
|
2616
|
+
output: WorkflowDefinitionModel
|
|
2617
|
+
},
|
|
2618
|
+
policy: { auth: "user" },
|
|
2619
|
+
sideEffects: {
|
|
2620
|
+
emits: [
|
|
2621
|
+
{
|
|
2622
|
+
key: "workflow.definition.created",
|
|
2623
|
+
version: "1.0.0",
|
|
2624
|
+
when: "Workflow is created",
|
|
2625
|
+
payload: WorkflowDefinitionModel
|
|
2646
2626
|
}
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2627
|
+
],
|
|
2628
|
+
audit: ["workflow.definition.created"]
|
|
2629
|
+
},
|
|
2630
|
+
acceptance: {
|
|
2631
|
+
scenarios: [
|
|
2632
|
+
{
|
|
2633
|
+
key: "create-workflow-happy-path",
|
|
2634
|
+
given: ["User is admin"],
|
|
2635
|
+
when: ["User creates new workflow definition"],
|
|
2636
|
+
then: [
|
|
2637
|
+
"Definition is created",
|
|
2638
|
+
"WorkflowDefinitionCreated event is emitted"
|
|
2639
|
+
]
|
|
2659
2640
|
}
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2641
|
+
],
|
|
2642
|
+
examples: [
|
|
2643
|
+
{
|
|
2644
|
+
key: "create-onboarding",
|
|
2645
|
+
input: {
|
|
2646
|
+
key: "onboarding-v1",
|
|
2647
|
+
name: "Employee Onboarding",
|
|
2648
|
+
version: "1.0.0"
|
|
2649
|
+
},
|
|
2650
|
+
output: { id: "def-123", status: "draft" }
|
|
2651
|
+
}
|
|
2652
|
+
]
|
|
2666
2653
|
}
|
|
2667
|
-
};
|
|
2668
|
-
var
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2654
|
+
});
|
|
2655
|
+
var UpdateWorkflowContract = defineCommand3({
|
|
2656
|
+
meta: {
|
|
2657
|
+
key: "workflow.definition.update",
|
|
2658
|
+
version: "1.0.0",
|
|
2659
|
+
stability: "stable",
|
|
2660
|
+
owners: [...OWNERS3],
|
|
2661
|
+
tags: ["workflow", "definition", "update"],
|
|
2662
|
+
description: "Update an existing workflow definition.",
|
|
2663
|
+
goal: "Allow users to modify workflow blueprints.",
|
|
2664
|
+
context: "Workflow designer."
|
|
2665
|
+
},
|
|
2666
|
+
io: {
|
|
2667
|
+
input: UpdateWorkflowInputModel,
|
|
2668
|
+
output: WorkflowDefinitionModel
|
|
2669
|
+
},
|
|
2670
|
+
policy: { auth: "user" },
|
|
2671
|
+
sideEffects: {
|
|
2672
|
+
emits: [
|
|
2673
|
+
{
|
|
2674
|
+
key: "workflow.definition.updated",
|
|
2675
|
+
version: "1.0.0",
|
|
2676
|
+
when: "Workflow is updated",
|
|
2677
|
+
payload: WorkflowDefinitionModel
|
|
2690
2678
|
}
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2679
|
+
],
|
|
2680
|
+
audit: ["workflow.definition.updated"]
|
|
2681
|
+
},
|
|
2682
|
+
acceptance: {
|
|
2683
|
+
scenarios: [
|
|
2684
|
+
{
|
|
2685
|
+
key: "update-workflow-happy-path",
|
|
2686
|
+
given: ["Workflow definition exists"],
|
|
2687
|
+
when: ["User updates definition"],
|
|
2688
|
+
then: [
|
|
2689
|
+
"Definition is updated",
|
|
2690
|
+
"WorkflowDefinitionUpdated event is emitted"
|
|
2691
|
+
]
|
|
2692
|
+
}
|
|
2693
|
+
],
|
|
2694
|
+
examples: [
|
|
2695
|
+
{
|
|
2696
|
+
key: "update-name",
|
|
2697
|
+
input: { workflowId: "def-123", name: "New Employee Onboarding" },
|
|
2698
|
+
output: { id: "def-123", name: "New Employee Onboarding" }
|
|
2699
|
+
}
|
|
2700
|
+
]
|
|
2698
2701
|
}
|
|
2699
|
-
};
|
|
2700
|
-
var
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
"",
|
|
2724
|
-
"## Steps Progress",
|
|
2725
|
-
""
|
|
2726
|
-
];
|
|
2727
|
-
if (definition) {
|
|
2728
|
-
for (const step of definition.steps) {
|
|
2729
|
-
const isCurrent = step.id === instance.currentStepId;
|
|
2730
|
-
const isCompleted = definition.steps.indexOf(step) < definition.steps.findIndex((s) => s.id === instance.currentStepId);
|
|
2731
|
-
let status = "⬜ Pending";
|
|
2732
|
-
if (isCompleted)
|
|
2733
|
-
status = "✅ Completed";
|
|
2734
|
-
if (isCurrent)
|
|
2735
|
-
status = "\uD83D\uDD04 In Progress";
|
|
2736
|
-
lines.push(`- ${status} **${step.name}**`);
|
|
2702
|
+
});
|
|
2703
|
+
var AddStepContract = defineCommand3({
|
|
2704
|
+
meta: {
|
|
2705
|
+
key: "workflow.step.add",
|
|
2706
|
+
version: "1.0.0",
|
|
2707
|
+
stability: "stable",
|
|
2708
|
+
owners: [...OWNERS3],
|
|
2709
|
+
tags: ["workflow", "step", "add"],
|
|
2710
|
+
description: "Add a step to a workflow definition.",
|
|
2711
|
+
goal: "Build workflow structure step by step.",
|
|
2712
|
+
context: "Workflow designer."
|
|
2713
|
+
},
|
|
2714
|
+
io: {
|
|
2715
|
+
input: AddStepInputModel,
|
|
2716
|
+
output: WorkflowStepModel
|
|
2717
|
+
},
|
|
2718
|
+
policy: { auth: "user" },
|
|
2719
|
+
sideEffects: {
|
|
2720
|
+
emits: [
|
|
2721
|
+
{
|
|
2722
|
+
key: "workflow.step.added",
|
|
2723
|
+
version: "1.0.0",
|
|
2724
|
+
when: "Step is added",
|
|
2725
|
+
payload: WorkflowStepModel
|
|
2737
2726
|
}
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
const [loading, setLoading] = useState(true);
|
|
2762
|
-
const [error, setError] = useState(null);
|
|
2763
|
-
const fetchData = useCallback(async () => {
|
|
2764
|
-
try {
|
|
2765
|
-
setLoading(true);
|
|
2766
|
-
setError(null);
|
|
2767
|
-
const [defResult, instResult] = await Promise.all([
|
|
2768
|
-
workflow.listDefinitions({ projectId, limit: 100 }),
|
|
2769
|
-
workflow.listInstances({ projectId, limit: 100 })
|
|
2770
|
-
]);
|
|
2771
|
-
setDefinitions(defResult.definitions);
|
|
2772
|
-
setInstances(instResult.instances);
|
|
2773
|
-
} catch (err) {
|
|
2774
|
-
setError(err instanceof Error ? err : new Error("Failed to load workflows"));
|
|
2775
|
-
} finally {
|
|
2776
|
-
setLoading(false);
|
|
2777
|
-
}
|
|
2778
|
-
}, [handlers, projectId]);
|
|
2779
|
-
useEffect(() => {
|
|
2780
|
-
fetchData();
|
|
2781
|
-
}, [fetchData]);
|
|
2782
|
-
const stats = {
|
|
2783
|
-
totalDefinitions: definitions.length,
|
|
2784
|
-
activeDefinitions: definitions.filter((d) => d.status === "ACTIVE").length,
|
|
2785
|
-
totalInstances: instances.length,
|
|
2786
|
-
pendingInstances: instances.filter((i) => i.status === "PENDING").length,
|
|
2787
|
-
completedInstances: instances.filter((i) => i.status === "COMPLETED").length,
|
|
2788
|
-
rejectedInstances: instances.filter((i) => i.status === "REJECTED").length
|
|
2789
|
-
};
|
|
2790
|
-
return {
|
|
2791
|
-
definitions,
|
|
2792
|
-
instances,
|
|
2793
|
-
loading,
|
|
2794
|
-
error,
|
|
2795
|
-
stats,
|
|
2796
|
-
refetch: fetchData
|
|
2797
|
-
};
|
|
2798
|
-
}
|
|
2799
|
-
|
|
2800
|
-
// src/ui/WorkflowDashboard.tsx
|
|
2801
|
-
import { useState as useState2 } from "react";
|
|
2802
|
-
import {
|
|
2803
|
-
Button,
|
|
2804
|
-
ErrorState,
|
|
2805
|
-
LoaderBlock,
|
|
2806
|
-
StatCard,
|
|
2807
|
-
StatCardGroup
|
|
2808
|
-
} from "@contractspec/lib.design-system";
|
|
2809
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2810
|
-
"use client";
|
|
2811
|
-
var STATUS_COLORS = {
|
|
2812
|
-
ACTIVE: "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",
|
|
2813
|
-
DRAFT: "bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",
|
|
2814
|
-
ARCHIVED: "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",
|
|
2815
|
-
PENDING: "bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",
|
|
2816
|
-
IN_PROGRESS: "bg-indigo-100 text-indigo-700 dark:bg-indigo-900/30 dark:text-indigo-400",
|
|
2817
|
-
COMPLETED: "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",
|
|
2818
|
-
REJECTED: "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",
|
|
2819
|
-
CANCELLED: "bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400"
|
|
2820
|
-
};
|
|
2821
|
-
function WorkflowDashboard() {
|
|
2822
|
-
const [activeTab, setActiveTab] = useState2("definitions");
|
|
2823
|
-
const { definitions, instances, loading, error, stats, refetch } = useWorkflowList();
|
|
2824
|
-
const tabs = [
|
|
2825
|
-
{ id: "definitions", label: "Definitions", icon: "\uD83D\uDCCB" },
|
|
2826
|
-
{ id: "instances", label: "Instances", icon: "\uD83D\uDD04" }
|
|
2827
|
-
];
|
|
2828
|
-
if (loading) {
|
|
2829
|
-
return /* @__PURE__ */ jsxDEV(LoaderBlock, {
|
|
2830
|
-
label: "Loading Workflows..."
|
|
2831
|
-
}, undefined, false, undefined, this);
|
|
2727
|
+
],
|
|
2728
|
+
audit: ["workflow.step.added"]
|
|
2729
|
+
},
|
|
2730
|
+
acceptance: {
|
|
2731
|
+
scenarios: [
|
|
2732
|
+
{
|
|
2733
|
+
key: "add-step-happy-path",
|
|
2734
|
+
given: ["Workflow definition exists"],
|
|
2735
|
+
when: ["User adds a step"],
|
|
2736
|
+
then: ["Step is added", "StepAdded event is emitted"]
|
|
2737
|
+
}
|
|
2738
|
+
],
|
|
2739
|
+
examples: [
|
|
2740
|
+
{
|
|
2741
|
+
key: "add-approval-step",
|
|
2742
|
+
input: {
|
|
2743
|
+
workflowId: "def-123",
|
|
2744
|
+
stepKey: "approve-contract",
|
|
2745
|
+
type: "approval"
|
|
2746
|
+
},
|
|
2747
|
+
output: { id: "step-456", key: "approve-contract" }
|
|
2748
|
+
}
|
|
2749
|
+
]
|
|
2832
2750
|
}
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2751
|
+
});
|
|
2752
|
+
var PublishWorkflowContract = defineCommand3({
|
|
2753
|
+
meta: {
|
|
2754
|
+
key: "workflow.definition.publish",
|
|
2755
|
+
version: "1.0.0",
|
|
2756
|
+
stability: "stable",
|
|
2757
|
+
owners: [...OWNERS3],
|
|
2758
|
+
tags: ["workflow", "definition", "publish"],
|
|
2759
|
+
description: "Publish a workflow definition to make it available for use.",
|
|
2760
|
+
goal: "Activate workflow for production use.",
|
|
2761
|
+
context: "Workflow designer, deployment."
|
|
2762
|
+
},
|
|
2763
|
+
io: {
|
|
2764
|
+
input: defineSchemaModel9({
|
|
2765
|
+
name: "PublishWorkflowInput",
|
|
2766
|
+
fields: {
|
|
2767
|
+
workflowId: {
|
|
2768
|
+
type: ScalarTypeEnum9.String_unsecure(),
|
|
2769
|
+
isOptional: false
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2772
|
+
}),
|
|
2773
|
+
output: WorkflowDefinitionModel
|
|
2774
|
+
},
|
|
2775
|
+
policy: { auth: "user" },
|
|
2776
|
+
sideEffects: {
|
|
2777
|
+
emits: [
|
|
2778
|
+
{
|
|
2779
|
+
key: "workflow.definition.published",
|
|
2780
|
+
version: "1.0.0",
|
|
2781
|
+
when: "Workflow is published",
|
|
2782
|
+
payload: WorkflowDefinitionModel
|
|
2783
|
+
}
|
|
2784
|
+
],
|
|
2785
|
+
audit: ["workflow.definition.published"]
|
|
2786
|
+
},
|
|
2787
|
+
acceptance: {
|
|
2788
|
+
scenarios: [
|
|
2789
|
+
{
|
|
2790
|
+
key: "publish-workflow-happy-path",
|
|
2791
|
+
given: ["Workflow definition is valid"],
|
|
2792
|
+
when: ["User publishes workflow"],
|
|
2793
|
+
then: ["Workflow becomes active", "WorkflowPublished event is emitted"]
|
|
2794
|
+
}
|
|
2795
|
+
],
|
|
2796
|
+
examples: [
|
|
2797
|
+
{
|
|
2798
|
+
key: "publish-onboarding",
|
|
2799
|
+
input: { workflowId: "def-123" },
|
|
2800
|
+
output: { id: "def-123", status: "published" }
|
|
2801
|
+
}
|
|
2802
|
+
]
|
|
2840
2803
|
}
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
}, undefined, false, undefined, this),
|
|
2900
|
-
tab.label
|
|
2901
|
-
]
|
|
2902
|
-
}, tab.id, true, undefined, this))
|
|
2903
|
-
}, undefined, false, undefined, this),
|
|
2904
|
-
/* @__PURE__ */ jsxDEV("div", {
|
|
2905
|
-
className: "min-h-[400px]",
|
|
2906
|
-
role: "tabpanel",
|
|
2907
|
-
children: [
|
|
2908
|
-
activeTab === "definitions" && /* @__PURE__ */ jsxDEV("div", {
|
|
2909
|
-
className: "border-border rounded-lg border",
|
|
2910
|
-
children: /* @__PURE__ */ jsxDEV("table", {
|
|
2911
|
-
className: "w-full",
|
|
2912
|
-
children: [
|
|
2913
|
-
/* @__PURE__ */ jsxDEV("thead", {
|
|
2914
|
-
className: "border-border bg-muted/30 border-b",
|
|
2915
|
-
children: /* @__PURE__ */ jsxDEV("tr", {
|
|
2916
|
-
children: [
|
|
2917
|
-
/* @__PURE__ */ jsxDEV("th", {
|
|
2918
|
-
className: "px-4 py-3 text-left text-sm font-medium",
|
|
2919
|
-
children: "Name"
|
|
2920
|
-
}, undefined, false, undefined, this),
|
|
2921
|
-
/* @__PURE__ */ jsxDEV("th", {
|
|
2922
|
-
className: "px-4 py-3 text-left text-sm font-medium",
|
|
2923
|
-
children: "Type"
|
|
2924
|
-
}, undefined, false, undefined, this),
|
|
2925
|
-
/* @__PURE__ */ jsxDEV("th", {
|
|
2926
|
-
className: "px-4 py-3 text-left text-sm font-medium",
|
|
2927
|
-
children: "Status"
|
|
2928
|
-
}, undefined, false, undefined, this),
|
|
2929
|
-
/* @__PURE__ */ jsxDEV("th", {
|
|
2930
|
-
className: "px-4 py-3 text-left text-sm font-medium",
|
|
2931
|
-
children: "Created"
|
|
2932
|
-
}, undefined, false, undefined, this)
|
|
2933
|
-
]
|
|
2934
|
-
}, undefined, true, undefined, this)
|
|
2935
|
-
}, undefined, false, undefined, this),
|
|
2936
|
-
/* @__PURE__ */ jsxDEV("tbody", {
|
|
2937
|
-
className: "divide-border divide-y",
|
|
2938
|
-
children: [
|
|
2939
|
-
definitions.map((def) => /* @__PURE__ */ jsxDEV("tr", {
|
|
2940
|
-
className: "hover:bg-muted/50",
|
|
2941
|
-
children: [
|
|
2942
|
-
/* @__PURE__ */ jsxDEV("td", {
|
|
2943
|
-
className: "px-4 py-3",
|
|
2944
|
-
children: [
|
|
2945
|
-
/* @__PURE__ */ jsxDEV("div", {
|
|
2946
|
-
className: "font-medium",
|
|
2947
|
-
children: def.name
|
|
2948
|
-
}, undefined, false, undefined, this),
|
|
2949
|
-
/* @__PURE__ */ jsxDEV("div", {
|
|
2950
|
-
className: "text-muted-foreground text-sm",
|
|
2951
|
-
children: def.description
|
|
2952
|
-
}, undefined, false, undefined, this)
|
|
2953
|
-
]
|
|
2954
|
-
}, undefined, true, undefined, this),
|
|
2955
|
-
/* @__PURE__ */ jsxDEV("td", {
|
|
2956
|
-
className: "px-4 py-3 font-mono text-sm",
|
|
2957
|
-
children: def.type
|
|
2958
|
-
}, undefined, false, undefined, this),
|
|
2959
|
-
/* @__PURE__ */ jsxDEV("td", {
|
|
2960
|
-
className: "px-4 py-3",
|
|
2961
|
-
children: /* @__PURE__ */ jsxDEV("span", {
|
|
2962
|
-
className: `inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${STATUS_COLORS[def.status] ?? ""}`,
|
|
2963
|
-
children: def.status
|
|
2964
|
-
}, undefined, false, undefined, this)
|
|
2965
|
-
}, undefined, false, undefined, this),
|
|
2966
|
-
/* @__PURE__ */ jsxDEV("td", {
|
|
2967
|
-
className: "text-muted-foreground px-4 py-3 text-sm",
|
|
2968
|
-
children: def.createdAt.toLocaleDateString()
|
|
2969
|
-
}, undefined, false, undefined, this)
|
|
2970
|
-
]
|
|
2971
|
-
}, def.id, true, undefined, this)),
|
|
2972
|
-
definitions.length === 0 && /* @__PURE__ */ jsxDEV("tr", {
|
|
2973
|
-
children: /* @__PURE__ */ jsxDEV("td", {
|
|
2974
|
-
colSpan: 4,
|
|
2975
|
-
className: "text-muted-foreground px-4 py-8 text-center",
|
|
2976
|
-
children: "No workflow definitions found"
|
|
2977
|
-
}, undefined, false, undefined, this)
|
|
2978
|
-
}, undefined, false, undefined, this)
|
|
2979
|
-
]
|
|
2980
|
-
}, undefined, true, undefined, this)
|
|
2981
|
-
]
|
|
2982
|
-
}, undefined, true, undefined, this)
|
|
2983
|
-
}, undefined, false, undefined, this),
|
|
2984
|
-
activeTab === "instances" && /* @__PURE__ */ jsxDEV("div", {
|
|
2985
|
-
className: "border-border rounded-lg border",
|
|
2986
|
-
children: /* @__PURE__ */ jsxDEV("table", {
|
|
2987
|
-
className: "w-full",
|
|
2988
|
-
children: [
|
|
2989
|
-
/* @__PURE__ */ jsxDEV("thead", {
|
|
2990
|
-
className: "border-border bg-muted/30 border-b",
|
|
2991
|
-
children: /* @__PURE__ */ jsxDEV("tr", {
|
|
2992
|
-
children: [
|
|
2993
|
-
/* @__PURE__ */ jsxDEV("th", {
|
|
2994
|
-
className: "px-4 py-3 text-left text-sm font-medium",
|
|
2995
|
-
children: "Instance ID"
|
|
2996
|
-
}, undefined, false, undefined, this),
|
|
2997
|
-
/* @__PURE__ */ jsxDEV("th", {
|
|
2998
|
-
className: "px-4 py-3 text-left text-sm font-medium",
|
|
2999
|
-
children: "Status"
|
|
3000
|
-
}, undefined, false, undefined, this),
|
|
3001
|
-
/* @__PURE__ */ jsxDEV("th", {
|
|
3002
|
-
className: "px-4 py-3 text-left text-sm font-medium",
|
|
3003
|
-
children: "Requested By"
|
|
3004
|
-
}, undefined, false, undefined, this),
|
|
3005
|
-
/* @__PURE__ */ jsxDEV("th", {
|
|
3006
|
-
className: "px-4 py-3 text-left text-sm font-medium",
|
|
3007
|
-
children: "Started"
|
|
3008
|
-
}, undefined, false, undefined, this)
|
|
3009
|
-
]
|
|
3010
|
-
}, undefined, true, undefined, this)
|
|
3011
|
-
}, undefined, false, undefined, this),
|
|
3012
|
-
/* @__PURE__ */ jsxDEV("tbody", {
|
|
3013
|
-
className: "divide-border divide-y",
|
|
3014
|
-
children: [
|
|
3015
|
-
instances.map((inst) => /* @__PURE__ */ jsxDEV("tr", {
|
|
3016
|
-
className: "hover:bg-muted/50",
|
|
3017
|
-
children: [
|
|
3018
|
-
/* @__PURE__ */ jsxDEV("td", {
|
|
3019
|
-
className: "px-4 py-3 font-mono text-sm",
|
|
3020
|
-
children: inst.id
|
|
3021
|
-
}, undefined, false, undefined, this),
|
|
3022
|
-
/* @__PURE__ */ jsxDEV("td", {
|
|
3023
|
-
className: "px-4 py-3",
|
|
3024
|
-
children: /* @__PURE__ */ jsxDEV("span", {
|
|
3025
|
-
className: `inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${STATUS_COLORS[inst.status] ?? ""}`,
|
|
3026
|
-
children: inst.status
|
|
3027
|
-
}, undefined, false, undefined, this)
|
|
3028
|
-
}, undefined, false, undefined, this),
|
|
3029
|
-
/* @__PURE__ */ jsxDEV("td", {
|
|
3030
|
-
className: "px-4 py-3 text-sm",
|
|
3031
|
-
children: inst.requestedBy
|
|
3032
|
-
}, undefined, false, undefined, this),
|
|
3033
|
-
/* @__PURE__ */ jsxDEV("td", {
|
|
3034
|
-
className: "text-muted-foreground px-4 py-3 text-sm",
|
|
3035
|
-
children: inst.startedAt.toLocaleDateString()
|
|
3036
|
-
}, undefined, false, undefined, this)
|
|
3037
|
-
]
|
|
3038
|
-
}, inst.id, true, undefined, this)),
|
|
3039
|
-
instances.length === 0 && /* @__PURE__ */ jsxDEV("tr", {
|
|
3040
|
-
children: /* @__PURE__ */ jsxDEV("td", {
|
|
3041
|
-
colSpan: 4,
|
|
3042
|
-
className: "text-muted-foreground px-4 py-8 text-center",
|
|
3043
|
-
children: "No workflow instances found"
|
|
3044
|
-
}, undefined, false, undefined, this)
|
|
3045
|
-
}, undefined, false, undefined, this)
|
|
3046
|
-
]
|
|
3047
|
-
}, undefined, true, undefined, this)
|
|
3048
|
-
]
|
|
3049
|
-
}, undefined, true, undefined, this)
|
|
3050
|
-
}, undefined, false, undefined, this)
|
|
3051
|
-
]
|
|
3052
|
-
}, undefined, true, undefined, this)
|
|
2804
|
+
});
|
|
2805
|
+
var ListWorkflowsContract = defineQuery3({
|
|
2806
|
+
meta: {
|
|
2807
|
+
key: "workflow.definition.list",
|
|
2808
|
+
version: "1.0.0",
|
|
2809
|
+
stability: "stable",
|
|
2810
|
+
owners: [...OWNERS3],
|
|
2811
|
+
tags: ["workflow", "definition", "list"],
|
|
2812
|
+
description: "List workflow definitions with filtering.",
|
|
2813
|
+
goal: "Browse and search available workflows.",
|
|
2814
|
+
context: "Workflow list, search."
|
|
2815
|
+
},
|
|
2816
|
+
io: {
|
|
2817
|
+
input: defineSchemaModel9({
|
|
2818
|
+
name: "ListWorkflowsInput",
|
|
2819
|
+
fields: {
|
|
2820
|
+
status: { type: WorkflowStatusEnum, isOptional: true },
|
|
2821
|
+
search: { type: ScalarTypeEnum9.String_unsecure(), isOptional: true },
|
|
2822
|
+
limit: {
|
|
2823
|
+
type: ScalarTypeEnum9.Int_unsecure(),
|
|
2824
|
+
isOptional: true,
|
|
2825
|
+
defaultValue: 20
|
|
2826
|
+
},
|
|
2827
|
+
offset: {
|
|
2828
|
+
type: ScalarTypeEnum9.Int_unsecure(),
|
|
2829
|
+
isOptional: true,
|
|
2830
|
+
defaultValue: 0
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
}),
|
|
2834
|
+
output: defineSchemaModel9({
|
|
2835
|
+
name: "ListWorkflowsOutput",
|
|
2836
|
+
fields: {
|
|
2837
|
+
workflows: {
|
|
2838
|
+
type: WorkflowDefinitionModel,
|
|
2839
|
+
isArray: true,
|
|
2840
|
+
isOptional: false
|
|
2841
|
+
},
|
|
2842
|
+
total: { type: ScalarTypeEnum9.Int_unsecure(), isOptional: false }
|
|
2843
|
+
}
|
|
2844
|
+
})
|
|
2845
|
+
},
|
|
2846
|
+
policy: { auth: "user" },
|
|
2847
|
+
acceptance: {
|
|
2848
|
+
scenarios: [
|
|
2849
|
+
{
|
|
2850
|
+
key: "list-workflows-happy-path",
|
|
2851
|
+
given: ["Workflow definitions exist"],
|
|
2852
|
+
when: ["User lists workflows"],
|
|
2853
|
+
then: ["List of workflows is returned"]
|
|
2854
|
+
}
|
|
2855
|
+
],
|
|
2856
|
+
examples: [
|
|
2857
|
+
{
|
|
2858
|
+
key: "list-all",
|
|
2859
|
+
input: { limit: 10 },
|
|
2860
|
+
output: { workflows: [], total: 5 }
|
|
2861
|
+
}
|
|
3053
2862
|
]
|
|
3054
|
-
}
|
|
3055
|
-
}
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
2863
|
+
}
|
|
2864
|
+
});
|
|
2865
|
+
var GetWorkflowContract = defineQuery3({
|
|
2866
|
+
meta: {
|
|
2867
|
+
key: "workflow.definition.get",
|
|
2868
|
+
version: "1.0.0",
|
|
2869
|
+
stability: "stable",
|
|
2870
|
+
owners: [...OWNERS3],
|
|
2871
|
+
tags: ["workflow", "definition", "get"],
|
|
2872
|
+
description: "Get a workflow definition with all steps.",
|
|
2873
|
+
goal: "View workflow details.",
|
|
2874
|
+
context: "Workflow designer, detail view."
|
|
2875
|
+
},
|
|
2876
|
+
io: {
|
|
2877
|
+
input: defineSchemaModel9({
|
|
2878
|
+
name: "GetWorkflowInput",
|
|
2879
|
+
fields: {
|
|
2880
|
+
workflowId: {
|
|
2881
|
+
type: ScalarTypeEnum9.String_unsecure(),
|
|
2882
|
+
isOptional: false
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
}),
|
|
2886
|
+
output: WorkflowDefinitionModel
|
|
2887
|
+
},
|
|
2888
|
+
policy: { auth: "user" },
|
|
2889
|
+
acceptance: {
|
|
2890
|
+
scenarios: [
|
|
2891
|
+
{
|
|
2892
|
+
key: "get-workflow-happy-path",
|
|
2893
|
+
given: ["Workflow definition exists"],
|
|
2894
|
+
when: ["User requests workflow details"],
|
|
2895
|
+
then: ["Workflow details are returned"]
|
|
2896
|
+
}
|
|
2897
|
+
],
|
|
2898
|
+
examples: [
|
|
2899
|
+
{
|
|
2900
|
+
key: "get-details",
|
|
2901
|
+
input: { workflowId: "def-123" },
|
|
2902
|
+
output: { id: "def-123", name: "Employee Onboarding" }
|
|
2903
|
+
}
|
|
2904
|
+
]
|
|
2905
|
+
}
|
|
2906
|
+
});
|
|
2907
|
+
// src/workflow-system.feature.ts
|
|
2908
|
+
import { defineFeature } from "@contractspec/lib.contracts-spec";
|
|
2909
|
+
var WorkflowSystemFeature = defineFeature({
|
|
2910
|
+
meta: {
|
|
2911
|
+
key: "workflow-system",
|
|
2912
|
+
title: "Workflow & Approval System",
|
|
2913
|
+
description: "State machine-based workflow engine with role-based approvals, delegation, and escalation",
|
|
2914
|
+
domain: "workflow",
|
|
2915
|
+
owners: ["@workflow-team"],
|
|
2916
|
+
tags: ["workflow", "approval", "state-machine", "automation"],
|
|
2917
|
+
stability: "experimental",
|
|
2918
|
+
version: "1.0.0"
|
|
2919
|
+
},
|
|
2920
|
+
operations: [
|
|
2921
|
+
{ key: "workflow.definition.create", version: "1.0.0" },
|
|
2922
|
+
{ key: "workflow.definition.update", version: "1.0.0" },
|
|
2923
|
+
{ key: "workflow.step.add", version: "1.0.0" },
|
|
2924
|
+
{ key: "workflow.definition.publish", version: "1.0.0" },
|
|
2925
|
+
{ key: "workflow.definition.list", version: "1.0.0" },
|
|
2926
|
+
{ key: "workflow.definition.get", version: "1.0.0" },
|
|
2927
|
+
{ key: "workflow.instance.start", version: "1.0.0" },
|
|
2928
|
+
{ key: "workflow.instance.transition", version: "1.0.0" },
|
|
2929
|
+
{ key: "workflow.instance.pause", version: "1.0.0" },
|
|
2930
|
+
{ key: "workflow.instance.resume", version: "1.0.0" },
|
|
2931
|
+
{ key: "workflow.instance.cancel", version: "1.0.0" },
|
|
2932
|
+
{ key: "workflow.instance.list", version: "1.0.0" },
|
|
2933
|
+
{ key: "workflow.instance.get", version: "1.0.0" },
|
|
2934
|
+
{ key: "workflow.approval.decide", version: "1.0.0" },
|
|
2935
|
+
{ key: "workflow.approval.delegate", version: "1.0.0" },
|
|
2936
|
+
{ key: "workflow.approval.comment.add", version: "1.0.0" },
|
|
2937
|
+
{ key: "workflow.approval.list.mine", version: "1.0.0" },
|
|
2938
|
+
{ key: "workflow.approval.get", version: "1.0.0" }
|
|
2939
|
+
],
|
|
2940
|
+
events: [
|
|
2941
|
+
{ key: "workflow.definition.created", version: "1.0.0" },
|
|
2942
|
+
{ key: "workflow.definition.updated", version: "1.0.0" },
|
|
2943
|
+
{ key: "workflow.definition.published", version: "1.0.0" },
|
|
2944
|
+
{ key: "workflow.step.added", version: "1.0.0" },
|
|
2945
|
+
{ key: "workflow.instance.started", version: "1.0.0" },
|
|
2946
|
+
{ key: "workflow.step.entered", version: "1.0.0" },
|
|
2947
|
+
{ key: "workflow.step.exited", version: "1.0.0" },
|
|
2948
|
+
{ key: "workflow.instance.completed", version: "1.0.0" },
|
|
2949
|
+
{ key: "workflow.instance.cancelled", version: "1.0.0" },
|
|
2950
|
+
{ key: "workflow.instance.paused", version: "1.0.0" },
|
|
2951
|
+
{ key: "workflow.instance.resumed", version: "1.0.0" },
|
|
2952
|
+
{ key: "workflow.instance.failed", version: "1.0.0" },
|
|
2953
|
+
{ key: "workflow.instance.timedOut", version: "1.0.0" },
|
|
2954
|
+
{ key: "workflow.approval.requested", version: "1.0.0" },
|
|
2955
|
+
{ key: "workflow.approval.decided", version: "1.0.0" },
|
|
2956
|
+
{ key: "workflow.approval.delegated", version: "1.0.0" },
|
|
2957
|
+
{ key: "workflow.approval.escalated", version: "1.0.0" }
|
|
2958
|
+
],
|
|
2959
|
+
presentations: [
|
|
2960
|
+
{ key: "workflow.designer", version: "1.0.0" },
|
|
2961
|
+
{ key: "workflow.definition.viewList", version: "1.0.0" },
|
|
2962
|
+
{ key: "workflow.definition.detail", version: "1.0.0" },
|
|
2963
|
+
{ key: "workflow.instance.viewList", version: "1.0.0" },
|
|
2964
|
+
{ key: "workflow.instance.detail", version: "1.0.0" },
|
|
2965
|
+
{ key: "workflow.instance.progress", version: "1.0.0" },
|
|
2966
|
+
{ key: "workflow.approval.inbox", version: "1.0.0" },
|
|
2967
|
+
{ key: "workflow.approval.detail", version: "1.0.0" },
|
|
2968
|
+
{ key: "workflow.approval.form", version: "1.0.0" },
|
|
2969
|
+
{ key: "workflow.approval.badge", version: "1.0.0" },
|
|
2970
|
+
{ key: "workflow.metrics", version: "1.0.0" }
|
|
2971
|
+
],
|
|
2972
|
+
opToPresentation: [
|
|
2973
|
+
{
|
|
2974
|
+
op: { key: "workflow.definition.list", version: "1.0.0" },
|
|
2975
|
+
pres: { key: "workflow.definition.viewList", version: "1.0.0" }
|
|
2976
|
+
},
|
|
2977
|
+
{
|
|
2978
|
+
op: { key: "workflow.instance.list", version: "1.0.0" },
|
|
2979
|
+
pres: { key: "workflow.instance.viewList", version: "1.0.0" }
|
|
2980
|
+
},
|
|
2981
|
+
{
|
|
2982
|
+
op: { key: "workflow.approval.list.mine", version: "1.0.0" },
|
|
2983
|
+
pres: { key: "workflow.approval.inbox", version: "1.0.0" }
|
|
2984
|
+
},
|
|
2985
|
+
{
|
|
2986
|
+
op: { key: "workflow.approval.decide", version: "1.0.0" },
|
|
2987
|
+
pres: { key: "workflow.approval.form", version: "1.0.0" }
|
|
2988
|
+
}
|
|
2989
|
+
],
|
|
2990
|
+
presentationsTargets: [
|
|
2991
|
+
{ key: "workflow.designer", version: "1.0.0", targets: ["react"] },
|
|
2992
|
+
{
|
|
2993
|
+
key: "workflow.definition.viewList",
|
|
2994
|
+
version: "1.0.0",
|
|
2995
|
+
targets: ["react", "markdown"]
|
|
2996
|
+
},
|
|
2997
|
+
{
|
|
2998
|
+
key: "workflow.definition.detail",
|
|
2999
|
+
version: "1.0.0",
|
|
3000
|
+
targets: ["react", "markdown"]
|
|
3001
|
+
},
|
|
3002
|
+
{
|
|
3003
|
+
key: "workflow.instance.viewList",
|
|
3004
|
+
version: "1.0.0",
|
|
3005
|
+
targets: ["react", "markdown"]
|
|
3006
|
+
},
|
|
3007
|
+
{
|
|
3008
|
+
key: "workflow.instance.detail",
|
|
3009
|
+
version: "1.0.0",
|
|
3010
|
+
targets: ["react", "markdown"]
|
|
3011
|
+
},
|
|
3012
|
+
{ key: "workflow.instance.progress", version: "1.0.0", targets: ["react"] },
|
|
3013
|
+
{
|
|
3014
|
+
key: "workflow.approval.inbox",
|
|
3015
|
+
version: "1.0.0",
|
|
3016
|
+
targets: ["react", "markdown"]
|
|
3017
|
+
},
|
|
3018
|
+
{
|
|
3019
|
+
key: "workflow.approval.detail",
|
|
3020
|
+
version: "1.0.0",
|
|
3021
|
+
targets: ["react", "markdown"]
|
|
3022
|
+
},
|
|
3023
|
+
{
|
|
3024
|
+
key: "workflow.metrics",
|
|
3025
|
+
version: "1.0.0",
|
|
3026
|
+
targets: ["react", "markdown"]
|
|
3027
|
+
}
|
|
3028
|
+
],
|
|
3029
|
+
capabilities: {
|
|
3030
|
+
requires: [
|
|
3031
|
+
{ key: "identity", version: "1.0.0" },
|
|
3032
|
+
{ key: "audit-trail", version: "1.0.0" },
|
|
3033
|
+
{ key: "notifications", version: "1.0.0" },
|
|
3034
|
+
{ key: "feature-flags", version: "1.0.0" }
|
|
3035
|
+
],
|
|
3036
|
+
provides: [
|
|
3037
|
+
{ key: "workflow", version: "1.0.0" },
|
|
3038
|
+
{ key: "approval", version: "1.0.0" },
|
|
3039
|
+
{ key: "state-machine", version: "1.0.0" }
|
|
3040
|
+
]
|
|
3041
|
+
},
|
|
3042
|
+
workflows: [
|
|
3043
|
+
{ key: "workflow-system.workflow.approval-chain", version: "1.0.0" }
|
|
3044
|
+
],
|
|
3045
|
+
telemetry: [{ key: "workflow-system.telemetry", version: "1.0.0" }],
|
|
3046
|
+
jobs: [
|
|
3047
|
+
{ key: "workflow-system.job.instance-timeout", version: "1.0.0" },
|
|
3048
|
+
{ key: "workflow-system.job.escalation", version: "1.0.0" }
|
|
3049
|
+
],
|
|
3050
|
+
docs: [
|
|
3051
|
+
"docs.examples.workflow-system",
|
|
3052
|
+
"docs.examples.workflow-system.goal",
|
|
3053
|
+
"docs.examples.workflow-system.usage",
|
|
3054
|
+
"docs.examples.workflow-system.constraints"
|
|
3055
|
+
]
|
|
3056
|
+
});
|
|
3059
3057
|
export {
|
|
3060
3058
|
workflowInstanceDetailMarkdownRenderer,
|
|
3061
3059
|
workflowDefinitionListMarkdownRenderer,
|