@pipedream/streak 0.0.1 → 0.0.3

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.
@@ -0,0 +1,96 @@
1
+ import streak from "../../streak.app.mjs";
2
+
3
+ const docLink = "https://streak.readme.io/reference/create-a-box";
4
+
5
+ export default {
6
+ key: "streak-create-box",
7
+ name: "Create Box",
8
+ description: `Create a new box in Streak. [See the docs](${docLink})`,
9
+ version: "0.0.1",
10
+ type: "action",
11
+ props: {
12
+ streak,
13
+ pipelineId: {
14
+ propDefinition: [
15
+ streak,
16
+ "pipelineId",
17
+ ],
18
+ reloadProps: true,
19
+ },
20
+ name: {
21
+ type: "string",
22
+ label: "Name",
23
+ description: "Name of the box",
24
+ },
25
+ stage: {
26
+ propDefinition: [
27
+ streak,
28
+ "stage",
29
+ (c) => ({
30
+ pipelineId: c.pipelineId,
31
+ }),
32
+ ],
33
+ optional: true,
34
+ },
35
+ notes: {
36
+ type: "string",
37
+ label: "Notes",
38
+ description: "The notes on the box",
39
+ optional: true,
40
+ },
41
+ teamId: {
42
+ propDefinition: [
43
+ streak,
44
+ "teamId",
45
+ ],
46
+ optional: true,
47
+ },
48
+ assignees: {
49
+ propDefinition: [
50
+ streak,
51
+ "teamMembers",
52
+ (c) => ({
53
+ teamId: c.teamId,
54
+ }),
55
+ ],
56
+ description: "The member(s) of your team this box will be assigned to",
57
+ optional: true,
58
+ },
59
+ },
60
+ async additionalProps() {
61
+ const props = {};
62
+ const fields = await this.streak.listPipelineFields({
63
+ pipelineId: this.pipelineId,
64
+ });
65
+ for (const field of fields) {
66
+ props[`${this.pipelineId}_${field.key}`] = this.streak.customFieldToProp(field);
67
+ }
68
+ return props;
69
+ },
70
+ async run({ $ }) {
71
+ const response = await this.streak.createBox({
72
+ $,
73
+ pipelineId: this.pipelineId,
74
+ data: {
75
+ name: this.name,
76
+ stageKey: this.stage,
77
+ notes: this.notes,
78
+ assignedToSharingEntries: this.assignees?.map((assignee) => ({
79
+ email: assignee,
80
+ })),
81
+ },
82
+ });
83
+
84
+ const updateCustomFields = Object.keys(this)
85
+ .filter((k) => k.includes(`${this.pipelineId}_`))
86
+ .map((k) => this.streak.updateFieldValue({
87
+ boxId: response.boxKey,
88
+ fieldId: k.split(`${this.pipelineId}_`)[1],
89
+ value: this[k],
90
+ }));
91
+ await Promise.all(updateCustomFields);
92
+
93
+ $.export("$summary", "Successfully created box");
94
+ return response;
95
+ },
96
+ };
@@ -0,0 +1,66 @@
1
+ import streak from "../../streak.app.mjs";
2
+
3
+ const docLink = "https://streak.readme.io/reference/create-a-task";
4
+
5
+ export default {
6
+ key: "streak-create-task",
7
+ name: "Create Task",
8
+ description: `Create a new task in a box. [See the docs](${docLink})`,
9
+ version: "0.0.1",
10
+ type: "action",
11
+ props: {
12
+ streak,
13
+ pipelineId: {
14
+ propDefinition: [
15
+ streak,
16
+ "pipelineId",
17
+ ],
18
+ },
19
+ boxId: {
20
+ propDefinition: [
21
+ streak,
22
+ "boxId",
23
+ (c) => ({
24
+ pipelineId: c.pipelineId,
25
+ }),
26
+ ],
27
+ },
28
+ text: {
29
+ type: "string",
30
+ label: "Text",
31
+ description: "Task description",
32
+ },
33
+ dueDate: {
34
+ type: "integer",
35
+ label: "Due Date",
36
+ description: "Due date in Unix milliseconds timestamp",
37
+ optional: true,
38
+ },
39
+ assignees: {
40
+ propDefinition: [
41
+ streak,
42
+ "teamMembers",
43
+ (c) => ({
44
+ teamId: c.teamId,
45
+ }),
46
+ ],
47
+ description: "The member(s) of your team this box will be assigned to",
48
+ optional: true,
49
+ },
50
+ },
51
+ async run({ $ }) {
52
+ const response = await this.streak.createTask({
53
+ $,
54
+ boxId: this.boxId,
55
+ data: {
56
+ text: this.text,
57
+ dueDate: this.dueDate,
58
+ assignedToSharingEntries: this.assignees?.map((assignee) => ({
59
+ email: assignee,
60
+ })),
61
+ },
62
+ });
63
+ $.export("$summary", "Successfully created task");
64
+ return response;
65
+ },
66
+ };
@@ -0,0 +1,52 @@
1
+ import streak from "../../streak.app.mjs";
2
+
3
+ const docLink = "https://streak.readme.io/reference/edit-a-box";
4
+
5
+ export default {
6
+ key: "streak-link-boxes",
7
+ name: "Link Boxes",
8
+ description: `Link boxes to a specific box. [See the docs](${docLink})`,
9
+ version: "0.0.1",
10
+ type: "action",
11
+ props: {
12
+ streak,
13
+ pipelineId: {
14
+ propDefinition: [
15
+ streak,
16
+ "pipelineId",
17
+ ],
18
+ },
19
+ boxId: {
20
+ propDefinition: [
21
+ streak,
22
+ "boxId",
23
+ (c) => ({
24
+ pipelineId: c.pipelineId,
25
+ }),
26
+ ],
27
+ },
28
+ boxes: {
29
+ propDefinition: [
30
+ streak,
31
+ "boxId",
32
+ (c) => ({
33
+ pipelineId: c.pipelineId,
34
+ previousBoxId: c.boxId,
35
+ }),
36
+ ],
37
+ type: "string[]",
38
+ description: "The list of boxes you would like to link to the selected box",
39
+ },
40
+ },
41
+ async run({ $ }) {
42
+ const response = await this.streak.updateBox({
43
+ $,
44
+ boxId: this.boxId,
45
+ data: {
46
+ linkedBoxKeys: this.boxes,
47
+ },
48
+ });
49
+ $.export("$summary", "Successfully linked boxes");
50
+ return response;
51
+ },
52
+ };
@@ -0,0 +1,85 @@
1
+ import streak from "../../streak.app.mjs";
2
+
3
+ const docLink = "https://streak.readme.io/reference/edit-a-box";
4
+
5
+ export default {
6
+ key: "streak-update-box",
7
+ name: "Update Box",
8
+ description: `Update the properties for a box. To update field values use **Update Box Field Value**. [See the docs](${docLink})`,
9
+ version: "0.0.1",
10
+ type: "action",
11
+ props: {
12
+ streak,
13
+ pipelineId: {
14
+ propDefinition: [
15
+ streak,
16
+ "pipelineId",
17
+ ],
18
+ },
19
+ boxId: {
20
+ propDefinition: [
21
+ streak,
22
+ "boxId",
23
+ (c) => ({
24
+ pipelineId: c.pipelineId,
25
+ }),
26
+ ],
27
+ },
28
+ name: {
29
+ type: "string",
30
+ label: "Name",
31
+ description: "Name of the box",
32
+ optional: true,
33
+ },
34
+ stage: {
35
+ propDefinition: [
36
+ streak,
37
+ "stage",
38
+ (c) => ({
39
+ pipelineId: c.pipelineId,
40
+ }),
41
+ ],
42
+ optional: true,
43
+ },
44
+ notes: {
45
+ type: "string",
46
+ label: "Notes",
47
+ description: "The notes on the box",
48
+ optional: true,
49
+ },
50
+ teamId: {
51
+ propDefinition: [
52
+ streak,
53
+ "teamId",
54
+ ],
55
+ optional: true,
56
+ },
57
+ assignees: {
58
+ propDefinition: [
59
+ streak,
60
+ "teamMembers",
61
+ (c) => ({
62
+ teamId: c.teamId,
63
+ }),
64
+ ],
65
+ description: "The member(s) of your team this box will be assigned to",
66
+ optional: true,
67
+ },
68
+ },
69
+ async run({ $ }) {
70
+ const response = await this.streak.updateBox({
71
+ $,
72
+ boxId: this.boxId,
73
+ data: {
74
+ name: this.name,
75
+ stageKey: this.stage,
76
+ notes: this.notes,
77
+ assignedToSharingEntries: this.assignees?.map((assignee) => ({
78
+ email: assignee,
79
+ })),
80
+ },
81
+ });
82
+ $.export("$summary", "Successfully updated box");
83
+ return response;
84
+ },
85
+ };
@@ -0,0 +1,64 @@
1
+ import streak from "../../streak.app.mjs";
2
+
3
+ const docLink = "https://streak.readme.io/reference/update-field-value-for-a-box";
4
+
5
+ export default {
6
+ key: "streak-update-box-field-value",
7
+ name: "Update Box Field Value",
8
+ description: `Update the values of the fields for a box. [See the docs](${docLink})`,
9
+ version: "0.0.1",
10
+ type: "action",
11
+ props: {
12
+ streak,
13
+ pipelineId: {
14
+ propDefinition: [
15
+ streak,
16
+ "pipelineId",
17
+ ],
18
+ },
19
+ boxId: {
20
+ propDefinition: [
21
+ streak,
22
+ "boxId",
23
+ (c) => ({
24
+ pipelineId: c.pipelineId,
25
+ }),
26
+ ],
27
+ reloadProps: true,
28
+ },
29
+ },
30
+ async additionalProps() {
31
+ const props = {};
32
+ const fields = await this.streak.listPipelineFields({
33
+ pipelineId: this.pipelineId,
34
+ });
35
+
36
+ const fieldValues = (await this.streak.listBoxFields({
37
+ boxId: this.boxId,
38
+ })).reduce((fields, x) => ({
39
+ ...fields,
40
+ [x.key]: x.value,
41
+ }), {});
42
+
43
+ for (const field of fields) {
44
+ const prop = this.streak.customFieldToProp(field, fieldValues[field.key]);
45
+ props[`${this.boxId}_${field.key}`] = prop;
46
+ }
47
+ return props;
48
+ },
49
+ async run({ $ }) {
50
+ const updateCustomFields = Object.keys(this)
51
+ .filter((k) => k.includes(`${this.boxId}_`))
52
+ .map((k) => this.streak.updateFieldValue({
53
+ boxId: this.boxId,
54
+ fieldId: k.split(`${this.boxId}_`)[1],
55
+ value: this[k],
56
+ }));
57
+ await Promise.all(updateCustomFields);
58
+
59
+ $.export("$summary", "Successfully updated box fields");
60
+ return this.streak.getBox({
61
+ boxId: this.boxId,
62
+ });
63
+ },
64
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/streak",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Pipedream Streak Components",
5
5
  "main": "streak.app.mjs",
6
6
  "keywords": [
@@ -5,7 +5,7 @@ export default {
5
5
  key: "streak-box-changed-pipeline",
6
6
  name: "Box Changed Pipeline (Instant)",
7
7
  description: "Emit new event when a box changes pipelines.",
8
- version: "0.0.1",
8
+ version: "0.0.2",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  methods: {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "streak-box-changed-stage",
6
6
  name: "Box Changed Stage (Instant)",
7
7
  description: "Emit new event when a box's stage is updated in a pipeline.",
8
- version: "0.0.1",
8
+ version: "0.0.2",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  methods: {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "streak-new-box",
6
6
  name: "New Box (Instant)",
7
7
  description: "Emit new event when a new box is created in a pipeline.",
8
- version: "0.0.1",
8
+ version: "0.0.2",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  methods: {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "streak-new-comment",
6
6
  name: "New Comment (Instant)",
7
7
  description: "Emit new event when a new comment is created within a pipeline.",
8
- version: "0.0.1",
8
+ version: "0.0.2",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  methods: {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "streak-new-contact",
6
6
  name: "New Contact (Instant)",
7
7
  description: "Emit new event when a new contact is created within a team.",
8
- version: "0.0.1",
8
+ version: "0.0.2",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  methods: {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "streak-new-email-on-box",
6
6
  name: "New Email on Box (Instant)",
7
7
  description: "Emit new event when an email is added to a box in a pipeline.",
8
- version: "0.0.1",
8
+ version: "0.0.2",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  methods: {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "streak-new-task",
6
6
  name: "New Task (Instant)",
7
7
  description: "Emit new event when a new task is created in a pipeline.",
8
- version: "0.0.1",
8
+ version: "0.0.2",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  methods: {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "streak-new-task-due",
6
6
  name: "New Task Due (Instant)",
7
7
  description: "Emit new event when a new task is created in a pipeline.",
8
- version: "0.0.1",
8
+ version: "0.0.2",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  methods: {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "streak-task-completed",
6
6
  name: "Task Completed (Instant)",
7
7
  description: "Emit new event when a task is completed in a pipeline.",
8
- version: "0.0.1",
8
+ version: "0.0.2",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  methods: {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "streak-updated-box",
6
6
  name: "Updated Box (Instant)",
7
7
  description: "Emit new event when a box is updated in a pipeline.",
8
- version: "0.0.1",
8
+ version: "0.0.2",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  methods: {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "streak-updated-contact",
6
6
  name: "Updated Contact (Instant)",
7
7
  description: "Emit new event when a contact is updated within a team.",
8
- version: "0.0.1",
8
+ version: "0.0.2",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  methods: {
package/streak.app.mjs CHANGED
@@ -1,4 +1,7 @@
1
- import { axios } from "@pipedream/platform";
1
+ import {
2
+ axios,
3
+ ConfigurationError,
4
+ } from "@pipedream/platform";
2
5
 
3
6
  export default {
4
7
  type: "app",
@@ -16,6 +19,20 @@ export default {
16
19
  }));
17
20
  },
18
21
  },
22
+ pipelineFields: {
23
+ type: "string[]",
24
+ label: "Pipeline Custom Fields",
25
+ description: "Pipeline Custom Fields",
26
+ async options({ pipelineId }) {
27
+ const results = await this.listPipelineFields({
28
+ pipelineId,
29
+ });
30
+ return results.map((field) => ({
31
+ label: field.name,
32
+ value: field.key,
33
+ }));
34
+ },
35
+ },
19
36
  teamId: {
20
37
  type: "string",
21
38
  label: "Team",
@@ -28,8 +45,111 @@ export default {
28
45
  }));
29
46
  },
30
47
  },
48
+ boxId: {
49
+ type: "string",
50
+ label: "Box",
51
+ description: "Select a box",
52
+ async options({
53
+ pipelineId, previousBoxId,
54
+ }) {
55
+ const results = await this.listBoxes({
56
+ pipelineId,
57
+ });
58
+ return results
59
+ .filter((box) => box.key !== previousBoxId)
60
+ .map((box) => ({
61
+ label: box.name,
62
+ value: box.key,
63
+ }));
64
+ },
65
+ },
66
+ teamMembers: {
67
+ type: "string[]",
68
+ label: "Team Members",
69
+ description: "Team members",
70
+ async options({ teamId }) {
71
+ if (!teamId) {
72
+ throw new ConfigurationError("**Team** prop configuration required");
73
+ }
74
+ const { members } = await this.listTeamMembers({
75
+ teamId,
76
+ });
77
+ return members.map((member) => ({
78
+ label: member.fullName,
79
+ value: member.email,
80
+ }));
81
+ },
82
+ },
83
+ stage: {
84
+ type: "string",
85
+ label: "Stage",
86
+ description: "Stage of the box",
87
+ async options({ pipelineId }) {
88
+ const results = await this.listStages({
89
+ pipelineId,
90
+ });
91
+ return Object.entries(results).map(([
92
+ key,
93
+ value,
94
+ ]) => ({
95
+ label: value.name,
96
+ value: key,
97
+ }));
98
+ },
99
+ },
31
100
  },
32
101
  methods: {
102
+ customFieldToProp(field, value) {
103
+ if (field.type === "TEXT_INPUT") {
104
+ return {
105
+ type: "string",
106
+ label: field.name,
107
+ default: value,
108
+ optional: true,
109
+ };
110
+ }
111
+ if (field.type === "DATE") {
112
+ return {
113
+ type: "integer",
114
+ label: field.name,
115
+ description: "Date in Unix milliseconds timestamp",
116
+ default: value,
117
+ optional: true,
118
+ };
119
+ }
120
+ if (field.type === "TAG") {
121
+ return {
122
+ type: "string[]",
123
+ label: field.name,
124
+ options: field.tagSettings.tags.map((x) => ({
125
+ label: x.tag,
126
+ value: x.key,
127
+ })),
128
+ default: value,
129
+ optional: true,
130
+ };
131
+ }
132
+ if (field.type === "DROPDOWN") {
133
+ return {
134
+ type: "string",
135
+ label: field.name,
136
+ options: field.dropdownSettings.items.map((x) => ({
137
+ label: x.name,
138
+ value: x.key,
139
+ })),
140
+ default: value,
141
+ optional: true,
142
+ };
143
+ }
144
+ if (field.type === "CHECKBOX") {
145
+ return {
146
+ type: "boolean",
147
+ label: field.name,
148
+ default: value,
149
+ optional: true,
150
+ };
151
+ }
152
+ },
33
153
  _getBaseUrl() {
34
154
  return "https://www.streak.com/api/";
35
155
  },
@@ -77,18 +197,58 @@ export default {
77
197
  ...args,
78
198
  });
79
199
  },
200
+ async getBox({
201
+ boxId, ...args
202
+ }) {
203
+ return this._makeRequest({
204
+ path: `v1/boxes/${boxId}`,
205
+ ...args,
206
+ });
207
+ },
80
208
  async listPipelines(args = {}) {
81
209
  return this._makeRequest({
82
210
  path: "v1/pipelines",
83
211
  ...args,
84
212
  });
85
213
  },
214
+ async listPipelineFields({
215
+ pipelineId, ...args
216
+ }) {
217
+ return this._makeRequest({
218
+ path: `v1/pipelines/${pipelineId}/fields`,
219
+ ...args,
220
+ });
221
+ },
222
+ async listBoxFields({
223
+ boxId, ...args
224
+ }) {
225
+ return this._makeRequest({
226
+ path: `v1/boxes/${boxId}/fields`,
227
+ ...args,
228
+ });
229
+ },
230
+ async listStages({
231
+ pipelineId, ...args
232
+ }) {
233
+ return this._makeRequest({
234
+ path: `v1/pipelines/${pipelineId}/stages`,
235
+ ...args,
236
+ });
237
+ },
86
238
  async listTeams(args = {}) {
87
239
  return this._makeRequest({
88
240
  path: "v2/users/me/teams",
89
241
  ...args,
90
242
  });
91
243
  },
244
+ async listTeamMembers({
245
+ teamId, ...args
246
+ }) {
247
+ return this._makeRequest({
248
+ path: `v2/teams/${teamId}`,
249
+ ...args,
250
+ });
251
+ },
92
252
  async listBoxes({
93
253
  pipelineId, ...args
94
254
  }) {
@@ -121,5 +281,44 @@ export default {
121
281
  ...args,
122
282
  });
123
283
  },
284
+ async createBox({
285
+ pipelineId, ...args
286
+ }) {
287
+ return this._makeRequest({
288
+ path: `v2/pipelines/${pipelineId}/boxes`,
289
+ method: "post",
290
+ ...args,
291
+ });
292
+ },
293
+ async updateBox({
294
+ boxId, ...args
295
+ }) {
296
+ return this._makeRequest({
297
+ path: `v1/boxes/${boxId}`,
298
+ method: "post",
299
+ ...args,
300
+ });
301
+ },
302
+ async updateFieldValue({
303
+ boxId, fieldId, value, ...args
304
+ }) {
305
+ return this._makeRequest({
306
+ ...args,
307
+ path: `v1/boxes/${boxId}/fields/${fieldId}`,
308
+ method: "post",
309
+ data: {
310
+ value,
311
+ },
312
+ });
313
+ },
314
+ async createTask({
315
+ boxId, ...args
316
+ }) {
317
+ return this._makeRequest({
318
+ path: `v2/boxes/${boxId}/tasks`,
319
+ method: "post",
320
+ ...args,
321
+ });
322
+ },
124
323
  },
125
324
  };