diff --git a/.npmrc b/.npmrc new file mode 100644 index 00000000..ce32e951 --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +@pariti:registry=https://europe-west2-npm.pkg.dev/platform-development-347309/pariti-platform-npm/ +//europe-west2-npm.pkg.dev/platform-development-347309/pariti-platform-npm/:always-auth=true diff --git a/build/airtable.browser.js b/build/airtable.browser.js index 74d3d106..862bd29b 100644 --- a/build/airtable.browser.js +++ b/build/airtable.browser.js @@ -445,7 +445,7 @@ module.exports = objectToQueryParamString; },{"lodash/isArray":79,"lodash/isNil":85,"lodash/keys":93}],12:[function(require,module,exports){ "use strict"; -module.exports = "0.11.6"; +module.exports = "0.11.6-pariti"; },{}],13:[function(require,module,exports){ "use strict"; @@ -608,6 +608,7 @@ function eachPage(pageCallback, done) { var records = result.records.map(function (recordJson) { return new record_1.default(_this._table, null, recordJson); }); + records.offset = result.offset; pageCallback(records, next); } }); @@ -653,7 +654,7 @@ exports.paramValidators = { filterByFormula: typecheck_1.default(isString_1.default, 'the value for `filterByFormula` should be a string'), maxRecords: typecheck_1.default(isNumber_1.default, 'the value for `maxRecords` should be a number'), pageSize: typecheck_1.default(isNumber_1.default, 'the value for `pageSize` should be a number'), - offset: typecheck_1.default(isNumber_1.default, 'the value for `offset` should be a number'), + offset: typecheck_1.default(isString_1.default, 'the value for `offset` should be a string'), sort: typecheck_1.default(typecheck_1.default.isArrayOf(function (obj) { return (isPlainObject_1.default(obj) && isString_1.default(obj.field) && diff --git a/package-lock.json b/package-lock.json index 5a78988b..f2111372 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "airtable", - "version": "0.11.5", + "version": "0.11.6", "license": "MIT", "dependencies": { "@types/node": ">=8.0.0 <15", diff --git a/package.json b/package.json index d2f339ae..23a58dfc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "airtable", - "version": "0.11.6", + "name": "@pariti/airtable", + "version": "0.11.6-pariti", "license": "MIT", "homepage": "https://github.com/airtable/airtable.js", "repository": "git://github.com/airtable/airtable.js.git", @@ -11,7 +11,8 @@ "format": "prettier --write '**/*.[j|t]s'", "test": "jest --env node --coverage --no-cache", "test-unit": "jest --env node", - "prepare": "rm -rf lib/* && rm -f build/airtable.browser.js && tsc && cp lib/airtable.js lib/tmp_airtable.js && grunt browserify && rm lib/tmp_airtable.js" + "prepare": "rm -rf lib/* && rm -f build/airtable.browser.js && tsc && cp lib/airtable.js lib/tmp_airtable.js && grunt browserify && rm lib/tmp_airtable.js", + "artifactregistry-login": "npx google-artifactregistry-auth" }, "dependencies": { "@types/node": ">=8.0.0 <15", diff --git a/src/query.ts b/src/query.ts index 7e2bccc3..629fd596 100644 --- a/src/query.ts +++ b/src/query.ts @@ -216,6 +216,7 @@ function eachPage( const records = result.records.map(recordJson => { return new Record(this._table, null, recordJson); }); + records.offset = result.offset; pageCallback(records, next); } diff --git a/src/query_params.ts b/src/query_params.ts index 447dd2ec..be92b1e4 100644 --- a/src/query_params.ts +++ b/src/query_params.ts @@ -16,7 +16,7 @@ export const paramValidators = { pageSize: check(isNumber, 'the value for `pageSize` should be a number'), - offset: check(isNumber, 'the value for `offset` should be a number'), + offset: check(isString, 'the value for `offset` should be a string'), sort: check( check.isArrayOf((obj): obj is {field: string; direction?: 'asc' | 'desc'} => { @@ -67,7 +67,7 @@ export interface QueryParams { filterByFormula?: string; maxRecords?: number; pageSize?: number; - offset?: number; + offset?: string; sort?: SortParameter[]; view?: string; cellFormat?: 'json' | 'string'; diff --git a/src/records.ts b/src/records.ts index b375f866..eb7111ee 100644 --- a/src/records.ts +++ b/src/records.ts @@ -1,4 +1,13 @@ import Record from './record'; import {FieldSet} from './field_set'; -export type Records = ReadonlyArray>; +export interface ResultMetadata { + offset: string +} + +/** + * Note: This type is used as the result of queries, but did not originally contain metadata such as the offset field + * required for pagination. We've kept the array type here for compatibility but somewhat hackily annotated it with + * additional properties. + */ +export type Records = ReadonlyArray> & ResultMetadata; diff --git a/test/test_files/airtable.browser.js b/test/test_files/airtable.browser.js index 74d3d106..515e85f7 100644 --- a/test/test_files/airtable.browser.js +++ b/test/test_files/airtable.browser.js @@ -608,6 +608,7 @@ function eachPage(pageCallback, done) { var records = result.records.map(function (recordJson) { return new record_1.default(_this._table, null, recordJson); }); + records.offset = result.offset; pageCallback(records, next); } }); @@ -653,7 +654,7 @@ exports.paramValidators = { filterByFormula: typecheck_1.default(isString_1.default, 'the value for `filterByFormula` should be a string'), maxRecords: typecheck_1.default(isNumber_1.default, 'the value for `maxRecords` should be a number'), pageSize: typecheck_1.default(isNumber_1.default, 'the value for `pageSize` should be a number'), - offset: typecheck_1.default(isNumber_1.default, 'the value for `offset` should be a number'), + offset: typecheck_1.default(isString_1.default, 'the value for `offset` should be a string'), sort: typecheck_1.default(typecheck_1.default.isArrayOf(function (obj) { return (isPlainObject_1.default(obj) && isString_1.default(obj.field) &&