Socket
Socket
Sign inDemoInstall

airtable

Package Overview
Dependencies
Maintainers
13
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

airtable - npm Package Compare versions

Comparing version 0.11.4 to 0.11.5

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# v0.11.5
* Update select() and list() to support to use POST endpoint when GET url length would exceed Airtable's 16k character limit
* Update select() and list() to explicitly choose to use GET or POST endpoint via new 'method' arg
# v0.11.4

@@ -2,0 +6,0 @@ * Add support for returnFieldsByFieldId param.

@@ -65,2 +65,8 @@ export declare const paramValidators: {

};
method: (value: "string" | "json") => {
pass: true;
} | {
pass: false;
error: string;
};
returnFieldsByFieldId: (value: boolean) => {

@@ -73,2 +79,4 @@ pass: true;

};
export declare const URL_CHARACTER_LENGTH_LIMIT = 15000;
export declare const shouldListRecordsParamBePassedAsParameter: (paramName: string) => boolean;
export interface SortParameter<TFields> {

@@ -89,3 +97,4 @@ field: keyof TFields;

userLocale?: string;
method?: string;
returnFieldsByFieldId?: boolean;
}

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.paramValidators = void 0;
exports.shouldListRecordsParamBePassedAsParameter = exports.URL_CHARACTER_LENGTH_LIMIT = exports.paramValidators = void 0;
var typecheck_1 = __importDefault(require("./typecheck"));

@@ -32,4 +32,11 @@ var isString_1 = __importDefault(require("lodash/isString"));

userLocale: typecheck_1.default(isString_1.default, 'the value for `userLocale` should be a string'),
method: typecheck_1.default(function (method) {
return isString_1.default(method) && ['get', 'post'].includes(method);
}, 'the value for `method` should be "get" or "post"'),
returnFieldsByFieldId: typecheck_1.default(isBoolean_1.default, 'the value for `returnFieldsByFieldId` should be a boolean'),
};
exports.URL_CHARACTER_LENGTH_LIMIT = 15000;
exports.shouldListRecordsParamBePassedAsParameter = function (paramName) {
return paramName === 'timeZone' || paramName === 'userLocale';
};
//# sourceMappingURL=query_params.js.map

@@ -94,2 +94,8 @@ import Table from './table';

};
method: (value: "string" | "json") => {
pass: true;
} | {
pass: false;
error: string;
};
returnFieldsByFieldId: (value: boolean) => {

@@ -96,0 +102,0 @@ pass: true;

@@ -22,2 +22,3 @@ "use strict";

var query_params_1 = require("./query_params");
var object_to_query_param_string_1 = __importDefault(require("./object_to_query_param_string"));
/**

@@ -110,6 +111,36 @@ * Builds a query object. Won't fetch until `firstPage` or

}
var path = "/" + this._table._urlEncodedNameOrId();
var params = __assign({}, this._params);
var pathAndParamsAsString = "/" + this._table._urlEncodedNameOrId() + "?" + object_to_query_param_string_1.default(params);
var queryParams = {};
var requestData = null;
var method;
var path;
if (params.method === 'post' || pathAndParamsAsString.length > query_params_1.URL_CHARACTER_LENGTH_LIMIT) {
// There is a 16kb limit on GET requests. Since the URL makes up nearly all of the request size, we check for any requests that
// that come close to this limit and send it as a POST instead. Additionally, we'll send the request as a post if it is specified
// with the request params
requestData = params;
method = 'post';
path = "/" + this._table._urlEncodedNameOrId() + "/listRecords";
var paramNames = Object.keys(params);
for (var _i = 0, paramNames_1 = paramNames; _i < paramNames_1.length; _i++) {
var paramName = paramNames_1[_i];
if (query_params_1.shouldListRecordsParamBePassedAsParameter(paramName)) {
// timeZone and userLocale is parsed from the GET request separately from the other params. This parsing
// does not occurring within the body parser we use for POST requests, so this will still need to be passed
// via query params
queryParams[paramName] = params[paramName];
}
else {
requestData[paramName] = params[paramName];
}
}
}
else {
method = 'get';
queryParams = params;
path = "/" + this._table._urlEncodedNameOrId();
}
var inner = function () {
_this._table._base.runAction('get', path, params, null, function (err, response, result) {
_this._table._base.runAction(method, path, queryParams, requestData, function (err, response, result) {
if (err) {

@@ -116,0 +147,0 @@ done(err, null);

3

lib/table.d.ts

@@ -13,2 +13,3 @@ import Query from './query';

typecast?: boolean;
method?: 'get' | 'post';
};

@@ -78,5 +79,5 @@ declare type RecordCollectionCallback<TFields extends FieldSet> = (error: TableError, records?: Records<TFields>) => void;

_destroyRecord(recordIds: string[], done: RecordCollectionCallback<TFields>): void;
_listRecords(limit: number, offset: number, opts: OptionalParameters | RecordListCallback<TFields>, done?: RecordListCallback<TFields>): void;
_listRecords(pageSize: number, offset: number, opts: OptionalParameters | RecordListCallback<TFields>, done?: RecordListCallback<TFields>): void;
_forEachRecord(opts: OptionalParameters, callback: RecordForEachCallback<TFields>, done: RecordForEachDoneCallback): void;
}
export = Table;

@@ -19,2 +19,4 @@ "use strict";

var query_1 = __importDefault(require("./query"));
var query_params_1 = require("./query_params");
var object_to_query_param_string_1 = __importDefault(require("./object_to_query_param_string"));
var record_1 = __importDefault(require("./record"));

@@ -158,3 +160,3 @@ var callback_to_promise_1 = __importDefault(require("./callback_to_promise"));

};
Table.prototype._listRecords = function (limit, offset, opts, done) {
Table.prototype._listRecords = function (pageSize, offset, opts, done) {
var _this = this;

@@ -165,5 +167,32 @@ if (!done) {

}
var listRecordsParameters = __assign({ limit: limit,
offset: offset }, opts);
this._base.runAction('get', "/" + this._urlEncodedNameOrId() + "/", listRecordsParameters, null, function (err, response, results) {
var pathAndParamsAsString = "/" + this._urlEncodedNameOrId() + "?" + object_to_query_param_string_1.default(opts);
var path;
var listRecordsParameters = {};
var listRecordsData = null;
var method;
if ((typeof opts !== 'function' && opts.method === 'post') ||
pathAndParamsAsString.length > query_params_1.URL_CHARACTER_LENGTH_LIMIT) {
// // There is a 16kb limit on GET requests. Since the URL makes up nearly all of the request size, we check for any requests that
// that come close to this limit and send it as a POST instead. Additionally, we'll send the request as a post if it is specified
// with the request params
path = "/" + this._urlEncodedNameOrId() + "/listRecords";
listRecordsData = __assign(__assign({}, (pageSize && { pageSize: pageSize })), (offset && { offset: offset }));
method = 'post';
var paramNames = Object.keys(opts);
for (var _i = 0, paramNames_1 = paramNames; _i < paramNames_1.length; _i++) {
var paramName = paramNames_1[_i];
if (query_params_1.shouldListRecordsParamBePassedAsParameter(paramName)) {
listRecordsParameters[paramName] = opts[paramName];
}
else {
listRecordsData[paramName] = opts[paramName];
}
}
}
else {
method = 'get';
path = "/" + this._urlEncodedNameOrId() + "/";
listRecordsParameters = __assign({ limit: pageSize, offset: offset }, opts);
}
this._base.runAction(method, path, listRecordsParameters, listRecordsData, function (err, response, results) {
if (err) {

@@ -170,0 +199,0 @@ done(err);

{
"name": "airtable",
"version": "0.11.4",
"version": "0.11.5",
"license": "MIT",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/airtable/airtable.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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

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