Skip to content

Commit 5fde0bd

Browse files
committed
fix jira type checks
1 parent 9e22d4a commit 5fde0bd

File tree

1 file changed

+46
-61
lines changed

1 file changed

+46
-61
lines changed

apps/sim/blocks/blocks/jira.ts

Lines changed: 46 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export const JiraBlock: BlockConfig<JiraResponse> = {
106106
placeholder: 'Select Jira project',
107107
dependsOn: ['credential', 'domain'],
108108
mode: 'basic',
109+
required: { field: 'operation', value: ['write', 'update', 'read-bulk'] },
109110
},
110111
// Manual project ID input (advanced mode)
111112
{
@@ -116,6 +117,7 @@ export const JiraBlock: BlockConfig<JiraResponse> = {
116117
placeholder: 'Enter Jira project ID',
117118
dependsOn: ['credential', 'domain'],
118119
mode: 'advanced',
120+
required: { field: 'operation', value: ['write', 'update', 'read-bulk'] },
119121
},
120122
// Issue selector (basic mode)
121123
{
@@ -148,6 +150,28 @@ export const JiraBlock: BlockConfig<JiraResponse> = {
148150
'remove_watcher',
149151
],
150152
},
153+
required: {
154+
field: 'operation',
155+
value: [
156+
'read',
157+
'update',
158+
'delete',
159+
'assign',
160+
'transition',
161+
'add_comment',
162+
'get_comments',
163+
'update_comment',
164+
'delete_comment',
165+
'get_attachments',
166+
'add_attachment',
167+
'add_worklog',
168+
'get_worklogs',
169+
'update_worklog',
170+
'delete_worklog',
171+
'add_watcher',
172+
'remove_watcher',
173+
],
174+
},
151175
mode: 'basic',
152176
},
153177
// Manual issue key input (advanced mode)
@@ -180,6 +204,28 @@ export const JiraBlock: BlockConfig<JiraResponse> = {
180204
'remove_watcher',
181205
],
182206
},
207+
required: {
208+
field: 'operation',
209+
value: [
210+
'read',
211+
'update',
212+
'delete',
213+
'assign',
214+
'transition',
215+
'add_comment',
216+
'get_comments',
217+
'update_comment',
218+
'delete_comment',
219+
'get_attachments',
220+
'add_attachment',
221+
'add_worklog',
222+
'get_worklogs',
223+
'update_worklog',
224+
'delete_worklog',
225+
'add_watcher',
226+
'remove_watcher',
227+
],
228+
},
183229
mode: 'advanced',
184230
},
185231
{
@@ -690,11 +736,6 @@ Return ONLY the comment text - no explanations.`,
690736

691737
switch (params.operation) {
692738
case 'write': {
693-
if (!effectiveProjectId) {
694-
throw new Error(
695-
'Project ID is required. Please select a project or enter a project ID manually.'
696-
)
697-
}
698739
// Parse comma-separated strings into arrays
699740
const parseCommaSeparated = (value: string | undefined): string[] | undefined => {
700741
if (!value || value.trim() === '') return undefined
@@ -727,16 +768,6 @@ Return ONLY the comment text - no explanations.`,
727768
}
728769
}
729770
case 'update': {
730-
if (!effectiveProjectId) {
731-
throw new Error(
732-
'Project ID is required. Please select a project or enter a project ID manually.'
733-
)
734-
}
735-
if (!effectiveIssueKey) {
736-
throw new Error(
737-
'Issue Key is required. Please select an issue or enter an issue key manually.'
738-
)
739-
}
740771
const updateParams = {
741772
projectId: effectiveProjectId,
742773
issueKey: effectiveIssueKey,
@@ -749,11 +780,6 @@ Return ONLY the comment text - no explanations.`,
749780
}
750781
}
751782
case 'read': {
752-
if (!effectiveIssueKey) {
753-
throw new Error(
754-
'Select a project to read issues, or provide an issue key to read a single issue.'
755-
)
756-
}
757783
return {
758784
...baseParams,
759785
issueKey: effectiveIssueKey,
@@ -762,40 +788,26 @@ Return ONLY the comment text - no explanations.`,
762788
}
763789
}
764790
case 'read-bulk': {
765-
if (!effectiveProjectId) {
766-
throw new Error(
767-
'Project ID is required. Please select a project or enter a project ID manually.'
768-
)
769-
}
770791
return {
771792
...baseParams,
772793
projectId: effectiveProjectId.trim(),
773794
}
774795
}
775796
case 'delete': {
776-
if (!effectiveIssueKey) {
777-
throw new Error('Issue Key is required to delete an issue.')
778-
}
779797
return {
780798
...baseParams,
781799
issueKey: effectiveIssueKey,
782800
deleteSubtasks: params.deleteSubtasks === 'true',
783801
}
784802
}
785803
case 'assign': {
786-
if (!effectiveIssueKey) {
787-
throw new Error('Issue Key is required to assign an issue.')
788-
}
789804
return {
790805
...baseParams,
791806
issueKey: effectiveIssueKey,
792807
accountId: params.accountId,
793808
}
794809
}
795810
case 'transition': {
796-
if (!effectiveIssueKey) {
797-
throw new Error('Issue Key is required to transition an issue.')
798-
}
799811
return {
800812
...baseParams,
801813
issueKey: effectiveIssueKey,
@@ -811,29 +823,20 @@ Return ONLY the comment text - no explanations.`,
811823
}
812824
}
813825
case 'add_comment': {
814-
if (!effectiveIssueKey) {
815-
throw new Error('Issue Key is required to add a comment.')
816-
}
817826
return {
818827
...baseParams,
819828
issueKey: effectiveIssueKey,
820829
body: params.commentBody,
821830
}
822831
}
823832
case 'get_comments': {
824-
if (!effectiveIssueKey) {
825-
throw new Error('Issue Key is required to get comments.')
826-
}
827833
return {
828834
...baseParams,
829835
issueKey: effectiveIssueKey,
830836
maxResults: params.maxResults ? Number.parseInt(params.maxResults) : undefined,
831837
}
832838
}
833839
case 'update_comment': {
834-
if (!effectiveIssueKey) {
835-
throw new Error('Issue Key is required to update a comment.')
836-
}
837840
return {
838841
...baseParams,
839842
issueKey: effectiveIssueKey,
@@ -842,19 +845,13 @@ Return ONLY the comment text - no explanations.`,
842845
}
843846
}
844847
case 'delete_comment': {
845-
if (!effectiveIssueKey) {
846-
throw new Error('Issue Key is required to delete a comment.')
847-
}
848848
return {
849849
...baseParams,
850850
issueKey: effectiveIssueKey,
851851
commentId: params.commentId,
852852
}
853853
}
854854
case 'get_attachments': {
855-
if (!effectiveIssueKey) {
856-
throw new Error('Issue Key is required to get attachments.')
857-
}
858855
return {
859856
...baseParams,
860857
issueKey: effectiveIssueKey,
@@ -905,9 +902,6 @@ Return ONLY the comment text - no explanations.`,
905902
}
906903
}
907904
case 'update_worklog': {
908-
if (!effectiveIssueKey) {
909-
throw new Error('Issue Key is required to update a worklog.')
910-
}
911905
return {
912906
...baseParams,
913907
issueKey: effectiveIssueKey,
@@ -920,9 +914,6 @@ Return ONLY the comment text - no explanations.`,
920914
}
921915
}
922916
case 'delete_worklog': {
923-
if (!effectiveIssueKey) {
924-
throw new Error('Issue Key is required to delete a worklog.')
925-
}
926917
return {
927918
...baseParams,
928919
issueKey: effectiveIssueKey,
@@ -945,19 +936,13 @@ Return ONLY the comment text - no explanations.`,
945936
}
946937
}
947938
case 'add_watcher': {
948-
if (!effectiveIssueKey) {
949-
throw new Error('Issue Key is required to add a watcher.')
950-
}
951939
return {
952940
...baseParams,
953941
issueKey: effectiveIssueKey,
954942
accountId: params.accountId,
955943
}
956944
}
957945
case 'remove_watcher': {
958-
if (!effectiveIssueKey) {
959-
throw new Error('Issue Key is required to remove a watcher.')
960-
}
961946
return {
962947
...baseParams,
963948
issueKey: effectiveIssueKey,

0 commit comments

Comments
 (0)