@airtable/blocks 1.18.1 → 1.18.2
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 +6 -1
- package/dist/cjs/color_utils.js +21 -23
- package/dist/cjs/colors.js +4 -60
- package/dist/cjs/error_utils.js +15 -25
- package/dist/cjs/event_tracker.js +5 -11
- package/dist/cjs/global_config.js +107 -188
- package/dist/cjs/index.js +16 -40
- package/dist/cjs/injected/airtable_interface.js +1 -6
- package/dist/cjs/models/abstract_model.js +50 -81
- package/dist/cjs/models/abstract_model_with_async_data.js +102 -177
- package/dist/cjs/models/base.js +211 -374
- package/dist/cjs/models/create_aggregators.js +53 -47
- package/dist/cjs/models/cursor.js +125 -201
- package/dist/cjs/models/field.js +256 -303
- package/dist/cjs/models/grouped_record_query_result.js +210 -286
- package/dist/cjs/models/linked_records_query_result.js +276 -454
- package/dist/cjs/models/models.js +36 -50
- package/dist/cjs/models/mutation_constants.js +5 -9
- package/dist/cjs/models/mutations.js +125 -338
- package/dist/cjs/models/object_pool.js +37 -94
- package/dist/cjs/models/record.js +132 -226
- package/dist/cjs/models/record_coloring.js +14 -19
- package/dist/cjs/models/record_query_result.js +323 -282
- package/dist/cjs/models/record_store.js +355 -688
- package/dist/cjs/models/session.js +99 -158
- package/dist/cjs/models/table.js +361 -549
- package/dist/cjs/models/table_or_view_query_result.js +410 -765
- package/dist/cjs/models/view.js +161 -204
- package/dist/cjs/models/view_data_store.js +177 -282
- package/dist/cjs/models/view_metadata_query_result.js +96 -127
- package/dist/cjs/perform_record_action.js +69 -103
- package/dist/cjs/private_utils.js +133 -223
- package/dist/cjs/sdk.js +97 -142
- package/dist/cjs/settings_button.js +30 -57
- package/dist/cjs/stats/block_stats.js +3 -15
- package/dist/cjs/testing/abstract_mock_airtable_interface.js +53 -97
- package/dist/cjs/types/airtable_interface.js +36 -8
- package/dist/cjs/types/field.js +66 -12
- package/dist/cjs/types/mutations.js +99 -6
- package/dist/cjs/types/permission_levels.js +2 -4
- package/dist/cjs/types/undo_redo.js +2 -3
- package/dist/cjs/types/view.js +16 -11
- package/dist/cjs/ui/base_provider.js +14 -9
- package/dist/cjs/ui/baymax_utils.js +107 -1102
- package/dist/cjs/ui/block_wrapper.js +30 -68
- package/dist/cjs/ui/box.js +52 -56
- package/dist/cjs/ui/button.js +60 -77
- package/dist/cjs/ui/cell_renderer.js +78 -139
- package/dist/cjs/ui/choice_token.js +45 -47
- package/dist/cjs/ui/collaborator_token.js +33 -54
- package/dist/cjs/ui/color_palette.js +58 -106
- package/dist/cjs/ui/color_palette_synced.js +41 -52
- package/dist/cjs/ui/confirmation_dialog.js +53 -69
- package/dist/cjs/ui/control_sizes.js +21 -46
- package/dist/cjs/ui/create_detect_element_resize.js +16 -50
- package/dist/cjs/ui/css_helpers.js +3 -10
- package/dist/cjs/ui/dialog.js +44 -71
- package/dist/cjs/ui/dialog_close_button.js +52 -72
- package/dist/cjs/ui/expand_record.js +4 -11
- package/dist/cjs/ui/expand_record_list.js +6 -11
- package/dist/cjs/ui/expand_record_picker_async.js +18 -35
- package/dist/cjs/ui/field_icon.js +25 -28
- package/dist/cjs/ui/field_picker.js +47 -81
- package/dist/cjs/ui/field_picker_synced.js +33 -44
- package/dist/cjs/ui/form_field.js +45 -64
- package/dist/cjs/ui/geometry/geometry.js +6 -10
- package/dist/cjs/ui/geometry/point.js +5 -13
- package/dist/cjs/ui/geometry/rect.js +7 -29
- package/dist/cjs/ui/geometry/size.js +5 -13
- package/dist/cjs/ui/global_alert.js +35 -61
- package/dist/cjs/ui/global_config_synced_component_helpers.js +4 -13
- package/dist/cjs/ui/heading.js +63 -92
- package/dist/cjs/ui/icon.js +44 -66
- package/dist/cjs/ui/icon_config.js +13 -24
- package/dist/cjs/ui/initialize_block.js +23 -36
- package/dist/cjs/ui/input.js +74 -87
- package/dist/cjs/ui/input_synced.js +34 -43
- package/dist/cjs/ui/key_codes.js +4 -9
- package/dist/cjs/ui/label.js +45 -50
- package/dist/cjs/ui/link.js +74 -89
- package/dist/cjs/ui/loader.js +26 -42
- package/dist/cjs/ui/modal.js +63 -89
- package/dist/cjs/ui/model_picker_select.js +29 -47
- package/dist/cjs/ui/popover.js +98 -180
- package/dist/cjs/ui/progress_bar.js +45 -51
- package/dist/cjs/ui/record_card.js +143 -278
- package/dist/cjs/ui/record_card_list.js +117 -165
- package/dist/cjs/ui/remote_utils.js +5 -13
- package/dist/cjs/ui/sdk_context.js +7 -9
- package/dist/cjs/ui/select.js +84 -118
- package/dist/cjs/ui/select_and_select_buttons_helpers.js +27 -45
- package/dist/cjs/ui/select_buttons.js +54 -90
- package/dist/cjs/ui/select_buttons_synced.js +32 -41
- package/dist/cjs/ui/select_synced.js +32 -42
- package/dist/cjs/ui/switch.js +66 -84
- package/dist/cjs/ui/switch_synced.js +32 -38
- package/dist/cjs/ui/synced.js +16 -43
- package/dist/cjs/ui/system/all_styles_set.js +89 -22
- package/dist/cjs/ui/system/appearance/appearance_set.js +15 -26
- package/dist/cjs/ui/system/appearance/background_color.js +6 -12
- package/dist/cjs/ui/system/appearance/border.js +6 -12
- package/dist/cjs/ui/system/appearance/border_radius.js +6 -12
- package/dist/cjs/ui/system/appearance/box_shadow.js +6 -12
- package/dist/cjs/ui/system/appearance/opacity.js +5 -11
- package/dist/cjs/ui/system/dimensions/dimensions_set.js +15 -27
- package/dist/cjs/ui/system/dimensions/height.js +5 -11
- package/dist/cjs/ui/system/dimensions/max_height.js +5 -11
- package/dist/cjs/ui/system/dimensions/max_width.js +5 -11
- package/dist/cjs/ui/system/dimensions/min_height.js +5 -11
- package/dist/cjs/ui/system/dimensions/min_width.js +5 -11
- package/dist/cjs/ui/system/dimensions/width.js +5 -11
- package/dist/cjs/ui/system/display.js +8 -9
- package/dist/cjs/ui/system/flex_container/align_content.js +6 -12
- package/dist/cjs/ui/system/flex_container/align_items.js +6 -12
- package/dist/cjs/ui/system/flex_container/flex_container_set.js +15 -27
- package/dist/cjs/ui/system/flex_container/flex_direction.js +5 -11
- package/dist/cjs/ui/system/flex_container/flex_wrap.js +5 -11
- package/dist/cjs/ui/system/flex_container/justify_content.js +5 -11
- package/dist/cjs/ui/system/flex_container/justify_items.js +5 -11
- package/dist/cjs/ui/system/flex_item/align_self.js +6 -12
- package/dist/cjs/ui/system/flex_item/flex.js +5 -11
- package/dist/cjs/ui/system/flex_item/flex_basis.js +5 -11
- package/dist/cjs/ui/system/flex_item/flex_grow.js +5 -11
- package/dist/cjs/ui/system/flex_item/flex_item_set.js +15 -28
- package/dist/cjs/ui/system/flex_item/flex_shrink.js +5 -11
- package/dist/cjs/ui/system/flex_item/justify_self.js +5 -11
- package/dist/cjs/ui/system/flex_item/order.js +5 -11
- package/dist/cjs/ui/system/index.js +310 -362
- package/dist/cjs/ui/system/overflow.js +8 -9
- package/dist/cjs/ui/system/position/bottom.js +6 -13
- package/dist/cjs/ui/system/position/left.js +5 -12
- package/dist/cjs/ui/system/position/position.js +5 -11
- package/dist/cjs/ui/system/position/position_set.js +15 -27
- package/dist/cjs/ui/system/position/right.js +5 -12
- package/dist/cjs/ui/system/position/top.js +5 -12
- package/dist/cjs/ui/system/position/z_index.js +5 -11
- package/dist/cjs/ui/system/spacing/margin.js +5 -12
- package/dist/cjs/ui/system/spacing/padding.js +5 -12
- package/dist/cjs/ui/system/spacing/spacing_set.js +15 -23
- package/dist/cjs/ui/system/typography/font_family.js +5 -11
- package/dist/cjs/ui/system/typography/font_size.js +5 -11
- package/dist/cjs/ui/system/typography/font_style.js +5 -11
- package/dist/cjs/ui/system/typography/font_weight.js +5 -11
- package/dist/cjs/ui/system/typography/letter_spacing.js +5 -11
- package/dist/cjs/ui/system/typography/line_height.js +5 -11
- package/dist/cjs/ui/system/typography/text_align.js +5 -11
- package/dist/cjs/ui/system/typography/text_color.js +5 -11
- package/dist/cjs/ui/system/typography/text_decoration.js +5 -11
- package/dist/cjs/ui/system/typography/text_transform.js +5 -11
- package/dist/cjs/ui/system/typography/typography_set.js +15 -31
- package/dist/cjs/ui/system/utils/create_responsive_prop_type.js +2 -4
- package/dist/cjs/ui/system/utils/create_style_prop_types.js +5 -13
- package/dist/cjs/ui/system/utils/ensure_numbers_are_within_scale.js +2 -14
- package/dist/cjs/ui/system/utils/get_style_props_for_responsive_prop.js +30 -70
- package/dist/cjs/ui/table_picker.js +26 -43
- package/dist/cjs/ui/table_picker_synced.js +33 -42
- package/dist/cjs/ui/text.js +59 -71
- package/dist/cjs/ui/text_button.js +80 -97
- package/dist/cjs/ui/theme/default_theme/button_variants.js +1 -5
- package/dist/cjs/ui/theme/default_theme/control_sizes.js +29 -42
- package/dist/cjs/ui/theme/default_theme/heading_styles.js +4 -5
- package/dist/cjs/ui/theme/default_theme/index.js +15 -32
- package/dist/cjs/ui/theme/default_theme/input_variants.js +1 -5
- package/dist/cjs/ui/theme/default_theme/link_variants.js +1 -5
- package/dist/cjs/ui/theme/default_theme/select_buttons_variants.js +1 -5
- package/dist/cjs/ui/theme/default_theme/select_variants.js +10 -21
- package/dist/cjs/ui/theme/default_theme/switch_variants.js +8 -20
- package/dist/cjs/ui/theme/default_theme/text_button_variants.js +1 -5
- package/dist/cjs/ui/theme/default_theme/text_styles.js +1 -2
- package/dist/cjs/ui/theme/default_theme/tokens.js +33 -35
- package/dist/cjs/ui/theme/theme_context.js +3 -6
- package/dist/cjs/ui/theme/use_theme.js +1 -7
- package/dist/cjs/ui/tooltip.js +38 -79
- package/dist/cjs/ui/types/aria_props.js +3 -7
- package/dist/cjs/ui/types/data_attributes_prop.js +8 -6
- package/dist/cjs/ui/types/tooltip_anchor_props.js +4 -5
- package/dist/cjs/ui/ui.js +89 -130
- package/dist/cjs/ui/unstable_standalone_ui.js +18 -42
- package/dist/cjs/ui/use_array_identity.js +0 -4
- package/dist/cjs/ui/use_base.js +4 -13
- package/dist/cjs/ui/use_cursor.js +3 -12
- package/dist/cjs/ui/use_form_field.js +4 -6
- package/dist/cjs/ui/use_global_config.js +3 -10
- package/dist/cjs/ui/use_loadable.js +59 -132
- package/dist/cjs/ui/use_record_action_data.js +6 -12
- package/dist/cjs/ui/use_records.js +23 -24
- package/dist/cjs/ui/use_session.js +6 -15
- package/dist/cjs/ui/use_settings_button.js +4 -11
- package/dist/cjs/ui/use_styled_system.js +12 -21
- package/dist/cjs/ui/use_synced.js +0 -7
- package/dist/cjs/ui/use_text_color_for_background_color.js +1 -5
- package/dist/cjs/ui/use_view_metadata.js +5 -8
- package/dist/cjs/ui/use_viewport.js +1 -7
- package/dist/cjs/ui/use_watchable.js +36 -74
- package/dist/cjs/ui/view_picker.js +44 -78
- package/dist/cjs/ui/view_picker_synced.js +33 -44
- package/dist/cjs/ui/viewport_constraint.js +37 -64
- package/dist/cjs/ui/with_hooks.js +17 -22
- package/dist/cjs/ui/with_styled_system.js +33 -60
- package/dist/cjs/undo_redo.js +12 -32
- package/dist/cjs/unstable_private_utils.js +6 -8
- package/dist/cjs/unstable_testing_utils.js +44 -57
- package/dist/cjs/viewport.js +127 -189
- package/dist/cjs/warning.js +5 -6
- package/dist/cjs/watchable.js +66 -148
- package/dist/types/src/colors.d.ts +1 -1
- package/dist/types/src/colors.d.ts.map +1 -1
- package/dist/types/src/global_config.d.ts +1 -1
- package/dist/types/src/global_config.d.ts.map +1 -1
- package/dist/types/src/models/base.d.ts +1 -1
- package/dist/types/src/models/base.d.ts.map +1 -1
- package/dist/types/src/models/cursor.d.ts +1 -1
- package/dist/types/src/models/cursor.d.ts.map +1 -1
- package/dist/types/src/models/field.d.ts +1 -1
- package/dist/types/src/models/field.d.ts.map +1 -1
- package/dist/types/src/models/linked_records_query_result.d.ts.map +1 -1
- package/dist/types/src/models/models.d.ts.map +1 -1
- package/dist/types/src/models/record.d.ts +1 -1
- package/dist/types/src/models/record.d.ts.map +1 -1
- package/dist/types/src/models/record_coloring.d.ts +2 -2
- package/dist/types/src/models/record_coloring.d.ts.map +1 -1
- package/dist/types/src/models/record_query_result.d.ts +3 -3
- package/dist/types/src/models/record_query_result.d.ts.map +1 -1
- package/dist/types/src/models/session.d.ts +1 -1
- package/dist/types/src/models/session.d.ts.map +1 -1
- package/dist/types/src/models/table.d.ts +1 -1
- package/dist/types/src/models/table.d.ts.map +1 -1
- package/dist/types/src/models/view.d.ts +1 -1
- package/dist/types/src/models/view.d.ts.map +1 -1
- package/dist/types/src/models/view_metadata_query_result.d.ts +2 -2
- package/dist/types/src/models/view_metadata_query_result.d.ts.map +1 -1
- package/dist/types/src/perform_record_action.d.ts +1 -1
- package/dist/types/src/perform_record_action.d.ts.map +1 -1
- package/dist/types/src/private_utils.d.ts +8 -8
- package/dist/types/src/private_utils.d.ts.map +1 -1
- package/dist/types/src/sdk.d.ts +1 -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/settings_button.d.ts.map +1 -1
- package/dist/types/src/types/aggregators.d.ts +1 -1
- package/dist/types/src/types/aggregators.d.ts.map +1 -1
- package/dist/types/src/types/airtable_interface.d.ts +6 -6
- package/dist/types/src/types/airtable_interface.d.ts.map +1 -1
- package/dist/types/src/types/attachment.d.ts +1 -1
- package/dist/types/src/types/attachment.d.ts.map +1 -1
- package/dist/types/src/types/base.d.ts +1 -1
- package/dist/types/src/types/base.d.ts.map +1 -1
- package/dist/types/src/types/block.d.ts +1 -1
- package/dist/types/src/types/block.d.ts.map +1 -1
- package/dist/types/src/types/collaborator.d.ts +1 -1
- package/dist/types/src/types/collaborator.d.ts.map +1 -1
- package/dist/types/src/types/field.d.ts +5 -5
- package/dist/types/src/types/field.d.ts.map +1 -1
- package/dist/types/src/types/global_config.d.ts +6 -6
- package/dist/types/src/types/global_config.d.ts.map +1 -1
- package/dist/types/src/types/mutations.d.ts +4 -4
- package/dist/types/src/types/mutations.d.ts.map +1 -1
- package/dist/types/src/types/permission_levels.d.ts +1 -1
- package/dist/types/src/types/permission_levels.d.ts.map +1 -1
- package/dist/types/src/types/record.d.ts +2 -2
- package/dist/types/src/types/record.d.ts.map +1 -1
- package/dist/types/src/types/record_action_data.d.ts +1 -1
- package/dist/types/src/types/record_action_data.d.ts.map +1 -1
- package/dist/types/src/types/table.d.ts +3 -3
- package/dist/types/src/types/table.d.ts.map +1 -1
- package/dist/types/src/types/undo_redo.d.ts +1 -1
- package/dist/types/src/types/undo_redo.d.ts.map +1 -1
- package/dist/types/src/types/view.d.ts +4 -4
- package/dist/types/src/types/view.d.ts.map +1 -1
- package/dist/types/src/ui/base_provider.d.ts +1 -1
- package/dist/types/src/ui/base_provider.d.ts.map +1 -1
- package/dist/types/src/ui/block_wrapper.d.ts +2 -2
- package/dist/types/src/ui/button.d.ts +1 -1
- package/dist/types/src/ui/button.d.ts.map +1 -1
- package/dist/types/src/ui/cell_renderer.d.ts +2 -2
- package/dist/types/src/ui/choice_token.d.ts +3 -3
- package/dist/types/src/ui/choice_token.d.ts.map +1 -1
- package/dist/types/src/ui/collaborator_token.d.ts +5 -5
- package/dist/types/src/ui/collaborator_token.d.ts.map +1 -1
- package/dist/types/src/ui/color_palette.d.ts +2 -2
- package/dist/types/src/ui/color_palette_synced.d.ts +2 -2
- package/dist/types/src/ui/confirmation_dialog.d.ts +1 -1
- package/dist/types/src/ui/control_sizes.d.ts +2 -2
- package/dist/types/src/ui/control_sizes.d.ts.map +1 -1
- package/dist/types/src/ui/dialog.d.ts +2 -2
- package/dist/types/src/ui/dialog.d.ts.map +1 -1
- package/dist/types/src/ui/dialog_close_button.d.ts +1 -1
- package/dist/types/src/ui/field_icon.d.ts +3 -3
- package/dist/types/src/ui/field_icon.d.ts.map +1 -1
- package/dist/types/src/ui/field_picker.d.ts +1 -1
- package/dist/types/src/ui/global_alert.d.ts +1 -1
- package/dist/types/src/ui/global_alert.d.ts.map +1 -1
- package/dist/types/src/ui/global_config_synced_component_helpers.d.ts +1 -1
- package/dist/types/src/ui/global_config_synced_component_helpers.d.ts.map +1 -1
- package/dist/types/src/ui/heading.d.ts +3 -3
- package/dist/types/src/ui/heading.d.ts.map +1 -1
- package/dist/types/src/ui/icon.d.ts +1 -1
- package/dist/types/src/ui/icon_config.d.ts +39 -39
- package/dist/types/src/ui/icon_config.d.ts.map +1 -1
- package/dist/types/src/ui/initialize_block.d.ts +3 -3
- package/dist/types/src/ui/initialize_block.d.ts.map +1 -1
- package/dist/types/src/ui/input.d.ts +15 -15
- package/dist/types/src/ui/input.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/loader.d.ts +1 -1
- package/dist/types/src/ui/loader.d.ts.map +1 -1
- package/dist/types/src/ui/model_picker_select.d.ts +1 -1
- package/dist/types/src/ui/model_picker_select.d.ts.map +1 -1
- package/dist/types/src/ui/popover.d.ts +5 -5
- package/dist/types/src/ui/popover.d.ts.map +1 -1
- package/dist/types/src/ui/progress_bar.d.ts +1 -1
- package/dist/types/src/ui/progress_bar.d.ts.map +1 -1
- package/dist/types/src/ui/record_card.d.ts +2 -2
- package/dist/types/src/ui/record_card.d.ts.map +1 -1
- package/dist/types/src/ui/record_card_list.d.ts +1 -1
- package/dist/types/src/ui/select.d.ts +4 -4
- package/dist/types/src/ui/select_and_select_buttons_helpers.d.ts +4 -4
- package/dist/types/src/ui/select_and_select_buttons_helpers.d.ts.map +1 -1
- package/dist/types/src/ui/select_buttons.d.ts +4 -4
- package/dist/types/src/ui/switch.d.ts +1 -1
- package/dist/types/src/ui/switch.d.ts.map +1 -1
- package/dist/types/src/ui/synced.d.ts +3 -3
- package/dist/types/src/ui/system/all_styles_set.d.ts +0 -1
- package/dist/types/src/ui/system/all_styles_set.d.ts.map +1 -1
- package/dist/types/src/ui/system/appearance/appearance_set.d.ts +0 -1
- package/dist/types/src/ui/system/appearance/appearance_set.d.ts.map +1 -1
- package/dist/types/src/ui/system/appearance/background_color.d.ts +0 -1
- package/dist/types/src/ui/system/appearance/background_color.d.ts.map +1 -1
- package/dist/types/src/ui/system/appearance/border.d.ts +0 -1
- package/dist/types/src/ui/system/appearance/border.d.ts.map +1 -1
- package/dist/types/src/ui/system/appearance/border_radius.d.ts +0 -1
- package/dist/types/src/ui/system/appearance/border_radius.d.ts.map +1 -1
- package/dist/types/src/ui/system/appearance/box_shadow.d.ts +0 -1
- package/dist/types/src/ui/system/appearance/box_shadow.d.ts.map +1 -1
- package/dist/types/src/ui/system/appearance/opacity.d.ts +0 -1
- package/dist/types/src/ui/system/appearance/opacity.d.ts.map +1 -1
- package/dist/types/src/ui/system/dimensions/dimensions_set.d.ts +0 -1
- package/dist/types/src/ui/system/dimensions/dimensions_set.d.ts.map +1 -1
- package/dist/types/src/ui/system/dimensions/height.d.ts +0 -1
- package/dist/types/src/ui/system/dimensions/height.d.ts.map +1 -1
- package/dist/types/src/ui/system/dimensions/max_height.d.ts +0 -1
- package/dist/types/src/ui/system/dimensions/max_height.d.ts.map +1 -1
- package/dist/types/src/ui/system/dimensions/max_width.d.ts +0 -1
- package/dist/types/src/ui/system/dimensions/max_width.d.ts.map +1 -1
- package/dist/types/src/ui/system/dimensions/min_height.d.ts +0 -1
- package/dist/types/src/ui/system/dimensions/min_height.d.ts.map +1 -1
- package/dist/types/src/ui/system/dimensions/min_width.d.ts +0 -1
- package/dist/types/src/ui/system/dimensions/min_width.d.ts.map +1 -1
- package/dist/types/src/ui/system/dimensions/width.d.ts +0 -1
- package/dist/types/src/ui/system/dimensions/width.d.ts.map +1 -1
- package/dist/types/src/ui/system/display.d.ts +0 -1
- package/dist/types/src/ui/system/display.d.ts.map +1 -1
- package/dist/types/src/ui/system/flex_container/align_content.d.ts +0 -1
- package/dist/types/src/ui/system/flex_container/align_content.d.ts.map +1 -1
- package/dist/types/src/ui/system/flex_container/align_items.d.ts +0 -1
- package/dist/types/src/ui/system/flex_container/align_items.d.ts.map +1 -1
- package/dist/types/src/ui/system/flex_container/flex_container_set.d.ts +0 -1
- package/dist/types/src/ui/system/flex_container/flex_container_set.d.ts.map +1 -1
- package/dist/types/src/ui/system/flex_container/flex_direction.d.ts +0 -1
- package/dist/types/src/ui/system/flex_container/flex_direction.d.ts.map +1 -1
- package/dist/types/src/ui/system/flex_container/flex_wrap.d.ts +0 -1
- package/dist/types/src/ui/system/flex_container/flex_wrap.d.ts.map +1 -1
- package/dist/types/src/ui/system/flex_container/justify_content.d.ts +0 -1
- package/dist/types/src/ui/system/flex_container/justify_content.d.ts.map +1 -1
- package/dist/types/src/ui/system/flex_container/justify_items.d.ts +0 -1
- package/dist/types/src/ui/system/flex_container/justify_items.d.ts.map +1 -1
- package/dist/types/src/ui/system/flex_item/align_self.d.ts +0 -1
- package/dist/types/src/ui/system/flex_item/align_self.d.ts.map +1 -1
- package/dist/types/src/ui/system/flex_item/flex.d.ts +0 -1
- package/dist/types/src/ui/system/flex_item/flex.d.ts.map +1 -1
- package/dist/types/src/ui/system/flex_item/flex_basis.d.ts +0 -1
- package/dist/types/src/ui/system/flex_item/flex_basis.d.ts.map +1 -1
- package/dist/types/src/ui/system/flex_item/flex_grow.d.ts +0 -1
- package/dist/types/src/ui/system/flex_item/flex_grow.d.ts.map +1 -1
- package/dist/types/src/ui/system/flex_item/flex_item_set.d.ts +0 -1
- package/dist/types/src/ui/system/flex_item/flex_item_set.d.ts.map +1 -1
- package/dist/types/src/ui/system/flex_item/flex_shrink.d.ts +0 -1
- package/dist/types/src/ui/system/flex_item/flex_shrink.d.ts.map +1 -1
- package/dist/types/src/ui/system/flex_item/justify_self.d.ts +0 -1
- package/dist/types/src/ui/system/flex_item/justify_self.d.ts.map +1 -1
- package/dist/types/src/ui/system/flex_item/order.d.ts +0 -1
- package/dist/types/src/ui/system/flex_item/order.d.ts.map +1 -1
- package/dist/types/src/ui/system/overflow.d.ts +0 -1
- package/dist/types/src/ui/system/overflow.d.ts.map +1 -1
- package/dist/types/src/ui/system/position/bottom.d.ts +0 -1
- package/dist/types/src/ui/system/position/bottom.d.ts.map +1 -1
- package/dist/types/src/ui/system/position/left.d.ts +0 -1
- package/dist/types/src/ui/system/position/left.d.ts.map +1 -1
- package/dist/types/src/ui/system/position/position.d.ts +0 -1
- package/dist/types/src/ui/system/position/position.d.ts.map +1 -1
- package/dist/types/src/ui/system/position/position_set.d.ts +0 -1
- package/dist/types/src/ui/system/position/position_set.d.ts.map +1 -1
- package/dist/types/src/ui/system/position/right.d.ts +0 -1
- package/dist/types/src/ui/system/position/right.d.ts.map +1 -1
- package/dist/types/src/ui/system/position/top.d.ts +0 -1
- package/dist/types/src/ui/system/position/top.d.ts.map +1 -1
- package/dist/types/src/ui/system/position/z_index.d.ts +0 -1
- package/dist/types/src/ui/system/position/z_index.d.ts.map +1 -1
- package/dist/types/src/ui/system/spacing/margin.d.ts +0 -1
- package/dist/types/src/ui/system/spacing/margin.d.ts.map +1 -1
- package/dist/types/src/ui/system/spacing/padding.d.ts +0 -1
- package/dist/types/src/ui/system/spacing/padding.d.ts.map +1 -1
- package/dist/types/src/ui/system/spacing/spacing_set.d.ts +0 -1
- package/dist/types/src/ui/system/spacing/spacing_set.d.ts.map +1 -1
- package/dist/types/src/ui/system/typography/font_family.d.ts +0 -1
- package/dist/types/src/ui/system/typography/font_family.d.ts.map +1 -1
- package/dist/types/src/ui/system/typography/font_size.d.ts +0 -1
- package/dist/types/src/ui/system/typography/font_size.d.ts.map +1 -1
- package/dist/types/src/ui/system/typography/font_style.d.ts +0 -1
- package/dist/types/src/ui/system/typography/font_style.d.ts.map +1 -1
- package/dist/types/src/ui/system/typography/font_weight.d.ts +0 -1
- package/dist/types/src/ui/system/typography/font_weight.d.ts.map +1 -1
- package/dist/types/src/ui/system/typography/letter_spacing.d.ts +0 -1
- package/dist/types/src/ui/system/typography/letter_spacing.d.ts.map +1 -1
- package/dist/types/src/ui/system/typography/line_height.d.ts +0 -1
- package/dist/types/src/ui/system/typography/line_height.d.ts.map +1 -1
- package/dist/types/src/ui/system/typography/text_align.d.ts +0 -1
- package/dist/types/src/ui/system/typography/text_align.d.ts.map +1 -1
- package/dist/types/src/ui/system/typography/text_color.d.ts +0 -1
- package/dist/types/src/ui/system/typography/text_color.d.ts.map +1 -1
- package/dist/types/src/ui/system/typography/text_decoration.d.ts +0 -1
- package/dist/types/src/ui/system/typography/text_decoration.d.ts.map +1 -1
- package/dist/types/src/ui/system/typography/text_transform.d.ts +0 -1
- package/dist/types/src/ui/system/typography/text_transform.d.ts.map +1 -1
- package/dist/types/src/ui/system/typography/typography_set.d.ts +0 -1
- package/dist/types/src/ui/system/typography/typography_set.d.ts.map +1 -1
- package/dist/types/src/ui/system/utils/create_style_prop_types.d.ts +1 -1
- package/dist/types/src/ui/system/utils/create_style_prop_types.d.ts.map +1 -1
- package/dist/types/src/ui/system/utils/csstype.d.ts +578 -578
- package/dist/types/src/ui/system/utils/csstype.d.ts.map +1 -1
- package/dist/types/src/ui/system/utils/types.d.ts +4 -4
- package/dist/types/src/ui/system/utils/types.d.ts.map +1 -1
- package/dist/types/src/ui/text.d.ts +3 -3
- package/dist/types/src/ui/text.d.ts.map +1 -1
- package/dist/types/src/ui/text_button.d.ts +1 -1
- package/dist/types/src/ui/text_button.d.ts.map +1 -1
- package/dist/types/src/ui/theme/default_theme/heading_styles.d.ts +2 -2
- package/dist/types/src/ui/theme/default_theme/heading_styles.d.ts.map +1 -1
- package/dist/types/src/ui/theme/default_theme/index.d.ts +1 -1
- package/dist/types/src/ui/theme/theme_context.d.ts +1 -3
- package/dist/types/src/ui/theme/theme_context.d.ts.map +1 -1
- package/dist/types/src/ui/theme/use_theme.d.ts +1 -1
- package/dist/types/src/ui/tooltip.d.ts +3 -3
- package/dist/types/src/ui/types/data_attributes_prop.d.ts.map +1 -1
- package/dist/types/src/ui/types/tooltip_anchor_props.d.ts +0 -1
- package/dist/types/src/ui/types/tooltip_anchor_props.d.ts.map +1 -1
- package/dist/types/src/ui/use_base.d.ts.map +1 -1
- package/dist/types/src/ui/use_cursor.d.ts.map +1 -1
- package/dist/types/src/ui/use_form_field.d.ts +0 -2
- package/dist/types/src/ui/use_form_field.d.ts.map +1 -1
- package/dist/types/src/ui/use_records.d.ts +2 -2
- package/dist/types/src/ui/use_records.d.ts.map +1 -1
- package/dist/types/src/ui/use_session.d.ts.map +1 -1
- package/dist/types/src/ui/view_picker.d.ts +2 -2
- package/dist/types/src/ui/view_picker.d.ts.map +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/viewport.d.ts +2 -2
- package/dist/types/src/viewport.d.ts.map +1 -1
- package/dist/types/src/warning.d.ts +1 -1
- package/dist/types/src/warning.d.ts.map +1 -1
- package/dist/types/stories/helpers/code_block.d.ts +2 -2
- package/dist/types/stories/helpers/code_block.d.ts.map +1 -1
- package/dist/types/stories/helpers/example.d.ts +5 -5
- package/dist/types/stories/helpers/example.d.ts.map +1 -1
- package/dist/types/stories/helpers/example_code_panel.d.ts +2 -2
- package/dist/types/stories/helpers/example_code_panel.d.ts.map +1 -1
- package/dist/types/stories/helpers/fake_cell_renderer.d.ts +2 -2
- package/dist/types/stories/helpers/fake_cell_renderer.d.ts.map +1 -1
- package/dist/types/stories/helpers/fake_foreign_record.d.ts +1 -1
- package/dist/types/stories/helpers/fake_foreign_record.d.ts.map +1 -1
- package/dist/types/stories/helpers/fake_record_card.d.ts +2 -2
- package/dist/types/stories/helpers/fake_record_card.d.ts.map +1 -1
- package/dist/types/stories/helpers/style_prop_list.d.ts +2 -2
- package/dist/types/stories/helpers/style_prop_list.d.ts.map +1 -1
- package/dist/types/stories/icon_example.d.ts +2 -2
- package/dist/types/stories/icon_example.d.ts.map +1 -1
- package/dist/types/test/airtable_interface_mocks/mock_airtable_interface.d.ts +0 -1
- package/dist/types/test/airtable_interface_mocks/mock_airtable_interface.d.ts.map +1 -1
- package/package.json +26 -25
|
@@ -1,96 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.array.from.js");
|
|
4
|
+
require("core-js/modules/es.array.slice.js");
|
|
5
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
6
|
+
require("core-js/modules/es.regexp.to-string.js");
|
|
3
7
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.symbol");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.symbol.description");
|
|
8
|
-
|
|
9
|
-
require("core-js/modules/es.array.filter");
|
|
10
|
-
|
|
11
|
-
require("core-js/modules/es.array.flat-map");
|
|
12
|
-
|
|
13
|
-
require("core-js/modules/es.array.includes");
|
|
14
|
-
|
|
15
|
-
require("core-js/modules/es.array.iterator");
|
|
16
|
-
|
|
17
|
-
require("core-js/modules/es.array.map");
|
|
18
|
-
|
|
19
|
-
require("core-js/modules/es.array.unscopables.flat-map");
|
|
20
|
-
|
|
21
|
-
require("core-js/modules/es.object.to-string");
|
|
22
|
-
|
|
23
|
-
require("core-js/modules/es.promise");
|
|
24
|
-
|
|
25
|
-
require("core-js/modules/es.set");
|
|
26
|
-
|
|
27
|
-
require("core-js/modules/es.string.includes");
|
|
28
|
-
|
|
29
|
-
require("core-js/modules/web.dom-collections.iterator");
|
|
30
|
-
|
|
31
|
-
require("core-js/modules/web.url.to-json");
|
|
32
|
-
|
|
33
8
|
Object.defineProperty(exports, "__esModule", {
|
|
34
9
|
value: true
|
|
35
10
|
});
|
|
36
11
|
exports.default = void 0;
|
|
37
|
-
|
|
38
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
39
|
-
|
|
40
12
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
41
|
-
|
|
42
|
-
require("
|
|
43
|
-
|
|
13
|
+
require("core-js/modules/es.symbol.js");
|
|
14
|
+
require("core-js/modules/es.symbol.description.js");
|
|
15
|
+
require("core-js/modules/es.array.filter.js");
|
|
16
|
+
require("core-js/modules/es.array.flat-map.js");
|
|
17
|
+
require("core-js/modules/es.array.includes.js");
|
|
18
|
+
require("core-js/modules/es.array.iterator.js");
|
|
19
|
+
require("core-js/modules/es.array.map.js");
|
|
20
|
+
require("core-js/modules/es.array.unscopables.flat-map.js");
|
|
21
|
+
require("core-js/modules/es.object.to-string.js");
|
|
22
|
+
require("core-js/modules/es.promise.js");
|
|
23
|
+
require("core-js/modules/es.set.js");
|
|
24
|
+
require("core-js/modules/es.string.includes.js");
|
|
25
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
26
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
27
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
44
28
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
45
|
-
|
|
46
29
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
47
|
-
|
|
48
30
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
49
|
-
|
|
50
31
|
var _airtable_interface = require("../types/airtable_interface");
|
|
51
|
-
|
|
52
32
|
var _mutations = require("../types/mutations");
|
|
53
|
-
|
|
54
33
|
var _private_utils = require("../private_utils");
|
|
55
|
-
|
|
56
34
|
var _error_utils = require("../error_utils");
|
|
57
|
-
|
|
58
35
|
var _mutation_constants = require("./mutation_constants");
|
|
59
|
-
|
|
36
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
37
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
38
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
60
39
|
// Limit for how many items can be updated from a single batch mutation.
|
|
61
40
|
// This is number of records for MULTIPLE_RECORDS type mutations, and number of global config paths
|
|
62
41
|
// for SET_MULTIPLE_GLOBAL_CONFIG_PATHS.
|
|
63
42
|
// Same limit is enforced liveapp-side
|
|
64
|
-
var MUTATIONS_MAX_BATCH_SIZE = 50;
|
|
65
|
-
// the other parts of the request
|
|
43
|
+
var MUTATIONS_MAX_BATCH_SIZE = 50;
|
|
66
44
|
|
|
45
|
+
// Liveapp requests must be under 2mb in size: we enforce a 1.9mb limit here to allow space for
|
|
46
|
+
// the other parts of the request
|
|
67
47
|
var MUTATIONS_MAX_BODY_SIZE = 1.9 * 1024 * 1024;
|
|
68
48
|
var MUTATION_HOLD_FOR_MS = 100;
|
|
69
|
-
/** @internal */
|
|
70
|
-
|
|
71
|
-
var Mutations =
|
|
72
|
-
/*#__PURE__*/
|
|
73
|
-
function () {
|
|
74
|
-
/** @internal */
|
|
75
|
-
|
|
76
|
-
/** @internal */
|
|
77
|
-
|
|
78
|
-
/** @internal */
|
|
79
|
-
|
|
80
|
-
/** @internal */
|
|
81
|
-
|
|
82
|
-
/** @internal */
|
|
83
|
-
|
|
84
|
-
/** @internal */
|
|
85
49
|
|
|
50
|
+
/** @internal */
|
|
51
|
+
var Mutations = /*#__PURE__*/function () {
|
|
86
52
|
/** @hidden */
|
|
87
53
|
function Mutations(sdk, session, base, applyModelChanges, applyGlobalConfigUpdates) {
|
|
88
54
|
(0, _classCallCheck2.default)(this, Mutations);
|
|
55
|
+
/** @internal */
|
|
89
56
|
(0, _defineProperty2.default)(this, "_airtableInterface", void 0);
|
|
57
|
+
/** @internal */
|
|
90
58
|
(0, _defineProperty2.default)(this, "_session", void 0);
|
|
59
|
+
/** @internal */
|
|
91
60
|
(0, _defineProperty2.default)(this, "_sdk", void 0);
|
|
61
|
+
/** @internal */
|
|
92
62
|
(0, _defineProperty2.default)(this, "_base", void 0);
|
|
63
|
+
/** @internal */
|
|
93
64
|
(0, _defineProperty2.default)(this, "_applyModelChanges", void 0);
|
|
65
|
+
/** @internal */
|
|
94
66
|
(0, _defineProperty2.default)(this, "_applyGlobalConfigUpdates", void 0);
|
|
95
67
|
this._airtableInterface = sdk.__airtableInterface;
|
|
96
68
|
this._session = session;
|
|
@@ -99,54 +71,44 @@ function () {
|
|
|
99
71
|
this._applyModelChanges = applyModelChanges;
|
|
100
72
|
this._applyGlobalConfigUpdates = applyGlobalConfigUpdates;
|
|
101
73
|
}
|
|
102
|
-
/** @hidden */
|
|
103
|
-
|
|
104
74
|
|
|
105
|
-
|
|
75
|
+
/** @hidden */
|
|
76
|
+
return (0, _createClass2.default)(Mutations, [{
|
|
106
77
|
key: "applyMutationAsync",
|
|
107
|
-
value: function
|
|
108
|
-
var
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
switch (_context.prev = _context.next) {
|
|
78
|
+
value: (function () {
|
|
79
|
+
var _applyMutationAsync = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(mutation) {
|
|
80
|
+
var permissionCheck, didApplyOptimisticUpdates;
|
|
81
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
82
|
+
while (1) switch (_context.prev = _context.next) {
|
|
112
83
|
case 0:
|
|
113
|
-
this._assertMutationIsValid(mutation);
|
|
84
|
+
this._assertMutationIsValid(mutation);
|
|
85
|
+
// Limit check is after validity check so that we display errors for when users pass in
|
|
114
86
|
// objects correctly (eg updating linked records cell value to be a record object) -
|
|
115
87
|
// otherwise the limit check will fail due to circular objects being converted to JSON first
|
|
116
|
-
|
|
117
|
-
|
|
118
88
|
this._assertMutationUnderLimits(mutation);
|
|
119
|
-
|
|
120
89
|
permissionCheck = this.checkPermissionsForMutation(mutation);
|
|
121
|
-
|
|
122
90
|
if (permissionCheck.hasPermission) {
|
|
123
91
|
_context.next = 5;
|
|
124
92
|
break;
|
|
125
93
|
}
|
|
126
|
-
|
|
127
94
|
throw (0, _error_utils.spawnError)('Cannot apply %s mutation: %s', mutation.type, permissionCheck.reasonDisplayString);
|
|
128
|
-
|
|
129
95
|
case 5:
|
|
130
96
|
didApplyOptimisticUpdates = this._applyOptimisticUpdatesForMutation(mutation);
|
|
131
97
|
_context.prev = 6;
|
|
132
98
|
_context.next = 9;
|
|
133
|
-
return
|
|
99
|
+
return this._airtableInterface.applyMutationAsync(mutation, {
|
|
134
100
|
holdForMs: MUTATION_HOLD_FOR_MS
|
|
135
|
-
})
|
|
136
|
-
|
|
101
|
+
});
|
|
137
102
|
case 9:
|
|
138
103
|
_context.next = 20;
|
|
139
104
|
break;
|
|
140
|
-
|
|
141
105
|
case 11:
|
|
142
106
|
_context.prev = 11;
|
|
143
107
|
_context.t0 = _context["catch"](6);
|
|
144
|
-
|
|
145
108
|
if (!didApplyOptimisticUpdates) {
|
|
146
109
|
_context.next = 19;
|
|
147
110
|
break;
|
|
148
111
|
}
|
|
149
|
-
|
|
150
112
|
// if we applied optimistic updates, we can't gracefully handle a promise rejection
|
|
151
113
|
// here - we can't un-apply optimistic updates, so the SDK's internal data model is
|
|
152
114
|
// in an unexpected state. Instead of letting this promise get rejected, throw an
|
|
@@ -157,31 +119,30 @@ function () {
|
|
|
157
119
|
throw _context.t0;
|
|
158
120
|
}, 0);
|
|
159
121
|
_context.next = 17;
|
|
160
|
-
return
|
|
161
|
-
|
|
122
|
+
return new Promise(() => {});
|
|
162
123
|
case 17:
|
|
163
124
|
_context.next = 20;
|
|
164
125
|
break;
|
|
165
|
-
|
|
166
126
|
case 19:
|
|
167
127
|
throw _context.t0;
|
|
168
|
-
|
|
169
128
|
case 20:
|
|
170
129
|
case "end":
|
|
171
130
|
return _context.stop();
|
|
172
131
|
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
132
|
+
}, _callee, this, [[6, 11]]);
|
|
133
|
+
}));
|
|
134
|
+
function applyMutationAsync(_x) {
|
|
135
|
+
return _applyMutationAsync.apply(this, arguments);
|
|
136
|
+
}
|
|
137
|
+
return applyMutationAsync;
|
|
138
|
+
}() /** @hidden */)
|
|
178
139
|
}, {
|
|
179
140
|
key: "checkPermissionsForMutation",
|
|
180
141
|
value: function checkPermissionsForMutation(mutation) {
|
|
181
142
|
return this._airtableInterface.checkPermissionsForMutation(mutation, this._base.__getBaseData());
|
|
182
143
|
}
|
|
183
|
-
/** @internal */
|
|
184
144
|
|
|
145
|
+
/** @internal */
|
|
185
146
|
}, {
|
|
186
147
|
key: "_assertMutationUnderLimits",
|
|
187
148
|
value: function _assertMutationUnderLimits(mutation) {
|
|
@@ -192,13 +153,12 @@ function () {
|
|
|
192
153
|
if (encodeURIComponent(JSON.stringify(mutation)).length > MUTATIONS_MAX_BODY_SIZE) {
|
|
193
154
|
throw (0, _error_utils.spawnError)('Request exceeds maximum size limit of %s bytes', MUTATIONS_MAX_BODY_SIZE);
|
|
194
155
|
}
|
|
195
|
-
|
|
196
156
|
if (this._doesMutationExceedBatchSizeLimit(mutation)) {
|
|
197
157
|
throw (0, _error_utils.spawnError)('Request exceeds maximum batch size limit of %s items', MUTATIONS_MAX_BATCH_SIZE);
|
|
198
158
|
}
|
|
199
159
|
}
|
|
200
|
-
/** @internal */
|
|
201
160
|
|
|
161
|
+
/** @internal */
|
|
202
162
|
}, {
|
|
203
163
|
key: "_doesMutationExceedBatchSizeLimit",
|
|
204
164
|
value: function _doesMutationExceedBatchSizeLimit(mutation) {
|
|
@@ -206,22 +166,19 @@ function () {
|
|
|
206
166
|
case _mutations.MutationTypes.SET_MULTIPLE_RECORDS_CELL_VALUES:
|
|
207
167
|
case _mutations.MutationTypes.CREATE_MULTIPLE_RECORDS:
|
|
208
168
|
return mutation.records.length > MUTATIONS_MAX_BATCH_SIZE;
|
|
209
|
-
|
|
210
169
|
case _mutations.MutationTypes.DELETE_MULTIPLE_RECORDS:
|
|
211
170
|
return mutation.recordIds.length > MUTATIONS_MAX_BATCH_SIZE;
|
|
212
|
-
|
|
213
171
|
case _mutations.MutationTypes.SET_MULTIPLE_GLOBAL_CONFIG_PATHS:
|
|
214
172
|
return mutation.updates.length > MUTATIONS_MAX_BATCH_SIZE;
|
|
215
173
|
// The "default" case cannot be reached because this method is only
|
|
216
174
|
// invoked after the mutation type has been validated.
|
|
217
175
|
// istanbul ignore next
|
|
218
|
-
|
|
219
176
|
default:
|
|
220
177
|
return false;
|
|
221
178
|
}
|
|
222
179
|
}
|
|
223
|
-
/** @internal */
|
|
224
180
|
|
|
181
|
+
/** @internal */
|
|
225
182
|
}, {
|
|
226
183
|
key: "_assertFieldIsValidForMutation",
|
|
227
184
|
value: function _assertFieldIsValidForMutation(field) {
|
|
@@ -229,28 +186,26 @@ function () {
|
|
|
229
186
|
throw (0, _error_utils.spawnError)("Can't set cell values: Field '%s' is computed and cannot be set", field.name);
|
|
230
187
|
}
|
|
231
188
|
}
|
|
232
|
-
/** @internal */
|
|
233
189
|
|
|
190
|
+
/** @internal */
|
|
234
191
|
}, {
|
|
235
192
|
key: "_assertFieldNameIsValidForMutation",
|
|
236
193
|
value: function _assertFieldNameIsValidForMutation(name, table) {
|
|
237
194
|
if (!name) {
|
|
238
195
|
throw (0, _error_utils.spawnError)("Can't create or update field: must provide non-empty name");
|
|
239
196
|
}
|
|
240
|
-
|
|
241
197
|
if (name.length > _mutation_constants.MAX_FIELD_NAME_LENGTH) {
|
|
242
198
|
throw (0, _error_utils.spawnError)("Can't create or update field: name '%s' exceeds maximum length of %s characters", name, _mutation_constants.MAX_FIELD_NAME_LENGTH);
|
|
243
|
-
}
|
|
244
|
-
|
|
199
|
+
}
|
|
245
200
|
|
|
201
|
+
// Verify the new name doesn't collide with any existing field name.
|
|
246
202
|
var existingLowercaseFieldNames = table.fields.map(field => field.name.toLowerCase());
|
|
247
|
-
|
|
248
203
|
if (existingLowercaseFieldNames.includes(name.toLowerCase())) {
|
|
249
204
|
throw (0, _error_utils.spawnError)("Can't create or update field: field with name '%s' already exists", name);
|
|
250
205
|
}
|
|
251
206
|
}
|
|
252
|
-
/** @internal */
|
|
253
207
|
|
|
208
|
+
/** @internal */
|
|
254
209
|
}, {
|
|
255
210
|
key: "_assertMutationIsValid",
|
|
256
211
|
value: function _assertMutationIsValid(mutation) {
|
|
@@ -262,61 +217,48 @@ function () {
|
|
|
262
217
|
// validations - it wouldn't cause issues outside of the block frame. But running them
|
|
263
218
|
// gives us slightly more confidence that we can do something other than completely crash
|
|
264
219
|
// the block in the event of an invalid mutation.
|
|
220
|
+
|
|
265
221
|
var appInterface = this._sdk.__appInterface;
|
|
266
222
|
var billingPlanGrouping = this._base.__billingPlanGrouping;
|
|
267
|
-
|
|
268
223
|
switch (mutation.type) {
|
|
269
224
|
case _mutations.MutationTypes.SET_MULTIPLE_RECORDS_CELL_VALUES:
|
|
270
225
|
{
|
|
271
226
|
var tableId = mutation.tableId,
|
|
272
|
-
|
|
273
|
-
|
|
227
|
+
records = mutation.records;
|
|
274
228
|
var table = this._base.getTableByIdIfExists(tableId);
|
|
275
|
-
|
|
276
229
|
if (!table) {
|
|
277
230
|
throw (0, _error_utils.spawnError)("Can't set cell values: No table with id %s exists", tableId);
|
|
278
|
-
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// For every mutation, we check that we're not trying to set fields that we don't support
|
|
279
234
|
// mutations for yet. When record data is loaded, we also check that the record we're
|
|
280
235
|
// updating actually exists and that the cell values are valid.
|
|
281
|
-
|
|
282
|
-
|
|
283
236
|
var recordStore = this._base.__getRecordStore(tableId);
|
|
284
|
-
|
|
285
237
|
var checkedFieldIds = new Set();
|
|
286
|
-
var
|
|
287
|
-
|
|
288
|
-
var _iteratorError = undefined;
|
|
289
|
-
|
|
238
|
+
var _iterator = _createForOfIteratorHelper(records),
|
|
239
|
+
_step;
|
|
290
240
|
try {
|
|
291
|
-
for (
|
|
241
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
292
242
|
var record = _step.value;
|
|
293
243
|
var existingRecord = null;
|
|
294
|
-
|
|
295
244
|
if (recordStore.isRecordMetadataLoaded) {
|
|
296
245
|
existingRecord = recordStore.getRecordByIdIfExists(record.id);
|
|
297
|
-
|
|
298
246
|
if (!existingRecord) {
|
|
299
247
|
throw (0, _error_utils.spawnError)("Can't set cell values: No record with id %s exists", record.id);
|
|
300
248
|
}
|
|
301
249
|
}
|
|
302
|
-
|
|
303
250
|
for (var _i = 0, _Object$keys = Object.keys(record.cellValuesByFieldId); _i < _Object$keys.length; _i++) {
|
|
304
251
|
var fieldId = _Object$keys[_i];
|
|
305
252
|
var field = table.getFieldByIdIfExists(fieldId);
|
|
306
|
-
|
|
307
253
|
if (!field) {
|
|
308
254
|
throw (0, _error_utils.spawnError)("Can't set cell values: No field with id %s exists in table '%s'", fieldId, table.name);
|
|
309
255
|
}
|
|
310
|
-
|
|
311
256
|
if (!checkedFieldIds.has(fieldId)) {
|
|
312
257
|
this._assertFieldIsValidForMutation(field);
|
|
313
|
-
|
|
314
258
|
checkedFieldIds.add(fieldId);
|
|
315
259
|
}
|
|
316
|
-
|
|
317
260
|
if (existingRecord && recordStore.areCellValuesLoadedForFieldId(fieldId)) {
|
|
318
261
|
var validationResult = this._airtableInterface.fieldTypeProvider.validateCellValueForUpdate(appInterface, record.cellValuesByFieldId[fieldId], existingRecord._getRawCellValue(field), field._data);
|
|
319
|
-
|
|
320
262
|
if (!validationResult.isValid) {
|
|
321
263
|
throw (0, _error_utils.spawnError)("Can't set cell values: invalid cell value for field '%s'.\n%s", field.name, validationResult.reason);
|
|
322
264
|
}
|
|
@@ -324,132 +266,79 @@ function () {
|
|
|
324
266
|
}
|
|
325
267
|
}
|
|
326
268
|
} catch (err) {
|
|
327
|
-
|
|
328
|
-
_iteratorError = err;
|
|
269
|
+
_iterator.e(err);
|
|
329
270
|
} finally {
|
|
330
|
-
|
|
331
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
332
|
-
_iterator.return();
|
|
333
|
-
}
|
|
334
|
-
} finally {
|
|
335
|
-
if (_didIteratorError) {
|
|
336
|
-
throw _iteratorError;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
271
|
+
_iterator.f();
|
|
339
272
|
}
|
|
340
|
-
|
|
341
273
|
return;
|
|
342
274
|
}
|
|
343
|
-
|
|
344
275
|
case _mutations.MutationTypes.DELETE_MULTIPLE_RECORDS:
|
|
345
276
|
{
|
|
346
277
|
var _tableId = mutation.tableId,
|
|
347
|
-
|
|
348
|
-
|
|
278
|
+
recordIds = mutation.recordIds;
|
|
349
279
|
var _table = this._base.getTableByIdIfExists(_tableId);
|
|
350
|
-
|
|
351
280
|
if (!_table) {
|
|
352
281
|
throw (0, _error_utils.spawnError)("Can't delete records: No table with id %s exists", _tableId);
|
|
353
282
|
}
|
|
354
|
-
|
|
355
283
|
var _recordStore = this._base.__getRecordStore(_tableId);
|
|
356
|
-
|
|
357
284
|
if (_recordStore.isRecordMetadataLoaded) {
|
|
358
|
-
var
|
|
359
|
-
|
|
360
|
-
var _iteratorError2 = undefined;
|
|
361
|
-
|
|
285
|
+
var _iterator2 = _createForOfIteratorHelper(recordIds),
|
|
286
|
+
_step2;
|
|
362
287
|
try {
|
|
363
|
-
for (
|
|
288
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
364
289
|
var recordId = _step2.value;
|
|
365
|
-
|
|
366
290
|
var _record = _recordStore.getRecordByIdIfExists(recordId);
|
|
367
|
-
|
|
368
291
|
if (!_record) {
|
|
369
292
|
throw (0, _error_utils.spawnError)("Can't delete records: No record with id %s exists in table '%s'", recordId, _table.name);
|
|
370
293
|
}
|
|
371
294
|
}
|
|
372
295
|
} catch (err) {
|
|
373
|
-
|
|
374
|
-
_iteratorError2 = err;
|
|
296
|
+
_iterator2.e(err);
|
|
375
297
|
} finally {
|
|
376
|
-
|
|
377
|
-
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
378
|
-
_iterator2.return();
|
|
379
|
-
}
|
|
380
|
-
} finally {
|
|
381
|
-
if (_didIteratorError2) {
|
|
382
|
-
throw _iteratorError2;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
298
|
+
_iterator2.f();
|
|
385
299
|
}
|
|
386
300
|
}
|
|
387
|
-
|
|
388
301
|
return;
|
|
389
302
|
}
|
|
390
|
-
|
|
391
303
|
case _mutations.MutationTypes.CREATE_MULTIPLE_RECORDS:
|
|
392
304
|
{
|
|
393
305
|
var _tableId2 = mutation.tableId,
|
|
394
|
-
|
|
395
|
-
|
|
306
|
+
_records = mutation.records;
|
|
396
307
|
var _checkedFieldIds = new Set();
|
|
397
|
-
|
|
398
308
|
var _table2 = this._base.getTableByIdIfExists(_tableId2);
|
|
399
|
-
|
|
400
309
|
if (!_table2) {
|
|
401
310
|
throw (0, _error_utils.spawnError)("Can't create records: No table with id %s exists", _tableId2);
|
|
402
311
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
var _didIteratorError3 = false;
|
|
406
|
-
var _iteratorError3 = undefined;
|
|
407
|
-
|
|
312
|
+
var _iterator3 = _createForOfIteratorHelper(_records),
|
|
313
|
+
_step3;
|
|
408
314
|
try {
|
|
409
|
-
for (
|
|
315
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
410
316
|
var _record2 = _step3.value;
|
|
411
|
-
|
|
412
317
|
for (var _i2 = 0, _Object$keys2 = Object.keys(_record2.cellValuesByFieldId); _i2 < _Object$keys2.length; _i2++) {
|
|
413
318
|
var _fieldId = _Object$keys2[_i2];
|
|
414
|
-
|
|
415
319
|
var _field = _table2.getFieldByIdIfExists(_fieldId);
|
|
416
|
-
|
|
417
320
|
if (!_field) {
|
|
418
321
|
throw (0, _error_utils.spawnError)("Can't create records: No field with id %s exists in table '%s'", _fieldId, _table2.name);
|
|
419
322
|
}
|
|
420
|
-
|
|
421
323
|
if (!_checkedFieldIds.has(_fieldId)) {
|
|
422
324
|
this._assertFieldIsValidForMutation(_field);
|
|
423
|
-
|
|
424
325
|
_checkedFieldIds.add(_fieldId);
|
|
425
|
-
}
|
|
426
|
-
|
|
326
|
+
}
|
|
427
327
|
|
|
328
|
+
// Current cell value is null since the record doesn't exist.
|
|
428
329
|
var _validationResult = this._airtableInterface.fieldTypeProvider.validateCellValueForUpdate(appInterface, _record2.cellValuesByFieldId[_fieldId], null, _field._data);
|
|
429
|
-
|
|
430
330
|
if (!_validationResult.isValid) {
|
|
431
331
|
throw (0, _error_utils.spawnError)("Can't create records: invalid cell value for field '%s'.\n%s", _field.name, _validationResult.reason);
|
|
432
332
|
}
|
|
433
333
|
}
|
|
434
334
|
}
|
|
435
335
|
} catch (err) {
|
|
436
|
-
|
|
437
|
-
_iteratorError3 = err;
|
|
336
|
+
_iterator3.e(err);
|
|
438
337
|
} finally {
|
|
439
|
-
|
|
440
|
-
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
441
|
-
_iterator3.return();
|
|
442
|
-
}
|
|
443
|
-
} finally {
|
|
444
|
-
if (_didIteratorError3) {
|
|
445
|
-
throw _iteratorError3;
|
|
446
|
-
}
|
|
447
|
-
}
|
|
338
|
+
_iterator3.f();
|
|
448
339
|
}
|
|
449
|
-
|
|
450
340
|
return;
|
|
451
341
|
}
|
|
452
|
-
|
|
453
342
|
case _mutations.MutationTypes.SET_MULTIPLE_GLOBAL_CONFIG_PATHS:
|
|
454
343
|
{
|
|
455
344
|
// globalConfig update is a special case: globalConfig handles validation before
|
|
@@ -457,247 +346,181 @@ function () {
|
|
|
457
346
|
// paths being set.
|
|
458
347
|
return;
|
|
459
348
|
}
|
|
460
|
-
|
|
461
349
|
case _mutations.MutationTypes.CREATE_SINGLE_FIELD:
|
|
462
350
|
{
|
|
463
351
|
var _tableId3 = mutation.tableId,
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
352
|
+
name = mutation.name,
|
|
353
|
+
config = mutation.config,
|
|
354
|
+
description = mutation.description;
|
|
468
355
|
var _table3 = this._base.getTableByIdIfExists(_tableId3);
|
|
469
|
-
|
|
470
356
|
if (!_table3) {
|
|
471
357
|
throw (0, _error_utils.spawnError)("Can't create field: No table with id %s exists", _tableId3);
|
|
472
358
|
}
|
|
473
|
-
|
|
474
359
|
if (_table3.fields.length >= _mutation_constants.MAX_NUM_FIELDS_PER_TABLE) {
|
|
475
360
|
throw (0, _error_utils.spawnError)("Can't create field: table already has the maximum of %s fields", _mutation_constants.MAX_NUM_FIELDS_PER_TABLE);
|
|
476
361
|
}
|
|
362
|
+
this._assertFieldNameIsValidForMutation(name, _table3);
|
|
477
363
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
364
|
+
// Current config / field data is null since the field doesn't exist.
|
|
481
365
|
var _validationResult2 = this._airtableInterface.fieldTypeProvider.validateConfigForUpdate(appInterface, config, null, null, billingPlanGrouping);
|
|
482
|
-
|
|
483
366
|
if (!_validationResult2.isValid) {
|
|
484
367
|
throw (0, _error_utils.spawnError)("Can't create field: invalid field config.\n%s", _validationResult2.reason);
|
|
485
368
|
}
|
|
486
|
-
|
|
487
369
|
if (description && description.length > _mutation_constants.MAX_FIELD_DESCRIPTION_LENGTH) {
|
|
488
370
|
throw (0, _error_utils.spawnError)("Can't create field: description exceeds maximum length of %s characters", _mutation_constants.MAX_FIELD_DESCRIPTION_LENGTH);
|
|
489
371
|
}
|
|
490
|
-
|
|
491
372
|
return;
|
|
492
373
|
}
|
|
493
|
-
|
|
494
374
|
case _mutations.MutationTypes.UPDATE_SINGLE_FIELD_CONFIG:
|
|
495
375
|
{
|
|
496
376
|
var _tableId4 = mutation.tableId,
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
377
|
+
id = mutation.id,
|
|
378
|
+
_config = mutation.config,
|
|
379
|
+
opts = mutation.opts;
|
|
501
380
|
var _table4 = this._base.getTableByIdIfExists(_tableId4);
|
|
502
|
-
|
|
503
381
|
if (!_table4) {
|
|
504
382
|
throw (0, _error_utils.spawnError)("Can't update field: No table with id %s exists", _tableId4);
|
|
505
383
|
}
|
|
506
|
-
|
|
507
384
|
var _field2 = _table4.getFieldByIdIfExists(id);
|
|
508
|
-
|
|
509
385
|
if (!_field2) {
|
|
510
386
|
throw (0, _error_utils.spawnError)("Can't update field: No field with id %s exists", id);
|
|
511
|
-
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// we get the config directly instead of using field.type/field.options to get it
|
|
512
390
|
// in one call and because field.options returns null instead of undefined when
|
|
513
391
|
// a field does not have options, whilst we need to pass undefined
|
|
514
|
-
|
|
515
|
-
|
|
516
392
|
var currentConfig = this._airtableInterface.fieldTypeProvider.getConfig(appInterface, _field2._data, _field2.parentTable.__getFieldNamesById());
|
|
517
|
-
|
|
518
393
|
var _validationResult3 = this._airtableInterface.fieldTypeProvider.validateConfigForUpdate(appInterface, _config, currentConfig, _field2._data, billingPlanGrouping, opts);
|
|
519
|
-
|
|
520
394
|
if (!_validationResult3.isValid) {
|
|
521
395
|
throw (0, _error_utils.spawnError)("Can't update field: invalid field config.\n%s", _validationResult3.reason);
|
|
522
396
|
}
|
|
523
|
-
|
|
524
397
|
return;
|
|
525
398
|
}
|
|
526
|
-
|
|
527
399
|
case _mutations.MutationTypes.UPDATE_SINGLE_FIELD_DESCRIPTION:
|
|
528
400
|
{
|
|
529
401
|
var _tableId5 = mutation.tableId,
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
402
|
+
_id = mutation.id,
|
|
403
|
+
_description = mutation.description;
|
|
533
404
|
var _table5 = this._base.getTableByIdIfExists(_tableId5);
|
|
534
|
-
|
|
535
405
|
if (!_table5) {
|
|
536
406
|
throw (0, _error_utils.spawnError)("Can't update field: No table with id %s exists", _tableId5);
|
|
537
407
|
}
|
|
538
|
-
|
|
539
408
|
var _field3 = _table5.getFieldByIdIfExists(_id);
|
|
540
|
-
|
|
541
409
|
if (!_field3) {
|
|
542
410
|
throw (0, _error_utils.spawnError)("Can't update field: No field with id %s exists", _id);
|
|
543
411
|
}
|
|
544
|
-
|
|
545
412
|
if (_description && _description.length > _mutation_constants.MAX_FIELD_DESCRIPTION_LENGTH) {
|
|
546
413
|
throw (0, _error_utils.spawnError)("Can't update field: description exceeds maximum length of %s characters", _mutation_constants.MAX_FIELD_DESCRIPTION_LENGTH);
|
|
547
414
|
}
|
|
548
|
-
|
|
549
415
|
return;
|
|
550
416
|
}
|
|
551
|
-
|
|
552
417
|
case _mutations.MutationTypes.UPDATE_SINGLE_FIELD_NAME:
|
|
553
418
|
{
|
|
554
419
|
var _tableId6 = mutation.tableId,
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
420
|
+
_id2 = mutation.id,
|
|
421
|
+
_name = mutation.name;
|
|
558
422
|
var _table6 = this._base.getTableByIdIfExists(_tableId6);
|
|
559
|
-
|
|
560
423
|
if (!_table6) {
|
|
561
424
|
throw (0, _error_utils.spawnError)("Can't update field: No table with id %s exists", _tableId6);
|
|
562
425
|
}
|
|
563
|
-
|
|
564
426
|
var _field4 = _table6.getFieldByIdIfExists(_id2);
|
|
565
|
-
|
|
566
427
|
if (!_field4) {
|
|
567
428
|
throw (0, _error_utils.spawnError)("Can't update field: No field with id %s exists", _id2);
|
|
568
|
-
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// We skip name validation if it's the same name:
|
|
569
432
|
// If it's exactly same name, this will result in no-op;
|
|
570
433
|
// If it's only case change, we allow update and we know this name is already validated before;
|
|
571
|
-
|
|
572
|
-
|
|
573
434
|
if (_field4.name.toLowerCase() !== _name.toLowerCase()) {
|
|
574
435
|
this._assertFieldNameIsValidForMutation(_name, _table6);
|
|
575
436
|
}
|
|
576
|
-
|
|
577
437
|
return;
|
|
578
438
|
}
|
|
579
|
-
|
|
580
439
|
case _mutations.MutationTypes.CREATE_SINGLE_TABLE:
|
|
581
440
|
{
|
|
582
441
|
var _name2 = mutation.name,
|
|
583
|
-
|
|
584
|
-
|
|
442
|
+
fields = mutation.fields;
|
|
585
443
|
if (!_name2) {
|
|
586
444
|
throw (0, _error_utils.spawnError)("Can't create table: must provide non-empty name");
|
|
587
445
|
}
|
|
588
|
-
|
|
589
446
|
if (_name2.length > _mutation_constants.MAX_TABLE_NAME_LENGTH) {
|
|
590
447
|
throw (0, _error_utils.spawnError)("Can't create table: name '%s' exceeds maximum length of %s characters", _name2, _mutation_constants.MAX_TABLE_NAME_LENGTH);
|
|
591
448
|
}
|
|
592
|
-
|
|
593
449
|
var existingLowercaseTableNames = this._base.tables.map(table => table.name.toLowerCase());
|
|
594
|
-
|
|
595
450
|
if (existingLowercaseTableNames.includes(_name2.toLowerCase())) {
|
|
596
451
|
throw (0, _error_utils.spawnError)("Can't create table: table with name '%s' already exists", _name2);
|
|
597
452
|
}
|
|
598
|
-
|
|
599
453
|
if (fields.length === 0) {
|
|
600
454
|
throw (0, _error_utils.spawnError)("Can't create table: must specify at least one field");
|
|
601
455
|
}
|
|
602
|
-
|
|
603
456
|
if (fields.length > _mutation_constants.MAX_NUM_FIELDS_PER_TABLE) {
|
|
604
457
|
throw (0, _error_utils.spawnError)("Can't create table: number of fields exceeds maximum of %s", _mutation_constants.MAX_NUM_FIELDS_PER_TABLE);
|
|
605
458
|
}
|
|
606
|
-
|
|
607
459
|
var lowercaseFieldNames = new Set();
|
|
608
|
-
var
|
|
609
|
-
|
|
610
|
-
var _iteratorError4 = undefined;
|
|
611
|
-
|
|
460
|
+
var _iterator4 = _createForOfIteratorHelper(fields),
|
|
461
|
+
_step4;
|
|
612
462
|
try {
|
|
613
|
-
for (
|
|
463
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
614
464
|
var _field5 = _step4.value;
|
|
615
|
-
|
|
616
465
|
if (!_field5.name) {
|
|
617
466
|
throw (0, _error_utils.spawnError)("Can't create table: must provide non-empty name for every field");
|
|
618
467
|
}
|
|
619
|
-
|
|
620
468
|
if (_field5.name.length > _mutation_constants.MAX_FIELD_NAME_LENGTH) {
|
|
621
469
|
throw (0, _error_utils.spawnError)("Can't create table: field name '%s' exceeds maximum length of %s characters", _field5.name, _mutation_constants.MAX_FIELD_NAME_LENGTH);
|
|
622
470
|
}
|
|
623
|
-
|
|
624
471
|
var lowercaseFieldName = _field5.name.toLowerCase();
|
|
625
|
-
|
|
626
472
|
if (lowercaseFieldNames.has(lowercaseFieldName)) {
|
|
627
473
|
throw (0, _error_utils.spawnError)("Can't create table: duplicate field name '%s'", _field5.name);
|
|
628
474
|
}
|
|
475
|
+
lowercaseFieldNames.add(lowercaseFieldName);
|
|
629
476
|
|
|
630
|
-
|
|
631
|
-
|
|
477
|
+
// Current config / field data is null since the field doesn't exist.
|
|
632
478
|
var _validationResult4 = this._airtableInterface.fieldTypeProvider.validateConfigForUpdate(appInterface, _field5.config, null, null, billingPlanGrouping);
|
|
633
|
-
|
|
634
479
|
if (!_validationResult4.isValid) {
|
|
635
480
|
throw (0, _error_utils.spawnError)("Can't create table: invalid field config for field '%s'.\n%s", _field5.name, _validationResult4.reason);
|
|
636
481
|
}
|
|
637
|
-
|
|
638
482
|
if (_field5.description && _field5.description.length > _mutation_constants.MAX_FIELD_DESCRIPTION_LENGTH) {
|
|
639
483
|
throw (0, _error_utils.spawnError)("Can't create table: description for field '%s' exceeds maximum length of %s characters", _field5.name, _mutation_constants.MAX_FIELD_DESCRIPTION_LENGTH);
|
|
640
484
|
}
|
|
641
485
|
}
|
|
642
486
|
} catch (err) {
|
|
643
|
-
|
|
644
|
-
_iteratorError4 = err;
|
|
487
|
+
_iterator4.e(err);
|
|
645
488
|
} finally {
|
|
646
|
-
|
|
647
|
-
if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
|
|
648
|
-
_iterator4.return();
|
|
649
|
-
}
|
|
650
|
-
} finally {
|
|
651
|
-
if (_didIteratorError4) {
|
|
652
|
-
throw _iteratorError4;
|
|
653
|
-
}
|
|
654
|
-
}
|
|
489
|
+
_iterator4.f();
|
|
655
490
|
}
|
|
656
|
-
|
|
657
491
|
var primaryField = fields[0];
|
|
658
|
-
|
|
659
492
|
if (!this._airtableInterface.fieldTypeProvider.canBePrimary(appInterface, primaryField.config, billingPlanGrouping)) {
|
|
660
493
|
throw (0, _error_utils.spawnError)("Can't create table: first field '%s' has type '%s' which cannot be a primary field", primaryField.name, primaryField.config.type);
|
|
661
494
|
}
|
|
662
|
-
|
|
663
495
|
return;
|
|
664
496
|
}
|
|
665
|
-
|
|
666
497
|
case _mutations.MutationTypes.UPDATE_VIEW_METADATA:
|
|
667
498
|
{
|
|
668
499
|
var _tableId7 = mutation.tableId,
|
|
669
|
-
|
|
500
|
+
viewId = mutation.viewId;
|
|
670
501
|
var runContext = this._airtableInterface.sdkInitData.runContext;
|
|
671
|
-
|
|
672
502
|
if (runContext.type !== _airtable_interface.BlockRunContextType.VIEW) {
|
|
673
503
|
throw (0, _error_utils.spawnError)('Setting view metadata is only valid for views');
|
|
674
504
|
}
|
|
675
|
-
|
|
676
505
|
if (runContext.viewId !== viewId || runContext.tableId !== _tableId7) {
|
|
677
506
|
throw (0, _error_utils.spawnError)('Custom views can only set view metadata on themselves');
|
|
678
507
|
}
|
|
679
|
-
|
|
680
508
|
var _table7 = this._base.getTableByIdIfExists(_tableId7);
|
|
681
|
-
|
|
682
509
|
if (!_table7) {
|
|
683
510
|
throw (0, _error_utils.spawnError)("Can't update metadata: No table with id %s exists", _tableId7);
|
|
684
511
|
}
|
|
685
|
-
|
|
686
512
|
var view = _table7.getViewByIdIfExists(viewId);
|
|
687
|
-
|
|
688
513
|
if (!view) {
|
|
689
514
|
throw (0, _error_utils.spawnError)("Can't update metadata: No view with id %s exists", viewId);
|
|
690
515
|
}
|
|
691
|
-
|
|
692
516
|
return;
|
|
693
517
|
}
|
|
694
|
-
|
|
695
518
|
default:
|
|
696
519
|
throw (0, _error_utils.spawnUnknownSwitchCaseError)('mutation type', mutation, 'type');
|
|
697
520
|
}
|
|
698
521
|
}
|
|
699
|
-
/** @internal */
|
|
700
522
|
|
|
523
|
+
/** @internal */
|
|
701
524
|
}, {
|
|
702
525
|
key: "_applyOptimisticUpdatesForMutation",
|
|
703
526
|
value: function _applyOptimisticUpdatesForMutation(mutation) {
|
|
@@ -706,22 +529,17 @@ function () {
|
|
|
706
529
|
// SET_MULTIPLE_GLOBAL_CONFIG_PATHS we always apply optimistic updates.
|
|
707
530
|
if (mutation.type === _mutations.MutationTypes.SET_MULTIPLE_GLOBAL_CONFIG_PATHS) {
|
|
708
531
|
this._applyGlobalConfigUpdates(mutation.updates);
|
|
709
|
-
|
|
710
532
|
return true;
|
|
711
533
|
}
|
|
712
|
-
|
|
713
534
|
var modelChanges = this._getOptimisticModelChangesForMutation(mutation);
|
|
714
|
-
|
|
715
535
|
if (modelChanges.length > 0) {
|
|
716
536
|
this._applyModelChanges(modelChanges);
|
|
717
|
-
|
|
718
537
|
return true;
|
|
719
538
|
}
|
|
720
|
-
|
|
721
539
|
return false;
|
|
722
540
|
}
|
|
723
|
-
/** @internal */
|
|
724
541
|
|
|
542
|
+
/** @internal */
|
|
725
543
|
}, {
|
|
726
544
|
key: "_getOptimisticModelChangesForMutation",
|
|
727
545
|
value: function _getOptimisticModelChangesForMutation(mutation) {
|
|
@@ -729,84 +547,59 @@ function () {
|
|
|
729
547
|
case _mutations.MutationTypes.SET_MULTIPLE_RECORDS_CELL_VALUES:
|
|
730
548
|
{
|
|
731
549
|
var tableId = mutation.tableId,
|
|
732
|
-
|
|
733
|
-
|
|
550
|
+
records = mutation.records;
|
|
734
551
|
var recordStore = this._base.__getRecordStore(tableId);
|
|
735
|
-
|
|
736
552
|
return records.flatMap(record => Object.keys(record.cellValuesByFieldId).filter(fieldId => recordStore.areCellValuesLoadedForFieldId(fieldId)).map(fieldId => ({
|
|
737
553
|
path: ['tablesById', tableId, 'recordsById', record.id, 'cellValuesByFieldId', fieldId],
|
|
738
554
|
value: record.cellValuesByFieldId[fieldId]
|
|
739
555
|
})));
|
|
740
556
|
}
|
|
741
|
-
|
|
742
557
|
case _mutations.MutationTypes.DELETE_MULTIPLE_RECORDS:
|
|
743
558
|
{
|
|
744
559
|
var _tableId8 = mutation.tableId,
|
|
745
|
-
|
|
746
|
-
|
|
560
|
+
recordIds = mutation.recordIds;
|
|
747
561
|
var _recordStore2 = this._base.__getRecordStore(_tableId8);
|
|
748
|
-
|
|
749
562
|
if (!_recordStore2.isRecordMetadataLoaded) {
|
|
750
563
|
return [];
|
|
751
564
|
}
|
|
752
|
-
|
|
753
565
|
return [...recordIds.map(recordId => ({
|
|
754
566
|
path: ['tablesById', _tableId8, 'recordsById', recordId],
|
|
755
567
|
value: undefined
|
|
756
568
|
})), ...this._base.getTableById(_tableId8).views.flatMap(view => {
|
|
757
569
|
var viewDataStore = _recordStore2.getViewDataStore(view.id);
|
|
758
|
-
|
|
759
570
|
if (!viewDataStore.isDataLoaded) {
|
|
760
571
|
return [];
|
|
761
572
|
}
|
|
762
|
-
|
|
763
573
|
return viewDataStore.__generateChangesForParentTableDeleteMultipleRecords(recordIds);
|
|
764
574
|
})];
|
|
765
575
|
}
|
|
766
|
-
|
|
767
576
|
case _mutations.MutationTypes.CREATE_MULTIPLE_RECORDS:
|
|
768
577
|
{
|
|
769
578
|
var _tableId9 = mutation.tableId,
|
|
770
|
-
|
|
771
|
-
|
|
579
|
+
_records2 = mutation.records;
|
|
772
580
|
var _recordStore3 = this._base.__getRecordStore(_tableId9);
|
|
773
|
-
|
|
774
581
|
if (!_recordStore3.isRecordMetadataLoaded) {
|
|
775
582
|
return [];
|
|
776
583
|
}
|
|
777
|
-
|
|
778
584
|
return [..._records2.map(record => {
|
|
779
585
|
// Only apply optimistic changes for fields that are loaded
|
|
780
586
|
var filteredCellValuesByFieldId = {};
|
|
781
|
-
var
|
|
782
|
-
|
|
783
|
-
var _iteratorError5 = undefined;
|
|
784
|
-
|
|
587
|
+
var _iterator5 = _createForOfIteratorHelper((0, _private_utils.entries)(record.cellValuesByFieldId)),
|
|
588
|
+
_step5;
|
|
785
589
|
try {
|
|
786
|
-
for (
|
|
590
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
787
591
|
var _step5$value = (0, _slicedToArray2.default)(_step5.value, 2),
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
592
|
+
fieldId = _step5$value[0],
|
|
593
|
+
cellValue = _step5$value[1];
|
|
791
594
|
if (_recordStore3.areCellValuesLoadedForFieldId(fieldId)) {
|
|
792
595
|
filteredCellValuesByFieldId[fieldId] = cellValue;
|
|
793
596
|
}
|
|
794
597
|
}
|
|
795
598
|
} catch (err) {
|
|
796
|
-
|
|
797
|
-
_iteratorError5 = err;
|
|
599
|
+
_iterator5.e(err);
|
|
798
600
|
} finally {
|
|
799
|
-
|
|
800
|
-
if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
|
|
801
|
-
_iterator5.return();
|
|
802
|
-
}
|
|
803
|
-
} finally {
|
|
804
|
-
if (_didIteratorError5) {
|
|
805
|
-
throw _iteratorError5;
|
|
806
|
-
}
|
|
807
|
-
}
|
|
601
|
+
_iterator5.f();
|
|
808
602
|
}
|
|
809
|
-
|
|
810
603
|
return {
|
|
811
604
|
path: ['tablesById', _tableId9, 'recordsById', record.id],
|
|
812
605
|
value: {
|
|
@@ -818,23 +611,20 @@ function () {
|
|
|
818
611
|
};
|
|
819
612
|
}), ...this._base.getTableById(_tableId9).views.flatMap(view => {
|
|
820
613
|
var viewDataStore = _recordStore3.getViewDataStore(view.id);
|
|
821
|
-
|
|
822
614
|
if (!viewDataStore.isDataLoaded) {
|
|
823
615
|
return [];
|
|
824
616
|
}
|
|
825
|
-
|
|
826
617
|
return viewDataStore.__generateChangesForParentTableAddMultipleRecords(_records2.map(record => record.id));
|
|
827
618
|
})];
|
|
828
619
|
}
|
|
620
|
+
|
|
829
621
|
// The following branch is unreachable because this method's only
|
|
830
622
|
// call site is preceded by an explicit guard for this condition.
|
|
831
623
|
// istanbul ignore next
|
|
832
|
-
|
|
833
624
|
case _mutations.MutationTypes.SET_MULTIPLE_GLOBAL_CONFIG_PATHS:
|
|
834
625
|
{
|
|
835
626
|
throw (0, _error_utils.spawnError)('attempting to generate model updates for SET_MULTIPLE_GLOBAL_CONFIG_PATH');
|
|
836
627
|
}
|
|
837
|
-
|
|
838
628
|
case _mutations.MutationTypes.CREATE_SINGLE_FIELD:
|
|
839
629
|
case _mutations.MutationTypes.UPDATE_SINGLE_FIELD_CONFIG:
|
|
840
630
|
case _mutations.MutationTypes.UPDATE_SINGLE_FIELD_DESCRIPTION:
|
|
@@ -845,17 +635,14 @@ function () {
|
|
|
845
635
|
// No optimistic updates for field, view metadata, or table mutations.
|
|
846
636
|
return [];
|
|
847
637
|
}
|
|
638
|
+
|
|
848
639
|
// The following branch is unreachable because this method's only
|
|
849
640
|
// call site is preceded by an explicit guard for this condition.
|
|
850
641
|
// istanbul ignore next
|
|
851
|
-
|
|
852
642
|
default:
|
|
853
643
|
throw (0, _error_utils.spawnUnknownSwitchCaseError)('mutation type', mutation, 'type');
|
|
854
644
|
}
|
|
855
645
|
}
|
|
856
646
|
}]);
|
|
857
|
-
return Mutations;
|
|
858
647
|
}();
|
|
859
|
-
|
|
860
|
-
var _default = Mutations;
|
|
861
|
-
exports.default = _default;
|
|
648
|
+
var _default = exports.default = Mutations;
|