@bothrs/airtable
Advanced tools
Comparing version 0.3.5 to 0.3.6
@@ -1,3 +0,3 @@ | ||
var $7aDPw$querystring = require("query-string"); | ||
var $7aDPw$axios = require("axios"); | ||
var $6iWTS$axios = require("axios"); | ||
var $6iWTS$querystring = require("query-string"); | ||
@@ -26,17 +26,17 @@ function $parcel$exportWildcard(dest, source) { | ||
} | ||
var $50ec0a944e93cc52$exports = {}; | ||
var $1e3db0c253a13461$exports = {}; | ||
$parcel$export($50ec0a944e93cc52$exports, "app", () => $50ec0a944e93cc52$export$729c8b7179294ba); | ||
$parcel$export($50ec0a944e93cc52$exports, "headers", () => $50ec0a944e93cc52$export$838e2a576d4d6ff6); | ||
$parcel$export($50ec0a944e93cc52$exports, "create", () => $50ec0a944e93cc52$export$185802fd694ee1f5); | ||
$parcel$export($50ec0a944e93cc52$exports, "unpack", () => $50ec0a944e93cc52$export$417857010dc9287f); | ||
$parcel$export($50ec0a944e93cc52$exports, "find", () => $50ec0a944e93cc52$export$71aa6c912b956294); | ||
$parcel$export($50ec0a944e93cc52$exports, "first", () => $50ec0a944e93cc52$export$43128fadae87b74a); | ||
$parcel$export($50ec0a944e93cc52$exports, "select", () => $50ec0a944e93cc52$export$2e6c959c16ff56b8); | ||
$parcel$export($50ec0a944e93cc52$exports, "selectAll", () => $50ec0a944e93cc52$export$90aca4adda6ff0f5); | ||
$parcel$export($50ec0a944e93cc52$exports, "update", () => $50ec0a944e93cc52$export$722fbec263ad908a); | ||
$parcel$export($50ec0a944e93cc52$exports, "remove", () => $50ec0a944e93cc52$export$cd7f480d6b8286c3); | ||
$parcel$export($50ec0a944e93cc52$exports, "pack", () => $50ec0a944e93cc52$export$2a703dbb0cb35339); | ||
$parcel$export($50ec0a944e93cc52$exports, "byIds", () => $50ec0a944e93cc52$export$fe0a1c6c4b0676fe); | ||
$parcel$export($50ec0a944e93cc52$exports, "where", () => $50ec0a944e93cc52$export$9c59b80dda569a6e); | ||
$parcel$export($1e3db0c253a13461$exports, "app", () => $1e3db0c253a13461$export$729c8b7179294ba); | ||
$parcel$export($1e3db0c253a13461$exports, "headers", () => $1e3db0c253a13461$export$838e2a576d4d6ff6); | ||
$parcel$export($1e3db0c253a13461$exports, "create", () => $1e3db0c253a13461$export$185802fd694ee1f5); | ||
$parcel$export($1e3db0c253a13461$exports, "unpack", () => $1e3db0c253a13461$export$417857010dc9287f); | ||
$parcel$export($1e3db0c253a13461$exports, "find", () => $1e3db0c253a13461$export$71aa6c912b956294); | ||
$parcel$export($1e3db0c253a13461$exports, "first", () => $1e3db0c253a13461$export$43128fadae87b74a); | ||
$parcel$export($1e3db0c253a13461$exports, "select", () => $1e3db0c253a13461$export$2e6c959c16ff56b8); | ||
$parcel$export($1e3db0c253a13461$exports, "selectAll", () => $1e3db0c253a13461$export$90aca4adda6ff0f5); | ||
$parcel$export($1e3db0c253a13461$exports, "update", () => $1e3db0c253a13461$export$722fbec263ad908a); | ||
$parcel$export($1e3db0c253a13461$exports, "remove", () => $1e3db0c253a13461$export$cd7f480d6b8286c3); | ||
$parcel$export($1e3db0c253a13461$exports, "pack", () => $1e3db0c253a13461$export$2a703dbb0cb35339); | ||
$parcel$export($1e3db0c253a13461$exports, "byIds", () => $1e3db0c253a13461$export$fe0a1c6c4b0676fe); | ||
$parcel$export($1e3db0c253a13461$exports, "where", () => $1e3db0c253a13461$export$9c59b80dda569a6e); | ||
@@ -46,4 +46,4 @@ | ||
// ------------------------------------------------------------------------- / | ||
function $50ec0a944e93cc52$var$fetchWithAxios(url, config) { | ||
return ($parcel$interopDefault($7aDPw$axios))({ | ||
function $1e3db0c253a13461$var$fetchWithAxios(url, config) { | ||
return ($parcel$interopDefault($6iWTS$axios))({ | ||
url: url, | ||
@@ -55,18 +55,18 @@ ...config | ||
} | ||
function $50ec0a944e93cc52$export$729c8b7179294ba(app) { | ||
return app.includes('/') ? app : 'https://api.airtable.com/v0/' + app + '/'; | ||
function $1e3db0c253a13461$export$729c8b7179294ba($1e3db0c253a13461$export$729c8b7179294ba) { | ||
return $1e3db0c253a13461$export$729c8b7179294ba.includes('/') ? $1e3db0c253a13461$export$729c8b7179294ba : 'https://api.airtable.com/v0/' + $1e3db0c253a13461$export$729c8b7179294ba + '/'; | ||
} | ||
function $50ec0a944e93cc52$export$838e2a576d4d6ff6(key) { | ||
function $1e3db0c253a13461$export$838e2a576d4d6ff6(key) { | ||
if (!key) throw new Error('AIRTABLE_API_KEY is a required env variable'); | ||
return { | ||
'Authorization': 'Bearer ' + key, | ||
'Accept': 'application/json', | ||
Authorization: 'Bearer ' + key, | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json' | ||
}; | ||
} | ||
async function $50ec0a944e93cc52$export$185802fd694ee1f5(env, tableName, fields) { | ||
env.log && env.log('create', tableName, fields); | ||
const response = await $50ec0a944e93cc52$var$fetchWithAxios($50ec0a944e93cc52$export$729c8b7179294ba(env.app) + tableName, { | ||
async function $1e3db0c253a13461$export$185802fd694ee1f5(environment, tableName, fields) { | ||
environment.log && environment.log('create', tableName, fields); | ||
const response = await $1e3db0c253a13461$var$fetchWithAxios($1e3db0c253a13461$export$729c8b7179294ba(environment.app) + tableName, { | ||
method: 'POST', | ||
headers: $50ec0a944e93cc52$export$838e2a576d4d6ff6(env.key), | ||
headers: $1e3db0c253a13461$export$838e2a576d4d6ff6(environment.key), | ||
data: { | ||
@@ -76,48 +76,51 @@ fields: fields | ||
}); | ||
return $50ec0a944e93cc52$export$417857010dc9287f(response.data); | ||
return $1e3db0c253a13461$export$417857010dc9287f(response.data); | ||
} | ||
async function $50ec0a944e93cc52$export$71aa6c912b956294(env, tableName, id) { | ||
env.log && env.log('find', tableName, id); | ||
const response = await $50ec0a944e93cc52$var$fetchWithAxios($50ec0a944e93cc52$export$729c8b7179294ba(env.app) + tableName + '/' + id, { | ||
headers: $50ec0a944e93cc52$export$838e2a576d4d6ff6(env.key) | ||
async function $1e3db0c253a13461$export$71aa6c912b956294(environment, tableName, id) { | ||
environment.log && environment.log('find', tableName, id); | ||
const response = await $1e3db0c253a13461$var$fetchWithAxios($1e3db0c253a13461$export$729c8b7179294ba(environment.app) + tableName + '/' + id, { | ||
headers: $1e3db0c253a13461$export$838e2a576d4d6ff6(environment.key) | ||
}); | ||
return $50ec0a944e93cc52$export$417857010dc9287f(response.data); | ||
return $1e3db0c253a13461$export$417857010dc9287f(response.data); | ||
} | ||
async function $50ec0a944e93cc52$export$43128fadae87b74a(env, tableName, filter = { | ||
}) { | ||
env.log && env.log('first', tableName, filter); | ||
const items = await $50ec0a944e93cc52$export$2e6c959c16ff56b8(env, tableName, filter); | ||
return items.length ? items[0] : null; | ||
async function $1e3db0c253a13461$export$43128fadae87b74a(environment, tableName, filter = {}) { | ||
environment.log && environment.log('first', tableName, filter); | ||
const items = await $1e3db0c253a13461$export$2e6c959c16ff56b8(environment, tableName, filter); | ||
return items.length > 0 ? items[0] : null; | ||
} | ||
async function $50ec0a944e93cc52$export$2e6c959c16ff56b8(env, tableName, filter = { | ||
}) { | ||
env.log && env.log('select', tableName, filter); | ||
const response = await $50ec0a944e93cc52$var$fetchWithAxios($50ec0a944e93cc52$export$729c8b7179294ba(env.app) + tableName + '?' + ($parcel$interopDefault($7aDPw$querystring)).stringify(filter), { | ||
headers: $50ec0a944e93cc52$export$838e2a576d4d6ff6(env.key) | ||
async function $1e3db0c253a13461$export$2e6c959c16ff56b8(environment, tableName, filter = {}) { | ||
environment.log && environment.log('select', tableName, filter); | ||
const response = await $1e3db0c253a13461$var$fetchWithAxios($1e3db0c253a13461$export$729c8b7179294ba(environment.app) + tableName + '?' + ($parcel$interopDefault($6iWTS$querystring)).stringify(filter), { | ||
headers: $1e3db0c253a13461$export$838e2a576d4d6ff6(environment.key) | ||
}); | ||
const { records: records } = response.data; | ||
if (records) return records.map($50ec0a944e93cc52$export$417857010dc9287f); | ||
if (records) return records.map($1e3db0c253a13461$export$417857010dc9287f); | ||
console.error(response.data); | ||
return []; | ||
} | ||
async function $50ec0a944e93cc52$export$90aca4adda6ff0f5(env, tableName, filter = { | ||
}, prepend = []) { | ||
env.log && env.log('selectAll', tableName, filter, prepend.length); | ||
const response = await $50ec0a944e93cc52$var$fetchWithAxios($50ec0a944e93cc52$export$729c8b7179294ba(env.app) + tableName + '?' + ($parcel$interopDefault($7aDPw$querystring)).stringify(filter), { | ||
headers: $50ec0a944e93cc52$export$838e2a576d4d6ff6(env.key) | ||
async function $1e3db0c253a13461$export$90aca4adda6ff0f5(environment, tableName, filter = {}, prepend = []) { | ||
environment.log && environment.log('selectAll', tableName, filter, prepend.length); | ||
const response = await $1e3db0c253a13461$var$fetchWithAxios($1e3db0c253a13461$export$729c8b7179294ba(environment.app) + tableName + '?' + ($parcel$interopDefault($6iWTS$querystring)).stringify(filter), { | ||
headers: $1e3db0c253a13461$export$838e2a576d4d6ff6(environment.key) | ||
}); | ||
const { offset: offset , records: records } = response.data; | ||
if (offset) return $50ec0a944e93cc52$export$90aca4adda6ff0f5(env, tableName, { | ||
if (offset) return $1e3db0c253a13461$export$90aca4adda6ff0f5(environment, tableName, { | ||
...filter, | ||
offset: offset | ||
}, prepend.concat(records)); | ||
if (records) return prepend.concat(records).map($50ec0a944e93cc52$export$417857010dc9287f); | ||
}, [ | ||
...prepend, | ||
...records, | ||
]); | ||
if (records) return [ | ||
...prepend, | ||
...records | ||
].map($1e3db0c253a13461$export$417857010dc9287f); | ||
console.error(response.data); | ||
return []; | ||
} | ||
async function $50ec0a944e93cc52$export$722fbec263ad908a(env, tableName, id, fields) { | ||
env.log && env.log('update', tableName, fields); | ||
const response = await $50ec0a944e93cc52$var$fetchWithAxios($50ec0a944e93cc52$export$729c8b7179294ba(env.app) + tableName + '/' + id, { | ||
async function $1e3db0c253a13461$export$722fbec263ad908a(environment, tableName, id, fields) { | ||
environment.log && environment.log('update', tableName, fields); | ||
const response = await $1e3db0c253a13461$var$fetchWithAxios($1e3db0c253a13461$export$729c8b7179294ba(environment.app) + tableName + '/' + id, { | ||
method: 'PATCH', | ||
headers: $50ec0a944e93cc52$export$838e2a576d4d6ff6(env.key), | ||
headers: $1e3db0c253a13461$export$838e2a576d4d6ff6(environment.key), | ||
data: { | ||
@@ -127,13 +130,13 @@ fields: fields | ||
}); | ||
return $50ec0a944e93cc52$export$417857010dc9287f(response.data); | ||
return $1e3db0c253a13461$export$417857010dc9287f(response.data); | ||
} | ||
async function $50ec0a944e93cc52$export$cd7f480d6b8286c3(env, tableName, id) { | ||
env.log && env.log('remove', tableName, id); | ||
const response = await $50ec0a944e93cc52$var$fetchWithAxios($50ec0a944e93cc52$export$729c8b7179294ba(env.app) + tableName + '/' + id, { | ||
async function $1e3db0c253a13461$export$cd7f480d6b8286c3(environment, tableName, id) { | ||
environment.log && environment.log('remove', tableName, id); | ||
const response = await $1e3db0c253a13461$var$fetchWithAxios($1e3db0c253a13461$export$729c8b7179294ba(environment.app) + tableName + '/' + id, { | ||
method: 'DELETE', | ||
headers: $50ec0a944e93cc52$export$838e2a576d4d6ff6(env.key) | ||
headers: $1e3db0c253a13461$export$838e2a576d4d6ff6(environment.key) | ||
}); | ||
return $50ec0a944e93cc52$export$417857010dc9287f(response.data); | ||
return $1e3db0c253a13461$export$417857010dc9287f(response.data); | ||
} | ||
function $50ec0a944e93cc52$export$2a703dbb0cb35339(fields) { | ||
function $1e3db0c253a13461$export$2a703dbb0cb35339(fields) { | ||
return { | ||
@@ -149,3 +152,3 @@ id: fields._id, | ||
} | ||
function $50ec0a944e93cc52$export$417857010dc9287f({ id: _id , fields: fields , createdTime: createdTime }) { | ||
function $1e3db0c253a13461$export$417857010dc9287f({ id: _id , fields: fields , createdTime: createdTime }) { | ||
return { | ||
@@ -157,3 +160,3 @@ _id: _id, | ||
} | ||
function $50ec0a944e93cc52$export$fe0a1c6c4b0676fe(ids) { | ||
function $1e3db0c253a13461$export$fe0a1c6c4b0676fe(ids) { | ||
return { | ||
@@ -163,3 +166,3 @@ filterByFormula: "OR(RECORD_ID()='" + ids.join("',RECORD_ID()='") + "')" | ||
} | ||
function $50ec0a944e93cc52$export$9c59b80dda569a6e(field, value) { | ||
function $1e3db0c253a13461$export$9c59b80dda569a6e(field, value) { | ||
return { | ||
@@ -171,9 +174,9 @@ filterByFormula: '{' + field + "}='" + value + "'" | ||
var $1b4460891c9bbf9a$exports = {}; | ||
var $7b84fdc13c3a8184$exports = {}; | ||
$parcel$exportWildcard(module.exports, $50ec0a944e93cc52$exports); | ||
$parcel$exportWildcard(module.exports, $1b4460891c9bbf9a$exports); | ||
$parcel$exportWildcard(module.exports, $1e3db0c253a13461$exports); | ||
$parcel$exportWildcard(module.exports, $7b84fdc13c3a8184$exports); | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,3 @@ | ||
import $lXay8$querystring from "query-string"; | ||
import $lXay8$axios from "axios"; | ||
import $8N6rY$axios from "axios"; | ||
import $8N6rY$querystring from "query-string"; | ||
@@ -7,17 +7,17 @@ function $parcel$export(e, n, v, s) { | ||
} | ||
var $db9fa288d1a4fa49$exports = {}; | ||
var $9dc5293fbe8c910e$exports = {}; | ||
$parcel$export($db9fa288d1a4fa49$exports, "app", () => $db9fa288d1a4fa49$export$729c8b7179294ba); | ||
$parcel$export($db9fa288d1a4fa49$exports, "headers", () => $db9fa288d1a4fa49$export$838e2a576d4d6ff6); | ||
$parcel$export($db9fa288d1a4fa49$exports, "create", () => $db9fa288d1a4fa49$export$185802fd694ee1f5); | ||
$parcel$export($db9fa288d1a4fa49$exports, "unpack", () => $db9fa288d1a4fa49$export$417857010dc9287f); | ||
$parcel$export($db9fa288d1a4fa49$exports, "find", () => $db9fa288d1a4fa49$export$71aa6c912b956294); | ||
$parcel$export($db9fa288d1a4fa49$exports, "first", () => $db9fa288d1a4fa49$export$43128fadae87b74a); | ||
$parcel$export($db9fa288d1a4fa49$exports, "select", () => $db9fa288d1a4fa49$export$2e6c959c16ff56b8); | ||
$parcel$export($db9fa288d1a4fa49$exports, "selectAll", () => $db9fa288d1a4fa49$export$90aca4adda6ff0f5); | ||
$parcel$export($db9fa288d1a4fa49$exports, "update", () => $db9fa288d1a4fa49$export$722fbec263ad908a); | ||
$parcel$export($db9fa288d1a4fa49$exports, "remove", () => $db9fa288d1a4fa49$export$cd7f480d6b8286c3); | ||
$parcel$export($db9fa288d1a4fa49$exports, "pack", () => $db9fa288d1a4fa49$export$2a703dbb0cb35339); | ||
$parcel$export($db9fa288d1a4fa49$exports, "byIds", () => $db9fa288d1a4fa49$export$fe0a1c6c4b0676fe); | ||
$parcel$export($db9fa288d1a4fa49$exports, "where", () => $db9fa288d1a4fa49$export$9c59b80dda569a6e); | ||
$parcel$export($9dc5293fbe8c910e$exports, "app", () => $9dc5293fbe8c910e$export$729c8b7179294ba); | ||
$parcel$export($9dc5293fbe8c910e$exports, "headers", () => $9dc5293fbe8c910e$export$838e2a576d4d6ff6); | ||
$parcel$export($9dc5293fbe8c910e$exports, "create", () => $9dc5293fbe8c910e$export$185802fd694ee1f5); | ||
$parcel$export($9dc5293fbe8c910e$exports, "unpack", () => $9dc5293fbe8c910e$export$417857010dc9287f); | ||
$parcel$export($9dc5293fbe8c910e$exports, "find", () => $9dc5293fbe8c910e$export$71aa6c912b956294); | ||
$parcel$export($9dc5293fbe8c910e$exports, "first", () => $9dc5293fbe8c910e$export$43128fadae87b74a); | ||
$parcel$export($9dc5293fbe8c910e$exports, "select", () => $9dc5293fbe8c910e$export$2e6c959c16ff56b8); | ||
$parcel$export($9dc5293fbe8c910e$exports, "selectAll", () => $9dc5293fbe8c910e$export$90aca4adda6ff0f5); | ||
$parcel$export($9dc5293fbe8c910e$exports, "update", () => $9dc5293fbe8c910e$export$722fbec263ad908a); | ||
$parcel$export($9dc5293fbe8c910e$exports, "remove", () => $9dc5293fbe8c910e$export$cd7f480d6b8286c3); | ||
$parcel$export($9dc5293fbe8c910e$exports, "pack", () => $9dc5293fbe8c910e$export$2a703dbb0cb35339); | ||
$parcel$export($9dc5293fbe8c910e$exports, "byIds", () => $9dc5293fbe8c910e$export$fe0a1c6c4b0676fe); | ||
$parcel$export($9dc5293fbe8c910e$exports, "where", () => $9dc5293fbe8c910e$export$9c59b80dda569a6e); | ||
@@ -27,4 +27,4 @@ | ||
// ------------------------------------------------------------------------- / | ||
function $db9fa288d1a4fa49$var$fetchWithAxios(url, config) { | ||
return $lXay8$axios({ | ||
function $9dc5293fbe8c910e$var$fetchWithAxios(url, config) { | ||
return $8N6rY$axios({ | ||
url: url, | ||
@@ -36,18 +36,18 @@ ...config | ||
} | ||
function $db9fa288d1a4fa49$export$729c8b7179294ba(app) { | ||
return app.includes('/') ? app : 'https://api.airtable.com/v0/' + app + '/'; | ||
function $9dc5293fbe8c910e$export$729c8b7179294ba($9dc5293fbe8c910e$export$729c8b7179294ba) { | ||
return $9dc5293fbe8c910e$export$729c8b7179294ba.includes('/') ? $9dc5293fbe8c910e$export$729c8b7179294ba : 'https://api.airtable.com/v0/' + $9dc5293fbe8c910e$export$729c8b7179294ba + '/'; | ||
} | ||
function $db9fa288d1a4fa49$export$838e2a576d4d6ff6(key) { | ||
function $9dc5293fbe8c910e$export$838e2a576d4d6ff6(key) { | ||
if (!key) throw new Error('AIRTABLE_API_KEY is a required env variable'); | ||
return { | ||
'Authorization': 'Bearer ' + key, | ||
'Accept': 'application/json', | ||
Authorization: 'Bearer ' + key, | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json' | ||
}; | ||
} | ||
async function $db9fa288d1a4fa49$export$185802fd694ee1f5(env, tableName, fields) { | ||
env.log && env.log('create', tableName, fields); | ||
const response = await $db9fa288d1a4fa49$var$fetchWithAxios($db9fa288d1a4fa49$export$729c8b7179294ba(env.app) + tableName, { | ||
async function $9dc5293fbe8c910e$export$185802fd694ee1f5(environment, tableName, fields) { | ||
environment.log && environment.log('create', tableName, fields); | ||
const response = await $9dc5293fbe8c910e$var$fetchWithAxios($9dc5293fbe8c910e$export$729c8b7179294ba(environment.app) + tableName, { | ||
method: 'POST', | ||
headers: $db9fa288d1a4fa49$export$838e2a576d4d6ff6(env.key), | ||
headers: $9dc5293fbe8c910e$export$838e2a576d4d6ff6(environment.key), | ||
data: { | ||
@@ -57,48 +57,51 @@ fields: fields | ||
}); | ||
return $db9fa288d1a4fa49$export$417857010dc9287f(response.data); | ||
return $9dc5293fbe8c910e$export$417857010dc9287f(response.data); | ||
} | ||
async function $db9fa288d1a4fa49$export$71aa6c912b956294(env, tableName, id) { | ||
env.log && env.log('find', tableName, id); | ||
const response = await $db9fa288d1a4fa49$var$fetchWithAxios($db9fa288d1a4fa49$export$729c8b7179294ba(env.app) + tableName + '/' + id, { | ||
headers: $db9fa288d1a4fa49$export$838e2a576d4d6ff6(env.key) | ||
async function $9dc5293fbe8c910e$export$71aa6c912b956294(environment, tableName, id) { | ||
environment.log && environment.log('find', tableName, id); | ||
const response = await $9dc5293fbe8c910e$var$fetchWithAxios($9dc5293fbe8c910e$export$729c8b7179294ba(environment.app) + tableName + '/' + id, { | ||
headers: $9dc5293fbe8c910e$export$838e2a576d4d6ff6(environment.key) | ||
}); | ||
return $db9fa288d1a4fa49$export$417857010dc9287f(response.data); | ||
return $9dc5293fbe8c910e$export$417857010dc9287f(response.data); | ||
} | ||
async function $db9fa288d1a4fa49$export$43128fadae87b74a(env, tableName, filter = { | ||
}) { | ||
env.log && env.log('first', tableName, filter); | ||
const items = await $db9fa288d1a4fa49$export$2e6c959c16ff56b8(env, tableName, filter); | ||
return items.length ? items[0] : null; | ||
async function $9dc5293fbe8c910e$export$43128fadae87b74a(environment, tableName, filter = {}) { | ||
environment.log && environment.log('first', tableName, filter); | ||
const items = await $9dc5293fbe8c910e$export$2e6c959c16ff56b8(environment, tableName, filter); | ||
return items.length > 0 ? items[0] : null; | ||
} | ||
async function $db9fa288d1a4fa49$export$2e6c959c16ff56b8(env, tableName, filter = { | ||
}) { | ||
env.log && env.log('select', tableName, filter); | ||
const response = await $db9fa288d1a4fa49$var$fetchWithAxios($db9fa288d1a4fa49$export$729c8b7179294ba(env.app) + tableName + '?' + $lXay8$querystring.stringify(filter), { | ||
headers: $db9fa288d1a4fa49$export$838e2a576d4d6ff6(env.key) | ||
async function $9dc5293fbe8c910e$export$2e6c959c16ff56b8(environment, tableName, filter = {}) { | ||
environment.log && environment.log('select', tableName, filter); | ||
const response = await $9dc5293fbe8c910e$var$fetchWithAxios($9dc5293fbe8c910e$export$729c8b7179294ba(environment.app) + tableName + '?' + $8N6rY$querystring.stringify(filter), { | ||
headers: $9dc5293fbe8c910e$export$838e2a576d4d6ff6(environment.key) | ||
}); | ||
const { records: records } = response.data; | ||
if (records) return records.map($db9fa288d1a4fa49$export$417857010dc9287f); | ||
if (records) return records.map($9dc5293fbe8c910e$export$417857010dc9287f); | ||
console.error(response.data); | ||
return []; | ||
} | ||
async function $db9fa288d1a4fa49$export$90aca4adda6ff0f5(env, tableName, filter = { | ||
}, prepend = []) { | ||
env.log && env.log('selectAll', tableName, filter, prepend.length); | ||
const response = await $db9fa288d1a4fa49$var$fetchWithAxios($db9fa288d1a4fa49$export$729c8b7179294ba(env.app) + tableName + '?' + $lXay8$querystring.stringify(filter), { | ||
headers: $db9fa288d1a4fa49$export$838e2a576d4d6ff6(env.key) | ||
async function $9dc5293fbe8c910e$export$90aca4adda6ff0f5(environment, tableName, filter = {}, prepend = []) { | ||
environment.log && environment.log('selectAll', tableName, filter, prepend.length); | ||
const response = await $9dc5293fbe8c910e$var$fetchWithAxios($9dc5293fbe8c910e$export$729c8b7179294ba(environment.app) + tableName + '?' + $8N6rY$querystring.stringify(filter), { | ||
headers: $9dc5293fbe8c910e$export$838e2a576d4d6ff6(environment.key) | ||
}); | ||
const { offset: offset , records: records } = response.data; | ||
if (offset) return $db9fa288d1a4fa49$export$90aca4adda6ff0f5(env, tableName, { | ||
if (offset) return $9dc5293fbe8c910e$export$90aca4adda6ff0f5(environment, tableName, { | ||
...filter, | ||
offset: offset | ||
}, prepend.concat(records)); | ||
if (records) return prepend.concat(records).map($db9fa288d1a4fa49$export$417857010dc9287f); | ||
}, [ | ||
...prepend, | ||
...records, | ||
]); | ||
if (records) return [ | ||
...prepend, | ||
...records | ||
].map($9dc5293fbe8c910e$export$417857010dc9287f); | ||
console.error(response.data); | ||
return []; | ||
} | ||
async function $db9fa288d1a4fa49$export$722fbec263ad908a(env, tableName, id, fields) { | ||
env.log && env.log('update', tableName, fields); | ||
const response = await $db9fa288d1a4fa49$var$fetchWithAxios($db9fa288d1a4fa49$export$729c8b7179294ba(env.app) + tableName + '/' + id, { | ||
async function $9dc5293fbe8c910e$export$722fbec263ad908a(environment, tableName, id, fields) { | ||
environment.log && environment.log('update', tableName, fields); | ||
const response = await $9dc5293fbe8c910e$var$fetchWithAxios($9dc5293fbe8c910e$export$729c8b7179294ba(environment.app) + tableName + '/' + id, { | ||
method: 'PATCH', | ||
headers: $db9fa288d1a4fa49$export$838e2a576d4d6ff6(env.key), | ||
headers: $9dc5293fbe8c910e$export$838e2a576d4d6ff6(environment.key), | ||
data: { | ||
@@ -108,13 +111,13 @@ fields: fields | ||
}); | ||
return $db9fa288d1a4fa49$export$417857010dc9287f(response.data); | ||
return $9dc5293fbe8c910e$export$417857010dc9287f(response.data); | ||
} | ||
async function $db9fa288d1a4fa49$export$cd7f480d6b8286c3(env, tableName, id) { | ||
env.log && env.log('remove', tableName, id); | ||
const response = await $db9fa288d1a4fa49$var$fetchWithAxios($db9fa288d1a4fa49$export$729c8b7179294ba(env.app) + tableName + '/' + id, { | ||
async function $9dc5293fbe8c910e$export$cd7f480d6b8286c3(environment, tableName, id) { | ||
environment.log && environment.log('remove', tableName, id); | ||
const response = await $9dc5293fbe8c910e$var$fetchWithAxios($9dc5293fbe8c910e$export$729c8b7179294ba(environment.app) + tableName + '/' + id, { | ||
method: 'DELETE', | ||
headers: $db9fa288d1a4fa49$export$838e2a576d4d6ff6(env.key) | ||
headers: $9dc5293fbe8c910e$export$838e2a576d4d6ff6(environment.key) | ||
}); | ||
return $db9fa288d1a4fa49$export$417857010dc9287f(response.data); | ||
return $9dc5293fbe8c910e$export$417857010dc9287f(response.data); | ||
} | ||
function $db9fa288d1a4fa49$export$2a703dbb0cb35339(fields) { | ||
function $9dc5293fbe8c910e$export$2a703dbb0cb35339(fields) { | ||
return { | ||
@@ -130,3 +133,3 @@ id: fields._id, | ||
} | ||
function $db9fa288d1a4fa49$export$417857010dc9287f({ id: _id , fields: fields , createdTime: createdTime }) { | ||
function $9dc5293fbe8c910e$export$417857010dc9287f({ id: _id , fields: fields , createdTime: createdTime }) { | ||
return { | ||
@@ -138,3 +141,3 @@ _id: _id, | ||
} | ||
function $db9fa288d1a4fa49$export$fe0a1c6c4b0676fe(ids) { | ||
function $9dc5293fbe8c910e$export$fe0a1c6c4b0676fe(ids) { | ||
return { | ||
@@ -144,3 +147,3 @@ filterByFormula: "OR(RECORD_ID()='" + ids.join("',RECORD_ID()='") + "')" | ||
} | ||
function $db9fa288d1a4fa49$export$9c59b80dda569a6e(field, value) { | ||
function $9dc5293fbe8c910e$export$9c59b80dda569a6e(field, value) { | ||
return { | ||
@@ -152,3 +155,3 @@ filterByFormula: '{' + field + "}='" + value + "'" | ||
var $406e97947eea4eed$exports = {}; | ||
var $1baa128e7a44950f$exports = {}; | ||
@@ -158,3 +161,3 @@ | ||
export {$db9fa288d1a4fa49$export$729c8b7179294ba as app, $db9fa288d1a4fa49$export$838e2a576d4d6ff6 as headers, $db9fa288d1a4fa49$export$185802fd694ee1f5 as create, $db9fa288d1a4fa49$export$417857010dc9287f as unpack, $db9fa288d1a4fa49$export$71aa6c912b956294 as find, $db9fa288d1a4fa49$export$43128fadae87b74a as first, $db9fa288d1a4fa49$export$2e6c959c16ff56b8 as select, $db9fa288d1a4fa49$export$90aca4adda6ff0f5 as selectAll, $db9fa288d1a4fa49$export$722fbec263ad908a as update, $db9fa288d1a4fa49$export$cd7f480d6b8286c3 as remove, $db9fa288d1a4fa49$export$2a703dbb0cb35339 as pack, $db9fa288d1a4fa49$export$fe0a1c6c4b0676fe as byIds, $db9fa288d1a4fa49$export$9c59b80dda569a6e as where}; | ||
export {$9dc5293fbe8c910e$export$729c8b7179294ba as app, $9dc5293fbe8c910e$export$838e2a576d4d6ff6 as headers, $9dc5293fbe8c910e$export$185802fd694ee1f5 as create, $9dc5293fbe8c910e$export$417857010dc9287f as unpack, $9dc5293fbe8c910e$export$71aa6c912b956294 as find, $9dc5293fbe8c910e$export$43128fadae87b74a as first, $9dc5293fbe8c910e$export$2e6c959c16ff56b8 as select, $9dc5293fbe8c910e$export$90aca4adda6ff0f5 as selectAll, $9dc5293fbe8c910e$export$722fbec263ad908a as update, $9dc5293fbe8c910e$export$cd7f480d6b8286c3 as remove, $9dc5293fbe8c910e$export$2a703dbb0cb35339 as pack, $9dc5293fbe8c910e$export$fe0a1c6c4b0676fe as byIds, $9dc5293fbe8c910e$export$9c59b80dda569a6e as where}; | ||
//# sourceMappingURL=module.js.map |
@@ -53,9 +53,9 @@ export type AirtableRecord = { | ||
}; | ||
export function create<T extends FieldSet>(env: Environment, tableName: string, fields: T): Promise<Unpacked<T>>; | ||
export function find<T extends FieldSet>(env: Environment, tableName: string, id: string): Promise<Unpacked<T>>; | ||
export function first<T extends FieldSet>(env: Environment, tableName: string, filter?: SelectOptions): Promise<Unpacked<T> | null>; | ||
export function select<T extends FieldSet>(env: Environment, tableName: string, filter?: SelectOptions): Promise<Unpacked<T>[]>; | ||
export function selectAll<T extends FieldSet>(env: Environment, tableName: string, filter?: SelectOptions, prepend?: Packed<T>[]): Promise<Unpacked<T>[]>; | ||
export function update<T extends FieldSet>(env: Environment, tableName: string, id: string, fields: T): Promise<Unpacked<T>>; | ||
export function remove<T extends FieldSet>(env: Environment, tableName: string, id: string): Promise<Unpacked<T>>; | ||
export function create<T extends FieldSet>(environment: Environment, tableName: string, fields: T): Promise<Unpacked<T>>; | ||
export function find<T extends FieldSet>(environment: Environment, tableName: string, id: string): Promise<Unpacked<T>>; | ||
export function first<T extends FieldSet>(environment: Environment, tableName: string, filter?: SelectOptions): Promise<Unpacked<T> | null>; | ||
export function select<T extends FieldSet>(environment: Environment, tableName: string, filter?: SelectOptions): Promise<Unpacked<T>[]>; | ||
export function selectAll<T extends FieldSet>(environment: Environment, tableName: string, filter?: SelectOptions, prepend?: Packed<T>[]): Promise<Unpacked<T>[]>; | ||
export function update<T extends FieldSet>(environment: Environment, tableName: string, id: string, fields: T): Promise<Unpacked<T>>; | ||
export function remove<T extends FieldSet>(environment: Environment, tableName: string, id: string): Promise<Unpacked<T>>; | ||
export function pack<T extends FieldSet & { | ||
@@ -62,0 +62,0 @@ _id: string; |
{ | ||
"name": "@bothrs/airtable", | ||
"repository": "git@github.com:bothrs/open-source.git", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"source": "src/index.ts", | ||
@@ -38,6 +38,6 @@ "main": "dist/index.js", | ||
"watch": "parcel watch", | ||
"build": "yarn build:clean && parcel build", | ||
"build:clean": "rimraf \"dist\"", | ||
"build": "yarn build:clean && parcel build", | ||
"test": "jest --config=\"../../jest.config.js\" --roots=\"./packages/airtable/src\" --coverage --runInBand --passWithNoTests", | ||
"lint": "echo \"No linting configured...\"" | ||
"lint": "eslint \"**/*.{js,ts,tsx}\"" | ||
}, | ||
@@ -49,8 +49,6 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@types/jest": "^27.0.2", | ||
"@types/node": "^12.20.37", | ||
"axios": "^0.24.0", | ||
"jest": "^27.2.4", | ||
"jest-extended": "^0.11.5", | ||
"parcel": "^2.0.0", | ||
"parcel": "2.5.0", | ||
"query-string": "^7.0.1", | ||
@@ -61,3 +59,3 @@ "rimraf": "^3.0.2", | ||
}, | ||
"gitHead": "15b0f20b0a0eaf914a24c1eb66582279c888df8d" | ||
"gitHead": "1744a8369a541bc392c5ba8cc2277b487e5b97e9" | ||
} |
@@ -11,14 +11,14 @@ # @bothrs/airtable | ||
**app**: helper function to fall back to the airtable api link if needed | ||
**headers**: build required headers for an airtable call | ||
**create**: create a new record | ||
**find**: find a record | ||
**first**: return the first record | ||
**select**: select some records | ||
**selectAll**: return all record in a table | ||
**update**: update a record with new data | ||
**remove**: remove a record | ||
**pack**: helper function to wrap data so it has n airtable format | ||
**unpack**: helper function to get the relevant data from an airtable foramtted doc | ||
**byIds**: helper function to write airtable filters in the url | ||
**where**: helper function to write airtable filters in the url | ||
- **app**: helper function to fall back to the airtable api link if needed | ||
- **headers**: build required headers for an airtable call | ||
- **create**: create a new record | ||
- **find**: find a record | ||
- **first**: return the first record | ||
- **select**: select some records | ||
- **selectAll**: return all record in a table | ||
- **update**: update a record with new data | ||
- **remove**: remove a record | ||
- **pack**: helper function to wrap data so it has n airtable format | ||
- **unpack**: helper function to get the relevant data from an airtable foramtted doc | ||
- **byIds**: helper function to write airtable filters in the url | ||
- **where**: helper function to write airtable filters in the url |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44850
8
376