@airtable/blocks 0.0.0-experimental-f52bc4e5e-20250709 → 0.0.0-experimental-75d011284-20250904
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/dist/cjs/base/assert_run_context.js +12 -0
- package/dist/cjs/base/index.js +30 -30
- package/dist/cjs/base/models/abstract_model_with_async_data.js +154 -237
- package/dist/cjs/base/models/base.js +188 -267
- package/dist/cjs/base/models/create_aggregators.js +29 -46
- package/dist/cjs/base/models/cursor.js +206 -294
- package/dist/cjs/base/models/field.js +307 -395
- package/dist/cjs/base/models/grouped_record_query_result.js +219 -338
- package/dist/cjs/base/models/linked_records_query_result.js +450 -625
- package/dist/cjs/base/models/models.js +19 -22
- package/dist/cjs/base/models/mutations.js +267 -293
- package/dist/cjs/base/models/object_pool.js +117 -156
- package/dist/cjs/base/models/record.js +191 -256
- package/dist/cjs/base/models/record_coloring.js +6 -6
- package/dist/cjs/base/models/record_query_result.js +351 -435
- package/dist/cjs/base/models/record_store.js +403 -753
- package/dist/cjs/base/models/session.js +125 -153
- package/dist/cjs/base/models/table.js +457 -605
- package/dist/cjs/base/models/table_or_view_query_result.js +656 -920
- package/dist/cjs/base/models/view.js +284 -389
- package/dist/cjs/base/models/view_data_store.js +218 -356
- package/dist/cjs/base/models/view_metadata_query_result.js +109 -157
- package/dist/cjs/base/perform_record_action.js +89 -131
- package/dist/cjs/base/sdk.js +129 -184
- package/dist/cjs/base/settings_button.js +54 -74
- package/dist/cjs/base/types/airtable_interface.js +1 -1
- package/dist/cjs/base/types/mutations.js +5 -11
- package/dist/cjs/base/types/undo_redo.js +1 -1
- package/dist/cjs/base/types/view.js +1 -1
- package/dist/cjs/base/ui/base_provider.js +6 -8
- package/dist/cjs/base/ui/baymax_utils.js +436 -108
- package/dist/cjs/base/ui/block_wrapper.js +81 -106
- package/dist/cjs/base/ui/box.js +34 -60
- package/dist/cjs/base/ui/button.js +44 -74
- package/dist/cjs/base/ui/cell_renderer.js +132 -189
- package/dist/cjs/base/ui/choice_token.js +25 -42
- package/dist/cjs/base/ui/collaborator_token.js +31 -53
- package/dist/cjs/base/ui/color_palette.js +130 -173
- package/dist/cjs/base/ui/color_palette_synced.js +41 -70
- package/dist/cjs/base/ui/confirmation_dialog.js +70 -120
- package/dist/cjs/base/ui/control_sizes.js +24 -22
- package/dist/cjs/base/ui/create_detect_element_resize.js +6 -10
- package/dist/cjs/base/ui/css_helpers.js +1 -1
- package/dist/cjs/base/ui/dialog.js +57 -98
- package/dist/cjs/base/ui/dialog_close_button.js +52 -98
- package/dist/cjs/base/ui/expand_record.js +1 -2
- package/dist/cjs/base/ui/expand_record_list.js +3 -4
- package/dist/cjs/base/ui/expand_record_picker_async.js +28 -57
- package/dist/cjs/base/ui/field_icon.js +15 -33
- package/dist/cjs/base/ui/field_picker.js +25 -70
- package/dist/cjs/base/ui/field_picker_synced.js +18 -40
- package/dist/cjs/base/ui/form_field.js +27 -55
- package/dist/cjs/base/ui/geometry/geometry.js +5 -5
- package/dist/cjs/base/ui/geometry/point.js +10 -12
- package/dist/cjs/base/ui/geometry/rect.js +36 -52
- package/dist/cjs/base/ui/geometry/size.js +10 -12
- package/dist/cjs/base/ui/global_alert.js +31 -52
- package/dist/cjs/base/ui/heading.js +45 -94
- package/dist/cjs/base/ui/icon.js +39 -59
- package/dist/cjs/base/ui/icon_config.js +6 -12
- package/dist/cjs/base/ui/initialize_block.js +16 -35
- package/dist/cjs/base/ui/input.js +62 -101
- package/dist/cjs/base/ui/input_synced.js +17 -40
- package/dist/cjs/base/ui/key_codes.js +2 -3
- package/dist/cjs/base/ui/label.js +30 -55
- package/dist/cjs/base/ui/link.js +54 -87
- package/dist/cjs/base/ui/loader.js +15 -36
- package/dist/cjs/base/ui/modal.js +88 -127
- package/dist/cjs/base/ui/model_picker_select.js +18 -44
- package/dist/cjs/base/ui/popover.js +236 -328
- package/dist/cjs/base/ui/progress_bar.js +34 -47
- package/dist/cjs/base/ui/record_card.js +389 -478
- package/dist/cjs/base/ui/record_card_list.js +150 -224
- package/dist/cjs/base/ui/select.js +60 -116
- package/dist/cjs/base/ui/select_and_select_buttons_helpers.js +15 -39
- package/dist/cjs/base/ui/select_buttons.js +50 -83
- package/dist/cjs/base/ui/select_buttons_synced.js +17 -39
- package/dist/cjs/base/ui/select_synced.js +17 -39
- package/dist/cjs/base/ui/switch.js +42 -71
- package/dist/cjs/base/ui/switch_synced.js +16 -38
- package/dist/cjs/base/ui/synced.js +27 -48
- package/dist/cjs/base/ui/system/all_styles_set.js +4 -12
- package/dist/cjs/base/ui/system/appearance/appearance_set.js +10 -13
- package/dist/cjs/base/ui/system/appearance/background_color.js +3 -6
- package/dist/cjs/base/ui/system/appearance/border.js +3 -6
- package/dist/cjs/base/ui/system/appearance/border_radius.js +3 -6
- package/dist/cjs/base/ui/system/appearance/box_shadow.js +3 -6
- package/dist/cjs/base/ui/system/appearance/opacity.js +3 -6
- package/dist/cjs/base/ui/system/dimensions/dimensions_set.js +11 -13
- package/dist/cjs/base/ui/system/dimensions/height.js +3 -6
- package/dist/cjs/base/ui/system/dimensions/max_height.js +3 -6
- package/dist/cjs/base/ui/system/dimensions/max_width.js +3 -6
- package/dist/cjs/base/ui/system/dimensions/min_height.js +3 -6
- package/dist/cjs/base/ui/system/dimensions/min_width.js +3 -6
- package/dist/cjs/base/ui/system/dimensions/width.js +3 -6
- package/dist/cjs/base/ui/system/display.js +3 -6
- package/dist/cjs/base/ui/system/flex_container/align_content.js +3 -6
- package/dist/cjs/base/ui/system/flex_container/align_items.js +3 -6
- package/dist/cjs/base/ui/system/flex_container/flex_container_set.js +11 -13
- package/dist/cjs/base/ui/system/flex_container/flex_direction.js +3 -6
- package/dist/cjs/base/ui/system/flex_container/flex_wrap.js +3 -6
- package/dist/cjs/base/ui/system/flex_container/justify_content.js +3 -6
- package/dist/cjs/base/ui/system/flex_container/justify_items.js +3 -6
- package/dist/cjs/base/ui/system/flex_item/align_self.js +3 -6
- package/dist/cjs/base/ui/system/flex_item/flex.js +3 -6
- package/dist/cjs/base/ui/system/flex_item/flex_basis.js +3 -6
- package/dist/cjs/base/ui/system/flex_item/flex_grow.js +3 -6
- package/dist/cjs/base/ui/system/flex_item/flex_item_set.js +12 -13
- package/dist/cjs/base/ui/system/flex_item/flex_shrink.js +3 -6
- package/dist/cjs/base/ui/system/flex_item/justify_self.js +3 -6
- package/dist/cjs/base/ui/system/flex_item/order.js +3 -6
- package/dist/cjs/base/ui/system/index.js +104 -416
- package/dist/cjs/base/ui/system/overflow.js +3 -6
- package/dist/cjs/base/ui/system/position/bottom.js +4 -6
- package/dist/cjs/base/ui/system/position/left.js +4 -6
- package/dist/cjs/base/ui/system/position/position.js +3 -6
- package/dist/cjs/base/ui/system/position/position_set.js +11 -13
- package/dist/cjs/base/ui/system/position/right.js +4 -6
- package/dist/cjs/base/ui/system/position/top.js +4 -6
- package/dist/cjs/base/ui/system/position/z_index.js +3 -6
- package/dist/cjs/base/ui/system/spacing/margin.js +4 -6
- package/dist/cjs/base/ui/system/spacing/padding.js +4 -6
- package/dist/cjs/base/ui/system/spacing/spacing_set.js +7 -13
- package/dist/cjs/base/ui/system/typography/font_family.js +3 -6
- package/dist/cjs/base/ui/system/typography/font_size.js +3 -6
- package/dist/cjs/base/ui/system/typography/font_style.js +3 -6
- package/dist/cjs/base/ui/system/typography/font_weight.js +3 -6
- package/dist/cjs/base/ui/system/typography/letter_spacing.js +3 -6
- package/dist/cjs/base/ui/system/typography/line_height.js +3 -6
- package/dist/cjs/base/ui/system/typography/text_align.js +3 -6
- package/dist/cjs/base/ui/system/typography/text_color.js +3 -6
- package/dist/cjs/base/ui/system/typography/text_decoration.js +3 -6
- package/dist/cjs/base/ui/system/typography/text_transform.js +3 -6
- package/dist/cjs/base/ui/system/typography/typography_set.js +15 -13
- package/dist/cjs/base/ui/system/utils/ensure_numbers_are_within_scale.js +3 -4
- package/dist/cjs/base/ui/system/utils/get_style_props_for_responsive_prop.js +47 -87
- package/dist/cjs/base/ui/table_picker.js +18 -42
- package/dist/cjs/base/ui/table_picker_synced.js +17 -39
- package/dist/cjs/base/ui/text.js +40 -73
- package/dist/cjs/base/ui/text_button.js +51 -83
- package/dist/cjs/base/ui/theme/default_theme/button_variants.js +3 -3
- package/dist/cjs/base/ui/theme/default_theme/control_sizes.js +51 -45
- package/dist/cjs/base/ui/theme/default_theme/heading_styles.js +1 -1
- package/dist/cjs/base/ui/theme/default_theme/index.js +9 -15
- package/dist/cjs/base/ui/theme/default_theme/input_variants.js +3 -3
- package/dist/cjs/base/ui/theme/default_theme/link_variants.js +3 -3
- package/dist/cjs/base/ui/theme/default_theme/select_buttons_variants.js +4 -4
- package/dist/cjs/base/ui/theme/default_theme/select_variants.js +8 -17
- package/dist/cjs/base/ui/theme/default_theme/switch_variants.js +23 -29
- package/dist/cjs/base/ui/theme/default_theme/text_button_variants.js +5 -5
- package/dist/cjs/base/ui/theme/default_theme/text_styles.js +1 -1
- package/dist/cjs/base/ui/theme/default_theme/tokens.js +14 -14
- package/dist/cjs/base/ui/theme/theme_context.js +2 -2
- package/dist/cjs/base/ui/theme/use_theme.js +2 -2
- package/dist/cjs/base/ui/tooltip.js +134 -174
- package/dist/cjs/base/ui/types/aria_props.js +1 -23
- package/dist/cjs/base/ui/types/data_attributes_prop.js +1 -18
- package/dist/cjs/base/ui/types/tooltip_anchor_props.js +1 -17
- package/dist/cjs/base/ui/ui.js +48 -49
- package/dist/cjs/base/ui/unstable_standalone_ui.js +27 -27
- package/dist/cjs/base/ui/use_base.js +1 -1
- package/dist/cjs/base/ui/use_cursor.js +5 -4
- package/dist/cjs/base/ui/use_form_field.js +1 -1
- package/dist/cjs/base/ui/use_loadable.js +25 -91
- package/dist/cjs/base/ui/use_record_action_data.js +4 -3
- package/dist/cjs/base/ui/use_records.js +9 -13
- package/dist/cjs/base/ui/use_session.js +1 -1
- package/dist/cjs/base/ui/use_settings_button.js +4 -3
- package/dist/cjs/base/ui/use_styled_system.js +7 -14
- package/dist/cjs/base/ui/use_text_color_for_background_color.js +4 -3
- package/dist/cjs/base/ui/use_view_metadata.js +4 -4
- package/dist/cjs/base/ui/use_viewport.js +2 -2
- package/dist/cjs/base/ui/view_picker.js +26 -70
- package/dist/cjs/base/ui/view_picker_synced.js +18 -40
- package/dist/cjs/base/ui/viewport_constraint.js +67 -114
- package/dist/cjs/base/ui/with_styled_system.js +25 -61
- package/dist/cjs/base/undo_redo.js +21 -32
- package/dist/cjs/base/unstable_testing_utils.js +27 -27
- package/dist/cjs/base/viewport.js +268 -312
- package/dist/cjs/injected/airtable_interface.js +4 -4
- package/dist/cjs/interface/assert_run_context.js +12 -0
- package/dist/cjs/interface/index.js +4 -18
- package/dist/cjs/interface/models/base.js +15 -34
- package/dist/cjs/interface/models/field.js +5 -19
- package/dist/cjs/interface/models/models.js +8 -7
- package/dist/cjs/interface/models/mutations.js +50 -66
- package/dist/cjs/interface/models/record.js +29 -49
- package/dist/cjs/interface/models/record_store.js +25 -57
- package/dist/cjs/interface/models/session.js +2 -16
- package/dist/cjs/interface/models/table.js +66 -95
- package/dist/cjs/interface/sdk.js +61 -87
- package/dist/cjs/interface/types/airtable_interface.js +2 -2
- package/dist/cjs/interface/types/mutations.js +3 -10
- package/dist/cjs/interface/ui/block_wrapper.js +56 -48
- package/dist/cjs/interface/ui/initialize_block.js +13 -28
- package/dist/cjs/interface/ui/ui.js +20 -19
- package/dist/cjs/interface/ui/use_base.js +1 -1
- package/dist/cjs/interface/ui/use_custom_properties.js +19 -35
- package/dist/cjs/interface/ui/use_records.js +6 -5
- package/dist/cjs/interface/ui/use_run_info.js +2 -2
- package/dist/cjs/interface/ui/use_session.js +1 -1
- package/dist/cjs/shared/color_utils.js +9 -16
- package/dist/cjs/shared/colors.js +2 -2
- package/dist/cjs/shared/error_utils.js +9 -11
- package/dist/cjs/shared/event_tracker.js +3 -3
- package/dist/cjs/shared/global_config.js +337 -449
- package/dist/cjs/shared/models/abstract_model.js +72 -97
- package/dist/cjs/shared/models/base_core.js +394 -514
- package/dist/cjs/shared/models/field_core.js +236 -279
- package/dist/cjs/shared/models/mutations_core.js +283 -379
- package/dist/cjs/shared/models/record_core.js +174 -231
- package/dist/cjs/shared/models/record_store_core.js +119 -172
- package/dist/cjs/shared/models/session_core.js +116 -170
- package/dist/cjs/shared/models/table_core.js +1258 -1501
- package/dist/cjs/shared/private_utils.js +54 -124
- package/dist/cjs/shared/sdk_core.js +68 -70
- package/dist/cjs/shared/types/field_core.js +1 -1
- package/dist/cjs/shared/types/mutation_constants.js +4 -4
- package/dist/cjs/shared/types/mutations_core.js +1 -1
- package/dist/cjs/shared/types/permission_levels.js +1 -1
- package/dist/cjs/shared/ui/global_config_synced_component_helpers.js +9 -9
- package/dist/cjs/shared/ui/loader.js +14 -35
- package/dist/cjs/shared/ui/remote_utils.js +5 -7
- package/dist/cjs/shared/ui/sdk_context.js +4 -8
- package/dist/cjs/shared/ui/use_array_identity.js +2 -2
- package/dist/cjs/shared/ui/use_base.js +6 -5
- package/dist/cjs/shared/ui/use_color_scheme.js +3 -8
- package/dist/cjs/shared/ui/use_global_config.js +5 -4
- package/dist/cjs/shared/ui/use_session.js +6 -5
- package/dist/cjs/shared/ui/use_synced.js +7 -5
- package/dist/cjs/shared/ui/use_watchable.js +13 -42
- package/dist/cjs/shared/ui/with_hooks.js +6 -13
- package/dist/cjs/shared/unstable_private_utils.js +4 -6
- package/dist/cjs/shared/warning.js +5 -5
- package/dist/cjs/shared/watchable.js +110 -176
- package/dist/cjs/stats/block_stats.js +62 -85
- package/dist/cjs/testing/base/abstract_mock_airtable_interface.js +208 -0
- package/dist/cjs/testing/interface/abstract_mock_airtable_interface.js +124 -0
- package/dist/types/src/base/assert_run_context.d.ts +2 -0
- package/dist/types/src/base/assert_run_context.d.ts.map +1 -0
- package/dist/types/src/base/index.d.ts +1 -0
- package/dist/types/src/base/index.d.ts.map +1 -1
- package/dist/types/src/base/models/models.d.ts +1 -0
- package/dist/types/src/base/models/models.d.ts.map +1 -1
- package/dist/types/src/base/models/mutations.d.ts.map +1 -1
- package/dist/types/src/base/sdk.d.ts.map +1 -1
- package/dist/types/src/base/ui/block_wrapper.d.ts +1 -1
- package/dist/types/src/base/ui/box.d.ts.map +1 -1
- package/dist/types/src/base/ui/button.d.ts +0 -5
- package/dist/types/src/base/ui/button.d.ts.map +1 -1
- package/dist/types/src/base/ui/cell_renderer.d.ts +1 -22
- package/dist/types/src/base/ui/cell_renderer.d.ts.map +1 -1
- package/dist/types/src/base/ui/choice_token.d.ts +1 -21
- package/dist/types/src/base/ui/choice_token.d.ts.map +1 -1
- package/dist/types/src/base/ui/collaborator_token.d.ts +0 -20
- package/dist/types/src/base/ui/collaborator_token.d.ts.map +1 -1
- package/dist/types/src/base/ui/color_palette.d.ts +1 -32
- package/dist/types/src/base/ui/color_palette.d.ts.map +1 -1
- package/dist/types/src/base/ui/color_palette_synced.d.ts +0 -14
- package/dist/types/src/base/ui/color_palette_synced.d.ts.map +1 -1
- package/dist/types/src/base/ui/confirmation_dialog.d.ts +0 -17
- package/dist/types/src/base/ui/confirmation_dialog.d.ts.map +1 -1
- package/dist/types/src/base/ui/control_sizes.d.ts +0 -1
- package/dist/types/src/base/ui/control_sizes.d.ts.map +1 -1
- package/dist/types/src/base/ui/dialog.d.ts +1 -23
- package/dist/types/src/base/ui/dialog.d.ts.map +1 -1
- package/dist/types/src/base/ui/dialog_close_button.d.ts +2 -24
- package/dist/types/src/base/ui/dialog_close_button.d.ts.map +1 -1
- package/dist/types/src/base/ui/field_icon.d.ts +1 -17
- package/dist/types/src/base/ui/field_icon.d.ts.map +1 -1
- package/dist/types/src/base/ui/field_picker.d.ts +0 -23
- package/dist/types/src/base/ui/field_picker.d.ts.map +1 -1
- package/dist/types/src/base/ui/field_picker_synced.d.ts.map +1 -1
- package/dist/types/src/base/ui/form_field.d.ts +0 -4
- package/dist/types/src/base/ui/form_field.d.ts.map +1 -1
- package/dist/types/src/base/ui/heading.d.ts +1 -1
- package/dist/types/src/base/ui/heading.d.ts.map +1 -1
- package/dist/types/src/base/ui/icon.d.ts +0 -16
- package/dist/types/src/base/ui/icon.d.ts.map +1 -1
- package/dist/types/src/base/ui/icon_config.d.ts +50 -51
- package/dist/types/src/base/ui/icon_config.d.ts.map +1 -1
- package/dist/types/src/base/ui/initialize_block.d.ts.map +1 -1
- package/dist/types/src/base/ui/input.d.ts +12 -46
- package/dist/types/src/base/ui/input.d.ts.map +1 -1
- package/dist/types/src/base/ui/input_synced.d.ts.map +1 -1
- package/dist/types/src/base/ui/label.d.ts.map +1 -1
- package/dist/types/src/base/ui/link.d.ts +1 -5
- package/dist/types/src/base/ui/link.d.ts.map +1 -1
- package/dist/types/src/base/ui/loader.d.ts +3 -20
- package/dist/types/src/base/ui/loader.d.ts.map +1 -1
- package/dist/types/src/base/ui/modal.d.ts +1 -14
- package/dist/types/src/base/ui/modal.d.ts.map +1 -1
- package/dist/types/src/base/ui/model_picker_select.d.ts.map +1 -1
- package/dist/types/src/base/ui/popover.d.ts +1 -17
- package/dist/types/src/base/ui/popover.d.ts.map +1 -1
- package/dist/types/src/base/ui/progress_bar.d.ts +1 -24
- package/dist/types/src/base/ui/progress_bar.d.ts.map +1 -1
- package/dist/types/src/base/ui/record_card.d.ts +1 -23
- package/dist/types/src/base/ui/record_card.d.ts.map +1 -1
- package/dist/types/src/base/ui/record_card_list.d.ts +1 -18
- package/dist/types/src/base/ui/record_card_list.d.ts.map +1 -1
- package/dist/types/src/base/ui/select.d.ts +0 -44
- package/dist/types/src/base/ui/select.d.ts.map +1 -1
- package/dist/types/src/base/ui/select_and_select_buttons_helpers.d.ts +0 -2
- package/dist/types/src/base/ui/select_and_select_buttons_helpers.d.ts.map +1 -1
- package/dist/types/src/base/ui/select_buttons.d.ts +0 -22
- package/dist/types/src/base/ui/select_buttons.d.ts.map +1 -1
- package/dist/types/src/base/ui/select_buttons_synced.d.ts.map +1 -1
- package/dist/types/src/base/ui/select_synced.d.ts.map +1 -1
- package/dist/types/src/base/ui/switch.d.ts +0 -22
- package/dist/types/src/base/ui/switch.d.ts.map +1 -1
- package/dist/types/src/base/ui/switch_synced.d.ts.map +1 -1
- package/dist/types/src/base/ui/synced.d.ts +2 -8
- package/dist/types/src/base/ui/synced.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/all_styles_set.d.ts +0 -3
- package/dist/types/src/base/ui/system/all_styles_set.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/appearance/appearance_set.d.ts +0 -1
- package/dist/types/src/base/ui/system/appearance/appearance_set.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/appearance/background_color.d.ts +0 -1
- package/dist/types/src/base/ui/system/appearance/background_color.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/appearance/border.d.ts +0 -1
- package/dist/types/src/base/ui/system/appearance/border.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/appearance/border_radius.d.ts +0 -1
- package/dist/types/src/base/ui/system/appearance/border_radius.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/appearance/box_shadow.d.ts +0 -1
- package/dist/types/src/base/ui/system/appearance/box_shadow.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/appearance/opacity.d.ts +0 -1
- package/dist/types/src/base/ui/system/appearance/opacity.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/dimensions/dimensions_set.d.ts +0 -1
- package/dist/types/src/base/ui/system/dimensions/dimensions_set.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/dimensions/height.d.ts +0 -1
- package/dist/types/src/base/ui/system/dimensions/height.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/dimensions/max_height.d.ts +0 -1
- package/dist/types/src/base/ui/system/dimensions/max_height.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/dimensions/max_width.d.ts +0 -1
- package/dist/types/src/base/ui/system/dimensions/max_width.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/dimensions/min_height.d.ts +0 -1
- package/dist/types/src/base/ui/system/dimensions/min_height.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/dimensions/min_width.d.ts +0 -1
- package/dist/types/src/base/ui/system/dimensions/min_width.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/dimensions/width.d.ts +0 -1
- package/dist/types/src/base/ui/system/dimensions/width.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/display.d.ts +0 -1
- package/dist/types/src/base/ui/system/display.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_container/align_content.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_container/align_content.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_container/align_items.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_container/align_items.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_container/flex_container_set.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_container/flex_container_set.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_container/flex_direction.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_container/flex_direction.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_container/flex_wrap.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_container/flex_wrap.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_container/justify_content.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_container/justify_content.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_container/justify_items.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_container/justify_items.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_item/align_self.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_item/align_self.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_item/flex.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_item/flex.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_item/flex_basis.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_item/flex_basis.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_item/flex_grow.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_item/flex_grow.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_item/flex_item_set.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_item/flex_item_set.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_item/flex_shrink.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_item/flex_shrink.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_item/justify_self.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_item/justify_self.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_item/order.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_item/order.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/index.d.ts +52 -52
- package/dist/types/src/base/ui/system/index.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/overflow.d.ts +0 -1
- package/dist/types/src/base/ui/system/overflow.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/position/bottom.d.ts +0 -1
- package/dist/types/src/base/ui/system/position/bottom.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/position/left.d.ts +0 -1
- package/dist/types/src/base/ui/system/position/left.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/position/position.d.ts +0 -1
- package/dist/types/src/base/ui/system/position/position.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/position/position_set.d.ts +0 -1
- package/dist/types/src/base/ui/system/position/position_set.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/position/right.d.ts +0 -1
- package/dist/types/src/base/ui/system/position/right.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/position/top.d.ts +0 -1
- package/dist/types/src/base/ui/system/position/top.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/position/z_index.d.ts +0 -1
- package/dist/types/src/base/ui/system/position/z_index.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/spacing/margin.d.ts +0 -1
- package/dist/types/src/base/ui/system/spacing/margin.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/spacing/padding.d.ts +0 -1
- package/dist/types/src/base/ui/system/spacing/padding.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/spacing/spacing_set.d.ts +0 -1
- package/dist/types/src/base/ui/system/spacing/spacing_set.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/font_family.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/font_family.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/font_size.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/font_size.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/font_style.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/font_style.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/font_weight.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/font_weight.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/letter_spacing.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/letter_spacing.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/line_height.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/line_height.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/text_align.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/text_align.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/text_color.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/text_color.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/text_decoration.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/text_decoration.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/text_transform.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/text_transform.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/typography_set.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/typography_set.d.ts.map +1 -1
- package/dist/types/src/base/ui/table_picker.d.ts +0 -21
- package/dist/types/src/base/ui/table_picker.d.ts.map +1 -1
- package/dist/types/src/base/ui/table_picker_synced.d.ts.map +1 -1
- package/dist/types/src/base/ui/text.d.ts +0 -3
- package/dist/types/src/base/ui/text.d.ts.map +1 -1
- package/dist/types/src/base/ui/text_button.d.ts +1 -5
- package/dist/types/src/base/ui/text_button.d.ts.map +1 -1
- package/dist/types/src/base/ui/theme/default_theme/index.d.ts +1 -1
- package/dist/types/src/base/ui/theme/theme_context.d.ts +1 -1
- package/dist/types/src/base/ui/theme/use_theme.d.ts +1 -1
- package/dist/types/src/base/ui/tooltip.d.ts +0 -16
- package/dist/types/src/base/ui/tooltip.d.ts.map +1 -1
- package/dist/types/src/base/ui/types/aria_props.d.ts.map +1 -1
- package/dist/types/src/base/ui/types/data_attributes_prop.d.ts +0 -4
- package/dist/types/src/base/ui/types/data_attributes_prop.d.ts.map +1 -1
- package/dist/types/src/base/ui/types/tooltip_anchor_props.d.ts +0 -7
- package/dist/types/src/base/ui/types/tooltip_anchor_props.d.ts.map +1 -1
- package/dist/types/src/base/ui/ui.d.ts +1 -0
- package/dist/types/src/base/ui/ui.d.ts.map +1 -1
- package/dist/types/src/base/ui/view_picker.d.ts +0 -23
- package/dist/types/src/base/ui/view_picker.d.ts.map +1 -1
- package/dist/types/src/base/ui/view_picker_synced.d.ts.map +1 -1
- package/dist/types/src/base/ui/viewport_constraint.d.ts +1 -14
- package/dist/types/src/base/ui/viewport_constraint.d.ts.map +1 -1
- package/dist/types/src/base/unstable_testing_utils.d.ts +1 -1
- package/dist/types/src/base/unstable_testing_utils.d.ts.map +1 -1
- package/dist/types/src/interface/assert_run_context.d.ts +2 -0
- package/dist/types/src/interface/assert_run_context.d.ts.map +1 -0
- package/dist/types/src/interface/index.d.ts +1 -6
- package/dist/types/src/interface/index.d.ts.map +1 -1
- package/dist/types/src/interface/models/models.d.ts +1 -0
- package/dist/types/src/interface/models/models.d.ts.map +1 -1
- package/dist/types/src/interface/models/mutations.d.ts.map +1 -1
- package/dist/types/src/interface/ui/initialize_block.d.ts.map +1 -1
- package/dist/types/src/interface/ui/ui.d.ts +1 -0
- package/dist/types/src/interface/ui/ui.d.ts.map +1 -1
- package/dist/types/src/interface/ui/use_custom_properties.d.ts +1 -1
- package/dist/types/src/shared/models/mutations_core.d.ts.map +1 -1
- package/dist/types/src/shared/private_utils.d.ts +0 -9
- package/dist/types/src/shared/private_utils.d.ts.map +1 -1
- package/dist/types/src/shared/ui/global_config_synced_component_helpers.d.ts +0 -2
- package/dist/types/src/shared/ui/global_config_synced_component_helpers.d.ts.map +1 -1
- package/dist/types/src/shared/ui/loader.d.ts.map +1 -1
- package/dist/types/src/shared/ui/with_hooks.d.ts +2 -2
- package/dist/types/src/shared/ui/with_hooks.d.ts.map +1 -1
- package/dist/types/src/testing/{abstract_mock_airtable_interface.d.ts → base/abstract_mock_airtable_interface.d.ts} +13 -13
- package/dist/types/src/testing/base/abstract_mock_airtable_interface.d.ts.map +1 -0
- package/dist/types/src/testing/interface/abstract_mock_airtable_interface.d.ts +51 -0
- package/dist/types/src/testing/interface/abstract_mock_airtable_interface.d.ts.map +1 -0
- package/package.json +13 -13
- package/dist/cjs/base/ui/system/utils/create_responsive_prop_type.js +0 -19
- package/dist/cjs/base/ui/system/utils/create_style_prop_types.js +0 -24
- package/dist/cjs/base/ui/system/utils/enum_prop_type_utils.js +0 -35
- package/dist/cjs/testing/abstract_mock_airtable_interface.js +0 -277
- package/dist/types/src/base/ui/system/utils/create_responsive_prop_type.d.ts +0 -2
- package/dist/types/src/base/ui/system/utils/create_responsive_prop_type.d.ts.map +0 -1
- package/dist/types/src/base/ui/system/utils/create_style_prop_types.d.ts +0 -4
- package/dist/types/src/base/ui/system/utils/create_style_prop_types.d.ts.map +0 -1
- package/dist/types/src/base/ui/system/utils/enum_prop_type_utils.d.ts +0 -21
- package/dist/types/src/base/ui/system/utils/enum_prop_type_utils.d.ts.map +0 -1
- package/dist/types/src/testing/abstract_mock_airtable_interface.d.ts.map +0 -1
|
@@ -1,40 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.symbol.js");
|
|
4
|
-
require("core-js/modules/es.symbol.description.js");
|
|
5
|
-
require("core-js/modules/es.array.from.js");
|
|
6
|
-
require("core-js/modules/es.array.iterator.js");
|
|
7
|
-
require("core-js/modules/es.array.slice.js");
|
|
8
|
-
require("core-js/modules/es.object.to-string.js");
|
|
9
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
10
|
-
require("core-js/modules/es.regexp.to-string.js");
|
|
11
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
12
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
13
3
|
Object.defineProperty(exports, "__esModule", {
|
|
14
4
|
value: true
|
|
15
5
|
});
|
|
16
6
|
exports.default = void 0;
|
|
17
|
-
require("core-js/modules/es.array.map.js");
|
|
18
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
19
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
20
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
21
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
22
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
23
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
24
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
25
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
26
7
|
var _watchable = _interopRequireDefault(require("./watchable"));
|
|
27
8
|
var _error_utils = require("./error_utils");
|
|
28
9
|
var _mutations_core = require("./types/mutations_core");
|
|
29
10
|
var _private_utils = require("./private_utils");
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
34
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /** @module @airtable/blocks: globalConfig */ /** */
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
/** @module @airtable/blocks: globalConfig */ /** */
|
|
13
|
+
|
|
35
14
|
/**
|
|
36
15
|
* You can watch any top-level key in global config. Use '*' to watch every change.
|
|
37
16
|
*/
|
|
17
|
+
|
|
38
18
|
// NOTE: GlobalConfig is essentially a wrapper around a generic key-value store.
|
|
39
19
|
// It's called GlobalConfig in order to convey two main points about its intended
|
|
40
20
|
// usage:
|
|
@@ -60,452 +40,360 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
60
40
|
*
|
|
61
41
|
* @docsPath models/GlobalConfig
|
|
62
42
|
*/
|
|
63
|
-
|
|
43
|
+
class GlobalConfig extends _watchable.default {
|
|
44
|
+
/** @internal */
|
|
45
|
+
static _className = 'GlobalConfig';
|
|
46
|
+
/** @internal */
|
|
47
|
+
static _isWatchableKey(key) {
|
|
48
|
+
// The user can store any arbitrary key in the global config, so there's
|
|
49
|
+
// not much we can do here to check if a key is valid.
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
/** @internal */
|
|
53
|
+
|
|
54
|
+
/** @internal */
|
|
55
|
+
|
|
56
|
+
/** @internal */
|
|
57
|
+
|
|
64
58
|
/**
|
|
65
59
|
* @internal
|
|
66
60
|
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
(0, _defineProperty2.default)(_this, "_sdk", void 0);
|
|
73
|
-
/** @internal */
|
|
74
|
-
(0, _defineProperty2.default)(_this, "_kvStore", void 0);
|
|
75
|
-
/** @internal */
|
|
76
|
-
(0, _defineProperty2.default)(_this, "_airtableInterface", void 0);
|
|
77
|
-
_this._kvStore = initialKvValuesByKey;
|
|
78
|
-
_this._sdk = sdk;
|
|
79
|
-
_this._airtableInterface = sdk.__airtableInterface;
|
|
80
|
-
return _this;
|
|
61
|
+
constructor(initialKvValuesByKey, sdk) {
|
|
62
|
+
super();
|
|
63
|
+
this._kvStore = initialKvValuesByKey;
|
|
64
|
+
this._sdk = sdk;
|
|
65
|
+
this._airtableInterface = sdk.__airtableInterface;
|
|
81
66
|
}
|
|
82
67
|
|
|
83
68
|
/**
|
|
84
69
|
* @internal
|
|
85
70
|
*/
|
|
86
|
-
(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
value: function __getTopLevelKey(key) {
|
|
90
|
-
if (Array.isArray(key)) {
|
|
91
|
-
return key[0];
|
|
92
|
-
}
|
|
93
|
-
return key;
|
|
71
|
+
__getTopLevelKey(key) {
|
|
72
|
+
if (Array.isArray(key)) {
|
|
73
|
+
return key[0];
|
|
94
74
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
return key;
|
|
75
|
+
return key;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
_formatKeyAsPath(key) {
|
|
81
|
+
if (!Array.isArray(key)) {
|
|
82
|
+
return [key];
|
|
105
83
|
}
|
|
84
|
+
return key;
|
|
85
|
+
}
|
|
106
86
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
if (path[0] === '*') {
|
|
118
|
-
return {
|
|
119
|
-
isValid: false,
|
|
120
|
-
reason: "cannot use '*' as a top-level key"
|
|
121
|
-
};
|
|
122
|
-
}
|
|
87
|
+
/**
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
_validatePath(path, store) {
|
|
91
|
+
const validation = this._airtableInterface.globalConfigHelpers.validatePath(path, store);
|
|
92
|
+
if (!validation.isValid) {
|
|
93
|
+
return validation;
|
|
94
|
+
}
|
|
95
|
+
if (path[0] === '*') {
|
|
123
96
|
return {
|
|
124
|
-
isValid:
|
|
97
|
+
isValid: false,
|
|
98
|
+
reason: "cannot use '*' as a top-level key"
|
|
125
99
|
};
|
|
126
100
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
// value is returned as `unknown` from getValueAtOwnPath, but we know it must be a `GlobalConfigValue | void`
|
|
154
|
-
return value;
|
|
101
|
+
return {
|
|
102
|
+
isValid: true
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Get the value at a path. Throws an error if the path is invalid.
|
|
107
|
+
*
|
|
108
|
+
* Returns undefined if no value exists at that path.
|
|
109
|
+
*
|
|
110
|
+
* @param key A string for the top-level key, or an array of strings describing the path to the value.
|
|
111
|
+
* @example
|
|
112
|
+
* ```js
|
|
113
|
+
* import {useGlobalConfig} from '@airtable/blocks/[placeholder-path]/ui';
|
|
114
|
+
*
|
|
115
|
+
* function MyApp() {
|
|
116
|
+
* const globalConfig = useGlobalConfig();
|
|
117
|
+
* const topLevelValue = globalConfig.get('topLevelKey');
|
|
118
|
+
* const nestedValue = globalConfig.get(['topLevelKey', 'nested', 'deeply']);
|
|
119
|
+
* }
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
get(key) {
|
|
123
|
+
const path = this._formatKeyAsPath(key);
|
|
124
|
+
const pathValidationResult = this._validatePath(path, this._kvStore);
|
|
125
|
+
if (!pathValidationResult.isValid) {
|
|
126
|
+
throw (0, _error_utils.spawnError)('Invalid globalConfig path: %s', pathValidationResult.reason);
|
|
155
127
|
}
|
|
128
|
+
const value = (0, _private_utils.getValueAtOwnPath)(this._kvStore, path);
|
|
129
|
+
// value is returned as `unknown` from getValueAtOwnPath, but we know it must be a `GlobalConfigValue | void`
|
|
130
|
+
return value;
|
|
131
|
+
}
|
|
156
132
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Checks whether the current user has permission to set the given global config key.
|
|
135
|
+
*
|
|
136
|
+
* Accepts partial input, in the same format as {@link setAsync}.
|
|
137
|
+
* The more information provided, the more accurate the permissions check will be.
|
|
138
|
+
*
|
|
139
|
+
* Returns `{hasPermission: true}` if the current user can set the specified key,
|
|
140
|
+
* `{hasPermission: false, reasonDisplayString: string}` otherwise. `reasonDisplayString` may
|
|
141
|
+
* be used to display an error message to the user.
|
|
142
|
+
*
|
|
143
|
+
* @param key A string for the top-level key, or an array of strings describing the path to set.
|
|
144
|
+
* @param value The value to set at the specified path. Use `undefined` to delete the value at the given path.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```js
|
|
148
|
+
* // Check if user can update a specific key and value.
|
|
149
|
+
* const setCheckResult =
|
|
150
|
+
* globalConfig.checkPermissionsForSet('favoriteColor', 'purple');
|
|
151
|
+
* if (!setCheckResult.hasPermission) {
|
|
152
|
+
* alert(setCheckResult.reasonDisplayString);
|
|
153
|
+
* }
|
|
154
|
+
*
|
|
155
|
+
* // Check if user can update a specific key without knowing the value
|
|
156
|
+
* const setKeyCheckResult =
|
|
157
|
+
* globalConfig.checkPermissionsForSet('favoriteColor');
|
|
158
|
+
*
|
|
159
|
+
* // Check if user can update globalConfig without knowing key or value
|
|
160
|
+
* const setUnknownKeyCheckResult = globalConfig.checkPermissionsForSet();
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
checkPermissionsForSet(key, value) {
|
|
164
|
+
return this.checkPermissionsForSetPaths([{
|
|
165
|
+
path: key ? this._formatKeyAsPath(key) : undefined,
|
|
166
|
+
value
|
|
167
|
+
}]);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* An alias for `globalConfig.checkPermissionsForSet(key, value).hasPermission`.
|
|
171
|
+
*
|
|
172
|
+
* Checks whether the current user has permission to set the given global config key.
|
|
173
|
+
*
|
|
174
|
+
* Accepts partial input, in the same format as {@link setAsync}.
|
|
175
|
+
* The more information provided, the more accurate the permissions check will be.
|
|
176
|
+
*
|
|
177
|
+
* @param key A string for the top-level key, or an array of strings describing the path to set.
|
|
178
|
+
* @param value The value to set at the specified path. Use `undefined` to delete the value at the given path.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```js
|
|
182
|
+
* // Check if user can update a specific key and value.
|
|
183
|
+
* const canSetFavoriteColorToPurple =
|
|
184
|
+
* globalConfig.hasPermissionToSet('favoriteColor', 'purple');
|
|
185
|
+
* if (!canSetFavoriteColorToPurple) {
|
|
186
|
+
* alert('Not allowed!');
|
|
187
|
+
* }
|
|
188
|
+
*
|
|
189
|
+
* // Check if user can update a specific key without knowing the value
|
|
190
|
+
* const canSetFavoriteColor = globalConfig.hasPermissionToSet('favoriteColor');
|
|
191
|
+
*
|
|
192
|
+
* // Check if user can update globalConfig without knowing key or value
|
|
193
|
+
* const canSetGlobalConfig = globalConfig.hasPermissionToSet();
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
hasPermissionToSet(key, value) {
|
|
197
|
+
return this.checkPermissionsForSet(key, value).hasPermission;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Sets a value at a path. Throws an error if the path or value is invalid.
|
|
201
|
+
*
|
|
202
|
+
* This action is asynchronous: `await` the returned promise if you wish to wait for the
|
|
203
|
+
* update to be persisted to Airtable servers.
|
|
204
|
+
*
|
|
205
|
+
* Updates are applied optimistically locally, so your change will be reflected in
|
|
206
|
+
* {@link GlobalConfig} before the promise resolves.
|
|
207
|
+
*
|
|
208
|
+
* @param key A string for the top-level key, or an array of strings describing the path to set.
|
|
209
|
+
* @param value The value to set at the specified path. Use `undefined` to delete the value at the given path.
|
|
210
|
+
* @example
|
|
211
|
+
* ```js
|
|
212
|
+
* import {useGlobalConfig} from '@airtable/blocks/[placeholder-path]/ui';
|
|
213
|
+
*
|
|
214
|
+
* function MyApp() {
|
|
215
|
+
* const globalConfig = useGlobalConfig();
|
|
216
|
+
* const updateFavoriteColorIfPossible = (color) => {
|
|
217
|
+
* if (globalConfig.hasPermissionToSet('favoriteColor', color)) {
|
|
218
|
+
* globalConfig.setAsync('favoriteColor', color);
|
|
219
|
+
* }
|
|
220
|
+
* // The update is now applied within your extension (eg will be
|
|
221
|
+
* // reflected in globalConfig) but are still being saved to
|
|
222
|
+
* // Airtable servers (e.g. may not be updated for other users yet)
|
|
223
|
+
* }
|
|
224
|
+
*
|
|
225
|
+
* const updateFavoriteColorIfPossibleAsync = async (color) => {
|
|
226
|
+
* if (globalConfig.hasPermissionToSet('favoriteColor', color)) {
|
|
227
|
+
* await globalConfig.setAsync('favoriteColor', color);
|
|
228
|
+
* }
|
|
229
|
+
* // globalConfig updates have been saved to Airtable servers.
|
|
230
|
+
* alert('favoriteColor has been updated');
|
|
231
|
+
* }
|
|
232
|
+
* }
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
async setAsync(key, value) {
|
|
236
|
+
const path = this._formatKeyAsPath(key);
|
|
237
|
+
await this.setPathsAsync([{
|
|
238
|
+
path,
|
|
239
|
+
value
|
|
240
|
+
}]);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Checks whether the current user has permission to perform the specified updates to global config.
|
|
244
|
+
*
|
|
245
|
+
* Accepts partial input, in the same format as {@link setPathsAsync}.
|
|
246
|
+
* The more information provided, the more accurate the permissions check will be.
|
|
247
|
+
*
|
|
248
|
+
* Returns `{hasPermission: true}` if the current user can set the specified key,
|
|
249
|
+
* `{hasPermission: false, reasonDisplayString: string}` otherwise. `reasonDisplayString` may be
|
|
250
|
+
* used to display an error message to the user.
|
|
251
|
+
*
|
|
252
|
+
* @param updates The paths and values to set.
|
|
253
|
+
* @example
|
|
254
|
+
* ```js
|
|
255
|
+
* // Check if user can update a specific keys and values.
|
|
256
|
+
* const setPathsCheckResult = globalConfig.checkPermissionsForSet([
|
|
257
|
+
* {path: ['topLevelKey1', 'nestedKey1'], value: 'foo'},
|
|
258
|
+
* {path: ['topLevelKey2', 'nestedKey2'], value: 'bar'},
|
|
259
|
+
* ]);
|
|
260
|
+
* if (!setPathsCheckResult.hasPermission) {
|
|
261
|
+
* alert(setPathsCheckResult.reasonDisplayString);
|
|
262
|
+
* }
|
|
263
|
+
*
|
|
264
|
+
* // Check if user could potentially set globalConfig values.
|
|
265
|
+
* // Equivalent to globalConfig.checkPermissionsForSet()
|
|
266
|
+
* const setUnknownPathsCheckResult =
|
|
267
|
+
* globalConfig.checkPermissionsForSetPaths();
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
checkPermissionsForSetPaths(updates) {
|
|
271
|
+
return this._sdk.__mutations.checkPermissionsForMutation({
|
|
272
|
+
type: _mutations_core.MutationTypesCore.SET_MULTIPLE_GLOBAL_CONFIG_PATHS,
|
|
273
|
+
updates: updates ? updates.map(_ref => {
|
|
274
|
+
let {
|
|
275
|
+
path,
|
|
276
|
+
value
|
|
277
|
+
} = _ref;
|
|
278
|
+
return {
|
|
279
|
+
path: path || undefined,
|
|
280
|
+
value
|
|
281
|
+
};
|
|
282
|
+
}) : undefined
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* An alias for `globalConfig.checkPermissionsForSetPaths(updates).hasPermission`.
|
|
287
|
+
*
|
|
288
|
+
* Checks whether the current user has permission to perform the specified updates to global
|
|
289
|
+
* config.
|
|
290
|
+
*
|
|
291
|
+
* Accepts partial input, in the same format as {@link setPathsAsync}.
|
|
292
|
+
* The more information provided, the more accurate the permissions check will be.
|
|
293
|
+
*
|
|
294
|
+
* @param updates The paths and values to set.
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```js
|
|
298
|
+
* // Check if user can update a specific keys and values.
|
|
299
|
+
* const canSetPaths = globalConfig.hasPermissionToSetPaths([
|
|
300
|
+
* {path: ['topLevelKey1', 'nestedKey1'], value: 'foo'},
|
|
301
|
+
* {path: ['topLevelKey2', 'nestedKey2'], value: 'bar'},
|
|
302
|
+
* ]);
|
|
303
|
+
* if (!canSetPaths) {
|
|
304
|
+
* alert('not allowed!');
|
|
305
|
+
* }
|
|
306
|
+
*
|
|
307
|
+
* // Check if user could potentially set globalConfig values.
|
|
308
|
+
* // Equivalent to globalConfig.hasPermissionToSet()
|
|
309
|
+
* const canSetAnyPaths = globalConfig.hasPermissionToSetPaths();
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
hasPermissionToSetPaths(updates) {
|
|
313
|
+
return this.checkPermissionsForSetPaths(updates).hasPermission;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Sets multiple values. Throws if any path or value is invalid.
|
|
317
|
+
*
|
|
318
|
+
* This action is asynchronous: `await` the returned promise if you wish to wait for the
|
|
319
|
+
* updates to be persisted to Airtable servers.
|
|
320
|
+
* Updates are applied optimistically locally, so your changes will be reflected in
|
|
321
|
+
* {@link GlobalConfig} before the promise resolves.
|
|
322
|
+
*
|
|
323
|
+
* @param updates The paths and values to set.
|
|
324
|
+
* @example
|
|
325
|
+
* ```js
|
|
326
|
+
* import {useGlobalConfig} from '@airtable/blocks/[placeholder-path]/ui';
|
|
327
|
+
*
|
|
328
|
+
* function MyApp() {
|
|
329
|
+
* const globalConfig = useGlobalConfig();
|
|
330
|
+
* const updates = [
|
|
331
|
+
* {path: ['topLevelKey1', 'nestedKey1'], value: 'foo'},
|
|
332
|
+
* {path: ['topLevelKey2', 'nestedKey2'], value: 'bar'},
|
|
333
|
+
* ];
|
|
334
|
+
*
|
|
335
|
+
* const applyUpdatesIfPossible = () => {
|
|
336
|
+
* if (globalConfig.hasPermissionToSetPaths(updates)) {
|
|
337
|
+
* globalConfig.setPathsAsync(updates);
|
|
338
|
+
* }
|
|
339
|
+
* // The updates are now applied within your extension (eg will be reflected in
|
|
340
|
+
* // globalConfig) but are still being saved to Airtable servers (e.g. they
|
|
341
|
+
* // may not be updated for other users yet)
|
|
342
|
+
* }
|
|
343
|
+
*
|
|
344
|
+
* const applyUpdatesIfPossibleAsync = async () => {
|
|
345
|
+
* if (globalConfig.hasPermissionToSetPaths(updates)) {
|
|
346
|
+
* await globalConfig.setPathsAsync(updates);
|
|
347
|
+
* }
|
|
348
|
+
* // globalConfig updates have been saved to Airtable servers.
|
|
349
|
+
* alert('globalConfig has been updated');
|
|
350
|
+
* }
|
|
351
|
+
* }
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
async setPathsAsync(updates) {
|
|
355
|
+
// Validate the updates. Usually applyMutationAsync performs validations, but globalConfig
|
|
356
|
+
// updates are a special case because it relies on internal globalConfig state to validate.
|
|
357
|
+
// We check here, instead of deeper (e.g. on the liveapp side) so the user
|
|
358
|
+
// gets a more useful error stack trace.
|
|
359
|
+
if (!this.hasPermissionToSetPaths(updates)) {
|
|
360
|
+
throw (0, _error_utils.spawnError)('Your permission level does not allow setting globalConfig values');
|
|
226
361
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
* update to be persisted to Airtable servers.
|
|
232
|
-
*
|
|
233
|
-
* Updates are applied optimistically locally, so your change will be reflected in
|
|
234
|
-
* {@link GlobalConfig} before the promise resolves.
|
|
235
|
-
*
|
|
236
|
-
* @param key A string for the top-level key, or an array of strings describing the path to set.
|
|
237
|
-
* @param value The value to set at the specified path. Use `undefined` to delete the value at the given path.
|
|
238
|
-
* @example
|
|
239
|
-
* ```js
|
|
240
|
-
* import {useGlobalConfig} from '@airtable/blocks/[placeholder-path]/ui';
|
|
241
|
-
*
|
|
242
|
-
* function MyApp() {
|
|
243
|
-
* const globalConfig = useGlobalConfig();
|
|
244
|
-
* const updateFavoriteColorIfPossible = (color) => {
|
|
245
|
-
* if (globalConfig.hasPermissionToSet('favoriteColor', color)) {
|
|
246
|
-
* globalConfig.setAsync('favoriteColor', color);
|
|
247
|
-
* }
|
|
248
|
-
* // The update is now applied within your extension (eg will be
|
|
249
|
-
* // reflected in globalConfig) but are still being saved to
|
|
250
|
-
* // Airtable servers (e.g. may not be updated for other users yet)
|
|
251
|
-
* }
|
|
252
|
-
*
|
|
253
|
-
* const updateFavoriteColorIfPossibleAsync = async (color) => {
|
|
254
|
-
* if (globalConfig.hasPermissionToSet('favoriteColor', color)) {
|
|
255
|
-
* await globalConfig.setAsync('favoriteColor', color);
|
|
256
|
-
* }
|
|
257
|
-
* // globalConfig updates have been saved to Airtable servers.
|
|
258
|
-
* alert('favoriteColor has been updated');
|
|
259
|
-
* }
|
|
260
|
-
* }
|
|
261
|
-
* ```
|
|
262
|
-
*/
|
|
263
|
-
}, {
|
|
264
|
-
key: "setAsync",
|
|
265
|
-
value: (function () {
|
|
266
|
-
var _setAsync = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(key, value) {
|
|
267
|
-
var path;
|
|
268
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
269
|
-
while (1) switch (_context.prev = _context.next) {
|
|
270
|
-
case 0:
|
|
271
|
-
path = this._formatKeyAsPath(key);
|
|
272
|
-
_context.next = 3;
|
|
273
|
-
return this.setPathsAsync([{
|
|
274
|
-
path,
|
|
275
|
-
value
|
|
276
|
-
}]);
|
|
277
|
-
case 3:
|
|
278
|
-
case "end":
|
|
279
|
-
return _context.stop();
|
|
280
|
-
}
|
|
281
|
-
}, _callee, this);
|
|
282
|
-
}));
|
|
283
|
-
function setAsync(_x, _x2) {
|
|
284
|
-
return _setAsync.apply(this, arguments);
|
|
362
|
+
for (const update of updates) {
|
|
363
|
+
const pathValidation = this._validatePath(update.path, this._kvStore);
|
|
364
|
+
if (!pathValidation.isValid) {
|
|
365
|
+
throw (0, _error_utils.spawnError)('Invalid globalConfig path: %s', pathValidation.reason);
|
|
285
366
|
}
|
|
286
|
-
return setAsync;
|
|
287
|
-
}()
|
|
288
|
-
/**
|
|
289
|
-
* Checks whether the current user has permission to perform the specified updates to global config.
|
|
290
|
-
*
|
|
291
|
-
* Accepts partial input, in the same format as {@link setPathsAsync}.
|
|
292
|
-
* The more information provided, the more accurate the permissions check will be.
|
|
293
|
-
*
|
|
294
|
-
* Returns `{hasPermission: true}` if the current user can set the specified key,
|
|
295
|
-
* `{hasPermission: false, reasonDisplayString: string}` otherwise. `reasonDisplayString` may be
|
|
296
|
-
* used to display an error message to the user.
|
|
297
|
-
*
|
|
298
|
-
* @param updates The paths and values to set.
|
|
299
|
-
* @example
|
|
300
|
-
* ```js
|
|
301
|
-
* // Check if user can update a specific keys and values.
|
|
302
|
-
* const setPathsCheckResult = globalConfig.checkPermissionsForSet([
|
|
303
|
-
* {path: ['topLevelKey1', 'nestedKey1'], value: 'foo'},
|
|
304
|
-
* {path: ['topLevelKey2', 'nestedKey2'], value: 'bar'},
|
|
305
|
-
* ]);
|
|
306
|
-
* if (!setPathsCheckResult.hasPermission) {
|
|
307
|
-
* alert(setPathsCheckResult.reasonDisplayString);
|
|
308
|
-
* }
|
|
309
|
-
*
|
|
310
|
-
* // Check if user could potentially set globalConfig values.
|
|
311
|
-
* // Equivalent to globalConfig.checkPermissionsForSet()
|
|
312
|
-
* const setUnknownPathsCheckResult =
|
|
313
|
-
* globalConfig.checkPermissionsForSetPaths();
|
|
314
|
-
* ```
|
|
315
|
-
*/
|
|
316
|
-
)
|
|
317
|
-
}, {
|
|
318
|
-
key: "checkPermissionsForSetPaths",
|
|
319
|
-
value: function checkPermissionsForSetPaths(updates) {
|
|
320
|
-
return this._sdk.__mutations.checkPermissionsForMutation({
|
|
321
|
-
type: _mutations_core.MutationTypesCore.SET_MULTIPLE_GLOBAL_CONFIG_PATHS,
|
|
322
|
-
updates: updates ? updates.map(_ref => {
|
|
323
|
-
var path = _ref.path,
|
|
324
|
-
value = _ref.value;
|
|
325
|
-
return {
|
|
326
|
-
path: path || undefined,
|
|
327
|
-
value
|
|
328
|
-
};
|
|
329
|
-
}) : undefined
|
|
330
|
-
});
|
|
331
367
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
* if (!canSetPaths) {
|
|
351
|
-
* alert('not allowed!');
|
|
352
|
-
* }
|
|
353
|
-
*
|
|
354
|
-
* // Check if user could potentially set globalConfig values.
|
|
355
|
-
* // Equivalent to globalConfig.hasPermissionToSet()
|
|
356
|
-
* const canSetAnyPaths = globalConfig.hasPermissionToSetPaths();
|
|
357
|
-
* ```
|
|
358
|
-
*/
|
|
359
|
-
}, {
|
|
360
|
-
key: "hasPermissionToSetPaths",
|
|
361
|
-
value: function hasPermissionToSetPaths(updates) {
|
|
362
|
-
return this.checkPermissionsForSetPaths(updates).hasPermission;
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Sets multiple values. Throws if any path or value is invalid.
|
|
366
|
-
*
|
|
367
|
-
* This action is asynchronous: `await` the returned promise if you wish to wait for the
|
|
368
|
-
* updates to be persisted to Airtable servers.
|
|
369
|
-
* Updates are applied optimistically locally, so your changes will be reflected in
|
|
370
|
-
* {@link GlobalConfig} before the promise resolves.
|
|
371
|
-
*
|
|
372
|
-
* @param updates The paths and values to set.
|
|
373
|
-
* @example
|
|
374
|
-
* ```js
|
|
375
|
-
* import {useGlobalConfig} from '@airtable/blocks/[placeholder-path]/ui';
|
|
376
|
-
*
|
|
377
|
-
* function MyApp() {
|
|
378
|
-
* const globalConfig = useGlobalConfig();
|
|
379
|
-
* const updates = [
|
|
380
|
-
* {path: ['topLevelKey1', 'nestedKey1'], value: 'foo'},
|
|
381
|
-
* {path: ['topLevelKey2', 'nestedKey2'], value: 'bar'},
|
|
382
|
-
* ];
|
|
383
|
-
*
|
|
384
|
-
* const applyUpdatesIfPossible = () => {
|
|
385
|
-
* if (globalConfig.hasPermissionToSetPaths(updates)) {
|
|
386
|
-
* globalConfig.setPathsAsync(updates);
|
|
387
|
-
* }
|
|
388
|
-
* // The updates are now applied within your extension (eg will be reflected in
|
|
389
|
-
* // globalConfig) but are still being saved to Airtable servers (e.g. they
|
|
390
|
-
* // may not be updated for other users yet)
|
|
391
|
-
* }
|
|
392
|
-
*
|
|
393
|
-
* const applyUpdatesIfPossibleAsync = async () => {
|
|
394
|
-
* if (globalConfig.hasPermissionToSetPaths(updates)) {
|
|
395
|
-
* await globalConfig.setPathsAsync(updates);
|
|
396
|
-
* }
|
|
397
|
-
* // globalConfig updates have been saved to Airtable servers.
|
|
398
|
-
* alert('globalConfig has been updated');
|
|
399
|
-
* }
|
|
400
|
-
* }
|
|
401
|
-
* ```
|
|
402
|
-
*/
|
|
403
|
-
}, {
|
|
404
|
-
key: "setPathsAsync",
|
|
405
|
-
value: (function () {
|
|
406
|
-
var _setPathsAsync = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(updates) {
|
|
407
|
-
var _iterator, _step, update, pathValidation;
|
|
408
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
409
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
410
|
-
case 0:
|
|
411
|
-
if (this.hasPermissionToSetPaths(updates)) {
|
|
412
|
-
_context2.next = 2;
|
|
413
|
-
break;
|
|
414
|
-
}
|
|
415
|
-
throw (0, _error_utils.spawnError)('Your permission level does not allow setting globalConfig values');
|
|
416
|
-
case 2:
|
|
417
|
-
_iterator = _createForOfIteratorHelper(updates);
|
|
418
|
-
_context2.prev = 3;
|
|
419
|
-
_iterator.s();
|
|
420
|
-
case 5:
|
|
421
|
-
if ((_step = _iterator.n()).done) {
|
|
422
|
-
_context2.next = 12;
|
|
423
|
-
break;
|
|
424
|
-
}
|
|
425
|
-
update = _step.value;
|
|
426
|
-
pathValidation = this._validatePath(update.path, this._kvStore);
|
|
427
|
-
if (pathValidation.isValid) {
|
|
428
|
-
_context2.next = 10;
|
|
429
|
-
break;
|
|
430
|
-
}
|
|
431
|
-
throw (0, _error_utils.spawnError)('Invalid globalConfig path: %s', pathValidation.reason);
|
|
432
|
-
case 10:
|
|
433
|
-
_context2.next = 5;
|
|
434
|
-
break;
|
|
435
|
-
case 12:
|
|
436
|
-
_context2.next = 17;
|
|
437
|
-
break;
|
|
438
|
-
case 14:
|
|
439
|
-
_context2.prev = 14;
|
|
440
|
-
_context2.t0 = _context2["catch"](3);
|
|
441
|
-
_iterator.e(_context2.t0);
|
|
442
|
-
case 17:
|
|
443
|
-
_context2.prev = 17;
|
|
444
|
-
_iterator.f();
|
|
445
|
-
return _context2.finish(17);
|
|
446
|
-
case 20:
|
|
447
|
-
_context2.next = 22;
|
|
448
|
-
return this._sdk.__mutations.applyMutationAsync({
|
|
449
|
-
type: _mutations_core.MutationTypesCore.SET_MULTIPLE_GLOBAL_CONFIG_PATHS,
|
|
450
|
-
updates
|
|
451
|
-
});
|
|
452
|
-
case 22:
|
|
453
|
-
case "end":
|
|
454
|
-
return _context2.stop();
|
|
455
|
-
}
|
|
456
|
-
}, _callee2, this, [[3, 14, 17, 20]]);
|
|
457
|
-
}));
|
|
458
|
-
function setPathsAsync(_x3) {
|
|
459
|
-
return _setPathsAsync.apply(this, arguments);
|
|
460
|
-
}
|
|
461
|
-
return setPathsAsync;
|
|
462
|
-
}()
|
|
463
|
-
/**
|
|
464
|
-
* @internal
|
|
465
|
-
* this shouldn't be called directly - instead, use this._sdk.__applyGlobalConfigUpdates()
|
|
466
|
-
*/
|
|
467
|
-
)
|
|
468
|
-
}, {
|
|
469
|
-
key: "__setMultipleKvPaths",
|
|
470
|
-
value: function __setMultipleKvPaths(updates) {
|
|
471
|
-
// This helper validates updates and throw errors if necessary.
|
|
472
|
-
// To avoid the case where an error is encountered after some updates have already been
|
|
473
|
-
// applied (where we'd have to crash the block instead of letting the developer catch the
|
|
474
|
-
// error), it doesn't mutate the current store: it returns newKvStore with changes applied.
|
|
475
|
-
var _this$_airtableInterf = this._airtableInterface.globalConfigHelpers.validateAndApplyUpdates(updates, this._kvStore),
|
|
476
|
-
newKvStore = _this$_airtableInterf.newKvStore,
|
|
477
|
-
changedTopLevelKeys = _this$_airtableInterf.changedTopLevelKeys;
|
|
368
|
+
await this._sdk.__mutations.applyMutationAsync({
|
|
369
|
+
type: _mutations_core.MutationTypesCore.SET_MULTIPLE_GLOBAL_CONFIG_PATHS,
|
|
370
|
+
updates
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* @internal
|
|
375
|
+
* this shouldn't be called directly - instead, use this._sdk.__applyGlobalConfigUpdates()
|
|
376
|
+
*/
|
|
377
|
+
__setMultipleKvPaths(updates) {
|
|
378
|
+
// This helper validates updates and throw errors if necessary.
|
|
379
|
+
// To avoid the case where an error is encountered after some updates have already been
|
|
380
|
+
// applied (where we'd have to crash the block instead of letting the developer catch the
|
|
381
|
+
// error), it doesn't mutate the current store: it returns newKvStore with changes applied.
|
|
382
|
+
const {
|
|
383
|
+
newKvStore,
|
|
384
|
+
changedTopLevelKeys
|
|
385
|
+
} = this._airtableInterface.globalConfigHelpers.validateAndApplyUpdates(updates, this._kvStore);
|
|
478
386
|
|
|
479
|
-
|
|
480
|
-
|
|
387
|
+
// The updates are all good! Replace our kvStore with the new version.
|
|
388
|
+
this._kvStore = newKvStore;
|
|
481
389
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
try {
|
|
486
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
487
|
-
var key = _step2.value;
|
|
488
|
-
this._onChange(key);
|
|
489
|
-
}
|
|
490
|
-
} catch (err) {
|
|
491
|
-
_iterator2.e(err);
|
|
492
|
-
} finally {
|
|
493
|
-
_iterator2.f();
|
|
494
|
-
}
|
|
495
|
-
if (changedTopLevelKeys.length) {
|
|
496
|
-
this._onChange('*');
|
|
497
|
-
}
|
|
390
|
+
// Now loop over the top level keys to fire change events.
|
|
391
|
+
for (const key of changedTopLevelKeys) {
|
|
392
|
+
this._onChange(key);
|
|
498
393
|
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
value: /** @internal */
|
|
502
|
-
function _isWatchableKey(key) {
|
|
503
|
-
// The user can store any arbitrary key in the global config, so there's
|
|
504
|
-
// not much we can do here to check if a key is valid.
|
|
505
|
-
return true;
|
|
394
|
+
if (changedTopLevelKeys.length) {
|
|
395
|
+
this._onChange('*');
|
|
506
396
|
}
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
/** @internal */
|
|
510
|
-
(0, _defineProperty2.default)(GlobalConfig, "_className", 'GlobalConfig');
|
|
397
|
+
}
|
|
398
|
+
}
|
|
511
399
|
var _default = exports.default = GlobalConfig;
|