@airtable/blocks 1.8.0 → 1.9.0-experimental
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 +16 -2
- package/dist/cjs/error_utils.js +17 -0
- package/dist/cjs/models/base.js +16 -5
- package/dist/cjs/models/cursor.js +2 -0
- package/dist/cjs/models/field.js +146 -27
- package/dist/cjs/models/grouped_record_query_result.js +5 -14
- package/dist/cjs/models/linked_records_query_result.js +75 -27
- package/dist/cjs/models/mutation_constants.js +3 -1
- package/dist/cjs/models/mutations.js +67 -176
- package/dist/cjs/models/query_manager.js +327 -0
- package/dist/cjs/models/record.js +308 -55
- package/dist/cjs/models/record_query_result.js +4 -1
- package/dist/cjs/models/record_store.js +554 -765
- package/dist/cjs/models/table.js +22 -13
- package/dist/cjs/models/table_or_view_query_result.js +480 -414
- package/dist/cjs/models/view_data_store.js +243 -295
- package/dist/cjs/private_utils.js +50 -0
- package/dist/cjs/sdk.js +12 -2
- package/dist/cjs/testing/{mock_airtable_interface.js → abstract_mock_airtable_interface.js} +71 -22
- package/dist/cjs/types/block_query_spec.js +85 -0
- package/dist/cjs/types/mutations.js +1 -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 +2 -2
- package/dist/cjs/watchable.js +123 -71
- package/dist/types/src/models/base.d.ts +10 -3
- 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 +65 -1
- 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/mutation_constants.d.ts +1 -0
- package/dist/types/src/models/mutation_constants.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 +12 -3
- 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 +8 -4
- 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_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 +30 -1
- 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/{mock_airtable_interface.d.ts → abstract_mock_airtable_interface.d.ts} +20 -15
- package/dist/types/src/testing/abstract_mock_airtable_interface.d.ts.map +1 -0
- package/dist/types/src/types/airtable_interface.d.ts +43 -19
- 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 +80 -44
- package/dist/types/src/types/field.d.ts.map +1 -1
- package/dist/types/src/types/mutations.d.ts +31 -3
- package/dist/types/src/types/mutations.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/use_global_config.d.ts +1 -1
- package/dist/types/src/unstable_testing_utils.d.ts +1 -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/fixture_data.d.ts +121 -0
- 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 +2 -2
- package/dist/types/test/airtable_interface_mocks/linked_records.d.ts.map +1 -1
- package/dist/types/test/airtable_interface_mocks/{mock_airtable_interface_internal.d.ts → mock_airtable_interface.d.ts} +26 -18
- package/dist/types/test/airtable_interface_mocks/mock_airtable_interface.d.ts.map +1 -0
- package/dist/types/test/airtable_interface_mocks/mock_base_data_stores.d.ts +51 -0
- package/dist/types/test/airtable_interface_mocks/mock_base_data_stores.d.ts.map +1 -0
- package/dist/types/test/airtable_interface_mocks/project_tracker.d.ts +2 -2
- 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/package.json +3 -1
- package/dist/types/src/testing/mock_airtable_interface.d.ts.map +0 -1
- package/dist/types/test/airtable_interface_mocks/mock_airtable_interface_internal.d.ts.map +0 -1
|
@@ -6,18 +6,12 @@ require("core-js/modules/es.symbol");
|
|
|
6
6
|
|
|
7
7
|
require("core-js/modules/es.symbol.description");
|
|
8
8
|
|
|
9
|
-
require("core-js/modules/es.array.filter");
|
|
10
|
-
|
|
11
|
-
require("core-js/modules/es.array.flat-map");
|
|
12
|
-
|
|
13
9
|
require("core-js/modules/es.array.includes");
|
|
14
10
|
|
|
15
11
|
require("core-js/modules/es.array.iterator");
|
|
16
12
|
|
|
17
13
|
require("core-js/modules/es.array.map");
|
|
18
14
|
|
|
19
|
-
require("core-js/modules/es.array.unscopables.flat-map");
|
|
20
|
-
|
|
21
15
|
require("core-js/modules/es.object.to-string");
|
|
22
16
|
|
|
23
17
|
require("core-js/modules/es.promise");
|
|
@@ -28,15 +22,11 @@ require("core-js/modules/es.string.includes");
|
|
|
28
22
|
|
|
29
23
|
require("core-js/modules/web.dom-collections.iterator");
|
|
30
24
|
|
|
31
|
-
require("core-js/modules/web.url.to-json");
|
|
32
|
-
|
|
33
25
|
Object.defineProperty(exports, "__esModule", {
|
|
34
26
|
value: true
|
|
35
27
|
});
|
|
36
28
|
exports.default = void 0;
|
|
37
29
|
|
|
38
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
39
|
-
|
|
40
30
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
41
31
|
|
|
42
32
|
require("regenerator-runtime/runtime");
|
|
@@ -51,8 +41,6 @@ var _airtable_interface = require("../types/airtable_interface");
|
|
|
51
41
|
|
|
52
42
|
var _mutations = require("../types/mutations");
|
|
53
43
|
|
|
54
|
-
var _private_utils = require("../private_utils");
|
|
55
|
-
|
|
56
44
|
var _error_utils = require("../error_utils");
|
|
57
45
|
|
|
58
46
|
var _mutation_constants = require("./mutation_constants");
|
|
@@ -81,22 +69,18 @@ function () {
|
|
|
81
69
|
|
|
82
70
|
/** @internal */
|
|
83
71
|
|
|
84
|
-
/** @internal */
|
|
85
|
-
|
|
86
72
|
/** @hidden */
|
|
87
|
-
function Mutations(sdk, session, base,
|
|
73
|
+
function Mutations(sdk, session, base, applyGlobalConfigUpdates) {
|
|
88
74
|
(0, _classCallCheck2.default)(this, Mutations);
|
|
89
75
|
(0, _defineProperty2.default)(this, "_airtableInterface", void 0);
|
|
90
76
|
(0, _defineProperty2.default)(this, "_session", void 0);
|
|
91
77
|
(0, _defineProperty2.default)(this, "_sdk", void 0);
|
|
92
78
|
(0, _defineProperty2.default)(this, "_base", void 0);
|
|
93
|
-
(0, _defineProperty2.default)(this, "_applyModelChanges", void 0);
|
|
94
79
|
(0, _defineProperty2.default)(this, "_applyGlobalConfigUpdates", void 0);
|
|
95
80
|
this._airtableInterface = sdk.__airtableInterface;
|
|
96
81
|
this._session = session;
|
|
97
82
|
this._sdk = sdk;
|
|
98
83
|
this._base = base;
|
|
99
|
-
this._applyModelChanges = applyModelChanges;
|
|
100
84
|
this._applyGlobalConfigUpdates = applyGlobalConfigUpdates;
|
|
101
85
|
}
|
|
102
86
|
/** @hidden */
|
|
@@ -270,9 +254,12 @@ function () {
|
|
|
270
254
|
try {
|
|
271
255
|
for (var _iterator = records[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
272
256
|
var record = _step.value;
|
|
273
|
-
var existingRecord = null;
|
|
257
|
+
var existingRecord = null; // Note - if isSubscribedToAllRecordsInTable is true then we know the record
|
|
258
|
+
// doesn't exist (or is deleted) but otherwise we can issue a mutation to a record
|
|
259
|
+
// that does not exist, having to deal with the error thrown by PublicAirtableInterfaceFrontend
|
|
260
|
+
// TODO: (#proj-blocks-sdk-record-limits) Write tests around this behavior
|
|
274
261
|
|
|
275
|
-
if (recordStore.
|
|
262
|
+
if (recordStore.isSubscribedToAllRecordsInTable || recordStore.isRecordLoaded(record.id)) {
|
|
276
263
|
existingRecord = recordStore.getRecordByIdIfExists(record.id);
|
|
277
264
|
|
|
278
265
|
if (!existingRecord) {
|
|
@@ -294,7 +281,7 @@ function () {
|
|
|
294
281
|
checkedFieldIds.add(fieldId);
|
|
295
282
|
}
|
|
296
283
|
|
|
297
|
-
if (existingRecord && recordStore.
|
|
284
|
+
if (existingRecord && recordStore.isRecordCellValueLoadedForFieldId(record.id, fieldId)) {
|
|
298
285
|
var validationResult = this._airtableInterface.fieldTypeProvider.validateCellValueForUpdate(appInterface, record.cellValuesByFieldId[fieldId], existingRecord._getRawCellValue(field), field._data);
|
|
299
286
|
|
|
300
287
|
if (!validationResult.isValid) {
|
|
@@ -332,9 +319,15 @@ function () {
|
|
|
332
319
|
throw (0, _error_utils.spawnError)("Can't delete records: No table with id %s exists", _tableId);
|
|
333
320
|
}
|
|
334
321
|
|
|
335
|
-
var _recordStore = this._base.__getRecordStore(_tableId);
|
|
322
|
+
var _recordStore = this._base.__getRecordStore(_tableId); // TODO: (#proj-blocks-sdk-record-limits) We substantially weaken our check here
|
|
323
|
+
// because we can only be sure if the record exists inside the SDK if we've loaded
|
|
324
|
+
// all records. It is possible to change this logic to ensure we don't double-delete
|
|
325
|
+
// records by caching previously deleted records (if the delete is undone, but
|
|
326
|
+
// we're not watching the record be re-created from the undo we would have to fail
|
|
327
|
+
// the delete if we detect double deletion). TODO to add tests around this behavior.
|
|
328
|
+
|
|
336
329
|
|
|
337
|
-
if (_recordStore.
|
|
330
|
+
if (_recordStore.isSubscribedToAllRecordsInTable) {
|
|
338
331
|
var _iteratorNormalCompletion2 = true;
|
|
339
332
|
var _didIteratorError2 = false;
|
|
340
333
|
var _iteratorError2 = undefined;
|
|
@@ -442,7 +435,8 @@ function () {
|
|
|
442
435
|
{
|
|
443
436
|
var _tableId3 = mutation.tableId,
|
|
444
437
|
name = mutation.name,
|
|
445
|
-
config = mutation.config
|
|
438
|
+
config = mutation.config,
|
|
439
|
+
description = mutation.description;
|
|
446
440
|
|
|
447
441
|
var _table3 = this._base.getTableByIdIfExists(_tableId3);
|
|
448
442
|
|
|
@@ -475,6 +469,10 @@ function () {
|
|
|
475
469
|
throw (0, _error_utils.spawnError)("Can't create field: invalid field config.\n%s", _validationResult2.reason);
|
|
476
470
|
}
|
|
477
471
|
|
|
472
|
+
if (description && description.length > _mutation_constants.MAX_FIELD_DESCRIPTION_LENGTH) {
|
|
473
|
+
throw (0, _error_utils.spawnError)("Can't create field: description exceeds maximum length of %s characters", _mutation_constants.MAX_FIELD_DESCRIPTION_LENGTH);
|
|
474
|
+
}
|
|
475
|
+
|
|
478
476
|
return;
|
|
479
477
|
}
|
|
480
478
|
|
|
@@ -511,6 +509,31 @@ function () {
|
|
|
511
509
|
return;
|
|
512
510
|
}
|
|
513
511
|
|
|
512
|
+
case _mutations.MutationTypes.UPDATE_SINGLE_FIELD_DESCRIPTION:
|
|
513
|
+
{
|
|
514
|
+
var _tableId5 = mutation.tableId,
|
|
515
|
+
_id = mutation.id,
|
|
516
|
+
_description = mutation.description;
|
|
517
|
+
|
|
518
|
+
var _table5 = this._base.getTableByIdIfExists(_tableId5);
|
|
519
|
+
|
|
520
|
+
if (!_table5) {
|
|
521
|
+
throw (0, _error_utils.spawnError)("Can't update field: No table with id %s exists", _tableId5);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
var _field3 = _table5.getFieldByIdIfExists(_id);
|
|
525
|
+
|
|
526
|
+
if (!_field3) {
|
|
527
|
+
throw (0, _error_utils.spawnError)("Can't update field: No field with id %s exists", _id);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
if (_description && _description.length > _mutation_constants.MAX_FIELD_DESCRIPTION_LENGTH) {
|
|
531
|
+
throw (0, _error_utils.spawnError)("Can't update field: description exceeds maximum length of %s characters", _mutation_constants.MAX_FIELD_DESCRIPTION_LENGTH);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
|
|
514
537
|
case _mutations.MutationTypes.CREATE_SINGLE_TABLE:
|
|
515
538
|
{
|
|
516
539
|
var _name = mutation.name,
|
|
@@ -545,28 +568,32 @@ function () {
|
|
|
545
568
|
|
|
546
569
|
try {
|
|
547
570
|
for (var _iterator4 = fields[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
|
548
|
-
var
|
|
571
|
+
var _field4 = _step4.value;
|
|
549
572
|
|
|
550
|
-
if (!
|
|
573
|
+
if (!_field4.name) {
|
|
551
574
|
throw (0, _error_utils.spawnError)("Can't create table: must provide non-empty name for every field");
|
|
552
575
|
}
|
|
553
576
|
|
|
554
|
-
if (
|
|
555
|
-
throw (0, _error_utils.spawnError)("Can't create table: field name '%s' exceeds maximum length of %s characters",
|
|
577
|
+
if (_field4.name.length > _mutation_constants.MAX_FIELD_NAME_LENGTH) {
|
|
578
|
+
throw (0, _error_utils.spawnError)("Can't create table: field name '%s' exceeds maximum length of %s characters", _field4.name, _mutation_constants.MAX_FIELD_NAME_LENGTH);
|
|
556
579
|
}
|
|
557
580
|
|
|
558
|
-
var lowercaseFieldName =
|
|
581
|
+
var lowercaseFieldName = _field4.name.toLowerCase();
|
|
559
582
|
|
|
560
583
|
if (lowercaseFieldNames.has(lowercaseFieldName)) {
|
|
561
|
-
throw (0, _error_utils.spawnError)("Can't create table: duplicate field name '%s'",
|
|
584
|
+
throw (0, _error_utils.spawnError)("Can't create table: duplicate field name '%s'", _field4.name);
|
|
562
585
|
}
|
|
563
586
|
|
|
564
587
|
lowercaseFieldNames.add(lowercaseFieldName); // Current config / field data is null since the field doesn't exist.
|
|
565
588
|
|
|
566
|
-
var _validationResult4 = this._airtableInterface.fieldTypeProvider.validateConfigForUpdate(appInterface,
|
|
589
|
+
var _validationResult4 = this._airtableInterface.fieldTypeProvider.validateConfigForUpdate(appInterface, _field4.config, null, null, billingPlanGrouping);
|
|
567
590
|
|
|
568
591
|
if (!_validationResult4.isValid) {
|
|
569
|
-
throw (0, _error_utils.spawnError)("Can't create table: invalid field config for field '%s'.\n%s",
|
|
592
|
+
throw (0, _error_utils.spawnError)("Can't create table: invalid field config for field '%s'.\n%s", _field4.name, _validationResult4.reason);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
if (_field4.description && _field4.description.length > _mutation_constants.MAX_FIELD_DESCRIPTION_LENGTH) {
|
|
596
|
+
throw (0, _error_utils.spawnError)("Can't create table: description for field '%s' exceeds maximum length of %s characters", _field4.name, _mutation_constants.MAX_FIELD_DESCRIPTION_LENGTH);
|
|
570
597
|
}
|
|
571
598
|
}
|
|
572
599
|
} catch (err) {
|
|
@@ -595,7 +622,7 @@ function () {
|
|
|
595
622
|
|
|
596
623
|
case _mutations.MutationTypes.UPDATE_VIEW_METADATA:
|
|
597
624
|
{
|
|
598
|
-
var
|
|
625
|
+
var _tableId6 = mutation.tableId,
|
|
599
626
|
viewId = mutation.viewId;
|
|
600
627
|
var runContext = this._airtableInterface.sdkInitData.runContext;
|
|
601
628
|
|
|
@@ -603,17 +630,17 @@ function () {
|
|
|
603
630
|
throw (0, _error_utils.spawnError)('Setting view metadata is only valid for views');
|
|
604
631
|
}
|
|
605
632
|
|
|
606
|
-
if (runContext.viewId !== viewId || runContext.tableId !==
|
|
633
|
+
if (runContext.viewId !== viewId || runContext.tableId !== _tableId6) {
|
|
607
634
|
throw (0, _error_utils.spawnError)('Custom views can only set view metadata on themselves');
|
|
608
635
|
}
|
|
609
636
|
|
|
610
|
-
var
|
|
637
|
+
var _table6 = this._base.getTableByIdIfExists(_tableId6);
|
|
611
638
|
|
|
612
|
-
if (!
|
|
613
|
-
throw (0, _error_utils.spawnError)("Can't update metadata: No table with id %s exists",
|
|
639
|
+
if (!_table6) {
|
|
640
|
+
throw (0, _error_utils.spawnError)("Can't update metadata: No table with id %s exists", _tableId6);
|
|
614
641
|
}
|
|
615
642
|
|
|
616
|
-
var view =
|
|
643
|
+
var view = _table6.getViewByIdIfExists(viewId);
|
|
617
644
|
|
|
618
645
|
if (!view) {
|
|
619
646
|
throw (0, _error_utils.spawnError)("Can't update metadata: No view with id %s exists", viewId);
|
|
@@ -638,149 +665,13 @@ function () {
|
|
|
638
665
|
this._applyGlobalConfigUpdates(mutation.updates);
|
|
639
666
|
|
|
640
667
|
return true;
|
|
641
|
-
}
|
|
668
|
+
} // https://airtable.com/appahuJQw7qfQTBBU/tblSbpimM8Spp9txp/viweAFIus3MhU9Gxa/recHOckY4V9QmM6JV?blocks=hide
|
|
669
|
+
// TODO: (#proj-blocks-sdk-record-limits) Fix this in a future stacked diff where optimistic
|
|
670
|
+
// updates are re-enabled https://docs.google.com/document/d/1CVZ4ZoPWEtpzKq_9cRLASGwgY71WI4nl6RVvs8S7Ubw/edit#
|
|
642
671
|
|
|
643
|
-
var modelChanges = this._getOptimisticModelChangesForMutation(mutation);
|
|
644
|
-
|
|
645
|
-
if (modelChanges.length > 0) {
|
|
646
|
-
this._applyModelChanges(modelChanges);
|
|
647
|
-
|
|
648
|
-
return true;
|
|
649
|
-
}
|
|
650
672
|
|
|
651
673
|
return false;
|
|
652
674
|
}
|
|
653
|
-
/** @internal */
|
|
654
|
-
|
|
655
|
-
}, {
|
|
656
|
-
key: "_getOptimisticModelChangesForMutation",
|
|
657
|
-
value: function _getOptimisticModelChangesForMutation(mutation) {
|
|
658
|
-
switch (mutation.type) {
|
|
659
|
-
case _mutations.MutationTypes.SET_MULTIPLE_RECORDS_CELL_VALUES:
|
|
660
|
-
{
|
|
661
|
-
var tableId = mutation.tableId,
|
|
662
|
-
records = mutation.records;
|
|
663
|
-
|
|
664
|
-
var recordStore = this._base.__getRecordStore(tableId);
|
|
665
|
-
|
|
666
|
-
return records.flatMap(record => Object.keys(record.cellValuesByFieldId).filter(fieldId => recordStore.areCellValuesLoadedForFieldId(fieldId)).map(fieldId => ({
|
|
667
|
-
path: ['tablesById', tableId, 'recordsById', record.id, 'cellValuesByFieldId', fieldId],
|
|
668
|
-
value: record.cellValuesByFieldId[fieldId]
|
|
669
|
-
})));
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
case _mutations.MutationTypes.DELETE_MULTIPLE_RECORDS:
|
|
673
|
-
{
|
|
674
|
-
var _tableId6 = mutation.tableId,
|
|
675
|
-
recordIds = mutation.recordIds;
|
|
676
|
-
|
|
677
|
-
var _recordStore2 = this._base.__getRecordStore(_tableId6);
|
|
678
|
-
|
|
679
|
-
if (!_recordStore2.isRecordMetadataLoaded) {
|
|
680
|
-
return [];
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
return [...recordIds.map(recordId => ({
|
|
684
|
-
path: ['tablesById', _tableId6, 'recordsById', recordId],
|
|
685
|
-
value: undefined
|
|
686
|
-
})), ...this._base.getTableById(_tableId6).views.flatMap(view => {
|
|
687
|
-
var viewDataStore = _recordStore2.getViewDataStore(view.id);
|
|
688
|
-
|
|
689
|
-
if (!viewDataStore.isDataLoaded) {
|
|
690
|
-
return [];
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
return viewDataStore.__generateChangesForParentTableDeleteMultipleRecords(recordIds);
|
|
694
|
-
})];
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
case _mutations.MutationTypes.CREATE_MULTIPLE_RECORDS:
|
|
698
|
-
{
|
|
699
|
-
var _tableId7 = mutation.tableId,
|
|
700
|
-
_records2 = mutation.records;
|
|
701
|
-
|
|
702
|
-
var _recordStore3 = this._base.__getRecordStore(_tableId7);
|
|
703
|
-
|
|
704
|
-
if (!_recordStore3.isRecordMetadataLoaded) {
|
|
705
|
-
return [];
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
return [..._records2.map(record => {
|
|
709
|
-
// Only apply optimistic changes for fields that are loaded
|
|
710
|
-
var filteredCellValuesByFieldId = {};
|
|
711
|
-
var _iteratorNormalCompletion5 = true;
|
|
712
|
-
var _didIteratorError5 = false;
|
|
713
|
-
var _iteratorError5 = undefined;
|
|
714
|
-
|
|
715
|
-
try {
|
|
716
|
-
for (var _iterator5 = (0, _private_utils.entries)(record.cellValuesByFieldId)[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
|
|
717
|
-
var _step5$value = (0, _slicedToArray2.default)(_step5.value, 2),
|
|
718
|
-
fieldId = _step5$value[0],
|
|
719
|
-
cellValue = _step5$value[1];
|
|
720
|
-
|
|
721
|
-
if (_recordStore3.areCellValuesLoadedForFieldId(fieldId)) {
|
|
722
|
-
filteredCellValuesByFieldId[fieldId] = cellValue;
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
} catch (err) {
|
|
726
|
-
_didIteratorError5 = true;
|
|
727
|
-
_iteratorError5 = err;
|
|
728
|
-
} finally {
|
|
729
|
-
try {
|
|
730
|
-
if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
|
|
731
|
-
_iterator5.return();
|
|
732
|
-
}
|
|
733
|
-
} finally {
|
|
734
|
-
if (_didIteratorError5) {
|
|
735
|
-
throw _iteratorError5;
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
return {
|
|
741
|
-
path: ['tablesById', _tableId7, 'recordsById', record.id],
|
|
742
|
-
value: {
|
|
743
|
-
id: record.id,
|
|
744
|
-
cellValuesByFieldId: filteredCellValuesByFieldId,
|
|
745
|
-
commentCount: 0,
|
|
746
|
-
createdTime: new Date().toJSON()
|
|
747
|
-
}
|
|
748
|
-
};
|
|
749
|
-
}), ...this._base.getTableById(_tableId7).views.flatMap(view => {
|
|
750
|
-
var viewDataStore = _recordStore3.getViewDataStore(view.id);
|
|
751
|
-
|
|
752
|
-
if (!viewDataStore.isDataLoaded) {
|
|
753
|
-
return [];
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
return viewDataStore.__generateChangesForParentTableAddMultipleRecords(_records2.map(record => record.id));
|
|
757
|
-
})];
|
|
758
|
-
}
|
|
759
|
-
// The following branch is unreachable because this method's only
|
|
760
|
-
// call site is preceded by an explicit guard for this condition.
|
|
761
|
-
// istanbul ignore next
|
|
762
|
-
|
|
763
|
-
case _mutations.MutationTypes.SET_MULTIPLE_GLOBAL_CONFIG_PATHS:
|
|
764
|
-
{
|
|
765
|
-
throw (0, _error_utils.spawnError)('attempting to generate model updates for SET_MULTIPLE_GLOBAL_CONFIG_PATH');
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
case _mutations.MutationTypes.CREATE_SINGLE_FIELD:
|
|
769
|
-
case _mutations.MutationTypes.UPDATE_SINGLE_FIELD_CONFIG:
|
|
770
|
-
case _mutations.MutationTypes.UPDATE_VIEW_METADATA:
|
|
771
|
-
case _mutations.MutationTypes.CREATE_SINGLE_TABLE:
|
|
772
|
-
{
|
|
773
|
-
// No optimistic updates for field, view metadata, or table mutations.
|
|
774
|
-
return [];
|
|
775
|
-
}
|
|
776
|
-
// The following branch is unreachable because this method's only
|
|
777
|
-
// call site is preceded by an explicit guard for this condition.
|
|
778
|
-
// istanbul ignore next
|
|
779
|
-
|
|
780
|
-
default:
|
|
781
|
-
throw (0, _error_utils.spawnUnknownSwitchCaseError)('mutation type', mutation, 'type');
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
675
|
}]);
|
|
785
676
|
return Mutations;
|
|
786
677
|
}();
|