@bothrs/airtable
Advanced tools
Comparing version 0.3.8 to 0.4.0
@@ -41,8 +41,15 @@ var $6iWTS$axios = require("axios"); | ||
$parcel$export($1e3db0c253a13461$exports, "where", () => $1e3db0c253a13461$export$9c59b80dda569a6e); | ||
/** | ||
* Manage Airtable data. | ||
* | ||
* Example: | ||
* | ||
* `await select({ app: '', key: '' }, 'Blogposts')` => Load blogposts | ||
* @module | ||
*/ | ||
// Internal Methods | ||
// ------------------------------------------------------------------------- / | ||
function $1e3db0c253a13461$var$fetchWithAxios(url, config) { | ||
return ($parcel$interopDefault($6iWTS$axios))({ | ||
return (0, ($parcel$interopDefault($6iWTS$axios)))({ | ||
url: url, | ||
@@ -54,17 +61,17 @@ ...config | ||
} | ||
function $1e3db0c253a13461$export$729c8b7179294ba($1e3db0c253a13461$export$729c8b7179294ba) { | ||
return $1e3db0c253a13461$export$729c8b7179294ba.includes('/') ? $1e3db0c253a13461$export$729c8b7179294ba : 'https://api.airtable.com/v0/' + $1e3db0c253a13461$export$729c8b7179294ba + '/'; | ||
function $1e3db0c253a13461$export$729c8b7179294ba(app) { | ||
return app.includes("/") ? app : "https://api.airtable.com/v0/" + app + "/"; | ||
} | ||
function $1e3db0c253a13461$export$838e2a576d4d6ff6(key) { | ||
if (!key) throw new Error('AIRTABLE_API_KEY is a required env variable'); | ||
if (!key) throw new Error("AIRTABLE_API_KEY is a required env variable"); | ||
return { | ||
Authorization: 'Bearer ' + key, | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json' | ||
Authorization: "Bearer " + key, | ||
Accept: "application/json", | ||
"Content-Type": "application/json" | ||
}; | ||
} | ||
async function $1e3db0c253a13461$export$185802fd694ee1f5(environment, tableName, fields) { | ||
environment.log && environment.log('create', tableName, fields); | ||
environment.log && environment.log("create", tableName, fields); | ||
const response = await $1e3db0c253a13461$var$fetchWithAxios($1e3db0c253a13461$export$729c8b7179294ba(environment.app) + tableName, { | ||
method: 'POST', | ||
method: "POST", | ||
headers: $1e3db0c253a13461$export$838e2a576d4d6ff6(environment.key), | ||
@@ -78,4 +85,4 @@ data: { | ||
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, { | ||
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) | ||
@@ -86,3 +93,3 @@ }); | ||
async function $1e3db0c253a13461$export$43128fadae87b74a(environment, tableName, filter = {}) { | ||
environment.log && environment.log('first', tableName, filter); | ||
environment.log && environment.log("first", tableName, filter); | ||
const items = await $1e3db0c253a13461$export$2e6c959c16ff56b8(environment, tableName, filter); | ||
@@ -92,4 +99,4 @@ return items.length > 0 ? items[0] : null; | ||
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), { | ||
environment.log && environment.log("select", tableName, filter); | ||
const response = await $1e3db0c253a13461$var$fetchWithAxios($1e3db0c253a13461$export$729c8b7179294ba(environment.app) + tableName + "?" + (0, ($parcel$interopDefault($6iWTS$querystring))).stringify(filter), { | ||
headers: $1e3db0c253a13461$export$838e2a576d4d6ff6(environment.key) | ||
@@ -103,4 +110,4 @@ }); | ||
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), { | ||
environment.log && environment.log("selectAll", tableName, filter, prepend.length); | ||
const response = await $1e3db0c253a13461$var$fetchWithAxios($1e3db0c253a13461$export$729c8b7179294ba(environment.app) + tableName + "?" + (0, ($parcel$interopDefault($6iWTS$querystring))).stringify(filter), { | ||
headers: $1e3db0c253a13461$export$838e2a576d4d6ff6(environment.key) | ||
@@ -114,3 +121,3 @@ }); | ||
...prepend, | ||
...records, | ||
...records | ||
]); | ||
@@ -125,5 +132,5 @@ if (records) return [ | ||
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', | ||
environment.log && environment.log("update", tableName, fields); | ||
const response = await $1e3db0c253a13461$var$fetchWithAxios($1e3db0c253a13461$export$729c8b7179294ba(environment.app) + tableName + "/" + id, { | ||
method: "PATCH", | ||
headers: $1e3db0c253a13461$export$838e2a576d4d6ff6(environment.key), | ||
@@ -137,5 +144,5 @@ data: { | ||
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', | ||
environment.log && environment.log("remove", tableName, id); | ||
const response = await $1e3db0c253a13461$var$fetchWithAxios($1e3db0c253a13461$export$729c8b7179294ba(environment.app) + tableName + "/" + id, { | ||
method: "DELETE", | ||
headers: $1e3db0c253a13461$export$838e2a576d4d6ff6(environment.key) | ||
@@ -170,3 +177,3 @@ }); | ||
return { | ||
filterByFormula: '{' + field + "}='" + value + "'" | ||
filterByFormula: "{" + field + "}='" + value + "'" | ||
}; | ||
@@ -173,0 +180,0 @@ } |
@@ -22,8 +22,15 @@ import $8N6rY$axios from "axios"; | ||
$parcel$export($9dc5293fbe8c910e$exports, "where", () => $9dc5293fbe8c910e$export$9c59b80dda569a6e); | ||
/** | ||
* Manage Airtable data. | ||
* | ||
* Example: | ||
* | ||
* `await select({ app: '', key: '' }, 'Blogposts')` => Load blogposts | ||
* @module | ||
*/ | ||
// Internal Methods | ||
// ------------------------------------------------------------------------- / | ||
function $9dc5293fbe8c910e$var$fetchWithAxios(url, config) { | ||
return $8N6rY$axios({ | ||
return (0, $8N6rY$axios)({ | ||
url: url, | ||
@@ -35,17 +42,17 @@ ...config | ||
} | ||
function $9dc5293fbe8c910e$export$729c8b7179294ba($9dc5293fbe8c910e$export$729c8b7179294ba) { | ||
return $9dc5293fbe8c910e$export$729c8b7179294ba.includes('/') ? $9dc5293fbe8c910e$export$729c8b7179294ba : 'https://api.airtable.com/v0/' + $9dc5293fbe8c910e$export$729c8b7179294ba + '/'; | ||
function $9dc5293fbe8c910e$export$729c8b7179294ba(app) { | ||
return app.includes("/") ? app : "https://api.airtable.com/v0/" + app + "/"; | ||
} | ||
function $9dc5293fbe8c910e$export$838e2a576d4d6ff6(key) { | ||
if (!key) throw new Error('AIRTABLE_API_KEY is a required env variable'); | ||
if (!key) throw new Error("AIRTABLE_API_KEY is a required env variable"); | ||
return { | ||
Authorization: 'Bearer ' + key, | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json' | ||
Authorization: "Bearer " + key, | ||
Accept: "application/json", | ||
"Content-Type": "application/json" | ||
}; | ||
} | ||
async function $9dc5293fbe8c910e$export$185802fd694ee1f5(environment, tableName, fields) { | ||
environment.log && environment.log('create', tableName, fields); | ||
environment.log && environment.log("create", tableName, fields); | ||
const response = await $9dc5293fbe8c910e$var$fetchWithAxios($9dc5293fbe8c910e$export$729c8b7179294ba(environment.app) + tableName, { | ||
method: 'POST', | ||
method: "POST", | ||
headers: $9dc5293fbe8c910e$export$838e2a576d4d6ff6(environment.key), | ||
@@ -59,4 +66,4 @@ data: { | ||
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, { | ||
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) | ||
@@ -67,3 +74,3 @@ }); | ||
async function $9dc5293fbe8c910e$export$43128fadae87b74a(environment, tableName, filter = {}) { | ||
environment.log && environment.log('first', tableName, filter); | ||
environment.log && environment.log("first", tableName, filter); | ||
const items = await $9dc5293fbe8c910e$export$2e6c959c16ff56b8(environment, tableName, filter); | ||
@@ -73,4 +80,4 @@ return items.length > 0 ? items[0] : null; | ||
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), { | ||
environment.log && environment.log("select", tableName, filter); | ||
const response = await $9dc5293fbe8c910e$var$fetchWithAxios($9dc5293fbe8c910e$export$729c8b7179294ba(environment.app) + tableName + "?" + (0, $8N6rY$querystring).stringify(filter), { | ||
headers: $9dc5293fbe8c910e$export$838e2a576d4d6ff6(environment.key) | ||
@@ -84,4 +91,4 @@ }); | ||
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), { | ||
environment.log && environment.log("selectAll", tableName, filter, prepend.length); | ||
const response = await $9dc5293fbe8c910e$var$fetchWithAxios($9dc5293fbe8c910e$export$729c8b7179294ba(environment.app) + tableName + "?" + (0, $8N6rY$querystring).stringify(filter), { | ||
headers: $9dc5293fbe8c910e$export$838e2a576d4d6ff6(environment.key) | ||
@@ -95,3 +102,3 @@ }); | ||
...prepend, | ||
...records, | ||
...records | ||
]); | ||
@@ -106,5 +113,5 @@ if (records) return [ | ||
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', | ||
environment.log && environment.log("update", tableName, fields); | ||
const response = await $9dc5293fbe8c910e$var$fetchWithAxios($9dc5293fbe8c910e$export$729c8b7179294ba(environment.app) + tableName + "/" + id, { | ||
method: "PATCH", | ||
headers: $9dc5293fbe8c910e$export$838e2a576d4d6ff6(environment.key), | ||
@@ -118,5 +125,5 @@ data: { | ||
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', | ||
environment.log && environment.log("remove", tableName, id); | ||
const response = await $9dc5293fbe8c910e$var$fetchWithAxios($9dc5293fbe8c910e$export$729c8b7179294ba(environment.app) + tableName + "/" + id, { | ||
method: "DELETE", | ||
headers: $9dc5293fbe8c910e$export$838e2a576d4d6ff6(environment.key) | ||
@@ -151,3 +158,3 @@ }); | ||
return { | ||
filterByFormula: '{' + field + "}='" + value + "'" | ||
filterByFormula: "{" + field + "}='" + value + "'" | ||
}; | ||
@@ -154,0 +161,0 @@ } |
{ | ||
"name": "@bothrs/airtable", | ||
"repository": "git@github.com:bothrs/open-source.git", | ||
"version": "0.3.8", | ||
"version": "0.4.0", | ||
"source": "src/index.ts", | ||
@@ -49,3 +49,3 @@ "main": "dist/index.js", | ||
"axios": "^0.24.0", | ||
"parcel": "2.5.0", | ||
"parcel": "^2.8.3", | ||
"query-string": "^7.0.1", | ||
@@ -55,3 +55,3 @@ "rimraf": "^3.0.2", | ||
}, | ||
"gitHead": "4ab40fc01ef06336bd7d460d10edcb44efb95f13" | ||
"gitHead": "87bb87a36f79c42e7e0b127d25d813b38360c3ed" | ||
} |
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
392
42148