Skip to content

Commit c3cb15e

Browse files
committed
create-issue updates
1 parent b1cf281 commit c3cb15e

File tree

3 files changed

+63
-35
lines changed

3 files changed

+63
-35
lines changed

components/jira/actions/create-issue/create-issue.mjs

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import constants from "../../common/constants.mjs";
22
import utils from "../../common/utils.mjs";
33
import common from "../common/issue.mjs";
4+
import { ConfigurationError } from "@pipedream/platform";
45

56
export default {
67
...common,
78
key: "jira-create-issue",
89
name: "Create Issue",
9-
description: "Creates an issue or, where the option to create subtasks is enabled in Jira, a subtask. [See the documentation](https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-issue-post)",
10-
version: "0.1.25",
10+
description: "Creates an issue or, where the option to create subtasks is enabled in Jira, a subtask. [See the documentation](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post)",
11+
version: "0.1.26",
1112
annotations: {
1213
destructiveHint: false,
1314
openWorldHint: true,
@@ -45,39 +46,50 @@ export default {
4546
],
4647
},
4748
},
48-
async additionalProps() {
49+
async additionalProps(existingProps) {
4950
const {
5051
cloudId,
5152
projectId,
5253
issueTypeId,
5354
} = this;
5455

55-
const {
56-
projects: [
57-
{
58-
issuetypes: [
59-
{ fields = {} } = {},
60-
],
56+
if (isNaN(projectId) || !cloudId || !isNaN(issueTypeId)) {
57+
existingProps.additionalProperties.optional = false;
58+
return {};
59+
}
60+
61+
try {
62+
const {
63+
projects: [
64+
{
65+
issuetypes: [
66+
{ fields = {} } = {},
67+
],
68+
},
69+
],
70+
} = await this.app.getCreateIssueMetadata({
71+
cloudId,
72+
params: {
73+
projectIds: projectId,
74+
issuetypeIds: issueTypeId,
75+
expand: "projects.issuetypes.fields",
6176
},
62-
],
63-
} = await this.app.getCreateIssueMetadata({
64-
cloudId,
65-
params: {
66-
projectIds: projectId,
67-
issuetypeIds: issueTypeId,
68-
expand: "projects.issuetypes.fields",
69-
},
70-
});
77+
});
7178

72-
const keys = [
73-
constants.FIELD_KEY.ISSUETYPE,
74-
constants.FIELD_KEY.PROJECT,
75-
];
79+
const keys = [
80+
constants.FIELD_KEY.ISSUETYPE,
81+
constants.FIELD_KEY.PROJECT,
82+
];
7683

77-
return this.getDynamicFields({
78-
fields,
79-
predicate: ({ key }) => !keys.includes(key),
80-
});
84+
existingProps.additionalProperties.optional = true;
85+
return this.getDynamicFields({
86+
fields,
87+
predicate: ({ key }) => !keys.includes(key),
88+
});
89+
} catch {
90+
existingProps.additionalProperties.optional = false;
91+
return {};
92+
}
8193
},
8294
async run({ $ }) {
8395
const {
@@ -94,6 +106,12 @@ export default {
94106
...dynamicFields
95107
} = this;
96108

109+
if ((!dynamicFields || Object.keys(dynamicFields).length === 0)
110+
&& (!additionalProperties || Object.keys(additionalProperties).length === 0)
111+
) {
112+
throw new ConfigurationError("Please provide at least one additional property");
113+
}
114+
97115
const fields = utils.reduceProperties({
98116
initialProps: {
99117
project: {

components/jira/jira.app.mjs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default {
1010
cloudId: {
1111
type: "string",
1212
label: "Cloud ID",
13-
description: "The cloud ID.",
13+
description: "The cloud ID",
1414
useQuery: true,
1515
async options() {
1616
const clouds = await this.getClouds();
@@ -24,7 +24,7 @@ export default {
2424
projectID: {
2525
type: "string",
2626
label: "Project ID",
27-
description: "The project ID.",
27+
description: "The project ID",
2828
useQuery: true,
2929
async options({
3030
prevContext, query, cloudId,
@@ -60,12 +60,16 @@ export default {
6060
async options({
6161
cloudId, projectId,
6262
}) {
63-
const issueTypes = await this.getProjectIssueTypes({
64-
cloudId,
65-
params: {
66-
projectId,
67-
},
68-
});
63+
const issueTypes = isNaN(projectId)
64+
? await this.getUserIssueTypes({
65+
cloudId,
66+
})
67+
: await this.getProjectIssueTypes({
68+
cloudId,
69+
params: {
70+
projectId,
71+
},
72+
});
6973
return issueTypes.map(({
7074
name: label, id: value,
7175
}) => ({
@@ -597,6 +601,12 @@ export default {
597601
...args,
598602
});
599603
},
604+
getUserIssueTypes(args = {}) {
605+
return this._makeRequest({
606+
path: "/issuetype",
607+
...args,
608+
});
609+
},
600610
getWebhook(args = {}) {
601611
return this._makeRequest({
602612
path: "/webhook",

components/jira/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/jira",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"description": "Pipedream Jira Components",
55
"main": "jira.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)