Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "airtable_oauth-create-comment",
name: "Create Comment",
description: "Create a comment on a selected record. [See the documentation](https://airtable.com/developers/web/api/create-comment)",
version: "0.0.9",
version: "0.0.10",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "airtable_oauth-create-field",
name: "Create Field",
description: "Create a new field in a table. [See the documentation](https://airtable.com/developers/web/api/create-field)",
version: "0.1.1",
version: "0.1.2",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
key: "airtable_oauth-create-multiple-records",
name: "Create Multiple Records",
description: "Create one or more records in a table in a single operation with an array. [See the documentation](https://airtable.com/developers/web/api/create-records)",
version: "0.0.9",
version: "0.0.10",
type: "action",
props: {
...common.props,
Expand All @@ -19,7 +19,7 @@
"records",
],
},
customExpressionInfo: {

Check warning on line 22 in components/airtable_oauth/actions/create-multiple-records/create-multiple-records.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop customExpressionInfo must have a label. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 22 in components/airtable_oauth/actions/create-multiple-records/create-multiple-records.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop customExpressionInfo must have a description. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: `You can use a custom expression that evaluates to an object for each entry in the array, e.g. \`{{ { "foo": "bar", "id": 123 } }}\`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
key: "airtable_oauth-create-or-update-record",
name: "Create or Update Record",
description: "Create a new record or update an existing one. [See the documentation](https://airtable.com/developers/web/api/create-records)",
version: "0.1.1",
version: "0.1.2",
type: "action",
props: {
...common.props,
tableId: {

Check warning on line 13 in components/airtable_oauth/actions/create-or-update-record/create-or-update-record.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop tableId must have a label. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 13 in components/airtable_oauth/actions/create-or-update-record/create-or-update-record.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop tableId must have a description. See https://pipedream.com/docs/components/guidelines/#props
...common.props.tableId,
reloadProps: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "airtable_oauth-create-single-record",
name: "Create Single Record",
description: "Adds a record to a table.",
version: "0.0.10",
version: "0.0.11",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "airtable_oauth-create-table",
name: "Create Table",
description: "Create a new table. [See the documentation](https://airtable.com/developers/web/api/create-table)",
version: "0.0.9",
version: "0.0.10",
type: "action",
props: {
airtable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "airtable_oauth-delete-record",
name: "Delete Record",
description: "Delete a selected record from a table. [See the documentation](https://airtable.com/developers/web/api/delete-record)",
version: "0.0.9",
version: "0.0.10",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
key: "airtable_oauth-get-record-or-create",
name: "Get Record Or Create",
description: "Get a specific record, or create one if it doesn't exist. [See the documentation](https://airtable.com/developers/web/api/create-records)",
version: "0.0.10",
version: "0.0.12",
type: "action",
props: {
...common.props,
tableId: {

Check warning on line 13 in components/airtable_oauth/actions/get-record-or-create/get-record-or-create.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop tableId must have a label. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 13 in components/airtable_oauth/actions/get-record-or-create/get-record-or-create.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop tableId must have a description. See https://pipedream.com/docs/components/guidelines/#props
...common.props.tableId,
reloadProps: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "airtable_oauth-get-record",
name: "Get Record",
description: "Get data of a selected record from a table. [See the documentation](https://airtable.com/developers/web/api/get-record)",
version: "0.0.10",
version: "0.0.11",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
name: "List Records in View",
description: "Retrieve records from a view, optionally sorting and filtering results. [See the documentation](https://airtable.com/developers/web/api/list-views)",
type: "action",
version: "0.0.9",
version: "0.0.10",
...commonList,
props: {
accountTierAlert: {

Check warning on line 12 in components/airtable_oauth/actions/list-records-in-view/list-records-in-view.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop accountTierAlert must have a label. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 12 in components/airtable_oauth/actions/list-records-in-view/list-records-in-view.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop accountTierAlert must have a description. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: "Note: views are only available for Airtable Enterprise accounts. [See the documentation](https://airtable.com/developers/web/api/list-views) for more information.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
name: "List Records",
description: "Retrieve records from a table, optionally sorting and filtering results. [See the documentation](https://airtable.com/developers/web/api/list-records)",
type: "action",
version: "0.0.9",
version: "0.0.10",
...commonList,
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "airtable_oauth-search-records",
name: "Search Records",
description: "Search for a record by formula or by field value. [See the documentation](https://airtable.com/developers/web/api/list-records)",
version: "0.0.11",
version: "0.0.12",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "airtable_oauth-update-comment",
name: "Update Comment",
description: "Update an existing comment on a selected record. [See the documentation](https://airtable.com/developers/web/api/update-comment)",
version: "0.0.9",
version: "0.0.10",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "airtable_oauth-update-field",
name: "Update Field",
description: "Update an existing field in a table. [See the documentation](https://airtable.com/developers/web/api/update-field)",
version: "0.0.9",
version: "0.0.10",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "airtable_oauth-update-record",
name: "Update Record",
description: "Update a single record in a table by Record ID. [See the documentation](https://airtable.com/developers/web/api/update-record)",
version: "0.0.10",
version: "0.0.11",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "airtable_oauth-update-table",
name: "Update Table",
description: "Update an existing table. [See the documentation](https://airtable.com/developers/web/api/update-table)",
version: "0.0.9",
version: "0.0.10",
type: "action",
props: {
...common.props,
Expand Down
4 changes: 2 additions & 2 deletions components/airtable_oauth/common/actions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default {
const baseId = ctx.baseId?.value ?? ctx.baseId;
const tableId = ctx.tableId?.value ?? ctx.tableId;

const record = ctx.record ?? makeRecord(ctx);
const record = ctx.record ?? await makeRecord(ctx);

ctx.airtable.validateRecord(record);

Expand Down Expand Up @@ -61,7 +61,7 @@ export default {
const recordId = ctx.recordId;

ctx.airtable.validateRecordID(recordId);
const record = ctx.record ?? makeRecord(ctx);
const record = ctx.record ?? await makeRecord(ctx);

let response;
try {
Expand Down
37 changes: 34 additions & 3 deletions components/airtable_oauth/common/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,48 @@ function makeFieldProps(tableSchema) {
* @param {object} props - A component's props
* @returns {object} a record
*/
function makeRecord(props) {
async function makeRecord(ctx) {
let record = {};
for (const key of Object.keys(props)) {
const fieldTypes = await mapFieldTypes(ctx);
for (const key of Object.keys(ctx)) {
if (key.startsWith(FIELD_PREFIX)) {
const fieldName = key.slice(FIELD_PREFIX.length);
record[fieldName] = props[key];
if (fieldTypes[fieldName] === FieldType.SINGLE_COLLABORATOR) {
record[fieldName] = buildSingleCollaboratorField(ctx[key]);
continue;
}
record[fieldName] = ctx[key];
}
}
return record;
}

async function mapFieldTypes(ctx) {
const baseId = ctx.baseId?.value ?? ctx.baseId;
const tableId = ctx.tableId?.value ?? ctx.tableId;
const { tables } = await ctx.airtable.listTables({
baseId,
});
const tableSchema = tables.find(({ id }) => id === tableId);
const fieldTypes = {};
for (const field of tableSchema?.fields ?? []) {
fieldTypes[field.name] = field.type;
}
return fieldTypes;
}

const isEmail = (str) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(str);

function buildSingleCollaboratorField(value) {
return isEmail(value)
? {
email: value,
}
: {
id: value,
};
}

export {
fieldTypeToPropType,
fieldToProp,
Expand Down
4 changes: 2 additions & 2 deletions components/airtable_oauth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/airtable_oauth",
"version": "0.4.3",
"version": "0.4.4",
"description": "Pipedream Airtable (OAuth) Components",
"main": "airtable_oauth.app.mjs",
"keywords": [
Expand All @@ -13,7 +13,7 @@
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^1.6.0",
"@pipedream/platform": "^3.0.3",
"airtable": "^0.11.1",
"bottleneck": "^2.19.5",
"lodash.chunk": "^4.2.0",
Expand Down
2 changes: 1 addition & 1 deletion components/airtable_oauth/sources/new-field/new-field.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "New Field Created (Instant)",
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)",
key: "airtable_oauth-new-field",
version: "1.0.1",
version: "1.0.2",
type: "source",
dedupe: "unique",
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
name: "New Record Created, Updated or Deleted (Instant)",
description: "Emit new event when a record is added, updated, or deleted in a table or selected view.",
key: "airtable_oauth-new-modified-or-deleted-records-instant",
version: "0.1.1",
version: "0.1.2",
type: "source",
dedupe: "unique",
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

export default {
...base,
name: "New, Modified or Deleted Records",

Check warning on line 6 in components/airtable_oauth/sources/new-modified-or-deleted-records/new-modified-or-deleted-records.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event each time a record is added, updated, or deleted in an Airtable table. Supports tables up to 10,000 records",
key: "airtable_oauth-new-modified-or-deleted-records",
version: "0.0.10",
version: "0.0.11",
type: "source",
dedupe: "unique",
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
name: "New or Modified Field (Instant)",
description: "Emit new event when a field is created or updated in the selected table",
key: "airtable_oauth-new-or-modified-field",
version: "1.0.1",
version: "1.0.2",
type: "source",
dedupe: "unique",
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
name: "New or Modified Records in View",
description: "Emit new event for each new or modified record in a view",
key: "airtable_oauth-new-or-modified-records-in-view",
version: "0.0.11",
version: "0.0.12",
type: "source",
props: {
...base.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
name: "New or Modified Records (Instant)",
key: "airtable_oauth-new-or-modified-records",
description: "Emit new event for each new or modified record in a table or view",
version: "1.0.1",
version: "1.0.2",
type: "source",
dedupe: "unique",
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
name: "New Records in View",
description: "Emit new event for each new record in a view",
key: "airtable_oauth-new-records-in-view",
version: "0.0.10",
version: "0.0.11",
type: "source",
dedupe: "unique",
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "New Record(s) Created (Instant)",
description: "Emit new event for each new record in a table",
key: "airtable_oauth-new-records",
version: "1.0.1",
version: "1.0.2",
type: "source",
dedupe: "unique",
methods: {
Expand Down
Loading
Loading