Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bothrs/airtable

Package Overview
Dependencies
Maintainers
7
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bothrs/airtable - npm Package Compare versions

Comparing version 0.2.4 to 0.3.0

dist/index.js.map

378

dist/index.js

@@ -1,270 +0,172 @@

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
var $7aDPw$querystring = require("query-string");
var $7aDPw$axios = require("axios");
function $parcel$exportWildcard(dest, source) {
Object.keys(source).forEach(function(key) {
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
return;
}
Object.defineProperty(dest, key, {
enumerable: true,
get: function get() {
return source[key];
}
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.where = exports.byIds = exports.unpack = exports.pack = exports.remove = exports.update = exports.selectAll = exports.select = exports.first = exports.find = exports.create = exports.headers = exports.app = void 0;
var query_string_1 = __importDefault(require("query-string"));
var node_fetch_1 = __importDefault(require("node-fetch"));
__exportStar(require("./types"), exports);
function app(app) {
});
return dest;
}
function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
}
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
var $50ec0a944e93cc52$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);
// Internal Methods
// ------------------------------------------------------------------------- /
function $50ec0a944e93cc52$var$fetchWithAxios(url, config) {
return $parcel$interopDefault($7aDPw$axios)({
url: url,
...config
}).catch((error)=>{
throw new Error(error.toJSON());
});
}
function $50ec0a944e93cc52$export$729c8b7179294ba(app) {
return app.includes('/') ? app : 'https://api.airtable.com/v0/' + app + '/';
}
exports.app = app;
function headers(key) {
if (!key) {
throw new Error('AIRTABLE_API_KEY is a required env variable');
}
function $50ec0a944e93cc52$export$838e2a576d4d6ff6(key) {
if (!key) throw new Error('AIRTABLE_API_KEY is a required env variable');
return {
Authorization: 'Bearer ' + key,
Accept: 'application/json',
'Content-Type': 'application/json',
'Content-Type': 'application/json'
};
}
exports.headers = headers;
function create(env, tableName, fields) {
return __awaiter(this, void 0, void 0, function () {
var body;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
env.log && env.log('create', tableName, fields);
return [4, (0, node_fetch_1.default)(app(env.app) + tableName, {
method: 'POST',
headers: headers(env.key),
body: JSON.stringify({ fields: fields }),
}).then(function (r) { return r.json(); })];
case 1:
body = _a.sent();
if (body.error) {
throw new Error(body.error.message);
}
return [2, unpack(body)];
}
});
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, {
method: 'POST',
headers: $50ec0a944e93cc52$export$838e2a576d4d6ff6(env.key),
data: {
fields: fields
}
});
return $50ec0a944e93cc52$export$417857010dc9287f(response.data);
}
exports.create = create;
function find(env, tableName, id) {
return __awaiter(this, void 0, void 0, function () {
var body;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
env.log && env.log('find', tableName, id);
return [4, (0, node_fetch_1.default)(app(env.app) + tableName + '/' + id, {
headers: headers(env.key),
}).then(function (r) { return r.json(); })];
case 1:
body = _a.sent();
if (body.error) {
throw new Error(body.error.message);
}
return [2, unpack(body)];
}
});
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)
});
return $50ec0a944e93cc52$export$417857010dc9287f(response.data);
}
exports.find = find;
function first(env, tableName, filter) {
if (filter === void 0) { filter = {}; }
return __awaiter(this, void 0, void 0, function () {
var items;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
env.log && env.log('first', tableName, filter);
return [4, select(env, tableName, filter)];
case 1:
items = _a.sent();
return [2, items.length ? items[0] : null];
}
});
});
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;
}
exports.first = first;
function select(env, tableName, filter) {
if (filter === void 0) { filter = {}; }
return __awaiter(this, void 0, void 0, function () {
var body, error, records;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
env.log && env.log('select', tableName, filter);
return [4, (0, node_fetch_1.default)(app(env.app) + tableName + '?' + query_string_1.default.stringify(filter), {
headers: headers(env.key),
}).then(function (r) { return r.json(); })];
case 1:
body = _a.sent();
error = body.error, records = body.records;
if (error) {
throw new Error(error.message);
}
if (records) {
return [2, records.map(unpack)];
}
console.error(body);
return [2, []];
}
});
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)
});
// TODO: Fix typings
const { records: records } = response.data;
if (records) return records.map($50ec0a944e93cc52$export$417857010dc9287f);
console.error(response.data);
return [];
}
exports.select = select;
function selectAll(env, tableName, filter, prepend) {
if (filter === void 0) { filter = {}; }
if (prepend === void 0) { prepend = []; }
return __awaiter(this, void 0, void 0, function () {
var body, error, offset, records;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
env.log && env.log('selectAll', tableName, filter, prepend.length);
return [4, (0, node_fetch_1.default)(app(env.app) + tableName + '?' + query_string_1.default.stringify(filter), {
headers: headers(env.key),
}).then(function (r) { return r.json(); })];
case 1:
body = _a.sent();
error = body.error, offset = body.offset, records = body.records;
if (error) {
throw new Error(error.message);
}
if (offset) {
return [2, selectAll(env, tableName, __assign(__assign({}, filter), { offset: offset }), prepend.concat(records))];
}
if (records) {
return [2, prepend.concat(records).map(unpack)];
}
console.error(body);
return [2, []];
}
});
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)
});
// TODO: Fix typings
const { offset: offset , records: records } = response.data;
if (offset) return $50ec0a944e93cc52$export$90aca4adda6ff0f5(env, tableName, {
...filter,
offset: offset
}, prepend.concat(records));
if (records) return prepend.concat(records).map($50ec0a944e93cc52$export$417857010dc9287f);
console.error(response.data);
return [];
}
exports.selectAll = selectAll;
function update(env, tableName, id, fields) {
return __awaiter(this, void 0, void 0, function () {
var body;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
env.log && env.log('update', tableName, fields);
return [4, (0, node_fetch_1.default)(app(env.app) + tableName + '/' + id, {
method: 'PATCH',
headers: headers(env.key),
body: JSON.stringify({ fields: fields }),
}).then(function (r) { return r.json(); })];
case 1:
body = _a.sent();
if (body.error) {
throw new Error(body.error.message);
}
return [2, unpack(body)];
}
});
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, {
method: 'PATCH',
headers: $50ec0a944e93cc52$export$838e2a576d4d6ff6(env.key),
data: {
fields: fields
}
});
return $50ec0a944e93cc52$export$417857010dc9287f(response.data);
}
exports.update = update;
function remove(env, tableName, id) {
return __awaiter(this, void 0, void 0, function () {
var body;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
env.log && env.log('remove', tableName, id);
return [4, (0, node_fetch_1.default)(app(env.app) + tableName + '/' + id, {
method: 'DELETE',
headers: headers(env.key),
}).then(function (r) { return r.json(); })];
case 1:
body = _a.sent();
if (body.error) {
throw new Error(body.error.message);
}
return [2, unpack(body)];
}
});
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, {
method: 'DELETE',
headers: $50ec0a944e93cc52$export$838e2a576d4d6ff6(env.key)
});
return $50ec0a944e93cc52$export$417857010dc9287f(response.data);
}
exports.remove = remove;
function pack(fields) {
function $50ec0a944e93cc52$export$2a703dbb0cb35339(fields) {
return {
id: fields._id,
fields: __assign(__assign({}, fields), { _id: null, createdTime: null }),
createdTime: fields.createdTime,
fields: {
...fields,
_id: null,
createdTime: null
},
createdTime: fields.createdTime
};
}
exports.pack = pack;
function unpack(_a) {
var _id = _a.id, fields = _a.fields, createdTime = _a.createdTime;
return __assign({ _id: _id, createdTime: createdTime }, fields);
function $50ec0a944e93cc52$export$417857010dc9287f({ id: _id , fields: fields , createdTime: createdTime }) {
return {
_id: _id,
createdTime: createdTime,
...fields
};
}
exports.unpack = unpack;
function byIds(ids) {
function $50ec0a944e93cc52$export$fe0a1c6c4b0676fe(ids) {
return {
filterByFormula: "OR(RECORD_ID()='" + ids.join("',RECORD_ID()='") + "')",
filterByFormula: "OR(RECORD_ID()='" + ids.join("',RECORD_ID()='") + "')"
};
}
exports.byIds = byIds;
function where(field, value) {
function $50ec0a944e93cc52$export$9c59b80dda569a6e(field, value) {
return {
filterByFormula: '{' + field + "}='" + value + "'",
filterByFormula: '{' + field + "}='" + value + "'"
};
}
exports.where = where;
var $1b4460891c9bbf9a$exports = {};
$parcel$exportWildcard(module.exports, $50ec0a944e93cc52$exports);
$parcel$exportWildcard(module.exports, $1b4460891c9bbf9a$exports);
//# sourceMappingURL=index.js.map
{
"name": "@bothrs/airtable",
"repository": "git@github.com:bothrs/open-source.git",
"version": "0.2.4",
"version": "0.3.0",
"source": "src/index.ts",
"main": "dist/index.js",
"module": "dist/index.js",
"module": "dist/module.js",
"types": "dist/types.d.ts",
"publishConfig": {

@@ -23,2 +25,6 @@ "access": "public"

"email": "info@thomasg.be"
},
{
"name": "Fabian Meul",
"email": "fabian@bothrs.com"
}

@@ -32,8 +38,10 @@ ],

"scripts": {
"build": "yarn build:clean && tsc",
"build:clean": "rimraf \"./dist\"",
"test": "jest --config=\"../../jest.config.js\" --roots=\"./packages/airtable/src\" --coverage --runInBand --passWithNoTests"
"watch": "parcel watch",
"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...\""
},
"peerDependencies": {
"node-fetch": "2.x",
"axios": "0.24.x",
"query-string": "7.x"

@@ -43,5 +51,6 @@ },

"@types/jest": "^27.0.2",
"axios": "^0.24.0",
"jest": "^27.2.4",
"jest-extended": "^0.11.5",
"node-fetch": "^3.0.0",
"parcel": "^2.0.0",
"query-string": "^7.0.1",

@@ -52,3 +61,3 @@ "rimraf": "^3.0.2",

},
"gitHead": "eaff8370a00f583fa6ae705b1cc954507a742744"
"gitHead": "36f6967961062ae97b3e867d9fb69e5e80f36dc2"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc