@airtable/blocks 1.11.1-experimental-68738f2-20220526 → 1.13.0
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/README.md +2 -2
- package/dist/cjs/error_utils.js +1 -19
- package/dist/cjs/global_config.js +3 -3
- package/dist/cjs/injected/airtable_interface.js +1 -1
- package/dist/cjs/models/base.js +9 -9
- package/dist/cjs/models/cursor.js +3 -3
- package/dist/cjs/models/field.js +3 -3
- package/dist/cjs/models/grouped_record_query_result.js +14 -5
- package/dist/cjs/models/linked_records_query_result.js +27 -78
- package/dist/cjs/models/mutations.js +163 -18
- package/dist/cjs/models/record.js +55 -310
- package/dist/cjs/models/record_query_result.js +2 -5
- package/dist/cjs/models/record_store.js +829 -555
- package/dist/cjs/models/session.js +3 -3
- package/dist/cjs/models/table.js +31 -31
- package/dist/cjs/models/table_or_view_query_result.js +419 -526
- package/dist/cjs/models/view.js +23 -1
- package/dist/cjs/models/view_data_store.js +295 -255
- package/dist/cjs/private_utils.js +0 -40
- package/dist/cjs/sdk.js +9 -12
- package/dist/cjs/settings_button.js +1 -1
- package/dist/cjs/testing/abstract_mock_airtable_interface.js +11 -57
- package/dist/cjs/types/airtable_interface.js +2 -17
- package/dist/cjs/ui/block_wrapper.js +2 -5
- package/dist/cjs/ui/expand_record_picker_async.js +1 -1
- package/dist/cjs/ui/global_config_synced_component_helpers.js +6 -0
- package/dist/cjs/ui/initialize_block.js +3 -3
- package/dist/cjs/ui/use_global_config.js +1 -1
- package/dist/cjs/ui/use_loadable.js +3 -3
- package/dist/cjs/ui/use_record_action_data.js +11 -11
- package/dist/cjs/ui/use_records.js +1 -5
- package/dist/cjs/ui/use_settings_button.js +1 -1
- package/dist/cjs/ui/viewport_constraint.js +1 -1
- package/dist/cjs/unstable_testing_utils.js +1 -61
- package/dist/cjs/viewport.js +9 -9
- package/dist/cjs/watchable.js +1 -15
- package/dist/types/src/error_utils.d.ts +1 -2
- package/dist/types/src/error_utils.d.ts.map +1 -1
- package/dist/types/src/global_config.d.ts +3 -3
- package/dist/types/src/models/base.d.ts +9 -9
- package/dist/types/src/models/cursor.d.ts +3 -3
- package/dist/types/src/models/field.d.ts +3 -3
- 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/record.d.ts +3 -12
- package/dist/types/src/models/record.d.ts.map +1 -1
- package/dist/types/src/models/record_query_result.d.ts +4 -5
- 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/session.d.ts +3 -3
- package/dist/types/src/models/table.d.ts +25 -25
- package/dist/types/src/models/table_or_view_query_result.d.ts +5 -3
- package/dist/types/src/models/table_or_view_query_result.d.ts.map +1 -1
- package/dist/types/src/models/view.d.ts +11 -0
- package/dist/types/src/models/view.d.ts.map +1 -1
- package/dist/types/src/models/view_data_store.d.ts +1 -0
- 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 +1 -24
- package/dist/types/src/private_utils.d.ts.map +1 -1
- package/dist/types/src/sdk.d.ts +3 -1
- package/dist/types/src/sdk.d.ts.map +1 -1
- package/dist/types/src/settings_button.d.ts +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/src/types/airtable_interface.d.ts +20 -59
- package/dist/types/src/types/airtable_interface.d.ts.map +1 -1
- package/dist/types/src/types/field.d.ts +10 -5
- package/dist/types/src/types/field.d.ts.map +1 -1
- package/dist/types/src/types/table.d.ts +2 -0
- package/dist/types/src/types/table.d.ts.map +1 -1
- package/dist/types/src/types/view.d.ts +9 -3
- package/dist/types/src/types/view.d.ts.map +1 -1
- package/dist/types/src/ui/block_wrapper.d.ts.map +1 -1
- package/dist/types/src/ui/expand_record_picker_async.d.ts +1 -1
- package/dist/types/src/ui/global_config_synced_component_helpers.d.ts.map +1 -1
- package/dist/types/src/ui/initialize_block.d.ts +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/ui/use_loadable.d.ts +2 -2
- package/dist/types/src/ui/use_record_action_data.d.ts +11 -11
- package/dist/types/src/ui/use_settings_button.d.ts +1 -1
- package/dist/types/src/ui/viewport_constraint.d.ts +3 -3
- package/dist/types/src/ui/viewport_constraint.d.ts.map +1 -1
- package/dist/types/src/unstable_testing_utils.d.ts +1 -4
- package/dist/types/src/unstable_testing_utils.d.ts.map +1 -1
- package/dist/types/src/viewport.d.ts +9 -9
- package/dist/types/src/watchable.d.ts.map +1 -1
- package/dist/types/{src/testing → test/airtable_interface_mocks}/fixture_data.d.ts +25 -44
- package/dist/types/test/airtable_interface_mocks/fixture_data.d.ts.map +1 -0
- 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 +12 -19
- 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 +0 -2
- package/dist/types/test/test_helpers.d.ts.map +1 -1
- package/package.json +2 -3
- package/dist/cjs/models/query_manager.js +0 -328
- package/dist/cjs/testing/fixture_data.js +0 -271
- package/dist/cjs/testing/mock_base_data_stores.js +0 -891
- package/dist/cjs/types/block_query_spec.js +0 -85
- package/dist/types/src/models/query_manager.d.ts +0 -2
- package/dist/types/src/models/query_manager.d.ts.map +0 -1
- package/dist/types/src/testing/fixture_data.d.ts.map +0 -1
- package/dist/types/src/testing/mock_base_data_stores.d.ts +0 -59
- package/dist/types/src/testing/mock_base_data_stores.d.ts.map +0 -1
- package/dist/types/src/types/block_query_spec.d.ts +0 -139
- package/dist/types/src/types/block_query_spec.d.ts.map +0 -1
- package/dist/types/test/testing/fixture_data.test.d.ts +0 -2
- package/dist/types/test/testing/fixture_data.test.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @airtable/blocks
|
|
2
2
|
|
|
3
|
-
With the Blocks SDK, you can create your own custom
|
|
4
|
-
integrations, visualizations, internal tools, and more!
|
|
3
|
+
With the Blocks SDK, you can create your own custom extensions on top of Airtable. These extensions
|
|
4
|
+
can be integrations, visualizations, internal tools, and more!
|
|
5
5
|
|
|
6
6
|
To get started, check out the
|
|
7
7
|
[official Blocks SDK documentation website](https://airtable.com/developers/blocks). If you have any
|
package/dist/cjs/error_utils.js
CHANGED
|
@@ -9,7 +9,6 @@ exports.spawnError = spawnError;
|
|
|
9
9
|
exports.logErrorToSentry = logErrorToSentry;
|
|
10
10
|
exports.invariant = invariant;
|
|
11
11
|
exports.spawnUnknownSwitchCaseError = spawnUnknownSwitchCaseError;
|
|
12
|
-
exports.spawnExhaustiveSwitchError = spawnExhaustiveSwitchError;
|
|
13
12
|
exports.spawnAbstractMethodError = spawnAbstractMethodError;
|
|
14
13
|
|
|
15
14
|
// If errorOriginFn is specified, all frames above and including the call to errorOriginFn
|
|
@@ -57,8 +56,7 @@ function spawnError(errorMessageFormat) {
|
|
|
57
56
|
} // istanbul ignore next
|
|
58
57
|
|
|
59
58
|
/**
|
|
60
|
-
* Logs an error to Sentry
|
|
61
|
-
* but we leave the definition here for future usage needs.
|
|
59
|
+
* Logs an error to Sentry
|
|
62
60
|
*
|
|
63
61
|
* @hidden
|
|
64
62
|
*/
|
|
@@ -98,22 +96,6 @@ function spawnUnknownSwitchCaseError(valueDescription, providedValue, key) {
|
|
|
98
96
|
var providedValueKeyString = providedValueKey !== null && providedValueKey !== undefined ? providedValueKey : 'null';
|
|
99
97
|
return spawnErrorWithOriginOmittedFromStackTrace('Unknown value %s for %s', [providedValueKeyString, valueDescription], spawnUnknownSwitchCaseError);
|
|
100
98
|
}
|
|
101
|
-
/**
|
|
102
|
-
* Forces TypeScript to prove that calling this function is impossible at a
|
|
103
|
-
* type level by accepting `never`. In the unlikely case this function is
|
|
104
|
-
* called we infer a useful error message.
|
|
105
|
-
*
|
|
106
|
-
* @internal
|
|
107
|
-
*/
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
function spawnExhaustiveSwitchError(impossibleValue) {
|
|
111
|
-
if (impossibleValue === null) {
|
|
112
|
-
return spawnErrorWithOriginOmittedFromStackTrace('Unexpected null in exhaustive switch', undefined, spawnExhaustiveSwitchError);
|
|
113
|
-
} else {
|
|
114
|
-
return spawnErrorWithOriginOmittedFromStackTrace("Unexpected %s in exhaustive switch", [typeof impossibleValue], spawnExhaustiveSwitchError);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
99
|
/**
|
|
118
100
|
* @internal
|
|
119
101
|
*/
|
|
@@ -59,7 +59,7 @@ var _private_utils = require("./private_utils");
|
|
|
59
59
|
// as a name seems a bit too vague in terms of intended usage).
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
* A key-value store for persisting configuration options for an
|
|
62
|
+
* A key-value store for persisting configuration options for an extension installation.
|
|
63
63
|
*
|
|
64
64
|
* The contents will be synced in real-time to all logged-in users of the installation.
|
|
65
65
|
* Contents will not be updated in real-time when the installation is running in
|
|
@@ -287,7 +287,7 @@ function (_Watchable) {
|
|
|
287
287
|
* if (globalConfig.hasPermissionToSetPaths('favoriteColor', color)) {
|
|
288
288
|
* globalConfig.setAsync('favoriteColor', color);
|
|
289
289
|
* }
|
|
290
|
-
* // The update is now applied within your
|
|
290
|
+
* // The update is now applied within your extension (eg will be
|
|
291
291
|
* // reflected in globalConfig) but are still being saved to
|
|
292
292
|
* // Airtable servers (e.g. may not be updated for other users yet)
|
|
293
293
|
* }
|
|
@@ -423,7 +423,7 @@ function (_Watchable) {
|
|
|
423
423
|
* if (globalConfig.hasPermissionToSetPaths(updates)) {
|
|
424
424
|
* globalConfig.setPathsAsync(updates);
|
|
425
425
|
* }
|
|
426
|
-
* // The updates are now applied within your
|
|
426
|
+
* // The updates are now applied within your extension (eg will be reflected in
|
|
427
427
|
* // globalConfig) but are still being saved to Airtable servers (e.g. they
|
|
428
428
|
* // may not be updated for other users yet)
|
|
429
429
|
* }
|
|
@@ -9,7 +9,7 @@ var _error_utils = require("../error_utils");
|
|
|
9
9
|
|
|
10
10
|
var AIRTABLE_INTERFACE_VERSION = 0;
|
|
11
11
|
var airtableInterface = null;
|
|
12
|
-
var missingAirtableInterfaceErrorMessage = ['Error:
|
|
12
|
+
var missingAirtableInterfaceErrorMessage = ['Error: Extension environment misconfigured', '\n\n', 'Airtable Extensions can only run in the presence of an Airtable Base. If you ', 'are trying to run your Extension with a Base hosted on airtable.com, then be ', 'sure you are using the Airtable CLI to serve your code and accessing it ', 'through a Custom Extension installed inside a Base on airtable.com.', '\n\n', 'If you are trying to run automated tests for your Extension, then make sure ', 'you have loaded the `@airtable/testing-library` module *before* the ', '`@airtable/blocks` module.'].join('');
|
|
13
13
|
/** @hidden */
|
|
14
14
|
|
|
15
15
|
function getAirtableInterface() {
|
package/dist/cjs/models/base.js
CHANGED
|
@@ -186,8 +186,8 @@ function (_AbstractModel) {
|
|
|
186
186
|
* The user matching the given ID, name, or email address. Returns null if that user does not
|
|
187
187
|
* exist or does not have access to this base.
|
|
188
188
|
*
|
|
189
|
-
* This method is convenient when building an
|
|
190
|
-
*
|
|
189
|
+
* This method is convenient when building an extension for a specific base, but for more generic
|
|
190
|
+
* extensions the best practice is to use the {@link getCollaboratorByIdIfExists} method instead.
|
|
191
191
|
*
|
|
192
192
|
* @param collaboratorIdOrNameOrEmail The ID of the user.
|
|
193
193
|
*/
|
|
@@ -254,8 +254,8 @@ function (_AbstractModel) {
|
|
|
254
254
|
* or does not have access to this base. Use {@link getCollaboratorIfExists} instead if you are
|
|
255
255
|
* unsure whether a collaborator with the given ID exists and has access to this base.
|
|
256
256
|
*
|
|
257
|
-
* This method is convenient when building an
|
|
258
|
-
*
|
|
257
|
+
* This method is convenient when building an extension for a specific base, but for more generic
|
|
258
|
+
* extensions the best practice is to use the {@link getCollaboratorById} method instead.
|
|
259
259
|
*
|
|
260
260
|
* @param collaboratorIdOrNameOrEmail The ID of the user.
|
|
261
261
|
*/
|
|
@@ -397,8 +397,8 @@ function (_AbstractModel) {
|
|
|
397
397
|
* The table matching the given ID or name. Returns `null` if no matching table exists within
|
|
398
398
|
* this base.
|
|
399
399
|
*
|
|
400
|
-
* This method is convenient when building an
|
|
401
|
-
*
|
|
400
|
+
* This method is convenient when building an extension for a specific base, but for more generic
|
|
401
|
+
* extensions the best practice is to use the {@link getTableByIdIfExists} or
|
|
402
402
|
* {@link getTableByNameIfExists} methods instead.
|
|
403
403
|
*
|
|
404
404
|
* @param tableIdOrName The ID or name of the table you're looking for.
|
|
@@ -416,8 +416,8 @@ function (_AbstractModel) {
|
|
|
416
416
|
* Use {@link getTableIfExists} instead if you are unsure whether a table exists with the given
|
|
417
417
|
* name/ID.
|
|
418
418
|
*
|
|
419
|
-
* This method is convenient when building an
|
|
420
|
-
*
|
|
419
|
+
* This method is convenient when building an extension for a specific base, but for more generic
|
|
420
|
+
* extensions the best practice is to use the {@link getTableById} or {@link getTableByName} methods
|
|
421
421
|
* instead.
|
|
422
422
|
*
|
|
423
423
|
* @param tableIdOrName The ID or name of the table you're looking for.
|
|
@@ -521,7 +521,7 @@ function (_AbstractModel) {
|
|
|
521
521
|
*
|
|
522
522
|
* This action is asynchronous. Unlike new records, new tables are **not** created
|
|
523
523
|
* optimistically locally. You must `await` the returned promise before using the new
|
|
524
|
-
* table in your
|
|
524
|
+
* table in your extension.
|
|
525
525
|
*
|
|
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
|
|
@@ -268,7 +268,7 @@ function (_AbstractModelWithAsy) {
|
|
|
268
268
|
key: "setActiveTable",
|
|
269
269
|
|
|
270
270
|
/**
|
|
271
|
-
* Sets the specified table to active in the Airtable UI. If the
|
|
271
|
+
* Sets the specified table to active in the Airtable UI. If the extension installation or extensions pane
|
|
272
272
|
* is fullscreen, fullscreen mode will be exited.
|
|
273
273
|
*
|
|
274
274
|
* @param tableOrTableId The target table or table ID to set as active in the Airtable main page.
|
|
@@ -279,8 +279,8 @@ function (_AbstractModelWithAsy) {
|
|
|
279
279
|
this._sdk.__airtableInterface.setActiveViewOrTable(tableId);
|
|
280
280
|
}
|
|
281
281
|
/**
|
|
282
|
-
* Sets the specified view (and corresponding table) to active in the Airtable UI. If the
|
|
283
|
-
* installation or
|
|
282
|
+
* Sets the specified view (and corresponding table) to active in the Airtable UI. If the extension
|
|
283
|
+
* installation or extensions pane is fullscreen, fullscreen mode will be exited.
|
|
284
284
|
*
|
|
285
285
|
* @param tableOrTableId The table or table ID that the target view belongs to.
|
|
286
286
|
* @param viewOrViewId The target view or view ID to set as active in the Airtable main page.
|
package/dist/cjs/models/field.js
CHANGED
|
@@ -225,7 +225,7 @@ function (_AbstractModel) {
|
|
|
225
225
|
*
|
|
226
226
|
* This action is asynchronous. Unlike updates to cell values, updates to field options are
|
|
227
227
|
* **not** applied optimistically locally. You must `await` the returned promise before
|
|
228
|
-
* relying on the change in your
|
|
228
|
+
* relying on the change in your extension.
|
|
229
229
|
*
|
|
230
230
|
* Optionally, you can pass an `opts` object as the second argument. See {@link UpdateFieldOptionsOpts}
|
|
231
231
|
* for available options.
|
|
@@ -342,7 +342,7 @@ function (_AbstractModel) {
|
|
|
342
342
|
*
|
|
343
343
|
* This action is asynchronous. Unlike updates to cell values, updates to field name are
|
|
344
344
|
* **not** applied optimistically locally. You must `await` the returned promise before
|
|
345
|
-
* relying on the change in your
|
|
345
|
+
* relying on the change in your extension.
|
|
346
346
|
*
|
|
347
347
|
* @param name new name for the field
|
|
348
348
|
*
|
|
@@ -440,7 +440,7 @@ function (_AbstractModel) {
|
|
|
440
440
|
*
|
|
441
441
|
* This action is asynchronous. Unlike updates to cell values, updates to field descriptions are
|
|
442
442
|
* **not** applied optimistically locally. You must `await` the returned promise before
|
|
443
|
-
* relying on the change in your
|
|
443
|
+
* relying on the change in your extension.
|
|
444
444
|
*
|
|
445
445
|
* @param description new description for the field
|
|
446
446
|
*
|
|
@@ -245,13 +245,19 @@ function (_RecordQueryResult) {
|
|
|
245
245
|
while (1) {
|
|
246
246
|
switch (_context2.prev = _context2.next) {
|
|
247
247
|
case 0:
|
|
248
|
-
//
|
|
249
|
-
//
|
|
250
|
-
this
|
|
248
|
+
this._parentQueryResult.__groupedRecordQueryResultPool.registerObjectForReuseStrong(this); // Ensure we invalidate our memoized computed recordIds whenever a relevant hook changes
|
|
249
|
+
// TODO: (SeanKeenan) At the moment this should never be relevant, because groups are recreated
|
|
250
|
+
// anytime the groups change - but this is how it should work once groups persist AND
|
|
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.
|
|
251
254
|
|
|
255
|
+
|
|
256
|
+
this.watch(['recordIds', 'groups', 'groupLevels'], this._invalidateComputedRecordIds, this);
|
|
257
|
+
this.watch(['recordIds'], this._invalidateRecordIdsSet, this);
|
|
252
258
|
return _context2.abrupt("return", this._getChangedKeysOnLoad());
|
|
253
259
|
|
|
254
|
-
case
|
|
260
|
+
case 4:
|
|
255
261
|
case "end":
|
|
256
262
|
return _context2.stop();
|
|
257
263
|
}
|
|
@@ -263,7 +269,10 @@ function (_RecordQueryResult) {
|
|
|
263
269
|
}, {
|
|
264
270
|
key: "_unloadData",
|
|
265
271
|
value: function _unloadData() {
|
|
266
|
-
//
|
|
272
|
+
// Ensure we invalidate our memoized computed recordIds whenever a relevant hook changes
|
|
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
|
+
|
|
267
276
|
this._invalidateComputedRecordIds();
|
|
268
277
|
|
|
269
278
|
this._invalidateRecordIdsSet();
|
|
@@ -29,8 +29,6 @@ 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
|
-
|
|
34
32
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
35
33
|
|
|
36
34
|
require("regenerator-runtime/runtime");
|
|
@@ -55,14 +53,8 @@ var _field = require("../types/field");
|
|
|
55
53
|
|
|
56
54
|
var _error_utils = require("../error_utils");
|
|
57
55
|
|
|
58
|
-
var _block_query_spec = require("../types/block_query_spec");
|
|
59
|
-
|
|
60
|
-
var _airtable_interface = require("../types/airtable_interface");
|
|
61
|
-
|
|
62
56
|
var _record_query_result = _interopRequireDefault(require("./record_query_result"));
|
|
63
57
|
|
|
64
|
-
var _record_store = require("./record_store");
|
|
65
|
-
|
|
66
58
|
/** @module @airtable/blocks/models: RecordQueryResult */
|
|
67
59
|
|
|
68
60
|
/** */
|
|
@@ -126,8 +118,6 @@ function (_RecordQueryResult) {
|
|
|
126
118
|
|
|
127
119
|
/** @internal */
|
|
128
120
|
|
|
129
|
-
/** @internal */
|
|
130
|
-
|
|
131
121
|
/** @internal */
|
|
132
122
|
function LinkedRecordsQueryResult(record, field, normalizedOpts, sdk) {
|
|
133
123
|
var _this;
|
|
@@ -144,7 +134,6 @@ function (_RecordQueryResult) {
|
|
|
144
134
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_computedRecordIdsSet", null);
|
|
145
135
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_computedFilteredSortedRecordIds", null);
|
|
146
136
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_cellValueChangeHandlerByFieldId", {});
|
|
147
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_recordStoreQueryId", null);
|
|
148
137
|
(0, _error_utils.invariant)(record.parentTable === field.parentTable, 'record and field must belong to the same table');
|
|
149
138
|
_this._record = record;
|
|
150
139
|
_this._field = field;
|
|
@@ -290,7 +279,7 @@ function (_RecordQueryResult) {
|
|
|
290
279
|
}, {
|
|
291
280
|
key: "_loadDataAsync",
|
|
292
281
|
value: function _loadDataAsync() {
|
|
293
|
-
var initiallyLoaded,
|
|
282
|
+
var initiallyLoaded, changedKeys, fieldIds, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, fieldId;
|
|
294
283
|
|
|
295
284
|
return _regenerator.default.async(function _loadDataAsync$(_context2) {
|
|
296
285
|
while (1) {
|
|
@@ -302,21 +291,11 @@ function (_RecordQueryResult) {
|
|
|
302
291
|
|
|
303
292
|
this._watchLinkedQueryResult();
|
|
304
293
|
|
|
305
|
-
initiallyLoaded = this._linkedQueryResult.isDataLoaded;
|
|
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
|
-
|
|
294
|
+
initiallyLoaded = this._linkedQueryResult.isDataLoaded;
|
|
311
295
|
_context2.next = 6;
|
|
312
|
-
return _regenerator.default.awrap(Promise.all([this._sdk.base.__getRecordStore(this._record.parentTable.id).
|
|
296
|
+
return _regenerator.default.awrap(Promise.all([this._sdk.base.__getRecordStore(this._record.parentTable.id).loadCellValuesInFieldIdsAsync([this._field.id]), this._linkedQueryResult.loadDataAsync(), this._loadRecordColorsAsync()]));
|
|
313
297
|
|
|
314
298
|
case 6:
|
|
315
|
-
_ref = _context2.sent;
|
|
316
|
-
_ref2 = (0, _slicedToArray2.default)(_ref, 1);
|
|
317
|
-
recordStoreQueryId = _ref2[0];
|
|
318
|
-
this._recordStoreQueryId = recordStoreQueryId;
|
|
319
|
-
|
|
320
299
|
this._invalidateComputedData();
|
|
321
300
|
|
|
322
301
|
changedKeys = ['records', 'recordIds', 'recordColors']; // If the linked query result was not initially loaded, then the
|
|
@@ -332,55 +311,55 @@ function (_RecordQueryResult) {
|
|
|
332
311
|
_iteratorNormalCompletion3 = true;
|
|
333
312
|
_didIteratorError3 = false;
|
|
334
313
|
_iteratorError3 = undefined;
|
|
335
|
-
_context2.prev =
|
|
314
|
+
_context2.prev = 13;
|
|
336
315
|
|
|
337
316
|
for (_iterator3 = fieldIds[Symbol.iterator](); !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
338
317
|
fieldId = _step3.value;
|
|
339
318
|
changedKeys.push(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId);
|
|
340
319
|
}
|
|
341
320
|
|
|
342
|
-
_context2.next =
|
|
321
|
+
_context2.next = 21;
|
|
343
322
|
break;
|
|
344
323
|
|
|
345
|
-
case
|
|
346
|
-
_context2.prev =
|
|
347
|
-
_context2.t0 = _context2["catch"](
|
|
324
|
+
case 17:
|
|
325
|
+
_context2.prev = 17;
|
|
326
|
+
_context2.t0 = _context2["catch"](13);
|
|
348
327
|
_didIteratorError3 = true;
|
|
349
328
|
_iteratorError3 = _context2.t0;
|
|
350
329
|
|
|
351
|
-
case
|
|
352
|
-
_context2.prev =
|
|
353
|
-
_context2.prev =
|
|
330
|
+
case 21:
|
|
331
|
+
_context2.prev = 21;
|
|
332
|
+
_context2.prev = 22;
|
|
354
333
|
|
|
355
334
|
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
356
335
|
_iterator3.return();
|
|
357
336
|
}
|
|
358
337
|
|
|
359
|
-
case
|
|
360
|
-
_context2.prev =
|
|
338
|
+
case 24:
|
|
339
|
+
_context2.prev = 24;
|
|
361
340
|
|
|
362
341
|
if (!_didIteratorError3) {
|
|
363
|
-
_context2.next =
|
|
342
|
+
_context2.next = 27;
|
|
364
343
|
break;
|
|
365
344
|
}
|
|
366
345
|
|
|
367
346
|
throw _iteratorError3;
|
|
368
347
|
|
|
369
|
-
case
|
|
370
|
-
return _context2.finish(
|
|
348
|
+
case 27:
|
|
349
|
+
return _context2.finish(24);
|
|
371
350
|
|
|
372
|
-
case
|
|
373
|
-
return _context2.finish(
|
|
351
|
+
case 28:
|
|
352
|
+
return _context2.finish(21);
|
|
374
353
|
|
|
375
|
-
case
|
|
354
|
+
case 29:
|
|
376
355
|
return _context2.abrupt("return", changedKeys);
|
|
377
356
|
|
|
378
|
-
case
|
|
357
|
+
case 30:
|
|
379
358
|
case "end":
|
|
380
359
|
return _context2.stop();
|
|
381
360
|
}
|
|
382
361
|
}
|
|
383
|
-
}, null, this, [[17, 21,
|
|
362
|
+
}, null, this, [[13, 17, 21, 29], [22,, 24, 28]]);
|
|
384
363
|
}
|
|
385
364
|
/** @internal */
|
|
386
365
|
|
|
@@ -397,9 +376,7 @@ function (_RecordQueryResult) {
|
|
|
397
376
|
|
|
398
377
|
this._unwatchLinkedQueryResult();
|
|
399
378
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
this._originRecordStore.unloadCellValuesForQueryIdsThatAreSubscribedToAllCells([this._recordStoreQueryId]);
|
|
379
|
+
this._originRecordStore.unloadCellValuesInFieldIds([this._field.id]);
|
|
403
380
|
|
|
404
381
|
this._linkedQueryResult.unloadData();
|
|
405
382
|
|
|
@@ -471,13 +448,7 @@ function (_RecordQueryResult) {
|
|
|
471
448
|
// result
|
|
472
449
|
|
|
473
450
|
|
|
474
|
-
this._originRecordStore.
|
|
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
|
|
451
|
+
this._originRecordStore.watch('recordIds', this._onOriginRecordsChange, this); // if the linked field in the origin table is deleted, we need to
|
|
481
452
|
// invalidate this result
|
|
482
453
|
|
|
483
454
|
|
|
@@ -626,12 +597,11 @@ function (_RecordQueryResult) {
|
|
|
626
597
|
if (Array.isArray(recordIds)) {
|
|
627
598
|
var recordIdsSet = this._getOrGenerateRecordIdsSet();
|
|
628
599
|
|
|
629
|
-
var filteredRecordIds = recordIds.filter(id => typeof id === 'string' && recordIdsSet[id] === true);
|
|
630
|
-
// type - not finding any is a fundamental mistake in our query engine
|
|
600
|
+
var filteredRecordIds = recordIds.filter(id => typeof id === 'string' && recordIdsSet[id] === true);
|
|
631
601
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
602
|
+
if (filteredRecordIds.length) {
|
|
603
|
+
this._onChange(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId, filteredRecordIds);
|
|
604
|
+
}
|
|
635
605
|
} else {
|
|
636
606
|
this._onChange(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId);
|
|
637
607
|
}
|
|
@@ -815,27 +785,6 @@ function (_RecordQueryResult) {
|
|
|
815
785
|
(0, _error_utils.invariant)(recordIdsSet, 'recordIdsSet must exist');
|
|
816
786
|
return recordIdsSet;
|
|
817
787
|
}
|
|
818
|
-
/**
|
|
819
|
-
* This allows a record query result to specify the source of the query
|
|
820
|
-
* eg: View, Table, Linked record when watching fields.
|
|
821
|
-
* This scopes the watch to those fields + rows in the query.
|
|
822
|
-
*
|
|
823
|
-
* @internal
|
|
824
|
-
*/
|
|
825
|
-
|
|
826
|
-
}, {
|
|
827
|
-
key: "__constructQuerySpecForBlockFieldSelectionSpec",
|
|
828
|
-
value: function __constructQuerySpecForBlockFieldSelectionSpec(fieldSelection) {
|
|
829
|
-
// The origin tableId is always the one referred to here as we must watch the origin record for deletion
|
|
830
|
-
var originTableId = this._record.parentTable.id;
|
|
831
|
-
return {
|
|
832
|
-
sourceType: _block_query_spec.BlockQuerySourceType.TABLE,
|
|
833
|
-
sourceTableId: originTableId,
|
|
834
|
-
recordSelection: {
|
|
835
|
-
fieldSelection
|
|
836
|
-
}
|
|
837
|
-
};
|
|
838
|
-
}
|
|
839
788
|
}, {
|
|
840
789
|
key: "isValid",
|
|
841
790
|
get: function get() {
|