@pipedream/upkeep 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2020 Pipedream, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,93 @@
1
+ import app from "../../upkeep.app.mjs";
2
+ import utils from "../../common/utils.mjs";
3
+ import { ConfigurationError } from "@pipedream/platform";
4
+
5
+ export default {
6
+ props: {
7
+ app,
8
+ vendorId: {
9
+ propDefinition: [
10
+ app,
11
+ "vendorId",
12
+ ],
13
+ },
14
+ categoryId: {
15
+ propDefinition: [
16
+ app,
17
+ "categoryId",
18
+ ],
19
+ },
20
+ purchaseOrderNumber: {
21
+ type: "string",
22
+ label: "Purchase Order Number",
23
+ description: "Set a custom purchase order number. If not passed, the default one from settings will be used.",
24
+ optional: true,
25
+ },
26
+ description: {
27
+ propDefinition: [
28
+ app,
29
+ "description",
30
+ ],
31
+ },
32
+ dueDate: {
33
+ type: "string",
34
+ label: "Due Date",
35
+ description: "Due date, in `yyyy-MM-dd` format, e.g. `2018-06-30`",
36
+ optional: true,
37
+ },
38
+ poDate: {
39
+ type: "string",
40
+ label: "Purchase Order Date",
41
+ description: "Date of purchase order, in `yyyy-MM-dd` format, e.g. `2018-06-28`",
42
+ optional: true,
43
+ },
44
+ parts: {
45
+ propDefinition: [
46
+ app,
47
+ "parts",
48
+ ],
49
+ description: "An array of Part IDs to include with the purchase order",
50
+ },
51
+ respectivePartQuantityUsed: {
52
+ propDefinition: [
53
+ app,
54
+ "respectivePartQuantityUsed",
55
+ ],
56
+ },
57
+ otherFields: {
58
+ type: "object",
59
+ label: "Other Fields",
60
+ description: "The fields does not exist in this integration. Please see (docs)[https://developers.onupkeep.com/#purchase-orders] for more fields, e.g. `{\"companyCity\":\"Los Angeles\",\"companyState\":\"California\",\"companyZip\":\"90224\"}`",
61
+ optional: true,
62
+ },
63
+ customFieldsPO: {
64
+ type: "string[]",
65
+ label: "Custom Fields",
66
+ description: "A list of custom fields of the purchase order. Its child attributes are `name`, `value`, and `unit`, e.g. `{\"name\": \"SAPPONumber\",\"value\": \"110-235\"}`",
67
+ optional: true,
68
+ },
69
+ },
70
+ methods: {
71
+ prepareData() {
72
+ if (this.parts.length != this.respectivePartQuantityUsed.length)
73
+ throw new ConfigurationError("`Respective Part Quantities` and `Parts` must have the same length!");
74
+ const parts = [];
75
+ for (let i = 0; i < this.parts.length; i++) {
76
+ parts.push({
77
+ id: this.parts[i],
78
+ quantity: this.respectivePartQuantityUsed[i],
79
+ });
80
+ }
81
+ return {
82
+ title: this.title,
83
+ vendor: this.vendorId,
84
+ category: this.categoryId,
85
+ purchaseOrderNumber: parseInt(this.purchaseOrderNumber),
86
+ description: this.description,
87
+ parts,
88
+ customFieldsPO: utils.parseArray(this.customFieldsPO),
89
+ ...utils.parseObject(this.otherFields),
90
+ };
91
+ },
92
+ },
93
+ };
@@ -0,0 +1,28 @@
1
+ import common from "../common/common-purchase-order.mjs";
2
+
3
+ export default {
4
+ type: "action",
5
+ key: "upkeep-create-purchase-order",
6
+ version: "0.0.1",
7
+ name: "Create Purchase Order",
8
+ description: "Create a Purchase Order, [See the docs](https://developers.onupkeep.com/#purchase-orders)",
9
+ ...common,
10
+ props: {
11
+ app: common.props.app,
12
+ title: {
13
+ propDefinition: [
14
+ common.props.app,
15
+ "title",
16
+ ],
17
+ },
18
+ ...common.props,
19
+ },
20
+ async run ({ $ }) {
21
+ const { result } = await this.app.createPurchaseOrder({
22
+ $,
23
+ data: this.prepareData(),
24
+ });
25
+ $.export("$summary", `Purchase order with ID ${result.id} has been created.`);
26
+ return result;
27
+ },
28
+ };
@@ -0,0 +1,80 @@
1
+ import app from "../../upkeep.app.mjs";
2
+
3
+ export default {
4
+ type: "action",
5
+ key: "upkeep-create-request",
6
+ version: "0.0.1",
7
+ name: "Create Request",
8
+ description: "Create a Request, [See the docs](https://developers.onupkeep.com/#create-a-request)",
9
+ props: {
10
+ app,
11
+ title: {
12
+ propDefinition: [
13
+ app,
14
+ "title",
15
+ ],
16
+ description: "Title of the Request",
17
+ },
18
+ description: {
19
+ propDefinition: [
20
+ app,
21
+ "description",
22
+ ],
23
+ label: "Description",
24
+ description: "",
25
+ },
26
+ priority: {
27
+ propDefinition: [
28
+ app,
29
+ "priority",
30
+ ],
31
+ },
32
+ locationId: {
33
+ propDefinition: [
34
+ app,
35
+ "locationId",
36
+ ],
37
+ },
38
+ assetId: {
39
+ propDefinition: [
40
+ app,
41
+ "assetId",
42
+ ],
43
+ },
44
+ teamId: {
45
+ propDefinition: [
46
+ app,
47
+ "teamId",
48
+ ],
49
+ },
50
+ userId: {
51
+ propDefinition: [
52
+ app,
53
+ "userId",
54
+ ],
55
+ },
56
+ dueDate: {
57
+ type: "string",
58
+ label: "Due Date",
59
+ description: "Due date, timestamp in milliseconds, e.g. `2018-01-09T07:20:22.310Z`",
60
+ optional: true,
61
+ },
62
+ },
63
+ async run ({ $ }) {
64
+ const { result } = await this.app.createRequest({
65
+ $,
66
+ data: {
67
+ title: this.title,
68
+ description: this.description,
69
+ priority: parseInt(this.priority),
70
+ location: this.locationId,
71
+ asset: this.assetId,
72
+ team: this.teamId,
73
+ assignedToUser: this.userId,
74
+ dueDate: this.dueDate,
75
+ },
76
+ });
77
+ $.export("$summary", `Request with ID ${result.id} has been created.`);
78
+ return result;
79
+ },
80
+ };
@@ -0,0 +1,133 @@
1
+ import app from "../../upkeep.app.mjs";
2
+ import utils from "../../common/utils.mjs";
3
+ import { ConfigurationError } from "@pipedream/platform";
4
+
5
+ export default {
6
+ type: "action",
7
+ key: "upkeep-create-work-order",
8
+ version: "0.0.1",
9
+ name: "Create Work Order",
10
+ description: "Create a Work Order, [See the docs](https://developers.onupkeep.com/#create-a-work-order)",
11
+ props: {
12
+ app,
13
+ title: {
14
+ propDefinition: [
15
+ app,
16
+ "title",
17
+ ],
18
+ description: "Title of the work order",
19
+ },
20
+ description: {
21
+ propDefinition: [
22
+ app,
23
+ "description",
24
+ ],
25
+ label: "Description",
26
+ description: "",
27
+ },
28
+ priority: {
29
+ propDefinition: [
30
+ app,
31
+ "priority",
32
+ ],
33
+ },
34
+ category: {
35
+ type: "string",
36
+ label: "Category",
37
+ description: "One of the set categories for Work Orders on your account, including the default ones",
38
+ optional: true,
39
+ },
40
+ dueDate: {
41
+ type: "string",
42
+ label: "Due Date",
43
+ description: "Due date, in ISO 8601 format, e.g. `2022-09-07` or `2022-09-07T13:26:53`",
44
+ optional: true,
45
+ },
46
+ assetId: {
47
+ propDefinition: [
48
+ app,
49
+ "assetId",
50
+ ],
51
+ },
52
+ locationId: {
53
+ propDefinition: [
54
+ app,
55
+ "locationId",
56
+ ],
57
+ },
58
+ userId: {
59
+ propDefinition: [
60
+ app,
61
+ "userId",
62
+ ],
63
+ },
64
+ parts: {
65
+ propDefinition: [
66
+ app,
67
+ "parts",
68
+ ],
69
+ },
70
+ respectivePartQuantityUsed: {
71
+ propDefinition: [
72
+ app,
73
+ "respectivePartQuantityUsed",
74
+ ],
75
+ },
76
+ decreaseInventory: {
77
+ type: "string",
78
+ label: "Decrease Inventory",
79
+ description: "Can be `auto` or `manual`. Default is `auto`. If set to `auto`, inventory will be automatically be decreased when a part is added to a work order. If set to `manual`, inventory will NOT be decreased when a part is added to a work order.",
80
+ optional: true,
81
+ options: [
82
+ "manual",
83
+ "auto",
84
+ ],
85
+ },
86
+ time: {
87
+ type: "integer",
88
+ label: "Time",
89
+ description: "The total time spent on the work order",
90
+ optional: true,
91
+ },
92
+ cost: {
93
+ type: "integer",
94
+ label: "Cost",
95
+ description: "The additional cost assigned to the work order",
96
+ optional: true,
97
+ },
98
+ additionalUsers: {
99
+ propDefinition: [
100
+ app,
101
+ "userId",
102
+ ],
103
+ type: "string[]",
104
+ description: "An array of user IDs for additional workers assigned to the work order.",
105
+ },
106
+ },
107
+ async run ({ $ }) {
108
+ const dueDate = Date.parse(this.dueDate);
109
+ if (isNaN(dueDate))
110
+ throw new ConfigurationError("Due Date should be in ISO 8601 format!");
111
+ const { result } = await this.app.createWorkOrder({
112
+ $,
113
+ data: {
114
+ title: this.title,
115
+ description: this.description,
116
+ priority: parseInt(this.priority),
117
+ category: this.category,
118
+ dueDate,
119
+ asset: this.assetId,
120
+ location: this.locationId,
121
+ assignedToUser: this.userId,
122
+ parts: this.parts,
123
+ respectivePartQuantityUsed: utils.parseArray(this.respectivePartQuantityUsed),
124
+ decreaseInventory: this.decreaseInventory,
125
+ time: parseInt(this.time),
126
+ cost: parseInt(this.cost),
127
+ additionalUsers: this.additionalUsers,
128
+ },
129
+ });
130
+ $.export("$summary", `Request with ID ${result.id} has been created.`);
131
+ return result;
132
+ },
133
+ };
@@ -0,0 +1,92 @@
1
+ import app from "../../upkeep.app.mjs";
2
+ import utils from "../../common/utils.mjs";
3
+
4
+ export default {
5
+ type: "action",
6
+ key: "upkeep-find-asset",
7
+ version: "0.0.1",
8
+ name: "Find Asset",
9
+ description: "Finds assets according to props configured, if no prop configured returns all assets, [See the docs](https://developers.onupkeep.com/#get-all-assets)",
10
+ props: {
11
+ app,
12
+ name: {
13
+ type: "string",
14
+ label: "Name",
15
+ description: "If set, the result will only include assets with that name.",
16
+ optional: true,
17
+ },
18
+ locationId: {
19
+ propDefinition: [
20
+ app,
21
+ "locationId",
22
+ ],
23
+ description: "The ID of the location. If set, the result will only include assets assigned to this location.",
24
+ },
25
+ status: {
26
+ type: "string",
27
+ label: "Status",
28
+ description: "If set, the result will only include assets with this status.",
29
+ optional: true,
30
+ options: [
31
+ {
32
+ label: "Operational",
33
+ value: "active",
34
+ },
35
+ {
36
+ label: "Not Operational",
37
+ value: "inactive",
38
+ },
39
+ ],
40
+ },
41
+ category: { //no method to fetch asset categories
42
+ type: "string",
43
+ label: "Category",
44
+ description: "If set, the result will only include assets with this category.",
45
+ optional: true,
46
+ },
47
+ userId: {
48
+ propDefinition: [
49
+ app,
50
+ "userId",
51
+ ],
52
+ description: "The ID of the user. If set, the result will only include assets assigned to this user.",
53
+ },
54
+ createdByUser: {
55
+ propDefinition: [
56
+ app,
57
+ "userId",
58
+ ],
59
+ label: "Created By User",
60
+ description: "The ID of the user. If set, the result will only include assets created by this user.",
61
+ },
62
+ downtimeStatus: {
63
+ propDefinition: [
64
+ app,
65
+ "downtimeStatus",
66
+ ],
67
+ },
68
+ },
69
+ async run ({ $ }) {
70
+ const items = [];
71
+ const resourcesStream = utils.getResourcesStream({
72
+ resourceFn: this.app.getAssets,
73
+ resourceFnArgs: {
74
+ $,
75
+ params: {
76
+ name: this.name,
77
+ location: this.locationId,
78
+ status: this.status,
79
+ category: this.category,
80
+ assignedToUser: this.userId,
81
+ createdByUser: this.createdByUser,
82
+ downtimeStatus: this.downtimeStatus,
83
+ },
84
+ },
85
+ });
86
+ for await (const item of resourcesStream)
87
+ items.push(item);
88
+ // eslint-disable-next-line multiline-ternary
89
+ $.export("$summary", `${items.length} asset${items.length != 1 ? "s" : ""} has been found.`);
90
+ return items;
91
+ },
92
+ };
@@ -0,0 +1,54 @@
1
+ import app from "../../upkeep.app.mjs";
2
+ import utils from "../../common/utils.mjs";
3
+
4
+ export default {
5
+ type: "action",
6
+ key: "upkeep-find-location",
7
+ version: "0.0.1",
8
+ name: "Find Location",
9
+ description: "Finds locations according to props configured, if no prop configured returns all locations, [See the docs](https://developers.onupkeep.com/#get-all-locations)",
10
+ props: {
11
+ app,
12
+ name: {
13
+ type: "string",
14
+ label: "Name",
15
+ description: "If set, the result will only include locations with that name.",
16
+ optional: true,
17
+ },
18
+ locationId: {
19
+ propDefinition: [
20
+ app,
21
+ "locationId",
22
+ ],
23
+ label: "Parent Location",
24
+ description: "If set, the result will only include sub locations of this parent location.",
25
+ },
26
+ createdByUser: {
27
+ propDefinition: [
28
+ app,
29
+ "userId",
30
+ ],
31
+ label: "Created By User",
32
+ description: "If set, the result will only include locations created by this user.",
33
+ },
34
+ },
35
+ async run ({ $ }) {
36
+ const items = [];
37
+ const resourcesStream = utils.getResourcesStream({
38
+ resourceFn: this.app.getLocations,
39
+ resourceFnArgs: {
40
+ $,
41
+ params: {
42
+ name: this.name,
43
+ parentLocation: this.locationId,
44
+ createdByUser: this.createdByUser,
45
+ },
46
+ },
47
+ });
48
+ for await (const item of resourcesStream)
49
+ items.push(item);
50
+ // eslint-disable-next-line multiline-ternary
51
+ $.export("$summary", `${items.length} location${items.length != 1 ? "s" : ""} has been found.`);
52
+ return items;
53
+ },
54
+ };
@@ -0,0 +1,60 @@
1
+ import app from "../../upkeep.app.mjs";
2
+ import utils from "../../common/utils.mjs";
3
+
4
+ export default {
5
+ type: "action",
6
+ key: "upkeep-find-part",
7
+ version: "0.0.1",
8
+ name: "Find Part",
9
+ description: "Finds parts according to props configured, if no prop configured returns all parts, [See the docs](https://developers.onupkeep.com/#get-all-parts)",
10
+ props: {
11
+ app,
12
+ name: {
13
+ type: "string",
14
+ label: "Name",
15
+ description: "If set, the result will only include parts with that name.",
16
+ optional: true,
17
+ },
18
+ category: { //no method to fetch part categories
19
+ type: "string",
20
+ label: "Category",
21
+ description: "If set, the result will only include parts with that category.",
22
+ optional: true,
23
+ },
24
+ locationId: {
25
+ propDefinition: [
26
+ app,
27
+ "locationId",
28
+ ],
29
+ description: "The ID of the location. If set, the result will only include parts assigned to this location.",
30
+ },
31
+ createdByUser: {
32
+ propDefinition: [
33
+ app,
34
+ "userId",
35
+ ],
36
+ label: "Created By User",
37
+ description: "The ID of the user. If set, the result will only include parts created by this user.",
38
+ },
39
+ },
40
+ async run ({ $ }) {
41
+ const items = [];
42
+ const resourcesStream = utils.getResourcesStream({
43
+ resourceFn: this.app.getParts,
44
+ resourceFnArgs: {
45
+ $,
46
+ params: {
47
+ name: this.name,
48
+ category: this.category,
49
+ location: this.locationId,
50
+ createdByUser: this.createdByUser,
51
+ },
52
+ },
53
+ });
54
+ for await (const item of resourcesStream)
55
+ items.push(item);
56
+ // eslint-disable-next-line multiline-ternary
57
+ $.export("$summary", `${items.length} part${items.length != 1 ? "s" : ""} has been found.`);
58
+ return items;
59
+ },
60
+ };
@@ -0,0 +1,43 @@
1
+ import app from "../../upkeep.app.mjs";
2
+ import utils from "../../common/utils.mjs";
3
+
4
+ export default {
5
+ type: "action",
6
+ key: "upkeep-find-user",
7
+ version: "0.0.1",
8
+ name: "Find User",
9
+ description: "Finds users according to props configured, if no prop configured returns all users, [See the docs](https://developers.onupkeep.com/#get-all-users)",
10
+ props: {
11
+ app,
12
+ email: {
13
+ type: "string",
14
+ label: "Email",
15
+ description: "If set, the result will only include user with that email.",
16
+ optional: true,
17
+ },
18
+ accountType: { //no method to fetch account types
19
+ type: "string",
20
+ label: "Category",
21
+ description: "If set, the result will only include user with that account type.",
22
+ optional: true,
23
+ },
24
+ },
25
+ async run ({ $ }) {
26
+ const items = [];
27
+ const resourcesStream = utils.getResourcesStream({
28
+ resourceFn: this.app.getUsers,
29
+ resourceFnArgs: {
30
+ $,
31
+ params: {
32
+ email: this.email,
33
+ accountType: this.accountType,
34
+ },
35
+ },
36
+ });
37
+ for await (const item of resourcesStream)
38
+ items.push(item);
39
+ // eslint-disable-next-line multiline-ternary
40
+ $.export("$summary", `${items.length} user${items.length != 1 ? "s" : ""} has been found.`);
41
+ return items;
42
+ },
43
+ };
@@ -0,0 +1,36 @@
1
+ import app from "../../upkeep.app.mjs";
2
+ import utils from "../../common/utils.mjs";
3
+
4
+ export default {
5
+ type: "action",
6
+ key: "upkeep-find-vendor",
7
+ version: "0.0.1",
8
+ name: "Find Vendor",
9
+ description: "Finds vendors according to props configured, if no prop configured returns all vendors. Note: enterprise/business-plus plan access only. [See the docs](https://developers.onupkeep.com/#get-all-vendors)",
10
+ props: {
11
+ app,
12
+ businessName: {
13
+ type: "string",
14
+ label: "Business Name",
15
+ description: "If set, the result will only include vendors with that business name.",
16
+ optional: true,
17
+ },
18
+ },
19
+ async run ({ $ }) {
20
+ const items = [];
21
+ const resourcesStream = utils.getResourcesStream({
22
+ resourceFn: this.app.getVendors,
23
+ resourceFnArgs: {
24
+ $,
25
+ params: {
26
+ businessName: this.businessName,
27
+ },
28
+ },
29
+ });
30
+ for await (const item of resourcesStream)
31
+ items.push(item);
32
+ // eslint-disable-next-line multiline-ternary
33
+ $.export("$summary", `${items.length} vendor${items.length != 1 ? "s" : ""} has been found.`);
34
+ return items;
35
+ },
36
+ };
@@ -0,0 +1,36 @@
1
+ import common from "../common/common-purchase-order.mjs";
2
+
3
+ export default {
4
+ type: "action",
5
+ key: "upkeep-update-purchase-order",
6
+ version: "0.0.1",
7
+ name: "Update Purchase Order",
8
+ description: "Update a Purchase Order, [See the docs](https://developers.onupkeep.com/#update-a-specific-purchase-order)",
9
+ ...common,
10
+ props: {
11
+ app: common.props.app,
12
+ purchaseOrderId: {
13
+ propDefinition: [
14
+ common.props.app,
15
+ "purchaseOrderId",
16
+ ],
17
+ },
18
+ title: {
19
+ propDefinition: [
20
+ common.props.app,
21
+ "title",
22
+ ],
23
+ optional: true,
24
+ },
25
+ ...common.props,
26
+ },
27
+ async run ({ $ }) {
28
+ const { result } = await this.app.updatePurchaseOrder({
29
+ $,
30
+ purchaseOrderId: this.purchaseOrderId,
31
+ data: this.prepareData(),
32
+ });
33
+ $.export("$summary", `Purchase order with ID ${result.id} has been updated.`);
34
+ return result;
35
+ },
36
+ };