@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
package/CHANGELOG.md
CHANGED
|
@@ -9,10 +9,29 @@ Not every commit needs to result in a change to this file (e.g. docs and chore c
|
|
|
9
9
|
commit that affects the code in a way that consumers might care about should include edits to the
|
|
10
10
|
'Unreleased' section though. Breaking changes should be prefixed with `**BREAKING:**`.
|
|
11
11
|
|
|
12
|
-
## [Unreleased](https://github.com/airtable/blocks/compare/@airtable/blocks@1.
|
|
12
|
+
## [Unreleased](https://github.com/airtable/blocks/compare/@airtable/blocks@1.10.2...HEAD)
|
|
13
13
|
|
|
14
14
|
No changes.
|
|
15
15
|
|
|
16
|
+
## [1.10.2](https://github.com/airtable/blocks/compare/@airtable/blocks@1.10.1...@airtable/blocks@1.10.2) - 2022-01-25
|
|
17
|
+
|
|
18
|
+
- Rare invariant failure addressed
|
|
19
|
+
|
|
20
|
+
## [1.10.1](https://github.com/airtable/blocks/compare/@airtable/blocks@1.10.0...@airtable/blocks@1.10.1) - 2021-12-22
|
|
21
|
+
|
|
22
|
+
- Update examples for table, view and field URLs.
|
|
23
|
+
- Use `keyof any` instead of `PropertyKey` in type definition to avoid incompatibility with the
|
|
24
|
+
"[keyofStringsOnly](https://www.typescriptlang.org/tsconfig#keyofStringsOnly)" tsconfig option
|
|
25
|
+
|
|
26
|
+
## [1.10.0](https://github.com/airtable/blocks/compare/@airtable/blocks@1.9.0...@airtable/blocks@1.10.0) - 2021-11-03
|
|
27
|
+
|
|
28
|
+
- Fix typo in cursor.ts documentation - thanks @m2creates!
|
|
29
|
+
- Add new `calendarDay` icon (and micro variant)
|
|
30
|
+
- Update documentation to include attachment url guidance
|
|
31
|
+
- Update field metadata writes documentation to mention that `null` will be coerced to `''`
|
|
32
|
+
- Fix a bug when unloading data from a `linkedRecordQueryResult` after a table deletion
|
|
33
|
+
- Update `children` prop of `Link` component to be optional
|
|
34
|
+
|
|
16
35
|
## [1.9.0](https://github.com/airtable/blocks/compare/@airtable/blocks@1.8.0...@airtable/blocks@1.9.0) - 2021-09-15
|
|
17
36
|
|
|
18
37
|
- Update documentation for `FieldType.CHECKBOX` cell read & write types to be more accurate.
|
package/dist/cjs/error_utils.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.array.iterator");
|
|
4
|
+
|
|
3
5
|
require("core-js/modules/es.string.replace");
|
|
4
6
|
|
|
7
|
+
require("core-js/modules/web.dom-collections.iterator");
|
|
8
|
+
|
|
5
9
|
Object.defineProperty(exports, "__esModule", {
|
|
6
10
|
value: true
|
|
7
11
|
});
|
|
8
12
|
exports.spawnError = spawnError;
|
|
13
|
+
exports.logErrorToRollbar = logErrorToRollbar;
|
|
9
14
|
exports.invariant = invariant;
|
|
10
15
|
exports.spawnUnknownSwitchCaseError = spawnUnknownSwitchCaseError;
|
|
16
|
+
exports.spawnExhaustiveSwitchError = spawnExhaustiveSwitchError;
|
|
11
17
|
exports.spawnAbstractMethodError = spawnAbstractMethodError;
|
|
12
18
|
|
|
13
19
|
// If errorOriginFn is specified, all frames above and including the call to errorOriginFn
|
|
@@ -52,6 +58,26 @@ function spawnError(errorMessageFormat) {
|
|
|
52
58
|
}
|
|
53
59
|
|
|
54
60
|
return spawnErrorWithOriginOmittedFromStackTrace(errorMessageFormat, errorMessageArgs, spawnError);
|
|
61
|
+
} // istanbul ignore next
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Logs an error to Rollbar
|
|
65
|
+
*
|
|
66
|
+
* @hidden
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
function logErrorToRollbar(errorMessageFormat) {
|
|
71
|
+
// See this comment for how to log via Rollbar: https://github.com/Hyperbase/hyperbase/blob/009dcd1dc4c5204277c2939e7f61dfce74535f30/client/run_block_frame.tsx#L548
|
|
72
|
+
var rollbar = window.Rollbar;
|
|
73
|
+
|
|
74
|
+
if (rollbar === null || rollbar === void 0 ? void 0 : rollbar.warn) {
|
|
75
|
+
for (var _len2 = arguments.length, errorMessageArgs = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
76
|
+
errorMessageArgs[_key2 - 1] = arguments[_key2];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
rollbar.warn(spawnError(errorMessageFormat, ...errorMessageArgs));
|
|
80
|
+
}
|
|
55
81
|
}
|
|
56
82
|
/**
|
|
57
83
|
* An alternative to facebook's invariant that's safe to use with base data
|
|
@@ -62,8 +88,8 @@ function spawnError(errorMessageFormat) {
|
|
|
62
88
|
|
|
63
89
|
function invariant(condition, errorMessageFormat) {
|
|
64
90
|
if (!condition) {
|
|
65
|
-
for (var
|
|
66
|
-
errorMessageArgs[
|
|
91
|
+
for (var _len3 = arguments.length, errorMessageArgs = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
|
92
|
+
errorMessageArgs[_key3 - 2] = arguments[_key3];
|
|
67
93
|
}
|
|
68
94
|
|
|
69
95
|
throw spawnErrorWithOriginOmittedFromStackTrace(errorMessageFormat, errorMessageArgs, invariant);
|
|
@@ -79,6 +105,22 @@ function spawnUnknownSwitchCaseError(valueDescription, providedValue, key) {
|
|
|
79
105
|
var providedValueKeyString = providedValueKey !== null && providedValueKey !== undefined ? providedValueKey : 'null';
|
|
80
106
|
return spawnErrorWithOriginOmittedFromStackTrace('Unknown value %s for %s', [providedValueKeyString, valueDescription], spawnUnknownSwitchCaseError);
|
|
81
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Forces TypeScript to prove that calling this function is impossible at a
|
|
110
|
+
* type level by accepting `never`. In the unlikely case this function is
|
|
111
|
+
* called we infer a useful error message.
|
|
112
|
+
*
|
|
113
|
+
* @internal
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
function spawnExhaustiveSwitchError(impossibleValue) {
|
|
118
|
+
if (impossibleValue === null) {
|
|
119
|
+
return spawnErrorWithOriginOmittedFromStackTrace('Unexpected null in exhaustive switch', undefined, spawnExhaustiveSwitchError);
|
|
120
|
+
} else {
|
|
121
|
+
return spawnErrorWithOriginOmittedFromStackTrace("Unexpected %s in exhaustive switch", [typeof impossibleValue], spawnExhaustiveSwitchError);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
82
124
|
/**
|
|
83
125
|
* @internal
|
|
84
126
|
*/
|
package/dist/cjs/models/base.js
CHANGED
|
@@ -526,7 +526,8 @@ function (_AbstractModel) {
|
|
|
526
526
|
* @param name name for the table. must be case-insensitive unique
|
|
527
527
|
* @param fields array of fields to create in the table: see below for an example. `name` and
|
|
528
528
|
* `type` must be specified for all fields, while `options` is only required for fields that
|
|
529
|
-
* have field options. `description` is optional and will be
|
|
529
|
+
* have field options. `description` is optional and will be `''` if not specified or if
|
|
530
|
+
* specified as `null`.
|
|
530
531
|
*
|
|
531
532
|
* @example
|
|
532
533
|
* ```js
|
|
@@ -89,6 +89,7 @@ var WatchableCursorKeys = Object.freeze({
|
|
|
89
89
|
* return (
|
|
90
90
|
* <div>
|
|
91
91
|
* Active table: {cursor.activeTableId}
|
|
92
|
+
* <br />
|
|
92
93
|
* Active view: {cursor.activeViewId}
|
|
93
94
|
* </div>
|
|
94
95
|
* );
|
|
@@ -109,6 +110,7 @@ var WatchableCursorKeys = Object.freeze({
|
|
|
109
110
|
* return (
|
|
110
111
|
* <div>
|
|
111
112
|
* Selected records: {cursor.selectedRecordIds.join(', ')}
|
|
113
|
+
* <br />
|
|
112
114
|
* Selected fields: {cursor.selectedFieldIds.join(', ')}
|
|
113
115
|
* </div>
|
|
114
116
|
* );
|
package/dist/cjs/models/field.js
CHANGED
|
@@ -337,7 +337,8 @@ function (_AbstractModel) {
|
|
|
337
337
|
/**
|
|
338
338
|
* Updates the description for this field.
|
|
339
339
|
*
|
|
340
|
-
* To remove an existing description, pass `''`
|
|
340
|
+
* To remove an existing description, pass `''` as the new description.
|
|
341
|
+
* `null` is also accepted and will be coerced to `''` for consistency with field creation.
|
|
341
342
|
*
|
|
342
343
|
* Throws an error if the user does not have permission to update the field, or if an invalid
|
|
343
344
|
* description is provided.
|
|
@@ -350,18 +351,7 @@ function (_AbstractModel) {
|
|
|
350
351
|
*
|
|
351
352
|
* @example
|
|
352
353
|
* ```js
|
|
353
|
-
*
|
|
354
|
-
* const updatedOptions = {
|
|
355
|
-
* choices: [
|
|
356
|
-
* ...selectField.options.choices,
|
|
357
|
-
* {name: nameForNewOption},
|
|
358
|
-
* ]
|
|
359
|
-
* };
|
|
360
|
-
*
|
|
361
|
-
* if (selectField.hasPermissionToUpdateOptions(updatedOptions)) {
|
|
362
|
-
* await selectField.updateOptionsAsync(updatedOptions);
|
|
363
|
-
* }
|
|
364
|
-
* }
|
|
354
|
+
* await myTextField.updateDescriptionAsync('This is a text field');
|
|
365
355
|
* ```
|
|
366
356
|
*/
|
|
367
357
|
|
|
@@ -245,19 +245,13 @@ function (_RecordQueryResult) {
|
|
|
245
245
|
while (1) {
|
|
246
246
|
switch (_context2.prev = _context2.next) {
|
|
247
247
|
case 0:
|
|
248
|
-
|
|
249
|
-
//
|
|
250
|
-
|
|
251
|
-
// watching recordIds only changes if records in this group change.
|
|
252
|
-
// In the meantime this does ensure that a deleted GroupedRecordQuery with stale recordIds
|
|
253
|
-
// doesn't return the cached array.
|
|
248
|
+
// TODO: This entire class assumes it is torn down and re-created by the parent whenever
|
|
249
|
+
// a change to the group is made.
|
|
250
|
+
this._parentQueryResult.__groupedRecordQueryResultPool.registerObjectForReuseStrong(this);
|
|
254
251
|
|
|
255
|
-
|
|
256
|
-
this.watch(['recordIds', 'groups', 'groupLevels'], this._invalidateComputedRecordIds, this);
|
|
257
|
-
this.watch(['recordIds'], this._invalidateRecordIdsSet, this);
|
|
258
252
|
return _context2.abrupt("return", this._getChangedKeysOnLoad());
|
|
259
253
|
|
|
260
|
-
case
|
|
254
|
+
case 2:
|
|
261
255
|
case "end":
|
|
262
256
|
return _context2.stop();
|
|
263
257
|
}
|
|
@@ -269,10 +263,7 @@ function (_RecordQueryResult) {
|
|
|
269
263
|
}, {
|
|
270
264
|
key: "_unloadData",
|
|
271
265
|
value: function _unloadData() {
|
|
272
|
-
//
|
|
273
|
-
this.unwatch(['recordIds', 'groups', 'groupLevels'], this._invalidateComputedRecordIds, this);
|
|
274
|
-
this.unwatch(['recordIds'], this._invalidateRecordIdsSet, this); // Invalidate both of the caches, as this object can no longer be accessed
|
|
275
|
-
|
|
266
|
+
// Invalidate both of the caches, as this object can no longer be accessed
|
|
276
267
|
this._invalidateComputedRecordIds();
|
|
277
268
|
|
|
278
269
|
this._invalidateRecordIdsSet();
|
|
@@ -29,6 +29,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
29
29
|
});
|
|
30
30
|
exports.default = exports.getLinkedTableId = void 0;
|
|
31
31
|
|
|
32
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
33
|
+
|
|
32
34
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
33
35
|
|
|
34
36
|
require("regenerator-runtime/runtime");
|
|
@@ -53,8 +55,14 @@ var _field = require("../types/field");
|
|
|
53
55
|
|
|
54
56
|
var _error_utils = require("../error_utils");
|
|
55
57
|
|
|
58
|
+
var _block_query_spec = require("../types/block_query_spec");
|
|
59
|
+
|
|
60
|
+
var _airtable_interface = require("../types/airtable_interface");
|
|
61
|
+
|
|
56
62
|
var _record_query_result = _interopRequireDefault(require("./record_query_result"));
|
|
57
63
|
|
|
64
|
+
var _record_store = require("./record_store");
|
|
65
|
+
|
|
58
66
|
/** @module @airtable/blocks/models: RecordQueryResult */
|
|
59
67
|
|
|
60
68
|
/** */
|
|
@@ -118,6 +126,8 @@ function (_RecordQueryResult) {
|
|
|
118
126
|
|
|
119
127
|
/** @internal */
|
|
120
128
|
|
|
129
|
+
/** @internal */
|
|
130
|
+
|
|
121
131
|
/** @internal */
|
|
122
132
|
function LinkedRecordsQueryResult(record, field, normalizedOpts, sdk) {
|
|
123
133
|
var _this;
|
|
@@ -134,6 +144,7 @@ function (_RecordQueryResult) {
|
|
|
134
144
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_computedRecordIdsSet", null);
|
|
135
145
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_computedFilteredSortedRecordIds", null);
|
|
136
146
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_cellValueChangeHandlerByFieldId", {});
|
|
147
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_recordStoreQueryId", null);
|
|
137
148
|
(0, _error_utils.invariant)(record.parentTable === field.parentTable, 'record and field must belong to the same table');
|
|
138
149
|
_this._record = record;
|
|
139
150
|
_this._field = field;
|
|
@@ -279,7 +290,7 @@ function (_RecordQueryResult) {
|
|
|
279
290
|
}, {
|
|
280
291
|
key: "_loadDataAsync",
|
|
281
292
|
value: function _loadDataAsync() {
|
|
282
|
-
var initiallyLoaded, changedKeys, fieldIds, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, fieldId;
|
|
293
|
+
var initiallyLoaded, _ref, _ref2, recordStoreQueryId, changedKeys, fieldIds, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, fieldId;
|
|
283
294
|
|
|
284
295
|
return _regenerator.default.async(function _loadDataAsync$(_context2) {
|
|
285
296
|
while (1) {
|
|
@@ -291,11 +302,21 @@ function (_RecordQueryResult) {
|
|
|
291
302
|
|
|
292
303
|
this._watchLinkedQueryResult();
|
|
293
304
|
|
|
294
|
-
initiallyLoaded = this._linkedQueryResult.isDataLoaded;
|
|
305
|
+
initiallyLoaded = this._linkedQueryResult.isDataLoaded; // https://airtable.com/appahuJQw7qfQTBBU/tblSbpimM8Spp9txp/viweAFIus3MhU9Gxa/recNjFYJpeV23LPhH?blocks=hide
|
|
306
|
+
// TODO: (#proj-blocks-sdk-record-limits) Currently queries all cell values in a table
|
|
307
|
+
// when loading linked record data. Must add a LinkedRecord query type in the future.
|
|
308
|
+
// Since _loadDataAsync can only be called once, this recordStoreQueryId is only set once,
|
|
309
|
+
// although it is guaranteed to be stable if needed (so long as this._field.id is stable)
|
|
310
|
+
|
|
295
311
|
_context2.next = 6;
|
|
296
|
-
return _regenerator.default.awrap(Promise.all([this._sdk.base.__getRecordStore(this._record.parentTable.id).
|
|
312
|
+
return _regenerator.default.awrap(Promise.all([this._sdk.base.__getRecordStore(this._record.parentTable.id).loadAllCellValuesInFieldIdsAsync([this._field.id]), this._linkedQueryResult.loadDataAsync(), this._loadRecordColorsAsync()]));
|
|
297
313
|
|
|
298
314
|
case 6:
|
|
315
|
+
_ref = _context2.sent;
|
|
316
|
+
_ref2 = (0, _slicedToArray2.default)(_ref, 1);
|
|
317
|
+
recordStoreQueryId = _ref2[0];
|
|
318
|
+
this._recordStoreQueryId = recordStoreQueryId;
|
|
319
|
+
|
|
299
320
|
this._invalidateComputedData();
|
|
300
321
|
|
|
301
322
|
changedKeys = ['records', 'recordIds', 'recordColors']; // If the linked query result was not initially loaded, then the
|
|
@@ -311,55 +332,55 @@ function (_RecordQueryResult) {
|
|
|
311
332
|
_iteratorNormalCompletion3 = true;
|
|
312
333
|
_didIteratorError3 = false;
|
|
313
334
|
_iteratorError3 = undefined;
|
|
314
|
-
_context2.prev =
|
|
335
|
+
_context2.prev = 17;
|
|
315
336
|
|
|
316
337
|
for (_iterator3 = fieldIds[Symbol.iterator](); !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
317
338
|
fieldId = _step3.value;
|
|
318
339
|
changedKeys.push(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId);
|
|
319
340
|
}
|
|
320
341
|
|
|
321
|
-
_context2.next =
|
|
342
|
+
_context2.next = 25;
|
|
322
343
|
break;
|
|
323
344
|
|
|
324
|
-
case
|
|
325
|
-
_context2.prev =
|
|
326
|
-
_context2.t0 = _context2["catch"](
|
|
345
|
+
case 21:
|
|
346
|
+
_context2.prev = 21;
|
|
347
|
+
_context2.t0 = _context2["catch"](17);
|
|
327
348
|
_didIteratorError3 = true;
|
|
328
349
|
_iteratorError3 = _context2.t0;
|
|
329
350
|
|
|
330
|
-
case
|
|
331
|
-
_context2.prev =
|
|
332
|
-
_context2.prev =
|
|
351
|
+
case 25:
|
|
352
|
+
_context2.prev = 25;
|
|
353
|
+
_context2.prev = 26;
|
|
333
354
|
|
|
334
355
|
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
335
356
|
_iterator3.return();
|
|
336
357
|
}
|
|
337
358
|
|
|
338
|
-
case
|
|
339
|
-
_context2.prev =
|
|
359
|
+
case 28:
|
|
360
|
+
_context2.prev = 28;
|
|
340
361
|
|
|
341
362
|
if (!_didIteratorError3) {
|
|
342
|
-
_context2.next =
|
|
363
|
+
_context2.next = 31;
|
|
343
364
|
break;
|
|
344
365
|
}
|
|
345
366
|
|
|
346
367
|
throw _iteratorError3;
|
|
347
368
|
|
|
348
|
-
case
|
|
349
|
-
return _context2.finish(
|
|
369
|
+
case 31:
|
|
370
|
+
return _context2.finish(28);
|
|
350
371
|
|
|
351
|
-
case
|
|
352
|
-
return _context2.finish(
|
|
372
|
+
case 32:
|
|
373
|
+
return _context2.finish(25);
|
|
353
374
|
|
|
354
|
-
case
|
|
375
|
+
case 33:
|
|
355
376
|
return _context2.abrupt("return", changedKeys);
|
|
356
377
|
|
|
357
|
-
case
|
|
378
|
+
case 34:
|
|
358
379
|
case "end":
|
|
359
380
|
return _context2.stop();
|
|
360
381
|
}
|
|
361
382
|
}
|
|
362
|
-
}, null, this, [[
|
|
383
|
+
}, null, this, [[17, 21, 25, 33], [26,, 28, 32]]);
|
|
363
384
|
}
|
|
364
385
|
/** @internal */
|
|
365
386
|
|
|
@@ -376,7 +397,9 @@ function (_RecordQueryResult) {
|
|
|
376
397
|
|
|
377
398
|
this._unwatchLinkedQueryResult();
|
|
378
399
|
|
|
379
|
-
|
|
400
|
+
(0, _error_utils.invariant)(this._recordStoreQueryId, 'Unsubscribing from linked record record store without queryId');
|
|
401
|
+
|
|
402
|
+
this._originRecordStore.unloadCellValuesForQueryIdsThatAreSubscribedToAllCells([this._recordStoreQueryId]);
|
|
380
403
|
|
|
381
404
|
this._linkedQueryResult.unloadData();
|
|
382
405
|
|
|
@@ -448,7 +471,13 @@ function (_RecordQueryResult) {
|
|
|
448
471
|
// result
|
|
449
472
|
|
|
450
473
|
|
|
451
|
-
this._originRecordStore.
|
|
474
|
+
this._originRecordStore.watchWithRecordQueryResult({
|
|
475
|
+
priority: _airtable_interface.BlockQueryCallbackPriority.SDK,
|
|
476
|
+
recordQueryResult: this,
|
|
477
|
+
keys: _record_store.WatchableRecordStoreKeys.recordIds,
|
|
478
|
+
callbackForRegistration: this._onOriginRecordsChange,
|
|
479
|
+
context: this
|
|
480
|
+
}); // if the linked field in the origin table is deleted, we need to
|
|
452
481
|
// invalidate this result
|
|
453
482
|
|
|
454
483
|
|
|
@@ -592,11 +621,12 @@ function (_RecordQueryResult) {
|
|
|
592
621
|
if (Array.isArray(recordIds)) {
|
|
593
622
|
var recordIdsSet = this._getOrGenerateRecordIdsSet();
|
|
594
623
|
|
|
595
|
-
var filteredRecordIds = recordIds.filter(id => typeof id === 'string' && recordIdsSet[id] === true);
|
|
624
|
+
var filteredRecordIds = recordIds.filter(id => typeof id === 'string' && recordIdsSet[id] === true); // There should always be a filteredRecordIds found for this query
|
|
625
|
+
// type - not finding any is a fundamental mistake in our query engine
|
|
596
626
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
627
|
+
(0, _error_utils.invariant)(filteredRecordIds.length, 'Filtered record change on incorrect record, query engine issue');
|
|
628
|
+
|
|
629
|
+
this._onChange(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId, filteredRecordIds);
|
|
600
630
|
} else {
|
|
601
631
|
this._onChange(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId);
|
|
602
632
|
}
|
|
@@ -776,6 +806,27 @@ function (_RecordQueryResult) {
|
|
|
776
806
|
(0, _error_utils.invariant)(recordIdsSet, 'recordIdsSet must exist');
|
|
777
807
|
return recordIdsSet;
|
|
778
808
|
}
|
|
809
|
+
/**
|
|
810
|
+
* This allows a record query result to specify the source of the query
|
|
811
|
+
* eg: View, Table, Linked record when watching fields.
|
|
812
|
+
* This scopes the watch to those fields + rows in the query.
|
|
813
|
+
*
|
|
814
|
+
* @internal
|
|
815
|
+
*/
|
|
816
|
+
|
|
817
|
+
}, {
|
|
818
|
+
key: "__constructQuerySpecForBlockFieldSelectionSpec",
|
|
819
|
+
value: function __constructQuerySpecForBlockFieldSelectionSpec(fieldSelection) {
|
|
820
|
+
// The origin tableId is always the one referred to here as we must watch the origin record for deletion
|
|
821
|
+
var originTableId = this._record.parentTable.id;
|
|
822
|
+
return {
|
|
823
|
+
sourceType: _block_query_spec.BlockQuerySourceType.TABLE,
|
|
824
|
+
sourceTableId: originTableId,
|
|
825
|
+
recordSelection: {
|
|
826
|
+
fieldSelection
|
|
827
|
+
}
|
|
828
|
+
};
|
|
829
|
+
}
|
|
779
830
|
}, {
|
|
780
831
|
key: "isValid",
|
|
781
832
|
get: function get() {
|