@airtable/blocks 1.9.0 → 1.10.2-experimental-640bd10-20220211
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -1
- package/dist/cjs/error_utils.js +44 -2
- package/dist/cjs/models/base.js +2 -1
- package/dist/cjs/models/cursor.js +2 -0
- package/dist/cjs/models/field.js +3 -13
- package/dist/cjs/models/grouped_record_query_result.js +5 -14
- package/dist/cjs/models/linked_records_query_result.js +78 -27
- package/dist/cjs/models/mutations.js +18 -162
- package/dist/cjs/models/query_manager.js +328 -0
- package/dist/cjs/models/record.js +311 -56
- package/dist/cjs/models/record_query_result.js +4 -1
- package/dist/cjs/models/record_store.js +557 -765
- package/dist/cjs/models/table.js +9 -8
- package/dist/cjs/models/table_or_view_query_result.js +526 -419
- package/dist/cjs/models/view.js +1 -1
- package/dist/cjs/models/view_data_store.js +255 -295
- package/dist/cjs/private_utils.js +40 -0
- package/dist/cjs/sdk.js +12 -2
- package/dist/cjs/testing/abstract_mock_airtable_interface.js +57 -11
- package/dist/cjs/testing/fixture_data.js +268 -0
- package/dist/cjs/testing/mock_base_data_stores.js +876 -0
- package/dist/cjs/types/airtable_interface.js +17 -2
- package/dist/cjs/types/block_query_spec.js +85 -0
- package/dist/cjs/ui/icon_config.js +4 -2
- package/dist/cjs/ui/use_global_config.js +1 -1
- package/dist/cjs/ui/use_records.js +5 -1
- package/dist/cjs/unstable_testing_utils.js +55 -1
- package/dist/cjs/watchable.js +15 -1
- package/dist/types/src/error_utils.d.ts +6 -0
- package/dist/types/src/error_utils.d.ts.map +1 -1
- package/dist/types/src/models/base.d.ts +2 -1
- package/dist/types/src/models/base.d.ts.map +1 -1
- package/dist/types/src/models/cursor.d.ts +2 -0
- package/dist/types/src/models/cursor.d.ts.map +1 -1
- package/dist/types/src/models/field.d.ts +3 -13
- package/dist/types/src/models/field.d.ts.map +1 -1
- package/dist/types/src/models/grouped_record_query_result.d.ts +3 -3
- package/dist/types/src/models/grouped_record_query_result.d.ts.map +1 -1
- package/dist/types/src/models/linked_records_query_result.d.ts.map +1 -1
- package/dist/types/src/models/mutations.d.ts.map +1 -1
- package/dist/types/src/models/query_manager.d.ts +2 -0
- package/dist/types/src/models/query_manager.d.ts.map +1 -0
- package/dist/types/src/models/record.d.ts +13 -4
- package/dist/types/src/models/record.d.ts.map +1 -1
- package/dist/types/src/models/record_query_result.d.ts +3 -2
- package/dist/types/src/models/record_query_result.d.ts.map +1 -1
- package/dist/types/src/models/record_store.d.ts.map +1 -1
- package/dist/types/src/models/table.d.ts +3 -2
- package/dist/types/src/models/table.d.ts.map +1 -1
- package/dist/types/src/models/table_or_view_query_result.d.ts +3 -5
- package/dist/types/src/models/table_or_view_query_result.d.ts.map +1 -1
- package/dist/types/src/models/view.d.ts +1 -1
- package/dist/types/src/models/view_data_store.d.ts +0 -1
- package/dist/types/src/models/view_data_store.d.ts.map +1 -1
- package/dist/types/src/models/view_metadata_query_result.d.ts +1 -1
- package/dist/types/src/models/view_metadata_query_result.d.ts.map +1 -1
- package/dist/types/src/private_utils.d.ts +26 -3
- package/dist/types/src/private_utils.d.ts.map +1 -1
- package/dist/types/src/sdk.d.ts.map +1 -1
- package/dist/types/src/testing/abstract_mock_airtable_interface.d.ts +11 -11
- package/dist/types/src/testing/abstract_mock_airtable_interface.d.ts.map +1 -1
- package/dist/types/{test/airtable_interface_mocks → src/testing}/fixture_data.d.ts +42 -19
- package/dist/types/src/testing/fixture_data.d.ts.map +1 -0
- package/dist/types/src/testing/mock_base_data_stores.d.ts +55 -0
- package/dist/types/src/testing/mock_base_data_stores.d.ts.map +1 -0
- package/dist/types/src/types/airtable_interface.d.ts +59 -20
- package/dist/types/src/types/airtable_interface.d.ts.map +1 -1
- package/dist/types/src/types/block_query_spec.d.ts +139 -0
- package/dist/types/src/types/block_query_spec.d.ts.map +1 -0
- package/dist/types/src/types/field.d.ts +7 -1
- package/dist/types/src/types/field.d.ts.map +1 -1
- package/dist/types/src/types/table.d.ts +0 -2
- package/dist/types/src/types/table.d.ts.map +1 -1
- package/dist/types/src/types/view.d.ts +3 -8
- package/dist/types/src/types/view.d.ts.map +1 -1
- package/dist/types/src/ui/icon_config.d.ts +5 -3
- package/dist/types/src/ui/icon_config.d.ts.map +1 -1
- package/dist/types/src/ui/link.d.ts +1 -1
- package/dist/types/src/ui/link.d.ts.map +1 -1
- package/dist/types/src/ui/record_card.d.ts +1 -1
- package/dist/types/src/ui/use_global_config.d.ts +1 -1
- package/dist/types/src/unstable_testing_utils.d.ts +4 -1
- package/dist/types/src/unstable_testing_utils.d.ts.map +1 -1
- package/dist/types/src/watchable.d.ts.map +1 -1
- package/dist/types/test/airtable_interface_mocks/linked_records.d.ts +1 -1
- package/dist/types/test/airtable_interface_mocks/linked_records.d.ts.map +1 -1
- package/dist/types/test/airtable_interface_mocks/mock_airtable_interface.d.ts +19 -12
- package/dist/types/test/airtable_interface_mocks/mock_airtable_interface.d.ts.map +1 -1
- package/dist/types/test/airtable_interface_mocks/project_tracker.d.ts +1 -1
- package/dist/types/test/airtable_interface_mocks/project_tracker.d.ts.map +1 -1
- package/dist/types/test/test_helpers.d.ts +2 -0
- package/dist/types/test/test_helpers.d.ts.map +1 -1
- package/dist/types/test/testing/fixture_data.test.d.ts +2 -0
- package/dist/types/test/testing/fixture_data.test.d.ts.map +1 -0
- package/package.json +3 -2
- package/dist/types/test/airtable_interface_mocks/fixture_data.d.ts.map +0 -1
|
@@ -12,6 +12,8 @@ require("core-js/modules/es.array.concat");
|
|
|
12
12
|
|
|
13
13
|
require("core-js/modules/es.array.filter");
|
|
14
14
|
|
|
15
|
+
require("core-js/modules/es.array.includes");
|
|
16
|
+
|
|
15
17
|
require("core-js/modules/es.array.iterator");
|
|
16
18
|
|
|
17
19
|
require("core-js/modules/es.array.map");
|
|
@@ -24,6 +26,8 @@ require("core-js/modules/es.promise");
|
|
|
24
26
|
|
|
25
27
|
require("core-js/modules/es.set");
|
|
26
28
|
|
|
29
|
+
require("core-js/modules/es.string.includes");
|
|
30
|
+
|
|
27
31
|
require("core-js/modules/es.string.starts-with");
|
|
28
32
|
|
|
29
33
|
require("core-js/modules/web.dom-collections.for-each");
|
|
@@ -59,8 +63,14 @@ var _private_utils = require("../private_utils");
|
|
|
59
63
|
|
|
60
64
|
var _error_utils = require("../error_utils");
|
|
61
65
|
|
|
66
|
+
var _airtable_interface = require("../types/airtable_interface");
|
|
67
|
+
|
|
68
|
+
var _block_query_spec = require("../types/block_query_spec");
|
|
69
|
+
|
|
62
70
|
var _table = _interopRequireWildcard(require("./table"));
|
|
63
71
|
|
|
72
|
+
var _view = _interopRequireDefault(require("./view"));
|
|
73
|
+
|
|
64
74
|
var _record_query_result = _interopRequireDefault(require("./record_query_result"));
|
|
65
75
|
|
|
66
76
|
var _record_coloring = require("./record_coloring");
|
|
@@ -97,6 +107,17 @@ function (_RecordQueryResult) {
|
|
|
97
107
|
|
|
98
108
|
/** @internal */
|
|
99
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Tracks a unique ID for each model query that has been loaded.
|
|
112
|
+
* Note that hyperbase may return a new model query ID even if the
|
|
113
|
+
* query itself is identical to a previous one. Having these unique
|
|
114
|
+
* IDs allows the SDK to maintain an accurate reference count of
|
|
115
|
+
* all model loads. _loadedSourceModelQueryIds must only be updated
|
|
116
|
+
* before unloading occurs.
|
|
117
|
+
*
|
|
118
|
+
* @internal
|
|
119
|
+
*/
|
|
120
|
+
|
|
100
121
|
/** @internal */
|
|
101
122
|
|
|
102
123
|
/** @internal */
|
|
@@ -124,17 +145,6 @@ function (_RecordQueryResult) {
|
|
|
124
145
|
/** @internal */
|
|
125
146
|
// lazily generated set of record ids
|
|
126
147
|
|
|
127
|
-
/** @internal */
|
|
128
|
-
// NOTE: when a cellValue key (cellValues or cellValuesInField:) is watched, we want
|
|
129
|
-
// to make sure we watch the associated key on the table. However, we need to make
|
|
130
|
-
// sure that we only watch the table once for each key. Otherwise, the callbacks
|
|
131
|
-
// for each key will get called more than once for each change event. This is because
|
|
132
|
-
// Watchable stores references to callbacks for each key, and on each _onChange event
|
|
133
|
-
// calls each callback for that key. If we watch the table more than once, then we'll
|
|
134
|
-
// call _onChange more than once, and each callback will be called more than once, which
|
|
135
|
-
// is undesirable. Instead, we'll store watch counts for each key to make sure we only
|
|
136
|
-
// watch the table once.
|
|
137
|
-
|
|
138
148
|
/** @internal */
|
|
139
149
|
|
|
140
150
|
/** @internal */
|
|
@@ -146,7 +156,8 @@ function (_RecordQueryResult) {
|
|
|
146
156
|
(0, _classCallCheck2.default)(this, TableOrViewQueryResult);
|
|
147
157
|
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(TableOrViewQueryResult).call(this, sdk, normalizedOpts));
|
|
148
158
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_sourceModel", void 0);
|
|
149
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "
|
|
159
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_mostRecentSourceModelLoadedPromise", void 0);
|
|
160
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_loadedSourceModelQueryIds", void 0);
|
|
150
161
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_table", void 0);
|
|
151
162
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_fieldIdsSetToLoadOrNullIfAllFields", void 0);
|
|
152
163
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_visList", void 0);
|
|
@@ -156,10 +167,156 @@ function (_RecordQueryResult) {
|
|
|
156
167
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_orderedGroups", void 0);
|
|
157
168
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_loadedGroupLevels", void 0);
|
|
158
169
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_recordIdsSet", null);
|
|
159
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_cellValueKeyWatchCounts", void 0);
|
|
160
170
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "__groupedRecordQueryResultPool", void 0);
|
|
171
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_watchConfigByWatchableKey", {
|
|
172
|
+
// Handles if this is a prefix
|
|
173
|
+
[_record_query_result.default.WatchableCellValuesInFieldKeyPrefix]: (key, _ref) => {
|
|
174
|
+
var callOnRecordStoreWithKey = _ref.callOnRecordStoreWithKey;
|
|
175
|
+
var fieldId = key.substring(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix.length);
|
|
176
|
+
|
|
177
|
+
if (_this._fieldIdsSetToLoadOrNullIfAllFields && !(0, _private_utils.has)(_this._fieldIdsSetToLoadOrNullIfAllFields, fieldId)) {
|
|
178
|
+
throw (0, _error_utils.spawnError)("Can't watch or unwatch field because it wasn't included in RecordQueryResult fields: %s", fieldId);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
callOnRecordStoreWithKey(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId);
|
|
182
|
+
},
|
|
183
|
+
[_record_query_result.default.WatchableKeys.cellValues]: (key, _ref2) => {
|
|
184
|
+
var callOnRecordStoreWithKey = _ref2.callOnRecordStoreWithKey;
|
|
185
|
+
|
|
186
|
+
if (_this._fieldIdsSetToLoadOrNullIfAllFields) {
|
|
187
|
+
for (var _i = 0, _Object$keys = Object.keys(_this._fieldIdsSetToLoadOrNullIfAllFields); _i < _Object$keys.length; _i++) {
|
|
188
|
+
var fieldId = _Object$keys[_i];
|
|
189
|
+
callOnRecordStoreWithKey(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId);
|
|
190
|
+
}
|
|
191
|
+
} else {
|
|
192
|
+
callOnRecordStoreWithKey(_record_query_result.default.WatchableKeys.cellValues);
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
[_record_query_result.default.WatchableKeys.groupLevels]: (key, _ref3) => {
|
|
196
|
+
var callOnViewDataStoreWithKey = _ref3.callOnViewDataStoreWithKey;
|
|
197
|
+
callOnViewDataStoreWithKey(_view_data_store.WatchableViewDataStoreKeys.groupLevels);
|
|
198
|
+
},
|
|
199
|
+
[_record_query_result.default.WatchableKeys.groups]: (key, _ref4) => {
|
|
200
|
+
var callOnViewDataStoreWithKey = _ref4.callOnViewDataStoreWithKey;
|
|
201
|
+
callOnViewDataStoreWithKey(_view_data_store.WatchableViewDataStoreKeys.groups);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_unloadDataAsync", () => {
|
|
205
|
+
var viewDataStore, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, sort, field;
|
|
206
|
+
|
|
207
|
+
return _regenerator.default.async(function _callee$(_context) {
|
|
208
|
+
while (1) {
|
|
209
|
+
switch (_context.prev = _context.next) {
|
|
210
|
+
case 0:
|
|
211
|
+
if (!_this._mostRecentSourceModelLoadedPromise) {
|
|
212
|
+
_context.next = 3;
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
_context.next = 3;
|
|
217
|
+
return _regenerator.default.awrap(_this._mostRecentSourceModelLoadedPromise);
|
|
218
|
+
|
|
219
|
+
case 3:
|
|
220
|
+
// Unload all queries that were subscribed to the entire query
|
|
221
|
+
if (_this._sourceModel instanceof _table.default) {
|
|
222
|
+
_this._recordStore.unloadCellValuesForQueryIdsThatAreSubscribedToAllCells(_this._loadedSourceModelQueryIds);
|
|
223
|
+
} else {
|
|
224
|
+
// Even if the view is deleted, we can still unsubscribe from the cells
|
|
225
|
+
_this._recordStore.unloadViewDataStoreAndCellValuesWithQueryIds(_this._loadedSourceModelQueryIds);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
_this._mostRecentSourceModelLoadedPromise = null;
|
|
229
|
+
|
|
230
|
+
if (_this._sourceModel instanceof _table.default) {
|
|
231
|
+
_this._recordStore.unwatch(_record_store.WatchableRecordStoreKeys.records, _this._onRecordsChanged, (0, _assertThisInitialized2.default)(_this));
|
|
232
|
+
} else {
|
|
233
|
+
if (!_this._sourceModel.isDeleted) {
|
|
234
|
+
viewDataStore = _this._recordStore.getViewDataStore(_this._sourceModel.id);
|
|
235
|
+
viewDataStore.unwatch(_view_data_store.WatchableViewDataStoreKeys.visibleRecords, _this._onRecordsChanged, (0, _assertThisInitialized2.default)(_this));
|
|
236
|
+
viewDataStore.unwatch(_view_data_store.WatchableViewDataStoreKeys.groups, _this._onGroupsChanged, (0, _assertThisInitialized2.default)(_this));
|
|
237
|
+
viewDataStore.unwatch(_view_data_store.WatchableViewDataStoreKeys.groupLevels, _this._onGroupLevelsChanged, (0, _assertThisInitialized2.default)(_this));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
_this._recordStore.unwatch(_this._cellValuesForSortWatchKeys, _this._onCellValuesForSortChanged, (0, _assertThisInitialized2.default)(_this));
|
|
242
|
+
|
|
243
|
+
_this._recordStore.unwatch(_this._cellValuesForGroupWatchKeys, _this._onCellValuesForGroupChanged, (0, _assertThisInitialized2.default)(_this));
|
|
244
|
+
|
|
245
|
+
_this._table.unwatch(_table.WatchableTableKeys.fields, _this._onTableFieldsChanged, (0, _assertThisInitialized2.default)(_this)); // If the table is deleted, can't call getFieldById on it below.
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
if (!(!_this._table.isDeleted && _this._sorts)) {
|
|
249
|
+
_context.next = 29;
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
_iteratorNormalCompletion = true;
|
|
254
|
+
_didIteratorError = false;
|
|
255
|
+
_iteratorError = undefined;
|
|
256
|
+
_context.prev = 13;
|
|
257
|
+
|
|
258
|
+
for (_iterator = _this._sorts[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
259
|
+
sort = _step.value;
|
|
260
|
+
field = _this._table.getFieldByIdIfExists(sort.fieldId);
|
|
261
|
+
|
|
262
|
+
if (field) {
|
|
263
|
+
field.unwatch('type', _this._onFieldConfigChanged, (0, _assertThisInitialized2.default)(_this));
|
|
264
|
+
field.unwatch('options', _this._onFieldConfigChanged, (0, _assertThisInitialized2.default)(_this));
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
_context.next = 21;
|
|
269
|
+
break;
|
|
270
|
+
|
|
271
|
+
case 17:
|
|
272
|
+
_context.prev = 17;
|
|
273
|
+
_context.t0 = _context["catch"](13);
|
|
274
|
+
_didIteratorError = true;
|
|
275
|
+
_iteratorError = _context.t0;
|
|
276
|
+
|
|
277
|
+
case 21:
|
|
278
|
+
_context.prev = 21;
|
|
279
|
+
_context.prev = 22;
|
|
280
|
+
|
|
281
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
282
|
+
_iterator.return();
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
case 24:
|
|
286
|
+
_context.prev = 24;
|
|
287
|
+
|
|
288
|
+
if (!_didIteratorError) {
|
|
289
|
+
_context.next = 27;
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
throw _iteratorError;
|
|
294
|
+
|
|
295
|
+
case 27:
|
|
296
|
+
return _context.finish(24);
|
|
297
|
+
|
|
298
|
+
case 28:
|
|
299
|
+
return _context.finish(21);
|
|
300
|
+
|
|
301
|
+
case 29:
|
|
302
|
+
_this._unloadOrderedGroupsIfNeeded();
|
|
303
|
+
|
|
304
|
+
_this._visList = null;
|
|
305
|
+
_this._orderedRecordIds = null;
|
|
306
|
+
_this._recordIdsSet = null;
|
|
307
|
+
|
|
308
|
+
_this._table.__tableOrViewQueryResultPool.unregisterObjectForReuseStrong((0, _assertThisInitialized2.default)(_this));
|
|
309
|
+
|
|
310
|
+
case 34:
|
|
311
|
+
case "end":
|
|
312
|
+
return _context.stop();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}, null, null, [[13, 17, 21, 29], [22,, 24, 28]]);
|
|
316
|
+
});
|
|
161
317
|
_this._sourceModel = sourceModel;
|
|
162
|
-
_this.
|
|
318
|
+
_this._mostRecentSourceModelLoadedPromise = null;
|
|
319
|
+
_this._loadedSourceModelQueryIds = [];
|
|
163
320
|
_this._table = normalizedOpts.table;
|
|
164
321
|
var sorts = _this._normalizedOpts.sorts;
|
|
165
322
|
_this._sorts = sorts !== null && sorts !== void 0 ? sorts : null; // TODO (SeanKeenan): Placeholder until we support groups from normalizedOpts
|
|
@@ -169,58 +326,57 @@ function (_RecordQueryResult) {
|
|
|
169
326
|
_this._orderedRecordIds = null;
|
|
170
327
|
_this._orderedGroups = null;
|
|
171
328
|
_this._loadedGroupLevels = null;
|
|
172
|
-
_this._cellValueKeyWatchCounts = {};
|
|
173
329
|
var fieldIdsSetToLoadOrNullIfAllFields = null;
|
|
174
330
|
|
|
175
331
|
if (_this._normalizedOpts.fieldIdsOrNullIfAllFields) {
|
|
176
332
|
fieldIdsSetToLoadOrNullIfAllFields = {};
|
|
177
|
-
var
|
|
178
|
-
var
|
|
179
|
-
var
|
|
333
|
+
var _iteratorNormalCompletion2 = true;
|
|
334
|
+
var _didIteratorError2 = false;
|
|
335
|
+
var _iteratorError2 = undefined;
|
|
180
336
|
|
|
181
337
|
try {
|
|
182
|
-
for (var
|
|
183
|
-
var fieldId =
|
|
338
|
+
for (var _iterator2 = _this._normalizedOpts.fieldIdsOrNullIfAllFields[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
339
|
+
var fieldId = _step2.value;
|
|
184
340
|
fieldIdsSetToLoadOrNullIfAllFields[fieldId] = true;
|
|
185
341
|
} // Need to load data for fields we're sorting by, even if
|
|
186
342
|
// they're not explicitly requested in the `fields` opt.
|
|
187
343
|
|
|
188
344
|
} catch (err) {
|
|
189
|
-
|
|
190
|
-
|
|
345
|
+
_didIteratorError2 = true;
|
|
346
|
+
_iteratorError2 = err;
|
|
191
347
|
} finally {
|
|
192
348
|
try {
|
|
193
|
-
if (!
|
|
194
|
-
|
|
349
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
350
|
+
_iterator2.return();
|
|
195
351
|
}
|
|
196
352
|
} finally {
|
|
197
|
-
if (
|
|
198
|
-
throw
|
|
353
|
+
if (_didIteratorError2) {
|
|
354
|
+
throw _iteratorError2;
|
|
199
355
|
}
|
|
200
356
|
}
|
|
201
357
|
}
|
|
202
358
|
|
|
203
359
|
if (_this._sorts !== null) {
|
|
204
|
-
var
|
|
205
|
-
var
|
|
206
|
-
var
|
|
360
|
+
var _iteratorNormalCompletion3 = true;
|
|
361
|
+
var _didIteratorError3 = false;
|
|
362
|
+
var _iteratorError3 = undefined;
|
|
207
363
|
|
|
208
364
|
try {
|
|
209
|
-
for (var
|
|
210
|
-
var sort =
|
|
365
|
+
for (var _iterator3 = _this._sorts[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
366
|
+
var sort = _step3.value;
|
|
211
367
|
fieldIdsSetToLoadOrNullIfAllFields[sort.fieldId] = true;
|
|
212
368
|
}
|
|
213
369
|
} catch (err) {
|
|
214
|
-
|
|
215
|
-
|
|
370
|
+
_didIteratorError3 = true;
|
|
371
|
+
_iteratorError3 = err;
|
|
216
372
|
} finally {
|
|
217
373
|
try {
|
|
218
|
-
if (!
|
|
219
|
-
|
|
374
|
+
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
375
|
+
_iterator3.return();
|
|
220
376
|
}
|
|
221
377
|
} finally {
|
|
222
|
-
if (
|
|
223
|
-
throw
|
|
378
|
+
if (_didIteratorError3) {
|
|
379
|
+
throw _iteratorError3;
|
|
224
380
|
}
|
|
225
381
|
}
|
|
226
382
|
}
|
|
@@ -260,26 +416,26 @@ function (_RecordQueryResult) {
|
|
|
260
416
|
value: function _getOrGenerateRecordIdsSet() {
|
|
261
417
|
if (!this._recordIdsSet) {
|
|
262
418
|
var recordIdsSet = {};
|
|
263
|
-
var
|
|
264
|
-
var
|
|
265
|
-
var
|
|
419
|
+
var _iteratorNormalCompletion4 = true;
|
|
420
|
+
var _didIteratorError4 = false;
|
|
421
|
+
var _iteratorError4 = undefined;
|
|
266
422
|
|
|
267
423
|
try {
|
|
268
|
-
for (var
|
|
269
|
-
var recordId =
|
|
424
|
+
for (var _iterator4 = this.recordIds[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
|
425
|
+
var recordId = _step4.value;
|
|
270
426
|
recordIdsSet[recordId] = true;
|
|
271
427
|
}
|
|
272
428
|
} catch (err) {
|
|
273
|
-
|
|
274
|
-
|
|
429
|
+
_didIteratorError4 = true;
|
|
430
|
+
_iteratorError4 = err;
|
|
275
431
|
} finally {
|
|
276
432
|
try {
|
|
277
|
-
if (!
|
|
278
|
-
|
|
433
|
+
if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
|
|
434
|
+
_iterator4.return();
|
|
279
435
|
}
|
|
280
436
|
} finally {
|
|
281
|
-
if (
|
|
282
|
-
throw
|
|
437
|
+
if (_didIteratorError4) {
|
|
438
|
+
throw _iteratorError4;
|
|
283
439
|
}
|
|
284
440
|
}
|
|
285
441
|
}
|
|
@@ -296,85 +452,72 @@ function (_RecordQueryResult) {
|
|
|
296
452
|
*/
|
|
297
453
|
|
|
298
454
|
}, {
|
|
299
|
-
key: "
|
|
300
|
-
|
|
301
|
-
/** @internal */
|
|
302
|
-
value: function _incrementCellValueKeyWatchCountAndWatchIfNecessary(key, watchCallback) {
|
|
303
|
-
if (!this._cellValueKeyWatchCounts[key]) {
|
|
304
|
-
this._cellValueKeyWatchCounts[key] = 0;
|
|
305
|
-
|
|
306
|
-
this._recordStore.watch(key, watchCallback, this);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
this._cellValueKeyWatchCounts[key]++;
|
|
310
|
-
}
|
|
311
|
-
/** @internal */
|
|
312
|
-
|
|
313
|
-
}, {
|
|
314
|
-
key: "_decrementCellValueKeyWatchCountAndUnwatchIfPossible",
|
|
315
|
-
value: function _decrementCellValueKeyWatchCountAndUnwatchIfPossible(key, watchCallback) {
|
|
316
|
-
if (!this._cellValueKeyWatchCounts[key]) {
|
|
317
|
-
// Key isn't watched, so just skip it. This matches behavior of Watchable,
|
|
318
|
-
// where calling unwatch on a key that isn't watched just no-ops.
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
this._cellValueKeyWatchCounts[key]--;
|
|
323
|
-
|
|
324
|
-
if (this._cellValueKeyWatchCounts[key] === 0) {
|
|
325
|
-
// We're down to zero watches for this key, so we can actually unwatch it now.
|
|
326
|
-
this._recordStore.unwatch(key, watchCallback, this);
|
|
455
|
+
key: "watch",
|
|
327
456
|
|
|
328
|
-
delete this._cellValueKeyWatchCounts[key];
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
457
|
/** @inheritdoc */
|
|
332
|
-
|
|
333
|
-
}, {
|
|
334
|
-
key: "watch",
|
|
335
458
|
value: function watch(keys, callback, context) {
|
|
336
459
|
var validKeys = (0, _get2.default)((0, _getPrototypeOf2.default)(TableOrViewQueryResult.prototype), "watch", this).call(this, keys, callback, context);
|
|
337
|
-
var _iteratorNormalCompletion4 = true;
|
|
338
|
-
var _didIteratorError4 = false;
|
|
339
|
-
var _iteratorError4 = undefined;
|
|
340
460
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
461
|
+
var callWatchOnRecordStoreWithKey = keyToWatch => {
|
|
462
|
+
this._recordStore.watchWithRecordQueryResult({
|
|
463
|
+
priority: _airtable_interface.BlockQueryCallbackPriority.BLOCK_CODE,
|
|
464
|
+
recordQueryResult: this,
|
|
465
|
+
keys: keyToWatch,
|
|
466
|
+
callbackForRegistration: callback,
|
|
467
|
+
context
|
|
468
|
+
});
|
|
469
|
+
};
|
|
344
470
|
|
|
345
|
-
|
|
346
|
-
|
|
471
|
+
var callWatchOnViewDataStoreWithKey = keyToWatch => {
|
|
472
|
+
(0, _error_utils.invariant)(this._sourceModel instanceof _view.default, 'To watch %s you must be subscribed to a view', keyToWatch);
|
|
347
473
|
|
|
348
|
-
|
|
349
|
-
throw (0, _error_utils.spawnError)("Can't watch field because it wasn't included in RecordQueryResult fields: %s", fieldId);
|
|
350
|
-
}
|
|
474
|
+
var viewDataStore = this._recordStore.getViewDataStore(this._sourceModel.id);
|
|
351
475
|
|
|
352
|
-
|
|
353
|
-
|
|
476
|
+
viewDataStore.watch(keyToWatch, callback, context);
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
var callWatchFunctions = {
|
|
480
|
+
callOnRecordStoreWithKey: callWatchOnRecordStoreWithKey,
|
|
481
|
+
callOnViewDataStoreWithKey: callWatchOnViewDataStoreWithKey
|
|
482
|
+
};
|
|
483
|
+
var _iteratorNormalCompletion5 = true;
|
|
484
|
+
var _didIteratorError5 = false;
|
|
485
|
+
var _iteratorError5 = undefined;
|
|
354
486
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
487
|
+
try {
|
|
488
|
+
for (var _iterator5 = validKeys[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
|
|
489
|
+
var _key2 = _step5.value;
|
|
490
|
+
|
|
491
|
+
// There are two watch systems:
|
|
492
|
+
// 1) the query-based watch
|
|
493
|
+
// 2) the non-query-based watch (through super)
|
|
494
|
+
// Depending on the key, we may use one or both of the systems.
|
|
495
|
+
// The non-query based watch system is used when when:
|
|
496
|
+
// - watching: records, recordIds
|
|
497
|
+
// - _loadDataAsync calls all watch keys on initial load
|
|
498
|
+
// - Support for _watchRecordColorsIfNeeded
|
|
499
|
+
// For all changes to the remaining keys - the query-based system is used.
|
|
500
|
+
if (_key2.startsWith(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix)) {
|
|
501
|
+
this._watchConfigByWatchableKey[_record_query_result.default.WatchableCellValuesInFieldKeyPrefix](_key2, callWatchFunctions);
|
|
502
|
+
} else {
|
|
503
|
+
var functionToCallWithKey = this._watchConfigByWatchableKey[_key2];
|
|
359
504
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
} else {
|
|
363
|
-
this._incrementCellValueKeyWatchCountAndWatchIfNecessary(_key2, this._onCellValuesChanged);
|
|
505
|
+
if (functionToCallWithKey) {
|
|
506
|
+
functionToCallWithKey(_key2, callWatchFunctions);
|
|
364
507
|
}
|
|
365
508
|
}
|
|
366
509
|
}
|
|
367
510
|
} catch (err) {
|
|
368
|
-
|
|
369
|
-
|
|
511
|
+
_didIteratorError5 = true;
|
|
512
|
+
_iteratorError5 = err;
|
|
370
513
|
} finally {
|
|
371
514
|
try {
|
|
372
|
-
if (!
|
|
373
|
-
|
|
515
|
+
if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
|
|
516
|
+
_iterator5.return();
|
|
374
517
|
}
|
|
375
518
|
} finally {
|
|
376
|
-
if (
|
|
377
|
-
throw
|
|
519
|
+
if (_didIteratorError5) {
|
|
520
|
+
throw _iteratorError5;
|
|
378
521
|
}
|
|
379
522
|
}
|
|
380
523
|
}
|
|
@@ -387,41 +530,53 @@ function (_RecordQueryResult) {
|
|
|
387
530
|
key: "unwatch",
|
|
388
531
|
value: function unwatch(keys, callback, context) {
|
|
389
532
|
var validKeys = (0, _get2.default)((0, _getPrototypeOf2.default)(TableOrViewQueryResult.prototype), "unwatch", this).call(this, keys, callback, context);
|
|
390
|
-
|
|
391
|
-
var
|
|
392
|
-
|
|
533
|
+
|
|
534
|
+
var callUnwatchOnRecordStoreWithKey = keysToUnwatch => {
|
|
535
|
+
this._recordStore.unwatch(keysToUnwatch, callback, context);
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
var callUnwatchOnViewDataStoreWithKey = keyToWatch => {
|
|
539
|
+
(0, _error_utils.invariant)(this._sourceModel instanceof _view.default, 'To watch %s you must be subscribed to a view', keyToWatch);
|
|
540
|
+
|
|
541
|
+
var viewDataStore = this._recordStore.getViewDataStore(this._sourceModel.id);
|
|
542
|
+
|
|
543
|
+
viewDataStore.unwatch(keyToWatch, callback, context);
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
var callWatchFunctions = {
|
|
547
|
+
callOnRecordStoreWithKey: callUnwatchOnRecordStoreWithKey,
|
|
548
|
+
callOnViewDataStoreWithKey: callUnwatchOnViewDataStoreWithKey
|
|
549
|
+
};
|
|
550
|
+
var _iteratorNormalCompletion6 = true;
|
|
551
|
+
var _didIteratorError6 = false;
|
|
552
|
+
var _iteratorError6 = undefined;
|
|
393
553
|
|
|
394
554
|
try {
|
|
395
|
-
for (var
|
|
396
|
-
var _key3 =
|
|
555
|
+
for (var _iterator6 = validKeys[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
|
|
556
|
+
var _key3 = _step6.value;
|
|
397
557
|
|
|
558
|
+
// This is the inverse of the watch logic
|
|
398
559
|
if (_key3.startsWith(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix)) {
|
|
399
|
-
this.
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
if (_key3 === _record_query_result.default.WatchableKeys.cellValues) {
|
|
403
|
-
if (this._fieldIdsSetToLoadOrNullIfAllFields) {
|
|
404
|
-
for (var _i2 = 0, _Object$keys2 = Object.keys(this._fieldIdsSetToLoadOrNullIfAllFields); _i2 < _Object$keys2.length; _i2++) {
|
|
405
|
-
var fieldId = _Object$keys2[_i2];
|
|
560
|
+
this._watchConfigByWatchableKey[_record_query_result.default.WatchableCellValuesInFieldKeyPrefix](_key3, callWatchFunctions);
|
|
561
|
+
} else {
|
|
562
|
+
var functionToCallWithKey = this._watchConfigByWatchableKey[_key3];
|
|
406
563
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
} else {
|
|
410
|
-
this._decrementCellValueKeyWatchCountAndUnwatchIfPossible(_key3, this._onCellValuesChanged);
|
|
564
|
+
if (functionToCallWithKey) {
|
|
565
|
+
functionToCallWithKey(_key3, callWatchFunctions);
|
|
411
566
|
}
|
|
412
567
|
}
|
|
413
568
|
}
|
|
414
569
|
} catch (err) {
|
|
415
|
-
|
|
416
|
-
|
|
570
|
+
_didIteratorError6 = true;
|
|
571
|
+
_iteratorError6 = err;
|
|
417
572
|
} finally {
|
|
418
573
|
try {
|
|
419
|
-
if (!
|
|
420
|
-
|
|
574
|
+
if (!_iteratorNormalCompletion6 && _iterator6.return != null) {
|
|
575
|
+
_iterator6.return();
|
|
421
576
|
}
|
|
422
577
|
} finally {
|
|
423
|
-
if (
|
|
424
|
-
throw
|
|
578
|
+
if (_didIteratorError6) {
|
|
579
|
+
throw _iteratorError6;
|
|
425
580
|
}
|
|
426
581
|
}
|
|
427
582
|
}
|
|
@@ -433,45 +588,54 @@ function (_RecordQueryResult) {
|
|
|
433
588
|
}, {
|
|
434
589
|
key: "loadDataAsync",
|
|
435
590
|
value: function loadDataAsync() {
|
|
436
|
-
var sourceModelLoadPromise,
|
|
437
|
-
return _regenerator.default.async(function loadDataAsync$(
|
|
591
|
+
var sourceModelLoadPromise, fieldIdsToLoadOrNullIfAllFields, allFieldsToQuery, metadataFieldId, sourceModelLoadedPromise;
|
|
592
|
+
return _regenerator.default.async(function loadDataAsync$(_context2) {
|
|
438
593
|
while (1) {
|
|
439
|
-
switch (
|
|
594
|
+
switch (_context2.prev = _context2.next) {
|
|
440
595
|
case 0:
|
|
441
596
|
if (!this._sourceModel.isDeleted) {
|
|
442
|
-
|
|
597
|
+
_context2.next = 2;
|
|
443
598
|
break;
|
|
444
599
|
}
|
|
445
600
|
|
|
446
601
|
throw this._spawnErrorForDeletion();
|
|
447
602
|
|
|
448
603
|
case 2:
|
|
449
|
-
|
|
450
|
-
cellValuesInFieldsLoadPromise = this._recordStore.loadCellValuesInFieldIdsAsync(Object.keys(this._fieldIdsSetToLoadOrNullIfAllFields));
|
|
451
|
-
} else {
|
|
452
|
-
// Load all fields.
|
|
453
|
-
cellValuesInFieldsLoadPromise = this._recordStore.loadDataAsync();
|
|
454
|
-
}
|
|
604
|
+
fieldIdsToLoadOrNullIfAllFields = this._fieldIdsSetToLoadOrNullIfAllFields ? Object.keys(this._fieldIdsSetToLoadOrNullIfAllFields) : null;
|
|
455
605
|
|
|
456
606
|
if (this._sourceModel instanceof _table.default) {
|
|
457
|
-
if (
|
|
458
|
-
|
|
607
|
+
if (fieldIdsToLoadOrNullIfAllFields) {
|
|
608
|
+
// TODO: (#proj-blocks-sdk-record-limits) Do we need to load the recordData metadata field
|
|
609
|
+
// in order to load any record data? If we do - this should be encapsulated entirely
|
|
610
|
+
// inside of the RecordStore in publicAirtableInterface.
|
|
611
|
+
// (should the queryModel be able to specify metadata requirements?)
|
|
612
|
+
allFieldsToQuery = fieldIdsToLoadOrNullIfAllFields;
|
|
613
|
+
metadataFieldId = this._recordStore._getFieldIdForCausingRecordMetadataToLoad();
|
|
614
|
+
|
|
615
|
+
if (!allFieldsToQuery.includes(metadataFieldId)) {
|
|
616
|
+
allFieldsToQuery = [...allFieldsToQuery, metadataFieldId];
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
sourceModelLoadPromise = this._recordStore.loadAllCellValuesInFieldIdsAsync(allFieldsToQuery);
|
|
459
620
|
} else {
|
|
460
|
-
//
|
|
461
|
-
|
|
462
|
-
sourceModelLoadPromise = null;
|
|
621
|
+
// Load all fields.
|
|
622
|
+
sourceModelLoadPromise = this._recordStore.loadAllCellValuesAsync();
|
|
463
623
|
}
|
|
464
624
|
} else {
|
|
465
|
-
sourceModelLoadPromise = this._recordStore.
|
|
466
|
-
}
|
|
625
|
+
sourceModelLoadPromise = this._recordStore.loadViewDataStoreAndCellValuesForFieldIdsAsync(this._sourceModel.id, fieldIdsToLoadOrNullIfAllFields);
|
|
626
|
+
} // See comment on _loadedSourceModelQueryIds declaration for details
|
|
627
|
+
|
|
467
628
|
|
|
468
|
-
|
|
469
|
-
|
|
629
|
+
sourceModelLoadedPromise = sourceModelLoadPromise.then(sourceModelQueryId => {
|
|
630
|
+
this._loadedSourceModelQueryIds.push(sourceModelQueryId);
|
|
631
|
+
});
|
|
632
|
+
this._mostRecentSourceModelLoadedPromise = Promise.all([sourceModelLoadedPromise, this._loadRecordColorsAsync()]);
|
|
633
|
+
_context2.next = 8;
|
|
470
634
|
return _regenerator.default.awrap((0, _get2.default)((0, _getPrototypeOf2.default)(TableOrViewQueryResult.prototype), "loadDataAsync", this).call(this));
|
|
471
635
|
|
|
472
|
-
case
|
|
636
|
+
case 8:
|
|
473
637
|
case "end":
|
|
474
|
-
return
|
|
638
|
+
return _context2.stop();
|
|
475
639
|
}
|
|
476
640
|
}
|
|
477
641
|
}, null, this);
|
|
@@ -487,26 +651,26 @@ function (_RecordQueryResult) {
|
|
|
487
651
|
|
|
488
652
|
var fieldIds = this._normalizedOpts.fieldIdsOrNullIfAllFields || this._table.fields.map(field => field.id);
|
|
489
653
|
|
|
490
|
-
var
|
|
491
|
-
var
|
|
492
|
-
var
|
|
654
|
+
var _iteratorNormalCompletion7 = true;
|
|
655
|
+
var _didIteratorError7 = false;
|
|
656
|
+
var _iteratorError7 = undefined;
|
|
493
657
|
|
|
494
658
|
try {
|
|
495
|
-
for (var
|
|
496
|
-
var fieldId =
|
|
659
|
+
for (var _iterator7 = fieldIds[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
|
|
660
|
+
var fieldId = _step7.value;
|
|
497
661
|
changedKeys.push(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId);
|
|
498
662
|
}
|
|
499
663
|
} catch (err) {
|
|
500
|
-
|
|
501
|
-
|
|
664
|
+
_didIteratorError7 = true;
|
|
665
|
+
_iteratorError7 = err;
|
|
502
666
|
} finally {
|
|
503
667
|
try {
|
|
504
|
-
if (!
|
|
505
|
-
|
|
668
|
+
if (!_iteratorNormalCompletion7 && _iterator7.return != null) {
|
|
669
|
+
_iterator7.return();
|
|
506
670
|
}
|
|
507
671
|
} finally {
|
|
508
|
-
if (
|
|
509
|
-
throw
|
|
672
|
+
if (_didIteratorError7) {
|
|
673
|
+
throw _iteratorError7;
|
|
510
674
|
}
|
|
511
675
|
}
|
|
512
676
|
}
|
|
@@ -518,55 +682,79 @@ function (_RecordQueryResult) {
|
|
|
518
682
|
}, {
|
|
519
683
|
key: "_loadDataAsync",
|
|
520
684
|
value: function _loadDataAsync() {
|
|
521
|
-
var viewDataStore,
|
|
685
|
+
var viewDataStore, _iteratorNormalCompletion8, _didIteratorError8, _iteratorError8, _iterator8, _step8, sort, field;
|
|
522
686
|
|
|
523
|
-
return _regenerator.default.async(function _loadDataAsync$(
|
|
687
|
+
return _regenerator.default.async(function _loadDataAsync$(_context3) {
|
|
524
688
|
while (1) {
|
|
525
|
-
switch (
|
|
689
|
+
switch (_context3.prev = _context3.next) {
|
|
526
690
|
case 0:
|
|
527
691
|
this._table.__tableOrViewQueryResultPool.registerObjectForReuseStrong(this);
|
|
528
692
|
|
|
529
|
-
(0, _error_utils.invariant)(this.
|
|
530
|
-
|
|
531
|
-
return _regenerator.default.awrap(this.
|
|
693
|
+
(0, _error_utils.invariant)(this._mostRecentSourceModelLoadedPromise, 'No source model load promises');
|
|
694
|
+
_context3.next = 4;
|
|
695
|
+
return _regenerator.default.awrap(this._mostRecentSourceModelLoadedPromise);
|
|
532
696
|
|
|
533
697
|
case 4:
|
|
534
698
|
if (this._sorts) {
|
|
535
699
|
this._replaceVisList();
|
|
536
700
|
}
|
|
537
701
|
|
|
538
|
-
this._orderedRecordIds = this._generateOrderedRecordIds();
|
|
539
|
-
this._orderedGroups = this._generateAndLoadOrderedGroups(); // The server provided value and developer supplied value are the same, no conversion needed
|
|
702
|
+
this._orderedRecordIds = this._generateOrderedRecordIds(); // Ensure that groups are not loaded
|
|
540
703
|
|
|
541
|
-
this.
|
|
704
|
+
this._orderedGroups = null; // The server provided value and developer supplied value are the same, no conversion needed
|
|
705
|
+
|
|
706
|
+
this._loadedGroupLevels = null;
|
|
542
707
|
|
|
543
708
|
if (this._sourceModel instanceof _table.default) {
|
|
544
|
-
|
|
709
|
+
// _onRecordsChanged actually just transforms data and passes to
|
|
710
|
+
// user provided watches
|
|
711
|
+
this._recordStore.watchWithRecordQueryResult({
|
|
712
|
+
priority: _airtable_interface.BlockQueryCallbackPriority.BLOCK_CODE,
|
|
713
|
+
recordQueryResult: this,
|
|
714
|
+
keys: _record_store.WatchableRecordStoreKeys.records,
|
|
715
|
+
callbackForRegistration: this._onRecordsChanged,
|
|
716
|
+
context: this
|
|
717
|
+
});
|
|
545
718
|
} else {
|
|
546
|
-
viewDataStore = this._recordStore.getViewDataStore(this._sourceModel.id);
|
|
547
|
-
|
|
548
|
-
viewDataStore.watch(_view_data_store.WatchableViewDataStoreKeys.groups, this._onGroupsChanged, this);
|
|
549
|
-
viewDataStore.watch(_view_data_store.WatchableViewDataStoreKeys.groupLevels, this._onGroupLevelsChanged, this);
|
|
550
|
-
}
|
|
719
|
+
viewDataStore = this._recordStore.getViewDataStore(this._sourceModel.id); // _onRecordsChanged actually just transforms data and passes to
|
|
720
|
+
// user provided watches
|
|
551
721
|
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
722
|
+
viewDataStore.watch(_view_data_store.WatchableViewDataStoreKeys.visibleRecords, this._onRecordsChanged, this);
|
|
723
|
+
viewDataStore.watchFromSdk(_view_data_store.WatchableViewDataStoreKeys.groups, this._onGroupsChanged, this);
|
|
724
|
+
viewDataStore.watchFromSdk(_view_data_store.WatchableViewDataStoreKeys.groupLevels, this._onGroupLevelsChanged, this);
|
|
725
|
+
} // This only watches cell values if a sort is specified
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
this._recordStore.watchWithRecordQueryResult({
|
|
729
|
+
priority: _airtable_interface.BlockQueryCallbackPriority.SDK,
|
|
730
|
+
recordQueryResult: this,
|
|
731
|
+
keys: this._cellValuesForSortWatchKeys,
|
|
732
|
+
callbackForRegistration: this._onCellValuesForSortChanged,
|
|
733
|
+
context: this
|
|
734
|
+
});
|
|
735
|
+
|
|
736
|
+
this._recordStore.watchWithRecordQueryResult({
|
|
737
|
+
priority: _airtable_interface.BlockQueryCallbackPriority.SDK,
|
|
738
|
+
recordQueryResult: this,
|
|
739
|
+
keys: this._cellValuesForGroupWatchKeys,
|
|
740
|
+
callbackForRegistration: this._onCellValuesForGroupChanged,
|
|
741
|
+
context: this
|
|
742
|
+
});
|
|
555
743
|
|
|
556
744
|
this._table.watch(_table.WatchableTableKeys.fields, this._onTableFieldsChanged, this);
|
|
557
745
|
|
|
558
746
|
if (!this._sorts) {
|
|
559
|
-
|
|
747
|
+
_context3.next = 32;
|
|
560
748
|
break;
|
|
561
749
|
}
|
|
562
750
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
751
|
+
_iteratorNormalCompletion8 = true;
|
|
752
|
+
_didIteratorError8 = false;
|
|
753
|
+
_iteratorError8 = undefined;
|
|
754
|
+
_context3.prev = 16;
|
|
567
755
|
|
|
568
|
-
for (
|
|
569
|
-
sort =
|
|
756
|
+
for (_iterator8 = this._sorts[Symbol.iterator](); !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
|
|
757
|
+
sort = _step8.value;
|
|
570
758
|
field = this._table.getFieldByIdIfExists(sort.fieldId);
|
|
571
759
|
|
|
572
760
|
if (field) {
|
|
@@ -575,45 +763,45 @@ function (_RecordQueryResult) {
|
|
|
575
763
|
}
|
|
576
764
|
}
|
|
577
765
|
|
|
578
|
-
|
|
766
|
+
_context3.next = 24;
|
|
579
767
|
break;
|
|
580
768
|
|
|
581
769
|
case 20:
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
770
|
+
_context3.prev = 20;
|
|
771
|
+
_context3.t0 = _context3["catch"](16);
|
|
772
|
+
_didIteratorError8 = true;
|
|
773
|
+
_iteratorError8 = _context3.t0;
|
|
586
774
|
|
|
587
775
|
case 24:
|
|
588
|
-
|
|
589
|
-
|
|
776
|
+
_context3.prev = 24;
|
|
777
|
+
_context3.prev = 25;
|
|
590
778
|
|
|
591
|
-
if (!
|
|
592
|
-
|
|
779
|
+
if (!_iteratorNormalCompletion8 && _iterator8.return != null) {
|
|
780
|
+
_iterator8.return();
|
|
593
781
|
}
|
|
594
782
|
|
|
595
783
|
case 27:
|
|
596
|
-
|
|
784
|
+
_context3.prev = 27;
|
|
597
785
|
|
|
598
|
-
if (!
|
|
599
|
-
|
|
786
|
+
if (!_didIteratorError8) {
|
|
787
|
+
_context3.next = 30;
|
|
600
788
|
break;
|
|
601
789
|
}
|
|
602
790
|
|
|
603
|
-
throw
|
|
791
|
+
throw _iteratorError8;
|
|
604
792
|
|
|
605
793
|
case 30:
|
|
606
|
-
return
|
|
794
|
+
return _context3.finish(27);
|
|
607
795
|
|
|
608
796
|
case 31:
|
|
609
|
-
return
|
|
797
|
+
return _context3.finish(24);
|
|
610
798
|
|
|
611
799
|
case 32:
|
|
612
|
-
return
|
|
800
|
+
return _context3.abrupt("return", this._getChangedKeysOnLoad());
|
|
613
801
|
|
|
614
802
|
case 33:
|
|
615
803
|
case "end":
|
|
616
|
-
return
|
|
804
|
+
return _context3.stop();
|
|
617
805
|
}
|
|
618
806
|
}
|
|
619
807
|
}, null, this, [[16, 20, 24, 32], [25,, 27, 31]]);
|
|
@@ -625,21 +813,9 @@ function (_RecordQueryResult) {
|
|
|
625
813
|
value: function unloadData() {
|
|
626
814
|
(0, _get2.default)((0, _getPrototypeOf2.default)(TableOrViewQueryResult.prototype), "unloadData", this).call(this);
|
|
627
815
|
|
|
628
|
-
if (this.
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
} else {
|
|
632
|
-
this._recordStore.unloadData();
|
|
633
|
-
}
|
|
634
|
-
} else {
|
|
635
|
-
// If the view is deleted, we can't get a data store for it.
|
|
636
|
-
if (!this._sourceModel.isDeleted) {
|
|
637
|
-
this._recordStore.getViewDataStore(this._sourceModel.id).unloadData();
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
if (this._fieldIdsSetToLoadOrNullIfAllFields) {
|
|
642
|
-
this._recordStore.unloadCellValuesInFieldIds(Object.keys(this._fieldIdsSetToLoadOrNullIfAllFields));
|
|
816
|
+
if (this._loadedSourceModelQueryIds.length === 0) {
|
|
817
|
+
// Source model must have loaded a queryId to unload
|
|
818
|
+
return;
|
|
643
819
|
}
|
|
644
820
|
|
|
645
821
|
this._unloadRecordColors();
|
|
@@ -649,119 +825,32 @@ function (_RecordQueryResult) {
|
|
|
649
825
|
}, {
|
|
650
826
|
key: "_unloadData",
|
|
651
827
|
value: function _unloadData() {
|
|
652
|
-
this.
|
|
653
|
-
|
|
654
|
-
if (this._sourceModel instanceof _table.default) {
|
|
655
|
-
this._recordStore.unwatch(_record_store.WatchableRecordStoreKeys.records, this._onRecordsChanged, this);
|
|
656
|
-
} else {
|
|
657
|
-
if (!this._sourceModel.isDeleted) {
|
|
658
|
-
var viewDataStore = this._recordStore.getViewDataStore(this._sourceModel.id);
|
|
659
|
-
|
|
660
|
-
viewDataStore.unwatch(_view_data_store.WatchableViewDataStoreKeys.visibleRecords, this._onRecordsChanged, this);
|
|
661
|
-
viewDataStore.unwatch(_view_data_store.WatchableViewDataStoreKeys.groups, this._onGroupsChanged, this);
|
|
662
|
-
viewDataStore.unwatch(_view_data_store.WatchableViewDataStoreKeys.groupLevels, this._onGroupLevelsChanged, this);
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
this._recordStore.unwatch(this._cellValuesForSortWatchKeys, this._onCellValuesForSortChanged, this);
|
|
667
|
-
|
|
668
|
-
this._recordStore.unwatch(this._cellValuesForGroupWatchKeys, this._onCellValuesForGroupChanged, this);
|
|
669
|
-
|
|
670
|
-
this._table.unwatch(_table.WatchableTableKeys.fields, this._onTableFieldsChanged, this); // If the table is deleted, can't call getFieldById on it below.
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
if (!this._table.isDeleted && this._sorts) {
|
|
674
|
-
var _iteratorNormalCompletion8 = true;
|
|
675
|
-
var _didIteratorError8 = false;
|
|
676
|
-
var _iteratorError8 = undefined;
|
|
677
|
-
|
|
678
|
-
try {
|
|
679
|
-
for (var _iterator8 = this._sorts[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
|
|
680
|
-
var sort = _step8.value;
|
|
681
|
-
|
|
682
|
-
var field = this._table.getFieldByIdIfExists(sort.fieldId);
|
|
683
|
-
|
|
684
|
-
if (field) {
|
|
685
|
-
field.unwatch('type', this._onFieldConfigChanged, this);
|
|
686
|
-
field.unwatch('options', this._onFieldConfigChanged, this);
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
} catch (err) {
|
|
690
|
-
_didIteratorError8 = true;
|
|
691
|
-
_iteratorError8 = err;
|
|
692
|
-
} finally {
|
|
693
|
-
try {
|
|
694
|
-
if (!_iteratorNormalCompletion8 && _iterator8.return != null) {
|
|
695
|
-
_iterator8.return();
|
|
696
|
-
}
|
|
697
|
-
} finally {
|
|
698
|
-
if (_didIteratorError8) {
|
|
699
|
-
throw _iteratorError8;
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
this._unloadOrderedGroupsIfNeeded();
|
|
706
|
-
|
|
707
|
-
this._visList = null;
|
|
708
|
-
this._orderedRecordIds = null;
|
|
709
|
-
this._recordIdsSet = null;
|
|
710
|
-
|
|
711
|
-
this._table.__tableOrViewQueryResultPool.unregisterObjectForReuseStrong(this);
|
|
828
|
+
(0, _private_utils.fireAndForgetPromise)(this._unloadDataAsync);
|
|
712
829
|
}
|
|
713
|
-
/** @internal */
|
|
714
|
-
|
|
715
830
|
}, {
|
|
716
831
|
key: "_addRecordIdsToVisList",
|
|
832
|
+
|
|
833
|
+
/** @internal */
|
|
717
834
|
value: function _addRecordIdsToVisList(recordIds) {
|
|
718
835
|
var visList = this._visList;
|
|
719
836
|
(0, _error_utils.invariant)(visList, 'No vis list');
|
|
720
|
-
|
|
721
|
-
var _didIteratorError9 = false;
|
|
722
|
-
var _iteratorError9 = undefined;
|
|
723
|
-
|
|
724
|
-
try {
|
|
725
|
-
for (var _iterator9 = recordIds[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
|
|
726
|
-
var recordId = _step9.value;
|
|
727
|
-
|
|
728
|
-
var record = this._recordStore.getRecordByIdIfExists(recordId);
|
|
729
|
-
|
|
730
|
-
(0, _error_utils.invariant)(record, 'Record missing in table');
|
|
731
|
-
visList.addRecordData(record._data);
|
|
732
|
-
}
|
|
733
|
-
} catch (err) {
|
|
734
|
-
_didIteratorError9 = true;
|
|
735
|
-
_iteratorError9 = err;
|
|
736
|
-
} finally {
|
|
737
|
-
try {
|
|
738
|
-
if (!_iteratorNormalCompletion9 && _iterator9.return != null) {
|
|
739
|
-
_iterator9.return();
|
|
740
|
-
}
|
|
741
|
-
} finally {
|
|
742
|
-
if (_didIteratorError9) {
|
|
743
|
-
throw _iteratorError9;
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
}
|
|
837
|
+
visList.addRecordIds(recordIds);
|
|
747
838
|
}
|
|
748
839
|
/** @internal */
|
|
749
840
|
|
|
750
841
|
}, {
|
|
751
842
|
key: "_onGroupLevelsChanged",
|
|
752
843
|
value: function _onGroupLevelsChanged(model, key, updates) {
|
|
753
|
-
this._loadedGroupLevels =
|
|
754
|
-
|
|
755
|
-
this._unloadRemovedGroupsAndLoadNewGroupsAndTriggerWatches();
|
|
844
|
+
this._loadedGroupLevels = null;
|
|
756
845
|
|
|
757
|
-
this.
|
|
846
|
+
this._unloadGroups();
|
|
758
847
|
}
|
|
759
848
|
/** @internal */
|
|
760
849
|
|
|
761
850
|
}, {
|
|
762
851
|
key: "_onGroupsChanged",
|
|
763
852
|
value: function _onGroupsChanged(model, key, updates) {
|
|
764
|
-
this.
|
|
853
|
+
this._unloadGroups();
|
|
765
854
|
}
|
|
766
855
|
/** @internal */
|
|
767
856
|
|
|
@@ -784,7 +873,11 @@ function (_RecordQueryResult) {
|
|
|
784
873
|
addedRecordIds: _addedRecordIds,
|
|
785
874
|
removedRecordIds: _removedRecordIds
|
|
786
875
|
};
|
|
787
|
-
}
|
|
876
|
+
} // We never need to handle an initial empty update coming from record_store
|
|
877
|
+
// since it does not issue empty initial updates.
|
|
878
|
+
// Keep the if statement for type safety. Invariant would also work, but is riskier.
|
|
879
|
+
// istanbul ignore if
|
|
880
|
+
|
|
788
881
|
|
|
789
882
|
if (!updates) {
|
|
790
883
|
// If there are no updates, do nothing, since we'll handle the initial
|
|
@@ -811,50 +904,50 @@ function (_RecordQueryResult) {
|
|
|
811
904
|
}
|
|
812
905
|
|
|
813
906
|
if (this._recordIdsSet) {
|
|
814
|
-
var
|
|
815
|
-
var
|
|
816
|
-
var
|
|
907
|
+
var _iteratorNormalCompletion9 = true;
|
|
908
|
+
var _didIteratorError9 = false;
|
|
909
|
+
var _iteratorError9 = undefined;
|
|
817
910
|
|
|
818
911
|
try {
|
|
819
|
-
for (var
|
|
820
|
-
var recordId =
|
|
912
|
+
for (var _iterator9 = addedRecordIds[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
|
|
913
|
+
var recordId = _step9.value;
|
|
821
914
|
this._recordIdsSet[recordId] = true;
|
|
822
915
|
}
|
|
823
916
|
} catch (err) {
|
|
824
|
-
|
|
825
|
-
|
|
917
|
+
_didIteratorError9 = true;
|
|
918
|
+
_iteratorError9 = err;
|
|
826
919
|
} finally {
|
|
827
920
|
try {
|
|
828
|
-
if (!
|
|
829
|
-
|
|
921
|
+
if (!_iteratorNormalCompletion9 && _iterator9.return != null) {
|
|
922
|
+
_iterator9.return();
|
|
830
923
|
}
|
|
831
924
|
} finally {
|
|
832
|
-
if (
|
|
833
|
-
throw
|
|
925
|
+
if (_didIteratorError9) {
|
|
926
|
+
throw _iteratorError9;
|
|
834
927
|
}
|
|
835
928
|
}
|
|
836
929
|
}
|
|
837
930
|
|
|
838
|
-
var
|
|
839
|
-
var
|
|
840
|
-
var
|
|
931
|
+
var _iteratorNormalCompletion10 = true;
|
|
932
|
+
var _didIteratorError10 = false;
|
|
933
|
+
var _iteratorError10 = undefined;
|
|
841
934
|
|
|
842
935
|
try {
|
|
843
|
-
for (var
|
|
844
|
-
var _recordId =
|
|
936
|
+
for (var _iterator10 = removedRecordIds[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
|
|
937
|
+
var _recordId = _step10.value;
|
|
845
938
|
this._recordIdsSet[_recordId] = undefined;
|
|
846
939
|
}
|
|
847
940
|
} catch (err) {
|
|
848
|
-
|
|
849
|
-
|
|
941
|
+
_didIteratorError10 = true;
|
|
942
|
+
_iteratorError10 = err;
|
|
850
943
|
} finally {
|
|
851
944
|
try {
|
|
852
|
-
if (!
|
|
853
|
-
|
|
945
|
+
if (!_iteratorNormalCompletion10 && _iterator10.return != null) {
|
|
946
|
+
_iterator10.return();
|
|
854
947
|
}
|
|
855
948
|
} finally {
|
|
856
|
-
if (
|
|
857
|
-
throw
|
|
949
|
+
if (_didIteratorError10) {
|
|
950
|
+
throw _iteratorError10;
|
|
858
951
|
}
|
|
859
952
|
}
|
|
860
953
|
}
|
|
@@ -883,6 +976,10 @@ function (_RecordQueryResult) {
|
|
|
883
976
|
}, {
|
|
884
977
|
key: "_onCellValuesForSortChanged",
|
|
885
978
|
value: function _onCellValuesForSortChanged(recordStore, key, recordIds, fieldId) {
|
|
979
|
+
// We never need to handle an initial empty update coming from record_store
|
|
980
|
+
// since it does not issue empty initial updates.
|
|
981
|
+
// Keep the if statement for type safety. Invariant would also work, but is riskier.
|
|
982
|
+
// istanbul ignore if
|
|
886
983
|
if (!recordIds || !fieldId) {
|
|
887
984
|
// If there are no updates, do nothing, since we'll handle the initial
|
|
888
985
|
// callback when the record set is loaded (and we don't want to fire
|
|
@@ -948,13 +1045,13 @@ function (_RecordQueryResult) {
|
|
|
948
1045
|
// deleted and then undeleted.
|
|
949
1046
|
|
|
950
1047
|
var wereAnyFieldsCreatedOrDeleted = false;
|
|
951
|
-
var
|
|
952
|
-
var
|
|
953
|
-
var
|
|
1048
|
+
var _iteratorNormalCompletion11 = true;
|
|
1049
|
+
var _didIteratorError11 = false;
|
|
1050
|
+
var _iteratorError11 = undefined;
|
|
954
1051
|
|
|
955
1052
|
try {
|
|
956
|
-
for (var
|
|
957
|
-
var fieldId =
|
|
1053
|
+
for (var _iterator11 = addedFieldIds[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
|
|
1054
|
+
var fieldId = _step11.value;
|
|
958
1055
|
|
|
959
1056
|
// If a field that we rely on was created (i.e. it was undeleted), we need to
|
|
960
1057
|
// make sure we're watching it's config.
|
|
@@ -971,16 +1068,16 @@ function (_RecordQueryResult) {
|
|
|
971
1068
|
// istanbul ignore else
|
|
972
1069
|
|
|
973
1070
|
} catch (err) {
|
|
974
|
-
|
|
975
|
-
|
|
1071
|
+
_didIteratorError11 = true;
|
|
1072
|
+
_iteratorError11 = err;
|
|
976
1073
|
} finally {
|
|
977
1074
|
try {
|
|
978
|
-
if (!
|
|
979
|
-
|
|
1075
|
+
if (!_iteratorNormalCompletion11 && _iterator11.return != null) {
|
|
1076
|
+
_iterator11.return();
|
|
980
1077
|
}
|
|
981
1078
|
} finally {
|
|
982
|
-
if (
|
|
983
|
-
throw
|
|
1079
|
+
if (_didIteratorError11) {
|
|
1080
|
+
throw _iteratorError11;
|
|
984
1081
|
}
|
|
985
1082
|
}
|
|
986
1083
|
}
|
|
@@ -1010,34 +1107,6 @@ function (_RecordQueryResult) {
|
|
|
1010
1107
|
}
|
|
1011
1108
|
/** @internal */
|
|
1012
1109
|
|
|
1013
|
-
}, {
|
|
1014
|
-
key: "_onCellValuesChanged",
|
|
1015
|
-
value: function _onCellValuesChanged(table, key, updates) {
|
|
1016
|
-
if (!updates) {
|
|
1017
|
-
// If there are no updates, do nothing, since we'll handle the initial
|
|
1018
|
-
// callback when the record set is loaded (and we don't want to fire
|
|
1019
|
-
// a cellValues change twice with no data).
|
|
1020
|
-
return;
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
this._onChange(_record_query_result.default.WatchableKeys.cellValues, updates);
|
|
1024
|
-
}
|
|
1025
|
-
/** @internal */
|
|
1026
|
-
|
|
1027
|
-
}, {
|
|
1028
|
-
key: "_onCellValuesInFieldChanged",
|
|
1029
|
-
value: function _onCellValuesInFieldChanged(table, key, recordIds, fieldId) {
|
|
1030
|
-
if (!recordIds && !fieldId) {
|
|
1031
|
-
// If there are no updates, do nothing, since we'll handle the initial
|
|
1032
|
-
// callback when the record set is loaded (and we don't want to fire
|
|
1033
|
-
// a cellValuesInField change twice with no data).
|
|
1034
|
-
return;
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
this._onChange(key, recordIds, fieldId);
|
|
1038
|
-
}
|
|
1039
|
-
/** @internal */
|
|
1040
|
-
|
|
1041
1110
|
}, {
|
|
1042
1111
|
key: "_generateOrderedRecordIds",
|
|
1043
1112
|
value: function _generateOrderedRecordIds() {
|
|
@@ -1055,7 +1124,6 @@ function (_RecordQueryResult) {
|
|
|
1055
1124
|
value: function _generateAndLoadOrderedGroups() {
|
|
1056
1125
|
// istanbul ignore next
|
|
1057
1126
|
if (this._groupLevels) {
|
|
1058
|
-
(0, _error_utils.invariant)(this._visList, 'Cannot generate record ids without a vis list');
|
|
1059
1127
|
throw (0, _error_utils.spawnError)('custom group configs not supported');
|
|
1060
1128
|
} else {
|
|
1061
1129
|
// Get the group from the view itself
|
|
@@ -1081,26 +1149,26 @@ function (_RecordQueryResult) {
|
|
|
1081
1149
|
key: "_unloadOrderedGroupsIfNeeded",
|
|
1082
1150
|
value: function _unloadOrderedGroupsIfNeeded() {
|
|
1083
1151
|
if (this._orderedGroups) {
|
|
1084
|
-
var
|
|
1085
|
-
var
|
|
1086
|
-
var
|
|
1152
|
+
var _iteratorNormalCompletion12 = true;
|
|
1153
|
+
var _didIteratorError12 = false;
|
|
1154
|
+
var _iteratorError12 = undefined;
|
|
1087
1155
|
|
|
1088
1156
|
try {
|
|
1089
|
-
for (var
|
|
1090
|
-
var group =
|
|
1157
|
+
for (var _iterator12 = this._orderedGroups[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
|
|
1158
|
+
var group = _step12.value;
|
|
1091
1159
|
group.unloadData();
|
|
1092
1160
|
}
|
|
1093
1161
|
} catch (err) {
|
|
1094
|
-
|
|
1095
|
-
|
|
1162
|
+
_didIteratorError12 = true;
|
|
1163
|
+
_iteratorError12 = err;
|
|
1096
1164
|
} finally {
|
|
1097
1165
|
try {
|
|
1098
|
-
if (!
|
|
1099
|
-
|
|
1166
|
+
if (!_iteratorNormalCompletion12 && _iterator12.return != null) {
|
|
1167
|
+
_iterator12.return();
|
|
1100
1168
|
}
|
|
1101
1169
|
} finally {
|
|
1102
|
-
if (
|
|
1103
|
-
throw
|
|
1170
|
+
if (_didIteratorError12) {
|
|
1171
|
+
throw _iteratorError12;
|
|
1104
1172
|
}
|
|
1105
1173
|
}
|
|
1106
1174
|
}
|
|
@@ -1108,24 +1176,21 @@ function (_RecordQueryResult) {
|
|
|
1108
1176
|
}
|
|
1109
1177
|
/**
|
|
1110
1178
|
* If groupings change then some groups will need to be created, and some removed
|
|
1111
|
-
*
|
|
1112
|
-
*
|
|
1179
|
+
* Triggers the WatchableKeys.group, as by necessity this will have changed.
|
|
1180
|
+
* TODO: This _should_ handle the diffing necessary to unload, and reload only the changed groups.
|
|
1113
1181
|
*
|
|
1114
1182
|
* @internal
|
|
1115
1183
|
*/
|
|
1116
1184
|
// TODO: (SeanKeenan) Properly diff and only unload groups that need to be unloaded
|
|
1117
1185
|
// In the meantime it's not too expensive to just unload everything, and GroupedRecordQueryResults
|
|
1118
1186
|
// don't yet properly watch changes relevant to updating, so this isn't too bad.
|
|
1119
|
-
// (They do invalidate their recordId caches, which is some very cheap work that we could remove)
|
|
1120
1187
|
|
|
1121
1188
|
}, {
|
|
1122
|
-
key: "
|
|
1123
|
-
value: function
|
|
1189
|
+
key: "_unloadGroups",
|
|
1190
|
+
value: function _unloadGroups() {
|
|
1124
1191
|
this._unloadOrderedGroupsIfNeeded();
|
|
1125
1192
|
|
|
1126
|
-
this._orderedGroups =
|
|
1127
|
-
|
|
1128
|
-
this._onChange(_record_query_result.default.WatchableKeys.groups);
|
|
1193
|
+
this._orderedGroups = null;
|
|
1129
1194
|
}
|
|
1130
1195
|
/** @internal */
|
|
1131
1196
|
|
|
@@ -1133,15 +1198,14 @@ function (_RecordQueryResult) {
|
|
|
1133
1198
|
key: "_replaceVisList",
|
|
1134
1199
|
value: function _replaceVisList() {
|
|
1135
1200
|
var airtableInterface = this._sdk.__airtableInterface;
|
|
1136
|
-
var appInterface = this._sdk.__appInterface;
|
|
1137
1201
|
|
|
1138
|
-
var
|
|
1202
|
+
var recordIds = this._sourceModelRecords.map(record => record.id);
|
|
1139
1203
|
|
|
1140
1204
|
var fieldDatas = this._table.fields.map(field => field._data);
|
|
1141
1205
|
|
|
1142
1206
|
var filteredSorts = this._getSortsWithDeletedFieldsFiltered();
|
|
1143
1207
|
|
|
1144
|
-
this._visList = airtableInterface.
|
|
1208
|
+
this._visList = airtableInterface.createVisListWithRecordIds(recordIds, fieldDatas, filteredSorts, this._table.id);
|
|
1145
1209
|
}
|
|
1146
1210
|
/** @internal */
|
|
1147
1211
|
|
|
@@ -1167,6 +1231,31 @@ function (_RecordQueryResult) {
|
|
|
1167
1231
|
var sourceModelName = this._sourceModel instanceof _table.default ? 'table' : 'view';
|
|
1168
1232
|
return (0, _error_utils.spawnError)("RecordQueryResult's underlying %s has been deleted", sourceModelName);
|
|
1169
1233
|
}
|
|
1234
|
+
/** @internal */
|
|
1235
|
+
|
|
1236
|
+
}, {
|
|
1237
|
+
key: "__constructQuerySpecForBlockFieldSelectionSpec",
|
|
1238
|
+
value: function __constructQuerySpecForBlockFieldSelectionSpec(fieldSelection) {
|
|
1239
|
+
if (this._sourceModel instanceof _view.default) {
|
|
1240
|
+
return {
|
|
1241
|
+
sourceType: _block_query_spec.BlockQuerySourceType.VIEW,
|
|
1242
|
+
sourceTableId: this._table.id,
|
|
1243
|
+
sourceViewId: this._sourceModel.id,
|
|
1244
|
+
recordSelection: {
|
|
1245
|
+
fieldSelection
|
|
1246
|
+
},
|
|
1247
|
+
viewMetadataSelection: {}
|
|
1248
|
+
};
|
|
1249
|
+
} else {
|
|
1250
|
+
return {
|
|
1251
|
+
sourceType: _block_query_spec.BlockQuerySourceType.TABLE,
|
|
1252
|
+
sourceTableId: this._table.id,
|
|
1253
|
+
recordSelection: {
|
|
1254
|
+
fieldSelection
|
|
1255
|
+
}
|
|
1256
|
+
};
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1170
1259
|
}, {
|
|
1171
1260
|
key: "_dataOrNullIfDeleted",
|
|
1172
1261
|
get: function get() {
|
|
@@ -1175,9 +1264,7 @@ function (_RecordQueryResult) {
|
|
|
1175
1264
|
}
|
|
1176
1265
|
|
|
1177
1266
|
return {
|
|
1178
|
-
recordIds: this._orderedRecordIds
|
|
1179
|
-
groups: this._orderedGroups,
|
|
1180
|
-
groupLevels: this._loadedGroupLevels
|
|
1267
|
+
recordIds: this._orderedRecordIds
|
|
1181
1268
|
};
|
|
1182
1269
|
}
|
|
1183
1270
|
/** @internal */
|
|
@@ -1231,8 +1318,10 @@ function (_RecordQueryResult) {
|
|
|
1231
1318
|
var recordIds = this._data.recordIds; // Throws when the model has been deleted.
|
|
1232
1319
|
|
|
1233
1320
|
(0, _error_utils.invariant)(this.isDataLoaded, 'RecordQueryResult data is not loaded');
|
|
1234
|
-
(0, _error_utils.invariant)(recordIds, 'No recordIds');
|
|
1235
|
-
|
|
1321
|
+
(0, _error_utils.invariant)(recordIds, 'No recordIds'); // TODO: (#proj-blocks-sdk-record-limits) Change this to readonly upon the
|
|
1322
|
+
// next breaking change.
|
|
1323
|
+
|
|
1324
|
+
return [...recordIds];
|
|
1236
1325
|
}
|
|
1237
1326
|
/**
|
|
1238
1327
|
* The ordered GroupedRecordQueryResult's in this RecordQueryResult.
|
|
@@ -1245,12 +1334,19 @@ function (_RecordQueryResult) {
|
|
|
1245
1334
|
}, {
|
|
1246
1335
|
key: "groups",
|
|
1247
1336
|
get: function get() {
|
|
1337
|
+
var _this$_orderedGroups;
|
|
1338
|
+
|
|
1248
1339
|
// The following statements have been carefully sequenced to ensure
|
|
1249
1340
|
// that when this method fails, it reports the most salient error.
|
|
1250
|
-
|
|
1341
|
+
(0, _error_utils.invariant)(this._data, 'RecordQueryResult must not be deleted'); // Throws when the model has been deleted.
|
|
1251
1342
|
|
|
1252
1343
|
(0, _error_utils.invariant)(this.isDataLoaded, 'RecordQueryResult data is not loaded');
|
|
1253
|
-
|
|
1344
|
+
|
|
1345
|
+
if (!this._orderedGroups) {
|
|
1346
|
+
this._orderedGroups = this._generateAndLoadOrderedGroups();
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
return (_this$_orderedGroups = this._orderedGroups) !== null && _this$_orderedGroups !== void 0 ? _this$_orderedGroups : null;
|
|
1254
1350
|
}
|
|
1255
1351
|
/**
|
|
1256
1352
|
* The GroupLevels in this RecordQueryResult.
|
|
@@ -1263,10 +1359,15 @@ function (_RecordQueryResult) {
|
|
|
1263
1359
|
}, {
|
|
1264
1360
|
key: "groupLevels",
|
|
1265
1361
|
get: function get() {
|
|
1266
|
-
|
|
1362
|
+
(0, _error_utils.invariant)(this._data, 'RecordQueryResult must not be deleted'); // Throws when the model has been deleted.
|
|
1267
1363
|
|
|
1268
1364
|
(0, _error_utils.invariant)(this.isDataLoaded, 'RecordQueryResult data is not loaded');
|
|
1269
|
-
|
|
1365
|
+
|
|
1366
|
+
if (!this._loadedGroupLevels) {
|
|
1367
|
+
this._loadedGroupLevels = this._sourceModelGroupLevels;
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
return this._loadedGroupLevels ? this._loadedGroupLevels.map(singleLevel => _objectSpread({}, singleLevel, {
|
|
1270
1371
|
field: this.parentTable.getFieldById(singleLevel.fieldId)
|
|
1271
1372
|
})) : null;
|
|
1272
1373
|
}
|
|
@@ -1281,13 +1382,13 @@ function (_RecordQueryResult) {
|
|
|
1281
1382
|
// using RecordQueryResult) if the user had to manually watch for deletion
|
|
1282
1383
|
// on all the fields and recreate the RecordQueryResult.
|
|
1283
1384
|
|
|
1284
|
-
var
|
|
1285
|
-
var
|
|
1286
|
-
var
|
|
1385
|
+
var _iteratorNormalCompletion13 = true;
|
|
1386
|
+
var _didIteratorError13 = false;
|
|
1387
|
+
var _iteratorError13 = undefined;
|
|
1287
1388
|
|
|
1288
1389
|
try {
|
|
1289
|
-
for (var
|
|
1290
|
-
var fieldId =
|
|
1390
|
+
for (var _iterator13 = fieldIdsOrNullIfAllFields[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
|
|
1391
|
+
var fieldId = _step13.value;
|
|
1291
1392
|
|
|
1292
1393
|
var field = this._table.getFieldByIdIfExists(fieldId);
|
|
1293
1394
|
|
|
@@ -1296,16 +1397,16 @@ function (_RecordQueryResult) {
|
|
|
1296
1397
|
}
|
|
1297
1398
|
}
|
|
1298
1399
|
} catch (err) {
|
|
1299
|
-
|
|
1300
|
-
|
|
1400
|
+
_didIteratorError13 = true;
|
|
1401
|
+
_iteratorError13 = err;
|
|
1301
1402
|
} finally {
|
|
1302
1403
|
try {
|
|
1303
|
-
if (!
|
|
1304
|
-
|
|
1404
|
+
if (!_iteratorNormalCompletion13 && _iterator13.return != null) {
|
|
1405
|
+
_iterator13.return();
|
|
1305
1406
|
}
|
|
1306
1407
|
} finally {
|
|
1307
|
-
if (
|
|
1308
|
-
throw
|
|
1408
|
+
if (_didIteratorError13) {
|
|
1409
|
+
throw _iteratorError13;
|
|
1309
1410
|
}
|
|
1310
1411
|
}
|
|
1311
1412
|
}
|
|
@@ -1359,6 +1460,12 @@ function (_RecordQueryResult) {
|
|
|
1359
1460
|
get: function get() {
|
|
1360
1461
|
return this._sourceModel instanceof _table.default ? this._recordStore.records : this._recordStore.getViewDataStore(this._sourceModel.id).visibleRecords;
|
|
1361
1462
|
}
|
|
1463
|
+
/**
|
|
1464
|
+
* This is just a helper structure to better colocate watch and unwatch logic
|
|
1465
|
+
*
|
|
1466
|
+
* @internal
|
|
1467
|
+
*/
|
|
1468
|
+
|
|
1362
1469
|
}]);
|
|
1363
1470
|
return TableOrViewQueryResult;
|
|
1364
1471
|
}(_record_query_result.default);
|