Skip to content

Commit 2fdc30e

Browse files
Merge branch 'master' into danny/connect-apps-linking-docs
2 parents 10ef6b9 + 13522fb commit 2fdc30e

File tree

13 files changed

+227
-47
lines changed

13 files changed

+227
-47
lines changed

components/dust/dust.app.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export default {
2+
type: "app",
3+
app: "dust",
4+
propDefinitions: {},
5+
methods: {
6+
// this.$auth contains connected account data
7+
authKeys() {
8+
console.log(Object.keys(this.$auth));
9+
},
10+
},
11+
};

components/dust/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@pipedream/dust",
3+
"version": "0.0.1",
4+
"description": "Pipedream Dust Components",
5+
"main": "dust.app.mjs",
6+
"keywords": [
7+
"pipedream",
8+
"dust"
9+
],
10+
"homepage": "https://pipedream.com/apps/dust",
11+
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
12+
"publishConfig": {
13+
"access": "public"
14+
}
15+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import error from "../../error.app.mjs";
2+
3+
export default {
4+
name: "Throw Error",
5+
version: "0.0.1",
6+
key: "error-throw-error",
7+
description: "Quickly throw an error from your workflow.",
8+
props: {
9+
error,
10+
name: {
11+
propDefinition: [
12+
error,
13+
"name",
14+
],
15+
},
16+
errorMessage: {
17+
propDefinition: [
18+
error,
19+
"errorMessage",
20+
],
21+
},
22+
},
23+
type: "action",
24+
async run() {
25+
this.error.maybeCreateAndThrowError(this.name, this.errorMessage);
26+
},
27+
};

components/error/error.app.mjs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
export default {
2+
type: "app",
3+
app: "error",
4+
propDefinitions: {
5+
name: {
6+
type: "string",
7+
label: "Error Name",
8+
description:
9+
"The **name** (class) of error to throw, which you can define as any custom string. This will show up in all of the standard Pipedream error handling destinations.",
10+
default: "Error",
11+
},
12+
errorMessage: {
13+
type: "string",
14+
label: "Error Message",
15+
description:
16+
"The error **message** to throw. This will show up in all of the standard Pipedream error handling destinations.",
17+
optional: true,
18+
},
19+
},
20+
methods: {
21+
maybeCreateAndThrowError(name, message) {
22+
const errorClass = global[name];
23+
24+
// Check if the error class exists and is a subclass of Error
25+
if (
26+
typeof errorClass === "function" &&
27+
errorClass.prototype.isPrototypeOf.call(Error)
28+
) {
29+
throw new errorClass(message);
30+
}
31+
32+
class DynamicError extends Error {
33+
constructor(msg) {
34+
super(msg);
35+
this.name = name;
36+
}
37+
}
38+
throw new DynamicError(message);
39+
},
40+
},
41+
};

components/error/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@pipedream/error",
3+
"version": "0.0.2",
4+
"description": "Pipedream Error Components",
5+
"main": "error.app.mjs",
6+
"keywords": [
7+
"pipedream",
8+
"error"
9+
],
10+
"homepage": "https://pipedream.com/apps/error",
11+
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
12+
"publishConfig": {
13+
"access": "public"
14+
}
15+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export default {
2+
type: "app",
3+
app: "monday_oauth",
4+
propDefinitions: {},
5+
methods: {
6+
// this.$auth contains connected account data
7+
authKeys() {
8+
console.log(Object.keys(this.$auth));
9+
},
10+
},
11+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@pipedream/monday_oauth",
3+
"version": "0.0.1",
4+
"description": "Pipedream monday.com (OAuth) Components",
5+
"main": "monday_oauth.app.mjs",
6+
"keywords": [
7+
"pipedream",
8+
"monday_oauth"
9+
],
10+
"homepage": "https://pipedream.com/apps/monday_oauth",
11+
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
12+
"publishConfig": {
13+
"access": "public"
14+
}
15+
}

components/notion/package.json

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

components/notion/sources/updated-page/updated-page.mjs

Lines changed: 34 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
key: "notion-updated-page",
99
name: "Updated Page in Database", /* eslint-disable-line pipedream/source-name */
1010
description: "Emit new event when a page in a database is updated. To select a specific page, use `Updated Page ID` instead",
11-
version: "0.0.15",
11+
version: "0.0.16",
1212
type: "source",
1313
dedupe: "unique",
1414
props: {
@@ -40,14 +40,12 @@ export default {
4040
},
4141
hooks: {
4242
async deploy() {
43-
if (!this.properties?.length) {
44-
return;
45-
}
43+
const properties = await this.getProperties();
4644
const propertyValues = {};
4745
const pagesStream = this.notion.getPages(this.databaseId);
4846
for await (const page of pagesStream) {
4947
propertyValues[page.id] = {};
50-
for (const property of this.properties) {
48+
for (const property of properties) {
5149
propertyValues[page.id][property] = JSON.stringify(page.properties[property]);
5250
}
5351
}
@@ -62,70 +60,61 @@ export default {
6260
_setPropertyValues(propertyValues) {
6361
this.db.set("propertyValues", propertyValues);
6462
},
63+
async getProperties() {
64+
if (this.properties?.length) {
65+
return this.properties;
66+
}
67+
const { properties } = await this.notion.retrieveDatabase(this.databaseId);
68+
return Object.keys(properties);
69+
},
70+
generateMeta(obj, summary) {
71+
const { id } = obj;
72+
const title = this.notion.extractPageTitle(obj);
73+
const ts = Date.now();
74+
return {
75+
id: `${id}-${ts}`,
76+
summary: `${summary}: ${title} - ${id}`,
77+
ts,
78+
};
79+
},
6580
},
6681
async run() {
6782
const lastCheckedTimestamp = this.getLastUpdatedTimestamp();
68-
const lastCheckedTimestampDate = new Date(lastCheckedTimestamp);
69-
const lastCheckedTimestampISO = lastCheckedTimestampDate.toISOString();
7083
const propertyValues = this._getPropertyValues();
7184

72-
// Add a filter so that we only receive pages that have been updated since the last call.
7385
const params = {
7486
...this.lastUpdatedSortParam(),
75-
filter: {
76-
timestamp: "last_edited_time",
77-
last_edited_time: {
78-
after: lastCheckedTimestampISO,
79-
},
80-
},
8187
};
8288
let newLastUpdatedTimestamp = lastCheckedTimestamp;
83-
89+
const properties = await this.getProperties();
8490
const pagesStream = this.notion.getPages(this.databaseId, params);
8591

8692
for await (const page of pagesStream) {
87-
if (!this.isResultNew(page.last_edited_time, lastCheckedTimestamp)) {
88-
// The call to getPages() includes a descending sort by last_edited_time.
89-
// As soon as one page !isResultNew(), all of the following ones will also.
90-
// NOTE: the last_edited_filter means this will never be called,
91-
// but it's worth keeping as future-proofing.
92-
break;
93-
}
94-
9593
newLastUpdatedTimestamp = Math.max(
9694
newLastUpdatedTimestamp,
9795
Date.parse(page?.last_edited_time),
9896
);
9997

100-
if (this.properties?.length) {
101-
let propertyChangeFound = false;
102-
for (const property of this.properties) {
103-
const currentProperty = JSON.stringify(page.properties[property]);
104-
if (!propertyValues[page.id] || currentProperty !== propertyValues[page.id][property]) {
105-
propertyChangeFound = true;
106-
propertyValues[page.id] = {
107-
...propertyValues[page.id],
108-
[property]: currentProperty,
109-
};
110-
}
111-
}
112-
if (!propertyChangeFound) {
113-
continue;
98+
let propertyChangeFound = false;
99+
for (const property of properties) {
100+
const currentProperty = JSON.stringify(page.properties[property]);
101+
if (!propertyValues[page.id] || currentProperty !== propertyValues[page.id][property]) {
102+
propertyChangeFound = true;
103+
propertyValues[page.id] = {
104+
...propertyValues[page.id],
105+
[property]: currentProperty,
106+
};
114107
}
115108
}
109+
if (!propertyChangeFound && Date.parse(page?.last_edited_time) <= lastCheckedTimestamp) {
110+
continue;
111+
}
116112

117113
if (!this.includeNewPages && page?.last_edited_time === page?.created_time) {
118114
continue;
119115
}
120116

121-
const meta = this.generateMeta(
122-
page,
123-
constants.types.PAGE,
124-
constants.timestamps.LAST_EDITED_TIME,
125-
constants.summaries.PAGE_UPDATED,
126-
true,
127-
);
128-
117+
const meta = this.generateMeta(page, constants.summaries.PAGE_UPDATED);
129118
this.$emit(page, meta);
130119
}
131120

components/planly/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@pipedream/planly",
3+
"version": "0.0.1",
4+
"description": "Pipedream Planly Components",
5+
"main": "planly.app.mjs",
6+
"keywords": [
7+
"pipedream",
8+
"planly"
9+
],
10+
"homepage": "https://pipedream.com/apps/planly",
11+
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
12+
"publishConfig": {
13+
"access": "public"
14+
}
15+
}

0 commit comments

Comments
 (0)