@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.
Files changed (115) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/error_utils.js +1 -19
  3. package/dist/cjs/global_config.js +3 -3
  4. package/dist/cjs/injected/airtable_interface.js +1 -1
  5. package/dist/cjs/models/base.js +9 -9
  6. package/dist/cjs/models/cursor.js +3 -3
  7. package/dist/cjs/models/field.js +3 -3
  8. package/dist/cjs/models/grouped_record_query_result.js +14 -5
  9. package/dist/cjs/models/linked_records_query_result.js +27 -78
  10. package/dist/cjs/models/mutations.js +163 -18
  11. package/dist/cjs/models/record.js +55 -310
  12. package/dist/cjs/models/record_query_result.js +2 -5
  13. package/dist/cjs/models/record_store.js +829 -555
  14. package/dist/cjs/models/session.js +3 -3
  15. package/dist/cjs/models/table.js +31 -31
  16. package/dist/cjs/models/table_or_view_query_result.js +419 -526
  17. package/dist/cjs/models/view.js +23 -1
  18. package/dist/cjs/models/view_data_store.js +295 -255
  19. package/dist/cjs/private_utils.js +0 -40
  20. package/dist/cjs/sdk.js +9 -12
  21. package/dist/cjs/settings_button.js +1 -1
  22. package/dist/cjs/testing/abstract_mock_airtable_interface.js +11 -57
  23. package/dist/cjs/types/airtable_interface.js +2 -17
  24. package/dist/cjs/ui/block_wrapper.js +2 -5
  25. package/dist/cjs/ui/expand_record_picker_async.js +1 -1
  26. package/dist/cjs/ui/global_config_synced_component_helpers.js +6 -0
  27. package/dist/cjs/ui/initialize_block.js +3 -3
  28. package/dist/cjs/ui/use_global_config.js +1 -1
  29. package/dist/cjs/ui/use_loadable.js +3 -3
  30. package/dist/cjs/ui/use_record_action_data.js +11 -11
  31. package/dist/cjs/ui/use_records.js +1 -5
  32. package/dist/cjs/ui/use_settings_button.js +1 -1
  33. package/dist/cjs/ui/viewport_constraint.js +1 -1
  34. package/dist/cjs/unstable_testing_utils.js +1 -61
  35. package/dist/cjs/viewport.js +9 -9
  36. package/dist/cjs/watchable.js +1 -15
  37. package/dist/types/src/error_utils.d.ts +1 -2
  38. package/dist/types/src/error_utils.d.ts.map +1 -1
  39. package/dist/types/src/global_config.d.ts +3 -3
  40. package/dist/types/src/models/base.d.ts +9 -9
  41. package/dist/types/src/models/cursor.d.ts +3 -3
  42. package/dist/types/src/models/field.d.ts +3 -3
  43. package/dist/types/src/models/grouped_record_query_result.d.ts +3 -3
  44. package/dist/types/src/models/grouped_record_query_result.d.ts.map +1 -1
  45. package/dist/types/src/models/linked_records_query_result.d.ts.map +1 -1
  46. package/dist/types/src/models/mutations.d.ts.map +1 -1
  47. package/dist/types/src/models/record.d.ts +3 -12
  48. package/dist/types/src/models/record.d.ts.map +1 -1
  49. package/dist/types/src/models/record_query_result.d.ts +4 -5
  50. package/dist/types/src/models/record_query_result.d.ts.map +1 -1
  51. package/dist/types/src/models/record_store.d.ts.map +1 -1
  52. package/dist/types/src/models/session.d.ts +3 -3
  53. package/dist/types/src/models/table.d.ts +25 -25
  54. package/dist/types/src/models/table_or_view_query_result.d.ts +5 -3
  55. package/dist/types/src/models/table_or_view_query_result.d.ts.map +1 -1
  56. package/dist/types/src/models/view.d.ts +11 -0
  57. package/dist/types/src/models/view.d.ts.map +1 -1
  58. package/dist/types/src/models/view_data_store.d.ts +1 -0
  59. package/dist/types/src/models/view_data_store.d.ts.map +1 -1
  60. package/dist/types/src/models/view_metadata_query_result.d.ts +1 -1
  61. package/dist/types/src/models/view_metadata_query_result.d.ts.map +1 -1
  62. package/dist/types/src/private_utils.d.ts +1 -24
  63. package/dist/types/src/private_utils.d.ts.map +1 -1
  64. package/dist/types/src/sdk.d.ts +3 -1
  65. package/dist/types/src/sdk.d.ts.map +1 -1
  66. package/dist/types/src/settings_button.d.ts +1 -1
  67. package/dist/types/src/testing/abstract_mock_airtable_interface.d.ts +11 -11
  68. package/dist/types/src/testing/abstract_mock_airtable_interface.d.ts.map +1 -1
  69. package/dist/types/src/types/airtable_interface.d.ts +20 -59
  70. package/dist/types/src/types/airtable_interface.d.ts.map +1 -1
  71. package/dist/types/src/types/field.d.ts +10 -5
  72. package/dist/types/src/types/field.d.ts.map +1 -1
  73. package/dist/types/src/types/table.d.ts +2 -0
  74. package/dist/types/src/types/table.d.ts.map +1 -1
  75. package/dist/types/src/types/view.d.ts +9 -3
  76. package/dist/types/src/types/view.d.ts.map +1 -1
  77. package/dist/types/src/ui/block_wrapper.d.ts.map +1 -1
  78. package/dist/types/src/ui/expand_record_picker_async.d.ts +1 -1
  79. package/dist/types/src/ui/global_config_synced_component_helpers.d.ts.map +1 -1
  80. package/dist/types/src/ui/initialize_block.d.ts +1 -1
  81. package/dist/types/src/ui/record_card.d.ts +1 -1
  82. package/dist/types/src/ui/use_global_config.d.ts +1 -1
  83. package/dist/types/src/ui/use_loadable.d.ts +2 -2
  84. package/dist/types/src/ui/use_record_action_data.d.ts +11 -11
  85. package/dist/types/src/ui/use_settings_button.d.ts +1 -1
  86. package/dist/types/src/ui/viewport_constraint.d.ts +3 -3
  87. package/dist/types/src/ui/viewport_constraint.d.ts.map +1 -1
  88. package/dist/types/src/unstable_testing_utils.d.ts +1 -4
  89. package/dist/types/src/unstable_testing_utils.d.ts.map +1 -1
  90. package/dist/types/src/viewport.d.ts +9 -9
  91. package/dist/types/src/watchable.d.ts.map +1 -1
  92. package/dist/types/{src/testing → test/airtable_interface_mocks}/fixture_data.d.ts +25 -44
  93. package/dist/types/test/airtable_interface_mocks/fixture_data.d.ts.map +1 -0
  94. package/dist/types/test/airtable_interface_mocks/linked_records.d.ts +1 -1
  95. package/dist/types/test/airtable_interface_mocks/linked_records.d.ts.map +1 -1
  96. package/dist/types/test/airtable_interface_mocks/mock_airtable_interface.d.ts +12 -19
  97. package/dist/types/test/airtable_interface_mocks/mock_airtable_interface.d.ts.map +1 -1
  98. package/dist/types/test/airtable_interface_mocks/project_tracker.d.ts +1 -1
  99. package/dist/types/test/airtable_interface_mocks/project_tracker.d.ts.map +1 -1
  100. package/dist/types/test/test_helpers.d.ts +0 -2
  101. package/dist/types/test/test_helpers.d.ts.map +1 -1
  102. package/package.json +2 -3
  103. package/dist/cjs/models/query_manager.js +0 -328
  104. package/dist/cjs/testing/fixture_data.js +0 -271
  105. package/dist/cjs/testing/mock_base_data_stores.js +0 -891
  106. package/dist/cjs/types/block_query_spec.js +0 -85
  107. package/dist/types/src/models/query_manager.d.ts +0 -2
  108. package/dist/types/src/models/query_manager.d.ts.map +0 -1
  109. package/dist/types/src/testing/fixture_data.d.ts.map +0 -1
  110. package/dist/types/src/testing/mock_base_data_stores.d.ts +0 -59
  111. package/dist/types/src/testing/mock_base_data_stores.d.ts.map +0 -1
  112. package/dist/types/src/types/block_query_spec.d.ts +0 -139
  113. package/dist/types/src/types/block_query_spec.d.ts.map +0 -1
  114. package/dist/types/test/testing/fixture_data.test.d.ts +0 -2
  115. package/dist/types/test/testing/fixture_data.test.d.ts.map +0 -1
@@ -72,7 +72,7 @@ var WatchableSessionKeys = Object.freeze({
72
72
  * if (session.currentUser !== null) {
73
73
  * return <span>The current user's name is {session.currentUser.name}</span>;
74
74
  * } else {
75
- * return <span>This app is being viewed in a public share</span>;
75
+ * return <span>This extension is being viewed in a public share</span>;
76
76
  * }
77
77
  * }
78
78
  * ```
@@ -384,7 +384,7 @@ function (_AbstractModel) {
384
384
  return this._sessionData;
385
385
  }
386
386
  /**
387
- * The current user, or `null` if the app is running in a publicly shared base.
387
+ * The current user, or `null` if the extension is running in a publicly shared base.
388
388
  *
389
389
  * @example
390
390
  * ```js
@@ -394,7 +394,7 @@ function (_AbstractModel) {
394
394
  * const session = useSession();
395
395
  *
396
396
  * if (!session.currentUser) {
397
- * return <div>This app is being used in a public share.</div>;
397
+ * return <div>This extension is being used in a public share.</div>;
398
398
  * }
399
399
  *
400
400
  * return <ul>
@@ -279,8 +279,8 @@ function (_AbstractModel) {
279
279
  * The field matching the given ID or name. Returns `null` if no matching field exists within
280
280
  * this table.
281
281
  *
282
- * This method is convenient when building an app for a specific base, but for more generic
283
- * apps the best practice is to use the {@link getFieldByIdIfExists} or
282
+ * This method is convenient when building an extension for a specific base, but for more generic
283
+ * extensions the best practice is to use the {@link getFieldByIdIfExists} or
284
284
  * {@link getFieldByNameIfExists} methods instead.
285
285
  *
286
286
  * @param fieldIdOrName The ID or name of the field you're looking for.
@@ -298,8 +298,8 @@ function (_AbstractModel) {
298
298
  * Use {@link getFieldIfExists} instead if you are unsure whether a field exists with the given
299
299
  * name/ID.
300
300
  *
301
- * This method is convenient when building an app for a specific base, but for more generic
302
- * apps the best practice is to use the {@link getFieldById} or {@link getFieldByName} methods
301
+ * This method is convenient when building an extension for a specific base, but for more generic
302
+ * extensions the best practice is to use the {@link getFieldById} or {@link getFieldByName} methods
303
303
  * instead.
304
304
  *
305
305
  * @param fieldIdOrName The ID or name of the field you're looking for.
@@ -460,8 +460,8 @@ function (_AbstractModel) {
460
460
  * The view matching the given ID or name. Returns `null` if no matching view exists within
461
461
  * this table.
462
462
  *
463
- * This method is convenient when building an app for a specific base, but for more generic
464
- * apps the best practice is to use the {@link getViewByIdIfExists} or
463
+ * This method is convenient when building an extension for a specific base, but for more generic
464
+ * extensions the best practice is to use the {@link getViewByIdIfExists} or
465
465
  * {@link getViewByNameIfExists} methods instead.
466
466
  *
467
467
  * @param viewIdOrName The ID or name of the view you're looking for.
@@ -479,8 +479,8 @@ function (_AbstractModel) {
479
479
  * Use {@link getViewIfExists} instead if you are unsure whether a view exists with the given
480
480
  * name/ID.
481
481
  *
482
- * This method is convenient when building an app for a specific base, but for more generic
483
- * apps the best practice is to use the {@link getViewById} or {@link getViewByName} methods
482
+ * This method is convenient when building an extension for a specific base, but for more generic
483
+ * extensions the best practice is to use the {@link getViewById} or {@link getViewByName} methods
484
484
  * instead.
485
485
  *
486
486
  * @param viewIdOrName The ID or name of the view you're looking for.
@@ -662,7 +662,7 @@ function (_AbstractModel) {
662
662
  *
663
663
  * This action is asynchronous: `await` the returned promise if you wish to wait for the updated
664
664
  * cell values to be persisted to Airtable servers.
665
- * Updates are applied optimistically locally, so your changes will be reflected in your app
665
+ * Updates are applied optimistically locally, so your changes will be reflected in your extension
666
666
  * before the promise resolves.
667
667
  *
668
668
  * @param recordOrRecordId the record to update
@@ -673,7 +673,7 @@ function (_AbstractModel) {
673
673
  * if (table.hasPermissionToUpdateRecord(record, recordFields)) {
674
674
  * table.updateRecordAsync(record, recordFields);
675
675
  * }
676
- * // The updated values will now show in your app (eg in
676
+ * // The updated values will now show in your extension (eg in
677
677
  * // `table.selectRecords()` result) but are still being saved to Airtable
678
678
  * // servers (e.g. other users may not be able to see them yet).
679
679
  * }
@@ -768,7 +768,7 @@ function (_AbstractModel) {
768
768
  *
769
769
  * // Check if user could update specific fields, when you don't know the
770
770
  * // specific record that will be updated yet. (for example, if the field is
771
- * // selected by the user and you want to check if your app can write to it).
771
+ * // selected by the user and you want to check if your extension can write to it).
772
772
  * const updateUnknownRecordCheckResult =
773
773
  * table.checkPermissionsForUpdateRecord(undefined, {
774
774
  * 'My field name': 'updated value',
@@ -779,7 +779,7 @@ function (_AbstractModel) {
779
779
  *
780
780
  * // Check if user could perform updates within the table, without knowing the
781
781
  * // specific record or fields that will be updated yet (e.g., to render your
782
- * // app in "read only" mode).
782
+ * // extension in "read only" mode).
783
783
  * const updateUnknownRecordAndFieldsCheckResult =
784
784
  * table.checkPermissionsForUpdateRecord();
785
785
  * ```
@@ -829,7 +829,7 @@ function (_AbstractModel) {
829
829
  *
830
830
  * // Check if user could update specific fields, when you don't know the
831
831
  * // specific record that will be updated yet (e.g. if the field is selected
832
- * // by the user and you want to check if your app can write to it).
832
+ * // by the user and you want to check if your extension can write to it).
833
833
  * const canUpdateUnknownRecord =
834
834
  * table.hasPermissionToUpdateRecord(undefined, {
835
835
  * 'My field name': 'updated value',
@@ -840,7 +840,7 @@ function (_AbstractModel) {
840
840
  *
841
841
  * // Check if user could perform updates within the table, without knowing the
842
842
  * // specific record or fields that will be updated yet. (for example, to
843
- * // render your app in "read only" mode)
843
+ * // render your extension in "read only" mode)
844
844
  * const canUpdateUnknownRecordAndFields = table.hasPermissionToUpdateRecord();
845
845
  * ```
846
846
  */
@@ -864,7 +864,7 @@ function (_AbstractModel) {
864
864
  *
865
865
  * This action is asynchronous: `await` the returned promise if you wish to wait for the
866
866
  * updates to be persisted to Airtable servers.
867
- * Updates are applied optimistically locally, so your changes will be reflected in your app
867
+ * Updates are applied optimistically locally, so your changes will be reflected in your extension
868
868
  * before the promise resolves.
869
869
  *
870
870
  * @param records Array of objects containing recordId and fields/cellValues to update for that record (specified as an object mapping `FieldId` or field name to cell value)
@@ -911,7 +911,7 @@ function (_AbstractModel) {
911
911
  * if (table.hasPermissionToUpdateRecords(recordsToUpdate)) {
912
912
  * table.updateRecordsAsync(recordsToUpdate);
913
913
  * }
914
- * // The records are now updated within your app (eg will be reflected in
914
+ * // The records are now updated within your extension (eg will be reflected in
915
915
  * // `table.selectRecords()`) but are still being saved to Airtable servers
916
916
  * // (e.g. they may not be updated for other users yet).
917
917
  * }
@@ -1093,7 +1093,7 @@ function (_AbstractModel) {
1093
1093
  *
1094
1094
  * This action is asynchronous: `await` the returned promise if you wish to wait for the
1095
1095
  * delete to be persisted to Airtable servers.
1096
- * Updates are applied optimistically locally, so your changes will be reflected in your app
1096
+ * Updates are applied optimistically locally, so your changes will be reflected in your extension
1097
1097
  * before the promise resolves.
1098
1098
  *
1099
1099
  * @param recordOrRecordId the record to be deleted
@@ -1103,7 +1103,7 @@ function (_AbstractModel) {
1103
1103
  * if (table.hasPermissionToDeleteRecord(record)) {
1104
1104
  * table.deleteRecordAsync(record);
1105
1105
  * }
1106
- * // The record is now deleted within your app (eg will not be returned
1106
+ * // The record is now deleted within your extension (eg will not be returned
1107
1107
  * // in `table.selectRecords`) but it is still being saved to Airtable
1108
1108
  * // servers (e.g. it may not look deleted to other users yet).
1109
1109
  * }
@@ -1208,7 +1208,7 @@ function (_AbstractModel) {
1208
1208
  *
1209
1209
  * This action is asynchronous: `await` the returned promise if you wish to wait for the
1210
1210
  * delete to be persisted to Airtable servers.
1211
- * Updates are applied optimistically locally, so your changes will be reflected in your app
1211
+ * Updates are applied optimistically locally, so your changes will be reflected in your extension
1212
1212
  * before the promise resolves.
1213
1213
  *
1214
1214
  * @param recordsOrRecordIds Array of Records and RecordIds
@@ -1219,7 +1219,7 @@ function (_AbstractModel) {
1219
1219
  * if (table.hasPermissionToDeleteRecords(records)) {
1220
1220
  * table.deleteRecordsAsync(records);
1221
1221
  * }
1222
- * // The records are now deleted within your app (eg will not be
1222
+ * // The records are now deleted within your extension (eg will not be
1223
1223
  * // returned in `table.selectRecords()`) but are still being saved to
1224
1224
  * // Airtable servers (e.g. they may not look deleted to other users yet).
1225
1225
  * }
@@ -1336,7 +1336,7 @@ function (_AbstractModel) {
1336
1336
  *
1337
1337
  * This action is asynchronous: `await` the returned promise if you wish to wait for the new
1338
1338
  * record to be persisted to Airtable servers.
1339
- * Updates are applied optimistically locally, so your changes will be reflected in your app
1339
+ * Updates are applied optimistically locally, so your changes will be reflected in your extension
1340
1340
  * before the promise resolves.
1341
1341
  *
1342
1342
  * The returned promise will resolve to the RecordId of the new record once it is persisted.
@@ -1348,7 +1348,7 @@ function (_AbstractModel) {
1348
1348
  * if (table.hasPermissionToCreateRecord(recordFields)) {
1349
1349
  * table.createRecordAsync(recordFields);
1350
1350
  * }
1351
- * // You can now access the new record in your app (eg
1351
+ * // You can now access the new record in your extension (eg
1352
1352
  * // `table.selectRecords()`) but it is still being saved to Airtable
1353
1353
  * // servers (e.g. other users may not be able to see it yet).
1354
1354
  * }
@@ -1507,7 +1507,7 @@ function (_AbstractModel) {
1507
1507
  *
1508
1508
  * This action is asynchronous: `await` the returned promise if you wish to wait for the new
1509
1509
  * record to be persisted to Airtable servers.
1510
- * Updates are applied optimistically locally, so your changes will be reflected in your app
1510
+ * Updates are applied optimistically locally, so your changes will be reflected in your extension
1511
1511
  * before the promise resolves.
1512
1512
  *
1513
1513
  * The returned promise will resolve to an array of RecordIds of the new records once the new
@@ -1551,7 +1551,7 @@ function (_AbstractModel) {
1551
1551
  * if (table.hasPermissionToCreateRecords(recordDefs)) {
1552
1552
  * table.createRecordsAsync(recordDefs);
1553
1553
  * }
1554
- * // You can now access the new records in your app (e.g.
1554
+ * // You can now access the new records in your extension (e.g.
1555
1555
  * // `table.selectRecords()`) but they are still being saved to Airtable
1556
1556
  * // servers (e.g. other users may not be able to see them yet.)
1557
1557
  * }
@@ -1805,7 +1805,7 @@ function (_AbstractModel) {
1805
1805
  *
1806
1806
  * This action is asynchronous. Unlike new records, new fields are **not** created
1807
1807
  * optimistically locally. You must `await` the returned promise before using the new
1808
- * field in your app.
1808
+ * field in your extension.
1809
1809
  *
1810
1810
  * @param name name for the field. must be case-insensitive unique
1811
1811
  * @param type type for the field
@@ -2024,11 +2024,7 @@ function (_AbstractModel) {
2024
2024
  if (didViewSchemaChange) {
2025
2025
  didTableSchemaChange = true;
2026
2026
  }
2027
- } // We must directly trigger deletions on the recordStore.viewDataStore
2028
- // because the viewModel might not have been created. (See above comment)
2029
-
2030
-
2031
- this._recordStore.sendViewDataDeletionIfViewIsDeleted(_viewId);
2027
+ }
2032
2028
  }
2033
2029
  } catch (err) {
2034
2030
  _didIteratorError4 = true;
@@ -2113,7 +2109,11 @@ function (_AbstractModel) {
2113
2109
 
2114
2110
 
2115
2111
  this._cachedFieldNamesById = null;
2116
- }
2112
+ } // NOTE: Record store onChange triggers must be performed AFTER field onChange triggers to
2113
+ // ensure the column type providers are not stale.
2114
+
2115
+
2116
+ this._recordStore.triggerOnChangeForDirtyPaths(dirtyPaths);
2117
2117
 
2118
2118
  return didTableSchemaChange;
2119
2119
  }