Skip to content

Commit 84d5081

Browse files
committed
Improvements on Field and Record sources
1 parent b8069ce commit 84d5081

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

components/airtable_oauth/sources/common/common-webhook-record.mjs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,27 @@ export default {
1818
operation = changedRecord[0];
1919
recordObj = changedRecord[1];
2020
}
21+
22+
// for deleted record(s) we'll emit only their ids (no other info is available)
23+
if (operation === 'destroyedRecordIds' && Array.isArray(recordObj)) {
24+
const { length } = recordObj;
25+
const summary = length === 1 ? `Record deleted: ${recordObj[0]}` : `${length} records deleted`;
26+
this.$emit({
27+
originalPayload: payload,
28+
tableId,
29+
deletedRecordIds: recordObj,
30+
}, this.generateMeta(payload, summary));
31+
return;
32+
}
33+
2134
const [recordId, recordUpdateInfo] = Object.entries(recordObj)[0];
2235

2336
const timestamp = Date.parse(payload.timestamp);
2437
if (this.isDuplicateEvent(recordId, timestamp)) return;
2538
this._setLastObjectId(recordId);
2639
this._setLastTimestamp(timestamp);
2740

28-
let updateType = 'updated';
29-
if (operation === "createdRecordsById") {
30-
updateType = "created";
31-
} else if (operation === "deletedRecordsById") {
32-
updateType = "deleted";
33-
}
41+
let updateType = operation === "createdRecordsById" ? 'created' : 'updated';
3442

3543
const { fields } = await this.airtable.getRecord({
3644
baseId: this.baseId,
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import common from "../common/common-webhook.mjs";
1+
import common from "../common/common-webhook-field.mjs";
22

33
export default {
44
...common,
55
name: "New Field Created (Instant)",
66
description: "Emit new event when a field is created in the selected table. [See the documentation](https://airtable.com/developers/web/api/get-base-schema)",
77
key: "airtable_oauth-new-field",
8-
version: "1.0.0",
8+
version: "1.0.{{ts}}",
99
type: "source",
1010
dedupe: "unique",
1111
methods: {
@@ -15,10 +15,5 @@ export default {
1515
"add",
1616
];
1717
},
18-
getDataTypes() {
19-
return [
20-
"tableFields",
21-
];
22-
},
2318
},
2419
};

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
name: "New Record Created, Updated or Deleted (Instant)",
99
description: "Emit new event when a record is added, updated, or deleted in a table or selected view.",
1010
key: "airtable_oauth-new-modified-or-deleted-records-instant",
11-
version: "0.1.0",
11+
version: "0.1.{{ts}}",
1212
type: "source",
1313
dedupe: "unique",
1414
props: {
@@ -19,6 +19,7 @@ export default {
1919
description: "Select the types of record updates that should emit events. If not specified, all updates will emit events.",
2020
options: constants.CHANGE_TYPES,
2121
optional: true,
22+
default: ["add", "remove", "update"],
2223
},
2324
watchDataInFieldIds: {
2425
propDefinition: [

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import common from "../common/common-webhook-field.mjs";
2+
import airtable from "../../airtable_oauth.app.mjs";
23

34
export default {
45
...common,

0 commit comments

Comments
 (0)