@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 +7 -0
- package/actions/common/common-purchase-order.mjs +93 -0
- package/actions/create-purchase-order/create-purchase-order.mjs +28 -0
- package/actions/create-request/create-request.mjs +80 -0
- package/actions/create-work-order/create-work-order.mjs +133 -0
- package/actions/find-asset/find-asset.mjs +92 -0
- package/actions/find-location/find-location.mjs +54 -0
- package/actions/find-part/find-part.mjs +60 -0
- package/actions/find-user/find-user.mjs +43 -0
- package/actions/find-vendor/find-vendor.mjs +36 -0
- package/actions/update-purchase-order/update-purchase-order.mjs +36 -0
- package/common/utils.mjs +84 -0
- package/package.json +19 -0
- package/sources/common/common.mjs +83 -0
- package/sources/common/eventTypes.mjs +82 -0
- package/sources/custom-events/custom-events.mjs +36 -0
- package/sources/new-purchase-order/new-purchase-order.mjs +33 -0
- package/sources/new-request/new-request.mjs +33 -0
- package/sources/new-work-order/new-work-order.mjs +33 -0
- package/sources/purchase-order-status-changed/purchase-order-status-change.mjs +36 -0
- package/sources/request-approved/request-approved.mjs +33 -0
- package/sources/work-order-status-change/work-order-status-change.mjs +33 -0
- package/upkeep.app.mjs +340 -0
package/upkeep.app.mjs
ADDED
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { axios } from "@pipedream/platform";
|
|
2
|
+
import utils from "./common/utils.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
type: "app",
|
|
6
|
+
app: "upkeep",
|
|
7
|
+
propDefinitions: {
|
|
8
|
+
title: {
|
|
9
|
+
type: "string",
|
|
10
|
+
label: "Title",
|
|
11
|
+
description: "Title of the purchase order",
|
|
12
|
+
},
|
|
13
|
+
description: {
|
|
14
|
+
type: "string",
|
|
15
|
+
label: "Purchase Order Description",
|
|
16
|
+
description: "Description of the purchase order",
|
|
17
|
+
optional: true,
|
|
18
|
+
},
|
|
19
|
+
priority: {
|
|
20
|
+
type: "string",
|
|
21
|
+
label: "Priority",
|
|
22
|
+
description: "Priority of the request.",
|
|
23
|
+
optional: true,
|
|
24
|
+
options: [
|
|
25
|
+
{
|
|
26
|
+
label: "None",
|
|
27
|
+
value: "0",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
label: "Low",
|
|
31
|
+
value: "1",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
label: "Medium",
|
|
35
|
+
value: "2",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: "High",
|
|
39
|
+
value: "3",
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
respectivePartQuantityUsed: {
|
|
44
|
+
type: "integer[]",
|
|
45
|
+
label: "Respective Part Quantities",
|
|
46
|
+
description: "The respective quantities of each part included in the parts array",
|
|
47
|
+
optional: true,
|
|
48
|
+
},
|
|
49
|
+
vendorId: { //cannot fetch vendors, it is possible only in enterprise plan. I did not use options here.
|
|
50
|
+
type: "string",
|
|
51
|
+
label: "Vendor",
|
|
52
|
+
description: "The ID of the vendor",
|
|
53
|
+
optional: true,
|
|
54
|
+
},
|
|
55
|
+
purchaseOrderId: {
|
|
56
|
+
type: "string",
|
|
57
|
+
label: "Purchase Order Id",
|
|
58
|
+
description: "Id of the purchase order to be updated",
|
|
59
|
+
optional: true,
|
|
60
|
+
async options({ page }) {
|
|
61
|
+
return await utils.asyncPropHandler({
|
|
62
|
+
resourceFn: this.getPurchaseOrders,
|
|
63
|
+
page,
|
|
64
|
+
labelVal: {
|
|
65
|
+
label: "title",
|
|
66
|
+
value: "id",
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
categoryId: {
|
|
72
|
+
type: "string",
|
|
73
|
+
label: "Category",
|
|
74
|
+
description: "The category of the purchase order.",
|
|
75
|
+
optional: true,
|
|
76
|
+
async options({ page }) {
|
|
77
|
+
return await utils.asyncPropHandler({
|
|
78
|
+
resourceFn: this.getCategories,
|
|
79
|
+
page,
|
|
80
|
+
labelVal: {
|
|
81
|
+
label: "name",
|
|
82
|
+
value: "id",
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
locationId: {
|
|
88
|
+
type: "string",
|
|
89
|
+
label: "Location",
|
|
90
|
+
description: "Location Id",
|
|
91
|
+
optional: true,
|
|
92
|
+
async options({ page }) {
|
|
93
|
+
return await utils.asyncPropHandler({
|
|
94
|
+
resourceFn: this.getLocations,
|
|
95
|
+
page,
|
|
96
|
+
labelVal: {
|
|
97
|
+
label: "name",
|
|
98
|
+
value: "id",
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
assetId: {
|
|
104
|
+
type: "string",
|
|
105
|
+
label: "Asset",
|
|
106
|
+
description: "Asset Id",
|
|
107
|
+
optional: true,
|
|
108
|
+
async options({ page }) {
|
|
109
|
+
return await utils.asyncPropHandler({
|
|
110
|
+
resourceFn: this.getAssets,
|
|
111
|
+
page,
|
|
112
|
+
labelVal: {
|
|
113
|
+
label: "name",
|
|
114
|
+
value: "id",
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
teamId: {
|
|
120
|
+
type: "string",
|
|
121
|
+
label: "Team",
|
|
122
|
+
description: "Team Id",
|
|
123
|
+
optional: true,
|
|
124
|
+
async options({ page }) {
|
|
125
|
+
return await utils.asyncPropHandler({
|
|
126
|
+
resourceFn: this.getTeams,
|
|
127
|
+
page,
|
|
128
|
+
labelVal: {
|
|
129
|
+
label: "name",
|
|
130
|
+
value: "id",
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
userId: {
|
|
136
|
+
type: "string",
|
|
137
|
+
label: "User",
|
|
138
|
+
description: "User Id",
|
|
139
|
+
optional: true,
|
|
140
|
+
async options({ page }) {
|
|
141
|
+
return await utils.asyncPropHandler({
|
|
142
|
+
resourceFn: this.getUsers,
|
|
143
|
+
page,
|
|
144
|
+
labelVal: {
|
|
145
|
+
label: (user) => `${user.firstName} ${user.lastName}`,
|
|
146
|
+
value: "id",
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
parts: {
|
|
152
|
+
type: "string[]",
|
|
153
|
+
label: "Parts",
|
|
154
|
+
description: "An array of Part IDs to include with the work order",
|
|
155
|
+
optional: true,
|
|
156
|
+
async options({ page }) {
|
|
157
|
+
return await utils.asyncPropHandler({
|
|
158
|
+
resourceFn: this.getParts,
|
|
159
|
+
page,
|
|
160
|
+
labelVal: {
|
|
161
|
+
label: "name",
|
|
162
|
+
value: "id",
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
downtimeStatus: {
|
|
168
|
+
type: "string[]",
|
|
169
|
+
label: "Downtime Status",
|
|
170
|
+
description: "The ID of the asset downtime status. If set, the result will only include assets with this asset downtime status.",
|
|
171
|
+
optional: true,
|
|
172
|
+
async options({ page }) {
|
|
173
|
+
return await utils.asyncPropHandler({
|
|
174
|
+
resourceFn: this.getDowntimeStatuses,
|
|
175
|
+
page,
|
|
176
|
+
labelVal: {
|
|
177
|
+
label: "name",
|
|
178
|
+
value: "id",
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
methods: {
|
|
185
|
+
_getUrl(path) {
|
|
186
|
+
return `https://api.onupkeep.com/api/v2${path}`;
|
|
187
|
+
},
|
|
188
|
+
_accessToken() {
|
|
189
|
+
return this.$auth.oauth_access_token;
|
|
190
|
+
},
|
|
191
|
+
_getHeaders(headers = {}) {
|
|
192
|
+
return {
|
|
193
|
+
"Session-Token": this._accessToken(),
|
|
194
|
+
"Content-Type": "application/json",
|
|
195
|
+
"Accept": "application/json",
|
|
196
|
+
"User-Agent": "@PipedreamHQ/pipedream v0.1",
|
|
197
|
+
...headers,
|
|
198
|
+
};
|
|
199
|
+
},
|
|
200
|
+
async _makeRequest({
|
|
201
|
+
$ = this,
|
|
202
|
+
path,
|
|
203
|
+
headers,
|
|
204
|
+
...otherConfig
|
|
205
|
+
} = {}) {
|
|
206
|
+
const config = {
|
|
207
|
+
url: this._getUrl(path),
|
|
208
|
+
headers: this._getHeaders(headers),
|
|
209
|
+
...otherConfig,
|
|
210
|
+
};
|
|
211
|
+
return axios($, config);
|
|
212
|
+
},
|
|
213
|
+
async createWebhook({ ...args } = {}) {
|
|
214
|
+
return this._makeRequest({
|
|
215
|
+
method: "POST",
|
|
216
|
+
path: "/webhooks",
|
|
217
|
+
...args,
|
|
218
|
+
});
|
|
219
|
+
},
|
|
220
|
+
async deleteWebhook({
|
|
221
|
+
webhookId,
|
|
222
|
+
...args
|
|
223
|
+
} = {}) {
|
|
224
|
+
return this._makeRequest({
|
|
225
|
+
method: "DELETE",
|
|
226
|
+
path: `/webhooks/${webhookId}`,
|
|
227
|
+
...args,
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
async getVendors({ ...args } = {}) {
|
|
231
|
+
return this._makeRequest({
|
|
232
|
+
method: "GET",
|
|
233
|
+
path: "/vendors",
|
|
234
|
+
...args,
|
|
235
|
+
});
|
|
236
|
+
},
|
|
237
|
+
async getCategories({ ...args } = {}) {
|
|
238
|
+
return this._makeRequest({
|
|
239
|
+
method: "GET",
|
|
240
|
+
path: "/purchase-order-categories",
|
|
241
|
+
...args,
|
|
242
|
+
});
|
|
243
|
+
},
|
|
244
|
+
async getPurchaseOrders({ ...args } = {}) {
|
|
245
|
+
console.log("getPurchaseOrders", args);
|
|
246
|
+
return this._makeRequest({
|
|
247
|
+
method: "GET",
|
|
248
|
+
path: "/purchase-orders",
|
|
249
|
+
...args,
|
|
250
|
+
});
|
|
251
|
+
},
|
|
252
|
+
async getLocations({ ...args } = {}) {
|
|
253
|
+
return this._makeRequest({
|
|
254
|
+
method: "GET",
|
|
255
|
+
path: "/locations",
|
|
256
|
+
...args,
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
async getAssets({ ...args } = {}) {
|
|
260
|
+
return this._makeRequest({
|
|
261
|
+
method: "GET",
|
|
262
|
+
path: "/assets",
|
|
263
|
+
...args,
|
|
264
|
+
});
|
|
265
|
+
},
|
|
266
|
+
async getTeams({ ...args } = {}) {
|
|
267
|
+
return this._makeRequest({
|
|
268
|
+
method: "GET",
|
|
269
|
+
path: "/teams",
|
|
270
|
+
...args,
|
|
271
|
+
});
|
|
272
|
+
},
|
|
273
|
+
async getUsers({ ...args } = {}) {
|
|
274
|
+
return this._makeRequest({
|
|
275
|
+
method: "GET",
|
|
276
|
+
path: "/users",
|
|
277
|
+
...args,
|
|
278
|
+
});
|
|
279
|
+
},
|
|
280
|
+
async getParts({ ...args } = {}) {
|
|
281
|
+
return this._makeRequest({
|
|
282
|
+
method: "GET",
|
|
283
|
+
path: "/parts",
|
|
284
|
+
...args,
|
|
285
|
+
});
|
|
286
|
+
},
|
|
287
|
+
async getDowntimeStatuses({ ...args } = {}) {
|
|
288
|
+
return this._makeRequest({
|
|
289
|
+
method: "GET",
|
|
290
|
+
path: "/asset-downtime-statuses",
|
|
291
|
+
...args,
|
|
292
|
+
});
|
|
293
|
+
},
|
|
294
|
+
async getRequests({ ...args } = {}) {
|
|
295
|
+
return this._makeRequest({
|
|
296
|
+
method: "GET",
|
|
297
|
+
path: "/requests",
|
|
298
|
+
...args,
|
|
299
|
+
});
|
|
300
|
+
},
|
|
301
|
+
async getWorkOrders({ ...args } = {}) {
|
|
302
|
+
return this._makeRequest({
|
|
303
|
+
method: "GET",
|
|
304
|
+
path: "/work-orders",
|
|
305
|
+
...args,
|
|
306
|
+
});
|
|
307
|
+
},
|
|
308
|
+
async createPurchaseOrder({ ...args } = {}) {
|
|
309
|
+
return this._makeRequest({
|
|
310
|
+
method: "POST",
|
|
311
|
+
path: "/purchase-orders",
|
|
312
|
+
...args,
|
|
313
|
+
});
|
|
314
|
+
},
|
|
315
|
+
async updatePurchaseOrder({
|
|
316
|
+
purchaseOrderId,
|
|
317
|
+
...args
|
|
318
|
+
} = {}) {
|
|
319
|
+
return this._makeRequest({
|
|
320
|
+
method: "PATCH",
|
|
321
|
+
path: `/purchase-orders/${purchaseOrderId}`,
|
|
322
|
+
...args,
|
|
323
|
+
});
|
|
324
|
+
},
|
|
325
|
+
async createRequest({ ...args } = {}) {
|
|
326
|
+
return this._makeRequest({
|
|
327
|
+
method: "POST",
|
|
328
|
+
path: "/requests",
|
|
329
|
+
...args,
|
|
330
|
+
});
|
|
331
|
+
},
|
|
332
|
+
async createWorkOrder({ ...args } = {}) {
|
|
333
|
+
return this._makeRequest({
|
|
334
|
+
method: "POST",
|
|
335
|
+
path: "/work-orders",
|
|
336
|
+
...args,
|
|
337
|
+
});
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
};
|