Skip to content

Commit 76d24db

Browse files
authored
Shortcut - new source (#19128)
* new-event-received source * pnpm-lock.yaml * update * updates
1 parent 5fb72ed commit 76d24db

File tree

8 files changed

+404
-77
lines changed

8 files changed

+404
-77
lines changed

components/shortcut/actions/create-story/create-story.mjs

Lines changed: 53 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
key: "shortcut-create-story",
99
name: "Create Story",
1010
description: "Creates a new story in your Shortcut account. See [Create Story](https://shortcut.com/api/rest/v3#Create-Story) in Shortcut Rest API, V3 reference for endpoint documentation.",
11-
version: "1.0.1",
11+
version: "1.0.2",
1212
annotations: {
1313
destructiveHint: false,
1414
openWorldHint: true,
@@ -18,83 +18,59 @@ export default {
1818
props: {
1919
shortcut,
2020
workflowStateId: {
21-
type: "integer",
22-
label: "Workflow State Id",
23-
description: "The ID of the workflow state the story will be in.",
24-
async options() {
25-
let options = [];
26-
const workflows = await this.shortcut.callWithRetry("listWorkflows");
27-
const isWorkflowDataAvailable = lodash.get(workflows, [
28-
"data",
29-
"length",
30-
]);
31-
if (!isWorkflowDataAvailable) {
32-
return options;
33-
}
34-
return workflows.data.reduce(function (options, workflow) {
35-
const hasState = lodash.get(workflow, [
36-
"states",
37-
"length",
38-
]);
39-
if (!hasState) {
40-
return options;
41-
}
42-
const optionsToAdd = workflow.states.map((state) => ({
43-
label: `${state.name} (${workflow.name})`,
44-
value: state.id,
45-
}));
46-
return options.concat(optionsToAdd);
47-
}, []);
48-
},
21+
propDefinition: [
22+
shortcut,
23+
"workflowStateId",
24+
],
4925
},
5026
name: {
5127
type: "string",
5228
label: "Name",
53-
description: "The name of the story.",
29+
description: "The name of the story",
5430
},
5531
archived: {
5632
type: "boolean",
5733
label: "Archived",
58-
description: "Controls the story's archived state.",
34+
description: "Controls the story's archived state",
5935
optional: true,
6036
},
6137
comment: {
62-
type: "object",
38+
type: "string",
6339
label: "Comment",
6440
description:
65-
"A comment object attached to the story must have the following structure: `author_id` which is the member ID of the Comment's author (defaults to the user identified by the API token), `created_at` which defaults to the time/date the comment is created, but can be set to reflect another date, `external_id` field that can be set to another unique ID. In the case that the comment has been imported from another tool, the ID in the other tool can be indicated here, `text` is the comment text, and `updated_at` which defaults to the time/date the comment is last updated in Shortcut but can be set to reflect another time/date. See [CreateStoryCommentParams](https://shortcut.com/api/rest/v3#CreateStoryCommentParams) for more info.",
41+
"A comment to attach to the story",
6642
optional: true,
6743
},
6844
completedAtOverride: {
6945
type: "string",
7046
label: "Completed at Override Date",
7147
description:
72-
"A manual override for the time/date the Story was completed.",
48+
"A manual override for the time/date the Story was completed",
7349
optional: true,
7450
},
7551
createdAt: {
7652
type: "string",
7753
label: "Created at Date",
78-
description: "The time/date the Story was created.",
54+
description: "The time/date the Story was created",
7955
optional: true,
8056
},
8157
dueDate: {
8258
type: "string",
8359
label: "Due Date",
84-
description: "The due date of the story.",
60+
description: "The due date of the story",
8561
optional: true,
8662
},
8763
description: {
8864
type: "string",
8965
label: "Description",
90-
description: "The description of the story.",
66+
description: "The description of the story",
9167
default: "",
9268
optional: true,
9369
},
9470
epicId: {
9571
type: "integer",
9672
label: "Epic ID",
97-
description: "The unique identifier of the epic the story belongs to.",
73+
description: "The unique identifier of the epic the story belongs to",
9874
async options() {
9975
let options = [];
10076
const epics = await this.shortcut.callWithRetry("listEpics");
@@ -117,26 +93,26 @@ export default {
11793
type: "integer",
11894
label: "Estimate",
11995
description:
120-
"The numeric point estimate of the story. Can also be null, which means unestimated.",
96+
"The numeric point estimate of the story. Can also be null, which means unestimated",
12197
optional: true,
12298
},
12399
externalId: {
124100
type: "string",
125-
label: "External Id",
101+
label: "External ID",
126102
description:
127103
"This field can be set to another unique ID. In the case that the Story has been imported from another tool, the ID in the other tool can be indicated here.",
128104
optional: true,
129105
},
130106
externalLinks: {
131107
type: "string[]",
132108
label: "External Links",
133-
description: "A string array of External Links associated with this story.",
109+
description: "A string array of External Links associated with this story",
134110
optional: true,
135111
},
136112
fileIds: {
137113
type: "integer[]",
138-
label: "File Ids",
139-
description: "An array of IDs of files attached to the story.",
114+
label: "File IDs",
115+
description: "An array of IDs of files attached to the story",
140116
async options() {
141117
let options = [];
142118
const files = await this.shortcut.callWithRetry("listFiles");
@@ -157,17 +133,17 @@ export default {
157133
},
158134
followerIds: {
159135
type: "string[]",
160-
label: "Follower Ids",
161-
description: "A string array of UUIDs of the followers of this story.",
136+
label: "Follower IDs",
137+
description: "A string array of UUIDs of the followers of this story",
162138
async options() {
163139
return await this.shortcut.listMembersAsOptions();
164140
},
165141
optional: true,
166142
},
167143
iterationId: {
168144
type: "integer",
169-
label: "Iteration Id",
170-
description: "The ID of the iteration the story belongs to.",
145+
label: "Iteration ID",
146+
description: "The ID of the iteration the story belongs to",
171147
async options() {
172148
let options = [];
173149
const iterations = await this.shortcut.callWithRetry("listIterations");
@@ -195,7 +171,7 @@ export default {
195171
},
196172
linkedFileIds: {
197173
type: "integer[]",
198-
label: "Linked File Ids",
174+
label: "Linked File IDs",
199175
description:
200176
"An array of IDs of linked files attached to the story.",
201177
async options() {
@@ -218,8 +194,8 @@ export default {
218194
},
219195
ownerIds: {
220196
type: "string[]",
221-
label: "Owner Ids",
222-
description: "A string array of UUIDs of the owners of this story.",
197+
label: "Owner IDs",
198+
description: "A string array of UUIDs of the owners of this story",
223199
async options() {
224200
return await this.shortcut.listMembersAsOptions();
225201
},
@@ -228,7 +204,7 @@ export default {
228204
requestedById: {
229205
type: "string",
230206
label: "Requested by ID",
231-
description: "The ID of the member that requested the story.",
207+
description: "The ID of the member that requested the story",
232208
async options() {
233209
return await this.shortcut.listMembersAsOptions();
234210
},
@@ -237,39 +213,37 @@ export default {
237213
startedAtOverride: {
238214
type: "string",
239215
label: "Started at Override Date",
240-
description: "A manual override for the time/date the Story was started.",
216+
description: "A manual override for the time/date the Story was started",
241217
optional: true,
242218
},
243-
storyLink: {
244-
type: "object",
245-
label: "Story Link",
246-
description:
247-
"An story link object attached to the story must have the following structure: `object_id` is the unique ID of the story defined as object, `subject_id` is the unique ID of the story defined as subject, and `verb` which indicates how the subject story acts on the object story, valid values are `blocks`, `duplicates`, or `relates to`. See [CreateStoryLinkParams](https://shortcut.com/api/rest/v3#CreateStoryLinkParams) for more info.",
248-
optional: true,
219+
storyIds: {
220+
propDefinition: [
221+
shortcut,
222+
"storyIds",
223+
],
249224
},
250225
storyType: {
251226
type: "string",
252227
label: "Story Type",
253-
description: "The type of story (feature, bug, chore).",
228+
description: "The type of story (feature, bug, chore)",
254229
options: constants.STORY_TYPES,
255230
default: "feature",
256231
optional: true,
257232
},
258-
task: {
259-
type: "object",
260-
label: "Task",
261-
description:
262-
"A task object attached to the story must have the following structure: `complete` which is a boolean, indicating whether the task is completed (defaults to `false`), `created_at` which defaults to the time/date the task is created but can be set to reflect another creation time/date, `description` as a description for the task, `external_id` a field can be set to another unique ID. In the case that the task has been imported from another tool, the ID in the other tool can be indicated here, `owner_ids` as an array of UUIDs for any members you want to add as owners on this new task, `updated_at` which defaults to the time/date the task was last updated in Shortcut but can be set to reflect another time/date. See [CreateTaskParams](https://shortcut.com/api/rest/v3#CreateTaskParams) for more info.",
233+
tasks: {
234+
type: "string[]",
235+
label: "Tasks",
236+
description: "An array of task descriptions to add to the story",
263237
optional: true,
264238
},
265239
updatedAt: {
266240
type: "string",
267241
label: "Updated at Date",
268-
description: "The time/date the story was updated.",
242+
description: "The time/date the story was updated",
269243
optional: true,
270244
},
271245
},
272-
async run() {
246+
async run({ $ }) {
273247
const constraints = {
274248
name: {
275249
length: {
@@ -324,7 +298,9 @@ export default {
324298
...(this.comment
325299
? {
326300
comments: [
327-
utils.parseJson(this.comment),
301+
{
302+
text: this.comment,
303+
},
328304
],
329305
}
330306
: undefined
@@ -337,25 +313,27 @@ export default {
337313
}
338314
: undefined
339315
),
340-
...(this.storyLink
316+
...(this.storyIds
341317
? {
342-
story_links: [
343-
utils.parseJson(this.storyLink),
344-
],
318+
story_links: this.storyIds.map((id) => ({
319+
subject_id: id,
320+
verb: "relates to",
321+
})),
345322
}
346323
: undefined
347324
),
348-
...(this.task
325+
...(this.tasks
349326
? {
350-
tasks: [
351-
utils.parseJson(this.task),
352-
],
327+
tasks: this.tasks.map((task) => ({
328+
description: task,
329+
})),
353330
}
354331
: undefined
355332
),
356333
};
357334

358335
const resp = await this.shortcut.callWithRetry("createStory", story);
336+
$.export("$summary", `Successfully created story with ID: ${resp.data.id}`);
359337
return resp.data;
360338
},
361339
};

components/shortcut/actions/search-stories/search-stories.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "shortcut-search-stories",
55
name: "Search Stories",
66
description: "Searches for stories in your Shortcut account.",
7-
version: "1.0.1",
7+
version: "1.0.2",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,

components/shortcut/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/shortcut",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "Pipedream Shortcut Components",
55
"main": "shortcut.app.mjs",
66
"keywords": [
@@ -10,6 +10,7 @@
1010
"homepage": "https://pipedream.com/apps/shortcut",
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"dependencies": {
13+
"@pipedream/platform": "^3.1.1",
1314
"@shortcut/client": "^2.2.0",
1415
"async-retry": "^1.3.1",
1516
"lodash": "^4.17.20",

components/shortcut/shortcut.app.mjs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,77 @@ import retry from "async-retry";
55
export default {
66
type: "app",
77
app: "shortcut",
8+
propDefinitions: {
9+
workflowStateId: {
10+
type: "integer",
11+
label: "Workflow State ID",
12+
description: "The ID of the workflow state the story will be in",
13+
async options() {
14+
let options = [];
15+
const workflows = await this.callWithRetry("listWorkflows");
16+
const isWorkflowDataAvailable = lodash.get(workflows, [
17+
"data",
18+
"length",
19+
]);
20+
if (!isWorkflowDataAvailable) {
21+
return options;
22+
}
23+
return workflows.data.reduce(function (options, workflow) {
24+
const hasState = lodash.get(workflow, [
25+
"states",
26+
"length",
27+
]);
28+
if (!hasState) {
29+
return options;
30+
}
31+
const optionsToAdd = workflow.states.map((state) => ({
32+
label: `${state.name} (${workflow.name})`,
33+
value: state.id,
34+
}));
35+
return options.concat(optionsToAdd);
36+
}, []);
37+
},
38+
},
39+
labelIds: {
40+
type: "integer[]",
41+
label: "Label IDs",
42+
description: "The IDs of the labels to filter events by",
43+
optional: true,
44+
async options() {
45+
const { data = [] } = await this.callWithRetry("listLabels");
46+
return data.map(({
47+
id: value, name: label,
48+
}) => ({
49+
label,
50+
value,
51+
}));
52+
},
53+
},
54+
storyIds: {
55+
type: "integer[]",
56+
label: "Story IDs",
57+
description: "The IDs of stories to link as related to the new story",
58+
optional: true,
59+
async options({ prevContext }) {
60+
const { data = [] } = await this.callWithRetry("searchStories", {
61+
query: "is:story",
62+
page_size: 25,
63+
next: prevContext?.next,
64+
});
65+
return {
66+
options: data.data?.map(({
67+
id: value, name: label,
68+
}) => ({
69+
label,
70+
value,
71+
})),
72+
context: {
73+
next: data.next || undefined,
74+
},
75+
};
76+
},
77+
},
78+
},
879
methods: {
980
api() {
1081
return new ShortcutClient(this.$auth.api_key);

0 commit comments

Comments
 (0)