Skip to content

Commit 7b0d38d

Browse files
committed
More source improvements
1 parent 567602a commit 7b0d38d

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

components/airtable_oauth/sources/new-or-modified-records-in-view/new-or-modified-records-in-view.mjs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import base from "../common/common.mjs";
2-
import moment from "moment";
32

43
export default {
54
...base,
6-
name: "New or Modified Records in View",
7-
description: "Emit new event for each new or modified record in a view",
5+
name: "New or Modified Record(s) In View",
6+
description: "Emit new event when a record is created or updated in the selected view. [See the documentation](https://airtable.com/developers/web/api/list-records)",
87
key: "airtable_oauth-new-or-modified-records-in-view",
98
version: "0.0.6",
109
type: "source",
@@ -18,7 +17,7 @@ export default {
1817
baseId,
1918
}),
2019
],
21-
description: "The table ID to watch for changes.",
20+
description: "Select a table to watch for records, or provide a table ID.",
2221
},
2322
viewId: {
2423
propDefinition: [
@@ -31,7 +30,7 @@ export default {
3130
tableId,
3231
}),
3332
],
34-
description: "The view ID to watch for changes.",
33+
description: "Select a view to watch for records, or provide a view ID.",
3534
},
3635
returnFieldsByFieldId: {
3736
propDefinition: [
@@ -73,7 +72,7 @@ export default {
7372

7473
let newRecords = 0, modifiedRecords = 0;
7574
for (const record of records) {
76-
if (!lastTimestamp || moment(record.createdTime) > moment(lastTimestamp)) {
75+
if (!lastTimestamp || Date.parse(record.createdTime) > Date.parse(lastTimestamp)) {
7776
record.type = "new_record";
7877
newRecords++;
7978
} else {
@@ -83,9 +82,13 @@ export default {
8382

8483
record.metadata = metadata;
8584

85+
const id = record.id;
8686
this.$emit(record, {
87-
summary: `${record.type}: ${JSON.stringify(record.fields)}`,
88-
id: record.id,
87+
summary: `${record.type === "new_record"
88+
? "New"
89+
: "Updated"} record: ${id}`,
90+
id,
91+
ts: Date.now(),
8992
});
9093
}
9194
console.log(`Emitted ${newRecords} new records(s) and ${modifiedRecords} modified record(s).`);

components/airtable_oauth/sources/new-or-modified-records/new-or-modified-records.mjs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import base from "../common/common.mjs";
22
import sampleEmit from "./test-event.mjs";
3-
import moment from "moment";
43

54
export default {
65
...base,
7-
name: "New or Modified Records",
6+
name: "New or Modified Record(s) In Table",
87
key: "airtable_oauth-new-or-modified-records",
9-
description: "Emit new event for each new or modified record in a table",
8+
description: "Emit new event when a record is created in the selected table. [See the documentation](https://airtable.com/developers/web/api/list-records)",
109
version: "0.0.8",
1110
type: "source",
1211
props: {
@@ -19,7 +18,7 @@ export default {
1918
baseId,
2019
}),
2120
],
22-
description: "The table ID to watch for changes.",
21+
description: "Select a table to watch for records, or provide a table ID.",
2322
},
2423
fieldIds: {
2524
propDefinition: [
@@ -34,7 +33,7 @@ export default {
3433
],
3534
type: "string[]",
3635
label: "Field IDs",
37-
description: "Identifiers of spedific fields/columns to watch for updates",
36+
description: "Select which fields/columns to watch for updates.",
3837
withLabel: true,
3938
},
4039
returnFieldsByFieldId: {
@@ -124,7 +123,7 @@ export default {
124123
if (this.fieldIds) {
125124
newFieldValues = this.updateFieldValues(newFieldValues, record);
126125
}
127-
if (!lastTimestamp || moment(record.createdTime) > moment(lastTimestamp)) {
126+
if (!lastTimestamp || Date.parse(record.createdTime) > Date.parse(lastTimestamp)) {
128127
record.type = "new_record";
129128
newRecords++;
130129
} else {
@@ -139,9 +138,12 @@ export default {
139138

140139
record.metadata = metadata;
141140

141+
const id = record.id;
142142
this.$emit(record, {
143-
summary: `${record.type}: ${JSON.stringify(record.fields)}`,
144-
id: record.id,
143+
summary: `${record.type === "new_record"
144+
? "New"
145+
: "Updated"} record: ${id}`,
146+
id,
145147
ts: Date.now(),
146148
});
147149
}

components/airtable_oauth/sources/new-records-in-view/new-records-in-view.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import base from "../common/common.mjs";
22

33
export default {
44
...base,
5-
name: "New Record(s) Created (in View)",
5+
name: "New Record(s) Created In View",
66
description: "Emit new event when a record is created in the selected view. [See the documentation](https://airtable.com/developers/web/api/list-records)",
77
key: "airtable_oauth-new-records-in-view",
88
version: "0.0.7",

components/airtable_oauth/sources/new-records/new-records.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import base from "../common/common.mjs";
22

33
export default {
44
...base,
5-
name: "New Record(s) Created (in Table)",
5+
name: "New Record(s) Created In Table",
66
description: "Emit new event when a record is created in the selected table. [See the documentation](https://airtable.com/developers/web/api/list-records)",
77
key: "airtable_oauth-new-records",
88
version: "0.0.7",

0 commit comments

Comments
 (0)