@airtable/blocks 1.10.2-experimental-640bd10-20220211 → 1.11.1
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 +12 -1
- package/dist/cjs/error_utils.js +9 -34
- package/dist/cjs/models/base.js +15 -0
- package/dist/cjs/models/field.js +99 -4
- package/dist/cjs/models/grouped_record_query_result.js +14 -5
- package/dist/cjs/models/linked_records_query_result.js +44 -86
- package/dist/cjs/models/mutations.js +234 -53
- package/dist/cjs/models/record.js +55 -310
- package/dist/cjs/models/record_query_result.js +1 -4
- package/dist/cjs/models/record_store.js +779 -557
- package/dist/cjs/models/table.js +6 -6
- package/dist/cjs/models/table_or_view_query_result.js +419 -526
- package/dist/cjs/models/view_data_store.js +295 -255
- package/dist/cjs/private_utils.js +0 -40
- package/dist/cjs/sdk.js +2 -12
- package/dist/cjs/testing/abstract_mock_airtable_interface.js +11 -57
- package/dist/cjs/types/airtable_interface.js +2 -17
- package/dist/cjs/types/mutations.js +1 -0
- package/dist/cjs/ui/use_records.js +1 -5
- package/dist/cjs/unstable_testing_utils.js +1 -55
- package/dist/cjs/watchable.js +1 -15
- package/dist/types/src/error_utils.d.ts +4 -2
- package/dist/types/src/error_utils.d.ts.map +1 -1
- package/dist/types/src/models/base.d.ts +10 -0
- package/dist/types/src/models/base.d.ts.map +1 -1
- package/dist/types/src/models/field.d.ts +58 -0
- 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/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 +2 -3
- 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_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_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.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/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/base.d.ts +1 -0
- package/dist/types/src/types/base.d.ts.map +1 -1
- package/dist/types/src/types/mutations.d.ts +25 -2
- package/dist/types/src/types/mutations.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 +8 -3
- package/dist/types/src/types/view.d.ts.map +1 -1
- package/dist/types/src/ui/record_card.d.ts +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/watchable.d.ts.map +1 -1
- package/dist/types/{src/testing → test/airtable_interface_mocks}/fixture_data.d.ts +19 -42
- 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 +1 -2
- package/dist/cjs/models/query_manager.js +0 -328
- package/dist/cjs/testing/fixture_data.js +0 -268
- package/dist/cjs/testing/mock_base_data_stores.js +0 -876
- 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 -55
- 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/CHANGELOG.md
CHANGED
|
@@ -9,10 +9,21 @@ 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.11.1...HEAD)
|
|
13
13
|
|
|
14
14
|
No changes.
|
|
15
15
|
|
|
16
|
+
## [1.11.1](https://github.com/airtable/blocks/compare/@airtable/blocks@1.11.0...@airtable/blocks@1.11.1) - 2022-04-13
|
|
17
|
+
|
|
18
|
+
- Update internal utilities for error reporting
|
|
19
|
+
|
|
20
|
+
## [1.11.0](https://github.com/airtable/blocks/compare/@airtable/blocks@1.10.2...@airtable/blocks@1.11.0) - 2022-03-10
|
|
21
|
+
|
|
22
|
+
- Add workspace id to base object.
|
|
23
|
+
- Add `Field.updateNameAsync`
|
|
24
|
+
- Fixes a crash when a linked record is deleted
|
|
25
|
+
- Fixes a crash when a record containing a linked record is deleted and restored
|
|
26
|
+
|
|
16
27
|
## [1.10.2](https://github.com/airtable/blocks/compare/@airtable/blocks@1.10.1...@airtable/blocks@1.10.2) - 2022-01-25
|
|
17
28
|
|
|
18
29
|
- Rare invariant failure addressed
|
package/dist/cjs/error_utils.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.array.iterator");
|
|
4
|
-
|
|
5
3
|
require("core-js/modules/es.string.replace");
|
|
6
4
|
|
|
7
|
-
require("core-js/modules/web.dom-collections.iterator");
|
|
8
|
-
|
|
9
5
|
Object.defineProperty(exports, "__esModule", {
|
|
10
6
|
value: true
|
|
11
7
|
});
|
|
12
8
|
exports.spawnError = spawnError;
|
|
13
|
-
exports.
|
|
9
|
+
exports.logErrorToSentry = logErrorToSentry;
|
|
14
10
|
exports.invariant = invariant;
|
|
15
11
|
exports.spawnUnknownSwitchCaseError = spawnUnknownSwitchCaseError;
|
|
16
|
-
exports.spawnExhaustiveSwitchError = spawnExhaustiveSwitchError;
|
|
17
12
|
exports.spawnAbstractMethodError = spawnAbstractMethodError;
|
|
18
13
|
|
|
19
14
|
// If errorOriginFn is specified, all frames above and including the call to errorOriginFn
|
|
@@ -61,22 +56,18 @@ function spawnError(errorMessageFormat) {
|
|
|
61
56
|
} // istanbul ignore next
|
|
62
57
|
|
|
63
58
|
/**
|
|
64
|
-
* Logs an error to
|
|
59
|
+
* Logs an error to Sentry
|
|
65
60
|
*
|
|
66
61
|
* @hidden
|
|
67
62
|
*/
|
|
68
63
|
|
|
69
64
|
|
|
70
|
-
function
|
|
71
|
-
// See this comment for how to log via
|
|
72
|
-
var
|
|
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
|
-
}
|
|
65
|
+
function logErrorToSentry(errorMessage, metadata) {
|
|
66
|
+
// See this comment for how to log via Sentry: https://github.com/Hyperbase/hyperbase/blob/2c5438ecaddcb9fa196e027e40df5e0c68c90989/client/run_block_frame.tsx#L333
|
|
67
|
+
var blocksErrorReporter = window.blocksErrorReporter;
|
|
78
68
|
|
|
79
|
-
|
|
69
|
+
if (blocksErrorReporter === null || blocksErrorReporter === void 0 ? void 0 : blocksErrorReporter.reportWarning) {
|
|
70
|
+
blocksErrorReporter.reportWarning(errorMessage, metadata);
|
|
80
71
|
}
|
|
81
72
|
}
|
|
82
73
|
/**
|
|
@@ -88,8 +79,8 @@ function logErrorToRollbar(errorMessageFormat) {
|
|
|
88
79
|
|
|
89
80
|
function invariant(condition, errorMessageFormat) {
|
|
90
81
|
if (!condition) {
|
|
91
|
-
for (var
|
|
92
|
-
errorMessageArgs[
|
|
82
|
+
for (var _len2 = arguments.length, errorMessageArgs = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
83
|
+
errorMessageArgs[_key2 - 2] = arguments[_key2];
|
|
93
84
|
}
|
|
94
85
|
|
|
95
86
|
throw spawnErrorWithOriginOmittedFromStackTrace(errorMessageFormat, errorMessageArgs, invariant);
|
|
@@ -105,22 +96,6 @@ function spawnUnknownSwitchCaseError(valueDescription, providedValue, key) {
|
|
|
105
96
|
var providedValueKeyString = providedValueKey !== null && providedValueKey !== undefined ? providedValueKey : 'null';
|
|
106
97
|
return spawnErrorWithOriginOmittedFromStackTrace('Unknown value %s for %s', [providedValueKeyString, valueDescription], spawnUnknownSwitchCaseError);
|
|
107
98
|
}
|
|
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
|
-
}
|
|
124
99
|
/**
|
|
125
100
|
* @internal
|
|
126
101
|
*/
|
package/dist/cjs/models/base.js
CHANGED
|
@@ -864,6 +864,21 @@ function (_AbstractModel) {
|
|
|
864
864
|
get: function get() {
|
|
865
865
|
return this._data.name;
|
|
866
866
|
}
|
|
867
|
+
/**
|
|
868
|
+
* The workspace id of the base.
|
|
869
|
+
*
|
|
870
|
+
* @example
|
|
871
|
+
* ```js
|
|
872
|
+
* import {base} from '@airtable/blocks';
|
|
873
|
+
* console.log('The workspace id of your base is', base.workspaceId);
|
|
874
|
+
* ```
|
|
875
|
+
*/
|
|
876
|
+
|
|
877
|
+
}, {
|
|
878
|
+
key: "workspaceId",
|
|
879
|
+
get: function get() {
|
|
880
|
+
return this._data.workspaceId;
|
|
881
|
+
}
|
|
867
882
|
/**
|
|
868
883
|
* The color of the base.
|
|
869
884
|
*
|
package/dist/cjs/models/field.js
CHANGED
|
@@ -279,6 +279,101 @@ function (_AbstractModel) {
|
|
|
279
279
|
}
|
|
280
280
|
}, null, this);
|
|
281
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* Checks whether the current user has permission to perform the given name update.
|
|
284
|
+
*
|
|
285
|
+
* Accepts partial input, in the same format as {@link updateNameAsync}.
|
|
286
|
+
*
|
|
287
|
+
* Returns `{hasPermission: true}` if the current user can update the specified field,
|
|
288
|
+
* `{hasPermission: false, reasonDisplayString: string}` otherwise. `reasonDisplayString` may be
|
|
289
|
+
* used to display an error message to the user.
|
|
290
|
+
*
|
|
291
|
+
* @param name new name for the field
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* ```js
|
|
295
|
+
* const updateFieldCheckResult = field.checkPermissionsForUpdateName();
|
|
296
|
+
*
|
|
297
|
+
* if (!updateFieldCheckResult.hasPermission) {
|
|
298
|
+
* alert(updateFieldCheckResult.reasonDisplayString);
|
|
299
|
+
* }
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
302
|
+
|
|
303
|
+
}, {
|
|
304
|
+
key: "checkPermissionsForUpdateName",
|
|
305
|
+
value: function checkPermissionsForUpdateName(name) {
|
|
306
|
+
return this._sdk.__mutations.checkPermissionsForMutation({
|
|
307
|
+
type: _mutations.MutationTypes.UPDATE_SINGLE_FIELD_NAME,
|
|
308
|
+
tableId: this.parentTable.id,
|
|
309
|
+
id: this.id,
|
|
310
|
+
name
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* An alias for `checkPermissionsForUpdateName(options).hasPermission`.
|
|
315
|
+
*
|
|
316
|
+
* Checks whether the current user has permission to perform the name update.
|
|
317
|
+
*
|
|
318
|
+
* Accepts partial input, in the same format as {@link updateNameAsync}.
|
|
319
|
+
*
|
|
320
|
+
* @param name new name for the field
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* ```js
|
|
324
|
+
* const canUpdateField = field.hasPermissionToUpdateName();
|
|
325
|
+
*
|
|
326
|
+
* if (!canUpdateField) {
|
|
327
|
+
* alert('not allowed!');
|
|
328
|
+
* }
|
|
329
|
+
* ```
|
|
330
|
+
*/
|
|
331
|
+
|
|
332
|
+
}, {
|
|
333
|
+
key: "hasPermissionToUpdateName",
|
|
334
|
+
value: function hasPermissionToUpdateName(name) {
|
|
335
|
+
return this.checkPermissionsForUpdateName(name).hasPermission;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Updates the name for this field.
|
|
339
|
+
*
|
|
340
|
+
* Throws an error if the user does not have permission to update the field, or if an invalid
|
|
341
|
+
* name is provided.
|
|
342
|
+
*
|
|
343
|
+
* This action is asynchronous. Unlike updates to cell values, updates to field name are
|
|
344
|
+
* **not** applied optimistically locally. You must `await` the returned promise before
|
|
345
|
+
* relying on the change in your app.
|
|
346
|
+
*
|
|
347
|
+
* @param name new name for the field
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* ```js
|
|
351
|
+
* await myTextField.updateNameAsync('My New Name');
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
|
|
355
|
+
}, {
|
|
356
|
+
key: "updateNameAsync",
|
|
357
|
+
value: function updateNameAsync(name) {
|
|
358
|
+
return _regenerator.default.async(function updateNameAsync$(_context2) {
|
|
359
|
+
while (1) {
|
|
360
|
+
switch (_context2.prev = _context2.next) {
|
|
361
|
+
case 0:
|
|
362
|
+
_context2.next = 2;
|
|
363
|
+
return _regenerator.default.awrap(this._sdk.__mutations.applyMutationAsync({
|
|
364
|
+
type: _mutations.MutationTypes.UPDATE_SINGLE_FIELD_NAME,
|
|
365
|
+
tableId: this.parentTable.id,
|
|
366
|
+
id: this.id,
|
|
367
|
+
name
|
|
368
|
+
}));
|
|
369
|
+
|
|
370
|
+
case 2:
|
|
371
|
+
case "end":
|
|
372
|
+
return _context2.stop();
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}, null, this);
|
|
376
|
+
}
|
|
282
377
|
/**
|
|
283
378
|
* Checks whether the current user has permission to perform the given description update.
|
|
284
379
|
*
|
|
@@ -358,11 +453,11 @@ function (_AbstractModel) {
|
|
|
358
453
|
}, {
|
|
359
454
|
key: "updateDescriptionAsync",
|
|
360
455
|
value: function updateDescriptionAsync(description) {
|
|
361
|
-
return _regenerator.default.async(function updateDescriptionAsync$(
|
|
456
|
+
return _regenerator.default.async(function updateDescriptionAsync$(_context3) {
|
|
362
457
|
while (1) {
|
|
363
|
-
switch (
|
|
458
|
+
switch (_context3.prev = _context3.next) {
|
|
364
459
|
case 0:
|
|
365
|
-
|
|
460
|
+
_context3.next = 2;
|
|
366
461
|
return _regenerator.default.awrap(this._sdk.__mutations.applyMutationAsync({
|
|
367
462
|
type: _mutations.MutationTypes.UPDATE_SINGLE_FIELD_DESCRIPTION,
|
|
368
463
|
tableId: this.parentTable.id,
|
|
@@ -372,7 +467,7 @@ function (_AbstractModel) {
|
|
|
372
467
|
|
|
373
468
|
case 2:
|
|
374
469
|
case "end":
|
|
375
|
-
return
|
|
470
|
+
return _context3.stop();
|
|
376
471
|
}
|
|
377
472
|
}
|
|
378
473
|
}, null, this);
|
|
@@ -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
|
|
|
@@ -549,12 +520,17 @@ function (_RecordQueryResult) {
|
|
|
549
520
|
}, {
|
|
550
521
|
key: "_onLinkedRecordIdsChange",
|
|
551
522
|
value: function _onLinkedRecordIdsChange() {
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
523
|
+
if (!this.isDataLoaded || this._record.isDeleted) {
|
|
524
|
+
//TODO(jamesmoody-at): Adding this._dataOrNullIfDeleted as an exit condition here is a temporary fix to address an issue where
|
|
525
|
+
// we are not reseting isValid to true while restoring deleted records that contain linked record fields. It seems the only way
|
|
526
|
+
// to do this is by creating a new LinkRecordsQueryResult instance but it seems like we might be reusing the original instance
|
|
527
|
+
// that we've already set isValid to false with. We'll need to do more investigating to figure out the right way to restore these
|
|
528
|
+
// records while keeping the behavior of isValid consistent
|
|
555
529
|
return;
|
|
556
530
|
}
|
|
557
531
|
|
|
532
|
+
(0, _error_utils.invariant)(this.isValid, 'watch key change event whilst invalid');
|
|
533
|
+
|
|
558
534
|
this._invalidateComputedData(); // we don't actually know at this stage whether anything changed or
|
|
559
535
|
// not. it may have done though, so notify watchers
|
|
560
536
|
|
|
@@ -621,12 +597,11 @@ function (_RecordQueryResult) {
|
|
|
621
597
|
if (Array.isArray(recordIds)) {
|
|
622
598
|
var recordIdsSet = this._getOrGenerateRecordIdsSet();
|
|
623
599
|
|
|
624
|
-
var filteredRecordIds = recordIds.filter(id => typeof id === 'string' && recordIdsSet[id] === true);
|
|
625
|
-
// type - not finding any is a fundamental mistake in our query engine
|
|
600
|
+
var filteredRecordIds = recordIds.filter(id => typeof id === 'string' && recordIdsSet[id] === true);
|
|
626
601
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
602
|
+
if (filteredRecordIds.length) {
|
|
603
|
+
this._onChange(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId, filteredRecordIds);
|
|
604
|
+
}
|
|
630
605
|
} else {
|
|
631
606
|
this._onChange(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId);
|
|
632
607
|
}
|
|
@@ -640,15 +615,19 @@ function (_RecordQueryResult) {
|
|
|
640
615
|
}, {
|
|
641
616
|
key: "_onOriginCellValueChange",
|
|
642
617
|
value: function _onOriginCellValueChange() {
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
618
|
+
if (!this.isDataLoaded || this._field.isDeleted) {
|
|
619
|
+
//TODO(jamesmoody-at): Adding this._dataOrNullIfDeleted as an exit condition here is a temporary fix to address an issue where
|
|
620
|
+
// we are not resetting isValid to true while restoring deleted records that contain linked record fields. It seems the only way
|
|
621
|
+
// to do this is by creating a new LinkRecordsQueryResult instance but it seems like we might be reusing the original instance
|
|
622
|
+
// that we've already set isValid to false with. We'll need to do more investigating to figure out the right way to restore these
|
|
623
|
+
// records while keeping the behavior of isValid consistent
|
|
646
624
|
return;
|
|
647
|
-
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
(0, _error_utils.invariant)(this.isValid, 'watch key change event whilst invalid'); // when the origin cell value (listing all the linked records) changes,
|
|
648
628
|
// invalidate all the data we have stored - we need to completely
|
|
649
629
|
// regenerate it
|
|
650
630
|
|
|
651
|
-
|
|
652
631
|
this._invalidateComputedData(); // notify watchers that our set of linked records has changed
|
|
653
632
|
|
|
654
633
|
|
|
@@ -806,27 +785,6 @@ function (_RecordQueryResult) {
|
|
|
806
785
|
(0, _error_utils.invariant)(recordIdsSet, 'recordIdsSet must exist');
|
|
807
786
|
return recordIdsSet;
|
|
808
787
|
}
|
|
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
|
-
}
|
|
830
788
|
}, {
|
|
831
789
|
key: "isValid",
|
|
832
790
|
get: function get() {
|