Skip to content

Commit 898616d

Browse files
Merge branch 'master' of github.com:PipedreamHQ/pipedream
2 parents 0cf5ca9 + e8b7531 commit 898616d

File tree

131 files changed

+5341
-1010
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+5341
-1010
lines changed

components/gmail/package.json

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

components/gmail/sources/common/polling-history.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@ export default {
103103
if (this.excludeLabels && message.labelIds.some((i) => this.excludeLabels.includes(i))) {
104104
return;
105105
}
106-
} catch {
107-
console.log(`Message ${id} not found`);
106+
} catch (error) {
107+
console.log(`Message ${id} not found: ${error.message}`);
108+
return;
108109
}
109110
this.emitEvent(message);
110111
},

components/gmail/sources/new-email-received/new-email-received.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default {
1515
name: "New Email Received",
1616
description: "Emit new event when a new email is received.",
1717
type: "source",
18-
version: "0.2.0",
18+
version: "0.2.1",
1919
dedupe: "unique",
2020
props: {
2121
gmail,

components/gmail/sources/new-labeled-email/new-labeled-email.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
name: "New Labeled Email",
99
description: "Emit new event when a new email is labeled.",
1010
type: "source",
11-
version: "0.0.7",
11+
version: "0.0.8",
1212
dedupe: "unique",
1313
props: {
1414
...common.props,

components/openai/actions/chat-using-functions/chat-using-functions.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import constants from "../../common/constants.mjs";
55
export default {
66
...common,
77
name: "Chat using Functions",
8-
version: "0.0.3",
8+
version: "0.0.4",
99
key: "openai-chat-using-functions",
1010
description: "Chat with your models and allow them to invoke functions. Optionally, you can build and invoke workflows as functions. [See the documentation](https://platform.openai.com/docs/guides/function-calling)",
1111
type: "action",
@@ -14,7 +14,7 @@ export default {
1414
alert: {
1515
type: "alert",
1616
alertType: "info",
17-
content: "Provide function names and parameters, and the model will either answer the question directly or decide to invoke one of the functions, returning a function call that adheres to your specified schema. Add a custom code step that includes all available functions which can be invoked based on the model's response - [you can even build an entire workflow as a function](https://pipedream.com/docs/workflows/building-workflows/code/nodejs/#invoke-another-workflow)! Once the appropriate function or workflow is executed, continue the overall execution or pass the result back to the model for further analysis. For more details, [see this guide](https://platform.openai.com/docs/guides/function-calling?api-mode=responses#overview).",
17+
content: "Provide function names and parameters, and the model will either answer the question directly or decide to invoke one of the functions, returning a function call that adheres to your specified schema. Add a custom code step that includes all available functions which can be invoked based on the model's response - [you can even build an entire workflow as a function](https://pipedream.com/docs/workflows/building-workflows/code/nodejs/#invoke-another-workflow)! Once the appropriate function or workflow is executed, continue the overall execution or pass the result back to the model for further analysis. For more details, [see this guide](https://platform.openai.com/docs/guides/function-calling?api-mode=responses#overview) and this [walkthrough](https://pipedream.com/blog/introducing-enhanced-openai-chat-actions-for-pipedream/#using-pipedream-workflows-as-functions).",
1818
},
1919
modelId: {
2020
propDefinition: [

components/openai/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/openai",
3-
"version": "0.9.2",
3+
"version": "0.9.3",
44
"description": "Pipedream OpenAI Components",
55
"main": "openai.app.mjs",
66
"keywords": [
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Overview
2+
3+
The Pipedream Utils app is a set of pre-built functions that streamline common tasks in your workflows. It acts like a Swiss Army knife for developers, providing essential tools such as format conversion, date manipulation, and text processing. By leveraging these functions, you can reduce the boilerplate code needed for routine operations, speeding up the development of intricate automations. The Helper Functions API can be a game changer when it comes to tasks like parsing dates in user-friendly formats, encoding and decoding data, or generating UUIDs, making them more efficient and less error-prone.
4+
5+
# Example Use Cases
6+
7+
- **Format User Input for Database Storage**
8+
In an app where users submit data through forms, the Helper Functions API can be used to sanitize and format user input before it is stored in a database, such as Airtable. This ensures that data is clean and uniform, simplifying retrieval and analysis.
9+
10+
- **Process Webhook Payloads**
11+
When dealing with incoming webhooks from apps like GitHub, the Helper Functions API can parse and transform JSON payloads. This allows you to extract specific data points and reformat them for use in other apps like Slack for team notifications or JIRA for creating issues.
12+
13+
- **Automate Content Publication Workflow**
14+
A content calendar on Google Sheets can trigger a workflow that uses Helper Functions to parse dates and format post titles. The workflow could then use this data to automatically schedule and publish content on platforms like WordPress or social media apps.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import pipedream_utils from "../../pipedream_utils.app.mjs";
3+
import commonDateTime from "../../common/date-time/commonDateTime.mjs";
4+
import {
5+
DATE_FORMAT_PARSE_MAP, DEFAULT_FORMAT_VALUE,
6+
} from "../../common/date-time/dateFormats.mjs";
7+
import { DATE_TIME_UNITS } from "../../common/date-time/dateTimeUnits.mjs";
8+
import sugar from "sugar";
9+
const OPERATION_OPTIONS = {
10+
ADD: "Add",
11+
SUBTRACT: "Subtract",
12+
};
13+
export default {
14+
...commonDateTime,
15+
name: "Formatting - [Date/Time] Add/Subtract Time",
16+
description: "Add or subtract time from a given input",
17+
key: "pipedream_utils-add-subtract-time",
18+
version: "0.0.5",
19+
type: "action",
20+
props: {
21+
...commonDateTime.props,
22+
operation: {
23+
label: "Operation",
24+
description: "Whether to add or subtract time.",
25+
type: "string",
26+
options: Object.values(OPERATION_OPTIONS),
27+
},
28+
duration: {
29+
label: "Duration",
30+
description: "The duration for the operation. You can use the shorthand duration, for example: `1s`, `1m`, `1h`, `1d`, `1w`, `1y` equal one second, minute, hour, day, week, and year respectively",
31+
type: "string",
32+
},
33+
outputFormat: {
34+
propDefinition: [
35+
pipedream_utils,
36+
"outputFormat",
37+
],
38+
},
39+
},
40+
methods: {
41+
...commonDateTime.methods,
42+
getOperationMilliseconds(str) {
43+
let result = 0;
44+
const {
45+
second, minute, hour, day, week, year,
46+
} = DATE_TIME_UNITS;
47+
Object.entries({
48+
s: second,
49+
m: minute,
50+
h: hour,
51+
d: day,
52+
w: week,
53+
y: year,
54+
}).forEach(([
55+
identifier,
56+
multiplier,
57+
]) => {
58+
const substr = str.match(new RegExp(`[0-9]+\\s*${identifier}`))?.[0];
59+
if (substr) {
60+
const value = Number(substr.match(/[0-9]+/));
61+
result += value * multiplier;
62+
}
63+
});
64+
return result;
65+
},
66+
},
67+
async run({ $ }) {
68+
const {
69+
operation, duration, outputFormat,
70+
} = this;
71+
const dateObj = this.getDateFromInput();
72+
const value = dateObj.valueOf();
73+
let amount = this.getOperationMilliseconds(duration);
74+
if (operation === OPERATION_OPTIONS.SUBTRACT)
75+
amount *= -1;
76+
const result = value + amount;
77+
const format = outputFormat ?? this.inputFormat ?? DEFAULT_FORMAT_VALUE;
78+
try {
79+
const { outputFn } = DATE_FORMAT_PARSE_MAP.get(format);
80+
const output = outputFn(sugar.Date.create(result));
81+
$.export("$summary", `Successfully ${operation === OPERATION_OPTIONS.SUBTRACT
82+
? "subtracted"
83+
: "added"} time`);
84+
return output;
85+
}
86+
catch (err) {
87+
console.log("Error parsing date", err);
88+
throw new ConfigurationError("**Parse error** - check your input and if the selected format is correct.");
89+
}
90+
},
91+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// legacy_hash_id: a_0Mio28
2+
import pipedream_utils from "../../pipedream_utils.app.mjs";
3+
4+
export default {
5+
key: "pipedream_utils-base64-decode-string",
6+
name: "Helper Functions - Base64 Decode String",
7+
description: "Accepts a base64-encoded string, returns a decoded UTF-8 string",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
pipedream_utils,
12+
data: {
13+
type: "string",
14+
},
15+
},
16+
async run({ $ }) {
17+
const buffer = Buffer.from(this.data, "base64");
18+
$.export("data", buffer.toString("utf8"));
19+
},
20+
};
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import pipedream_utils from "../../pipedream_utils.app.mjs";
2+
3+
export default {
4+
key: "pipedream_utils-compare-arrays",
5+
name: "Helper Functions - Compare Arrays",
6+
description: "Get the difference, intersection, union, or symetric difference of two arrays/sets.",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
pipedream_utils,
11+
array1: {
12+
type: "string[]",
13+
label: "Array 1",
14+
description: "Array to compare to second array",
15+
default: [],
16+
},
17+
array2: {
18+
type: "string[]",
19+
label: "Array 2",
20+
description: "Array to be compared with first array",
21+
default: [],
22+
},
23+
actionType: {
24+
type: "string",
25+
label: "Compare Action",
26+
description: "Type of action to perform on the arrays",
27+
options: [
28+
"difference",
29+
"union",
30+
"intersection",
31+
"symmetric difference",
32+
],
33+
},
34+
},
35+
methods: {
36+
getDifference(set1, set2) {
37+
return new Set([
38+
...set1,
39+
].filter((x) => !set2.has(x)));
40+
},
41+
getIntersection(set1, set2) {
42+
return new Set([
43+
...set1,
44+
].filter((x) => set2.has(x)));
45+
},
46+
getUnion(set1, set2) {
47+
for (const elem of set2) {
48+
set1.add(elem);
49+
}
50+
return set1;
51+
},
52+
getSymmetricDifference(set1, set2) {
53+
for (const elem of set2) {
54+
if (set1.has(elem)) {
55+
set1.delete(elem);
56+
} else {
57+
set1.add(elem);
58+
}
59+
}
60+
return set1;
61+
},
62+
},
63+
run() {
64+
const set1 = new Set(this.array1);
65+
const set2 = new Set(this.array2);
66+
67+
let results;
68+
69+
switch (this.actionType) {
70+
case "difference": {
71+
results = this.getDifference(set1, set2);
72+
break;
73+
}
74+
case "union": {
75+
results = this.getUnion(set1, set2);
76+
break;
77+
}
78+
case "intersection": {
79+
results = this.getIntersection(set1, set2);
80+
break;
81+
}
82+
case "symmetric difference": {
83+
results = this.getSymmetricDifference(set1, set2);
84+
break;
85+
}
86+
default:
87+
throw new Error(`Unknown action type: ${this.actionType}`);
88+
}
89+
90+
return Array.from(results);
91+
},
92+
};

0 commit comments

Comments
 (0)