@wix/auto-patterns 1.26.0 → 1.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/dist/cjs/components/AutoPatternsApp/AutoPatternsApp.js +16 -7
  2. package/dist/cjs/components/AutoPatternsApp/AutoPatternsApp.js.map +1 -1
  3. package/dist/cjs/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js +2 -2
  4. package/dist/cjs/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js.map +1 -1
  5. package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +58 -4
  6. package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
  7. package/dist/cjs/components/AutoPatternsRoute/AutoPatternsRoutes.js +19 -5
  8. package/dist/cjs/components/AutoPatternsRoute/AutoPatternsRoutes.js.map +1 -1
  9. package/dist/cjs/dataSourceAdapters/cms/cmsAdapter.js +1 -1
  10. package/dist/cjs/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
  11. package/dist/cjs/dataSourceAdapters/cms/fetchCmsData.js +1 -1
  12. package/dist/cjs/dataSourceAdapters/cms/fetchCmsData.js.map +1 -1
  13. package/dist/cjs/hooks/index.js +19 -0
  14. package/dist/cjs/hooks/index.js.map +1 -1
  15. package/dist/cjs/hooks/useAutoPatternsOptimisticActions.js +13 -6
  16. package/dist/cjs/hooks/useAutoPatternsOptimisticActions.js.map +1 -1
  17. package/dist/cjs/hooks/useBaseCollectionParams.js +38 -0
  18. package/dist/cjs/hooks/useBaseCollectionParams.js.map +1 -0
  19. package/dist/cjs/hooks/useCommonCollectionFeatures.js +13 -6
  20. package/dist/cjs/hooks/useCommonCollectionFeatures.js.map +1 -1
  21. package/dist/cjs/hooks/useFetchData.js +4 -5
  22. package/dist/cjs/hooks/useFetchData.js.map +1 -1
  23. package/dist/cjs/hooks/useGridFeatures.js +9 -26
  24. package/dist/cjs/hooks/useGridFeatures.js.map +1 -1
  25. package/dist/cjs/hooks/useNavigationUtils.js +21 -6
  26. package/dist/cjs/hooks/useNavigationUtils.js.map +1 -1
  27. package/dist/cjs/hooks/useTableFeatures.js +9 -26
  28. package/dist/cjs/hooks/useTableFeatures.js.map +1 -1
  29. package/dist/cjs/hooks/useTableGridSwitchFeatures.js +11 -28
  30. package/dist/cjs/hooks/useTableGridSwitchFeatures.js.map +1 -1
  31. package/dist/cjs/hooks/useUpdateAppContextItems.js +18 -0
  32. package/dist/cjs/hooks/useUpdateAppContextItems.js.map +1 -0
  33. package/dist/cjs/providers/AppContext.js +58 -0
  34. package/dist/cjs/providers/AppContext.js.map +1 -0
  35. package/dist/cjs/providers/ItemsContext.js +37 -0
  36. package/dist/cjs/providers/ItemsContext.js.map +1 -0
  37. package/dist/cjs/providers/PatternsWizardOverridesContext.js +1 -1
  38. package/dist/cjs/providers/PatternsWizardOverridesContext.js.map +1 -1
  39. package/dist/cjs/providers/index.js +12 -0
  40. package/dist/cjs/providers/index.js.map +1 -1
  41. package/dist/cjs/types/CollectionPageConfig.js.map +1 -1
  42. package/dist/cjs/types/fetchData.js +4 -0
  43. package/dist/cjs/types/fetchData.js.map +1 -0
  44. package/dist/cjs/types/index.js +6 -0
  45. package/dist/cjs/types/index.js.map +1 -1
  46. package/dist/cjs/types/types.js.map +1 -1
  47. package/dist/docs/app_config_structure.md +1 -0
  48. package/dist/docs/auto-patterns-guide.md +270 -40
  49. package/dist/docs/bulk_actions.md +2 -5
  50. package/dist/docs/collection_page_actions.md +3 -12
  51. package/dist/docs/custom_overrides.md +1 -15
  52. package/dist/docs/entity_page_actions.md +3 -3
  53. package/dist/docs/entity_page_view_actions.md +2 -2
  54. package/dist/docs/error_handling.md +135 -0
  55. package/dist/docs/index.md +8 -0
  56. package/dist/docs/resolved_action.md +106 -0
  57. package/dist/docs/schema_config.md +11 -3
  58. package/dist/docs/wix_fqdn_custom_data_source.md +49 -7
  59. package/dist/esm/components/AutoPatternsApp/AutoPatternsApp.js +5 -3
  60. package/dist/esm/components/AutoPatternsApp/AutoPatternsApp.js.map +1 -1
  61. package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js +2 -2
  62. package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js.map +1 -1
  63. package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +24 -0
  64. package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
  65. package/dist/esm/components/AutoPatternsRoute/AutoPatternsRoutes.js +8 -0
  66. package/dist/esm/components/AutoPatternsRoute/AutoPatternsRoutes.js.map +1 -1
  67. package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js +1 -1
  68. package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
  69. package/dist/esm/dataSourceAdapters/cms/fetchCmsData.js +1 -1
  70. package/dist/esm/dataSourceAdapters/cms/fetchCmsData.js.map +1 -1
  71. package/dist/esm/hooks/index.js +2 -0
  72. package/dist/esm/hooks/index.js.map +1 -1
  73. package/dist/esm/hooks/useAutoPatternsOptimisticActions.js +14 -9
  74. package/dist/esm/hooks/useAutoPatternsOptimisticActions.js.map +1 -1
  75. package/dist/esm/hooks/useBaseCollectionParams.js +37 -0
  76. package/dist/esm/hooks/useBaseCollectionParams.js.map +1 -0
  77. package/dist/esm/hooks/useCommonCollectionFeatures.js +9 -2
  78. package/dist/esm/hooks/useCommonCollectionFeatures.js.map +1 -1
  79. package/dist/esm/hooks/useFetchData.js +2 -2
  80. package/dist/esm/hooks/useFetchData.js.map +1 -1
  81. package/dist/esm/hooks/useGridFeatures.js +10 -30
  82. package/dist/esm/hooks/useGridFeatures.js.map +1 -1
  83. package/dist/esm/hooks/useNavigationUtils.js +21 -6
  84. package/dist/esm/hooks/useNavigationUtils.js.map +1 -1
  85. package/dist/esm/hooks/useTableFeatures.js +10 -30
  86. package/dist/esm/hooks/useTableFeatures.js.map +1 -1
  87. package/dist/esm/hooks/useTableGridSwitchFeatures.js +12 -32
  88. package/dist/esm/hooks/useTableGridSwitchFeatures.js.map +1 -1
  89. package/dist/esm/hooks/useUpdateAppContextItems.js +13 -0
  90. package/dist/esm/hooks/useUpdateAppContextItems.js.map +1 -0
  91. package/dist/esm/providers/AppContext.js +31 -0
  92. package/dist/esm/providers/AppContext.js.map +1 -0
  93. package/dist/esm/providers/ItemsContext.js +23 -0
  94. package/dist/esm/providers/ItemsContext.js.map +1 -0
  95. package/dist/esm/providers/PatternsWizardOverridesContext.js.map +1 -1
  96. package/dist/esm/providers/index.js +1 -0
  97. package/dist/esm/providers/index.js.map +1 -1
  98. package/dist/esm/types/CollectionPageConfig.js.map +1 -1
  99. package/dist/esm/types/fetchData.js +2 -0
  100. package/dist/esm/types/fetchData.js.map +1 -0
  101. package/dist/esm/types/index.js +1 -0
  102. package/dist/esm/types/index.js.map +1 -1
  103. package/dist/esm/types/types.js.map +1 -1
  104. package/dist/types/components/AutoPatternsApp/AutoPatternsApp.d.ts +1 -0
  105. package/dist/types/components/AutoPatternsApp/AutoPatternsApp.d.ts.map +1 -1
  106. package/dist/types/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.d.ts.map +1 -1
  107. package/dist/types/components/AutoPatternsRoute/AutoPatternsRoutes.d.ts.map +1 -1
  108. package/dist/types/hooks/index.d.ts +2 -0
  109. package/dist/types/hooks/index.d.ts.map +1 -1
  110. package/dist/types/hooks/useAutoPatternsOptimisticActions.d.ts +7 -1
  111. package/dist/types/hooks/useAutoPatternsOptimisticActions.d.ts.map +1 -1
  112. package/dist/types/hooks/useBaseCollectionParams.d.ts +27 -0
  113. package/dist/types/hooks/useBaseCollectionParams.d.ts.map +1 -0
  114. package/dist/types/hooks/useCommonCollectionFeatures.d.ts +4 -3
  115. package/dist/types/hooks/useCommonCollectionFeatures.d.ts.map +1 -1
  116. package/dist/types/hooks/useFetchData.d.ts +3 -13
  117. package/dist/types/hooks/useFetchData.d.ts.map +1 -1
  118. package/dist/types/hooks/useGridFeatures.d.ts +1 -1
  119. package/dist/types/hooks/useGridFeatures.d.ts.map +1 -1
  120. package/dist/types/hooks/useNavigationUtils.d.ts +5 -1
  121. package/dist/types/hooks/useNavigationUtils.d.ts.map +1 -1
  122. package/dist/types/hooks/useTableFeatures.d.ts +1 -1
  123. package/dist/types/hooks/useTableFeatures.d.ts.map +1 -1
  124. package/dist/types/hooks/useTableGridSwitchFeatures.d.ts +1 -1
  125. package/dist/types/hooks/useTableGridSwitchFeatures.d.ts.map +1 -1
  126. package/dist/types/hooks/useUpdateAppContextItems.d.ts +2 -0
  127. package/dist/types/hooks/useUpdateAppContextItems.d.ts.map +1 -0
  128. package/dist/types/providers/AppContext.d.ts +11 -0
  129. package/dist/types/providers/AppContext.d.ts.map +1 -0
  130. package/dist/types/providers/ItemsContext.d.ts +11 -0
  131. package/dist/types/providers/ItemsContext.d.ts.map +1 -0
  132. package/dist/types/providers/PatternsWizardOverridesContext.d.ts +2 -1
  133. package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +1 -1
  134. package/dist/types/providers/index.d.ts +1 -0
  135. package/dist/types/providers/index.d.ts.map +1 -1
  136. package/dist/types/types/CollectionPageConfig.d.ts +4 -0
  137. package/dist/types/types/CollectionPageConfig.d.ts.map +1 -1
  138. package/dist/types/types/fetchData.d.ts +21 -0
  139. package/dist/types/types/fetchData.d.ts.map +1 -0
  140. package/dist/types/types/index.d.ts +1 -0
  141. package/dist/types/types/index.d.ts.map +1 -1
  142. package/dist/types/types/types.d.ts +6 -5
  143. package/dist/types/types/types.d.ts.map +1 -1
  144. package/package.json +14 -14
@@ -167,6 +167,7 @@ export interface AppConfig {
167
167
  reflectQueryInUrl?: boolean; // Reflects query state (search, filters, sorting) in the browser URL. Default: false
168
168
  selectAllScope?: 'page' | 'all'; // Controls "Select All" scope. 'all' selects entire collection, 'page' selects only visible items. Default: 'all'
169
169
  selectionUpdateMode?: 'preserve' | 'clear'; // Controls selection behavior when data changes. 'preserve' maintains selections, 'clear' clears them. Default: 'clear'
170
+ paginationMode?: 'cursor' | 'offset'; // Controls pagination strategy and expected find() return shape. 'cursor' => { items, cursor, total? }, 'offset' (default) => { items, hasNext, total? }
170
171
  };
171
172
  filters?: {
172
173
  panelTitle?: string; // Title of the filters panel
@@ -803,7 +804,7 @@ Custom collection page actions execute JavaScript code that you define for colle
803
804
  ```typescript
804
805
  import { CustomActionCollectionPageActionResolver } from '@wix/auto-patterns';
805
806
  import React from 'react';
806
- import { Download } from '@wix/ui-icons-common';
807
+ import { Download } from '@wix/wix-ui-icons-common';
807
808
 
808
809
  // IMPORTANT: Function name MUST match the action id in your configuration
809
810
  export const exportCollection: CustomActionCollectionPageActionResolver = (params) => {
@@ -923,16 +924,7 @@ Row click actions are configured at the table level using the `onRowClick` prope
923
924
 
924
925
  ⚠️ **CRITICAL**: When you configure `onRowClick` in your TypeScript configuration, you MUST provide a complete working implementation. The Auto Patterns framework cannot function without it.
925
926
 
926
- Custom row click actions use the `CustomActionCollectionPageActionOnRowClickResolver` type and MUST return a `ResolvedAction` object with all required properties:
927
-
928
- #### Required Return Object Structure:
929
- ```typescript
930
- return {
931
- label: string, // REQUIRED: Action label
932
- icon: ReactElement, // REQUIRED: Icon component
933
- onClick: () => void // REQUIRED: Click handler function
934
- };
935
- ```
927
+ Custom row click actions use the `CustomActionCollectionPageActionOnRowClickResolver` type and MUST return a `ResolvedAction`. See [ResolvedAction Reference](./resolved_action.md) for complete field documentation.
936
928
 
937
929
  #### Complete Implementation Example:
938
930
 
@@ -1092,7 +1084,7 @@ export const quickToggle: CustomActionCollectionPageActionOnRowClickResolver = (
1092
1084
  - **MANDATORY IMPLEMENTATION**: If you configure `onRowClick` in TypeScript configuration, you MUST provide a complete working implementation - the framework cannot function without it
1093
1085
  - The action `id` in the configuration MUST exactly match the function name exported from your actions folder
1094
1086
  - The implementation must use the `CustomActionCollectionPageActionOnRowClickResolver` type
1095
- - **Required Return Object**: Must return an object with `label`, `icon`, and `onClick` properties - all are required
1087
+ - **Required Return Object**: Must return a `ResolvedAction` object - see [ResolvedAction Reference](./resolved_action.md)
1096
1088
  - Access the clicked item's data through `actionParams.item`
1097
1089
  - The implementation must be exported as a named export and registered in your `PatternsWizardOverridesProvider`
1098
1090
  - When `onRowClick` is configured, the default navigation to entity page is completely disabled
@@ -1244,19 +1236,25 @@ export interface SchemaConfig {
1244
1236
  update: (updatedEntity: any) => Promise<any>;
1245
1237
  delete: (entityId: string) => Promise<any>;
1246
1238
  bulkDelete: (entityIds: string[]) => Promise<any>;
1239
+ // The return shape depends on pagination mode (see AppConfig.collection.paginationMode)
1240
+ // - Cursor mode: { items, cursor, total? }
1241
+ // - Offset mode (default): { items, hasNext, total? }
1247
1242
  find: (
1248
1243
  query: Query,
1249
1244
  options?: {
1250
1245
  searchableFieldIds?: string[];
1251
1246
  filterFieldMapping?: Record<string, { fieldId: string }>;
1252
1247
  },
1253
- ) => Promise<{ items: any[]; total: number }>;
1248
+ ) => Promise<
1249
+ | { items: any[]; cursor?: string | null; total?: number | null }
1250
+ | { items: any[]; hasNext?: boolean; total?: number | null }
1251
+ >;
1254
1252
  };
1255
1253
  }
1256
1254
 
1257
1255
  export interface Query {
1258
1256
  limit: number; // Maximum number of items to return per request (controls page size)
1259
- offset: number; // Number of items to skip from the beginning (for pagination)
1257
+ offset?: number; // Number of items to skip from the beginning (for pagination)
1260
1258
  page: number; // Current page number (1-based, works with limit for pagination)
1261
1259
  search?: string; // Text search query applied to searchable fields
1262
1260
  cursor?: string | null; // Cursor-based pagination token (alternative to offset-based pagination)
@@ -1355,7 +1353,9 @@ export type Field = ReferenceField | NonReferenceField;
1355
1353
  - `query`: Query object with pagination, filtering, sorting, and search criteria (see Query Interface section)
1356
1354
  - `options.searchableFieldIds`: Array of field IDs that support text search
1357
1355
  - `options.filterFieldMapping`: Maps filter IDs to actual field IDs for complex filtering
1358
- - Returns: `{ items: any[], total: number }`
1356
+ - Returns (depends on pagination mode):
1357
+ - Cursor mode: `{ items: any[]; cursor?: string | null; total?: number | null }`
1358
+ - Offset mode (default): `{ items: any[]; hasNext?: boolean; total?: number | null }`
1359
1359
 
1360
1360
  ### Field Type Information
1361
1361
 
@@ -1843,11 +1843,8 @@ Custom bulk actions execute JavaScript code that you define for bulk operations.
1843
1843
  - Be registered in the `actions` property of your `PatternsWizardOverridesProvider`
1844
1844
  - Follow JavaScript identifier naming rules (camelCase recommended)
1845
1845
 
1846
- 2. The implementation must return an object with:
1847
- - `label`: Text displayed for the action
1848
- - `icon`: An Icon component from "@wix/wix-ui-icons-common"
1849
- - `onClick`: Handler function for the bulk action
1850
- - `hidden` (optional): Boolean to hide the action when true
1846
+ 2. The implementation must return a `ResolvedAction`:
1847
+ For complete field documentation, see [ResolvedAction Reference](./resolved_action.md).
1851
1848
 
1852
1849
  3. The implementation must:
1853
1850
  - Use the correct type: `CustomBulkActionsActionResolver`
@@ -2470,7 +2467,7 @@ export const myMoreAction: CustomEntityPageActionResolver = (params) => {
2470
2467
 
2471
2468
  return {
2472
2469
  label: 'My More Action',
2473
- icon: <MyIcon />, // optional
2470
+ icon: <MyIcon />, // required
2474
2471
  onClick: () => {
2475
2472
  // Your custom logic here
2476
2473
  },
@@ -2490,7 +2487,7 @@ export const myMoreAction: CustomEntityPageActionResolver = (params) => {
2490
2487
  - The implementation must use the `CustomEntityPageActionResolver` type.
2491
2488
  - The implementation must be exported as a named export (not default export).
2492
2489
  - The function receives `{ actionParams, sdk }` as parameters.
2493
- - The returned object must include at least a `label` and an `onClick` handler (optionally an `icon`).
2490
+ - The returned object must be a `ResolvedAction`. See [ResolvedAction Reference](./resolved_action.md) for complete documentation.
2494
2491
 
2495
2492
  ---
2496
2493
 
@@ -2501,7 +2498,7 @@ export const myMoreAction: CustomEntityPageActionResolver = (params) => {
2501
2498
  ✓ Custom actions match implementations in overrides
2502
2499
  ✓ The resolver is exported and registered in the `actions` property of your `PatternsWizardOverridesProvider`
2503
2500
  ✓ The function signature matches `CustomEntityPageActionResolver`
2504
- ✓ The returned object includes `label`, `onClick`, and optionally `icon`
2501
+ ✓ The returned object is a `ResolvedAction` (see [ResolvedAction Reference](./resolved_action.md))
2505
2502
 
2506
2503
  ---
2507
2504
 
@@ -2608,7 +2605,7 @@ View mode actions follow the same resolver patterns as collection page actions:
2608
2605
  These actions are handled automatically by the AutoPatterns framework using the configuration provided.
2609
2606
 
2610
2607
  ### For Custom Actions
2611
- Custom actions require resolver implementations:
2608
+ Custom actions require resolver implementations that return a `ResolvedAction` object. See [ResolvedAction Reference](./resolved_action.md) for complete field documentation.
2612
2609
 
2613
2610
  ```typescript
2614
2611
  import { CustomEntityPageActionResolver } from '@wix/auto-patterns/types';
@@ -2619,7 +2616,7 @@ export const duplicateProduct: CustomEntityPageActionResolver = (params) => {
2619
2616
  const schema = sdk.getSchema(sdk.collectionId);
2620
2617
  return {
2621
2618
  label: 'Duplicate Product',
2622
- icon: <DuplicateIcon />, // optional
2619
+ icon: <DuplicateIcon />, // required
2623
2620
  onClick: async () => {
2624
2621
  // Your custom duplication logic here
2625
2622
  await schema.actions.create({
@@ -2650,6 +2647,115 @@ export const duplicateProduct: CustomEntityPageActionResolver = (params) => {
2650
2647
 
2651
2648
  ---
2652
2649
 
2650
+ # ResolvedAction: Common Return Type for Custom Actions
2651
+
2652
+ All custom action resolvers in Auto Patterns must return a `ResolvedAction`. This applies to:
2653
+ - Collection page actions (primary, secondary, menus) and `onRowClick`
2654
+ - Entity page actions (view mode: primary/secondary/more; edit mode: moreActions)
2655
+ - Bulk action toolbar actions
2656
+ - Action Cell actions
2657
+
2658
+ ## Type Definition
2659
+
2660
+ From `@wix/auto-patterns`:
2661
+
2662
+ ```typescript
2663
+ export interface ResolvedAction {
2664
+ label: string;
2665
+ icon: IconElement;
2666
+ onClick: () => void;
2667
+ disabled?: boolean;
2668
+ hidden?: boolean;
2669
+ tooltip?: string;
2670
+ skin?: string;
2671
+ }
2672
+ ```
2673
+
2674
+ ## Field Reference
2675
+
2676
+ ### Required Fields
2677
+
2678
+ - **`label`** (string): Text displayed in the button or menu item.
2679
+ - **`icon`** (IconElement): An icon component, typically from `@wix/wix-ui-icons-common`. Example: `icon: <Delete />`.
2680
+ - **`onClick`** (function): Handler function invoked when the user triggers the action. Can be async.
2681
+
2682
+ ### Optional Fields
2683
+
2684
+ - **`disabled`** (boolean): When `true`, renders the action as disabled. Pair with `tooltip` to explain why the action is unavailable.
2685
+ - **`hidden`** (boolean): When `true`, the action is completely omitted from the UI. Useful for permission-based or state-based visibility control.
2686
+ - **`tooltip`** (string): Tooltip text displayed on hover. Especially useful when the action is disabled.
2687
+ - **`skin`** (string): Visual style of the action button. Availability may vary by placement context. Recommended values:
2688
+ - Primary actions: `"standard"`, `"inverted"`, `"premium"`
2689
+ - Secondary/more/menu items: `"dark"`, `"destructive"`, `"premium"`
2690
+ - If unsure, omit `skin` or use `"standard"` for primary actions and `"dark"` for secondary actions.
2691
+
2692
+ ## Examples
2693
+
2694
+ ### Minimal Example
2695
+
2696
+ ```typescript
2697
+ import { Add } from '@wix/wix-ui-icons-common';
2698
+
2699
+ return {
2700
+ label: 'Create',
2701
+ icon: <Add />,
2702
+ onClick: () => {
2703
+ // Your action logic here
2704
+ }
2705
+ };
2706
+ ```
2707
+
2708
+ ### Complete Example with State Control
2709
+
2710
+ ```typescript
2711
+ import { Download } from '@wix/wix-ui-icons-common';
2712
+
2713
+ return {
2714
+ label: 'Export',
2715
+ icon: <Download />,
2716
+ onClick: async () => {
2717
+ try {
2718
+ // Perform export logic using SDK
2719
+ await performExport();
2720
+ } catch (error) {
2721
+ // Handle errors, show toast, etc.
2722
+ }
2723
+ },
2724
+ disabled: total === 0,
2725
+ tooltip: total === 0 ? 'Select at least one item to export' : undefined,
2726
+ hidden: !userHasExportPermission,
2727
+ skin: 'premium'
2728
+ };
2729
+ ```
2730
+
2731
+ ## Context-Specific Notes
2732
+
2733
+ ### Collection Page Actions
2734
+ - **onRowClick**: Access clicked item data via `actionParams.item`
2735
+ - **Collection-level actions**: Access collection context via `actionParams.collectionId`
2736
+
2737
+ ### Entity Page Actions
2738
+ - **View/Edit mode**: Access entity data via `actionParams.entity`
2739
+ - **Edit mode only**: Access form instance via `actionParams.form`
2740
+
2741
+ ### Bulk Actions
2742
+ - **Selection data**: Use `actionParams.selectedValues` and `actionParams.total`
2743
+ - **State control**: Commonly use `disabled: selectedValues.length === 0`
2744
+
2745
+ ### Action Cell Actions
2746
+ - **Row context**: Access item and position via `actionParams.item` and `actionParams.index`
2747
+
2748
+ ## See Also
2749
+
2750
+ - [Collection Page Actions](./collection_page_actions.md)
2751
+ - [Entity Page Actions](./entity_page_actions.md) (edit mode)
2752
+ - [Entity Page View Actions](./entity_page_view_actions.md)
2753
+ - [Bulk Actions Toolbar](./bulk_actions.md)
2754
+ - [Action Cell](./action_cell.md)
2755
+ - [App Config Structure](./app_config_structure.md) (action item `skin` property)
2756
+
2757
+ ---
2758
+
2653
2759
  # Installation & Setup
2654
2760
 
2655
2761
  ## 1. Install Packages
@@ -2736,6 +2842,7 @@ export default withDashboard(Index);
2736
2842
 
2737
2843
  - **Custom overrides are restricted to the defined areas only** - attempting to override or modify any other aspect of `AutoPatternsApp` is prohibited and can cause unexpected behavior
2738
2844
  - **Always verify override implementation** - when implementing custom overrides, you MUST ensure they are correctly imported and passed to the `PatternsWizardOverridesProvider`
2845
+ - **CRITICAL: Error handling for custom actions** - Custom actions that make external API calls (using `fetch()`, `axios`, etc.) should NOT use `errorHandler.withErrorHandler`. Only Wix HTTP requests (httpClient from @wix/essentials, Wix APIs like wix/data and wix/stores, and httpClient.fetchWithAuth()) require errorHandler wrapping. See the "Error Handling for HTTP Requests" section for details.
2739
2846
 
2740
2847
  The `PatternsWizardOverridesProvider` allows you to inject custom code to override default behaviors or add additional functionality. Below are the areas where overrides can be applied:
2741
2848
 
@@ -3542,22 +3649,7 @@ When implementing custom data sources, you need to map your data source field ty
3542
3649
  - **Reference fields** → `'REFERENCE'`
3543
3650
  - **URL fields** → `'URL'`
3544
3651
 
3545
- ### Error Handling
3546
3652
 
3547
- Custom data sources should include proper error handling:
3548
-
3549
- ```tsx
3550
- actions: {
3551
- get: async (entityId: string) => {
3552
- try {
3553
- const result = await yourDataSourceCall(entityId);
3554
- return result;
3555
- } catch (error) {
3556
- throw new Error(`Failed to fetch entity: ${error.message}`);
3557
- }
3558
- }
3559
- }
3560
- ```
3561
3653
 
3562
3654
  ### Validation Requirements
3563
3655
 
@@ -3904,3 +3996,141 @@ export default function YourPage() {
3904
3996
  Slots provide a powerful way to enhance collection pages with custom functionality while maintaining the structure and features of the AutoPatterns system.
3905
3997
 
3906
3998
  ---
3999
+
4000
+ # Error Handling for HTTP Requests
4001
+
4002
+ **⚠️ CRITICAL**: When implementing custom data sources that make HTTP requests, you **MUST** wrap specific HTTP calls with proper error handling. This ensures consistent error management, prevents unhandled promise rejections, and provides better user experience.
4003
+
4004
+ ## What Requires Error Handling
4005
+
4006
+ **ONLY the following HTTP requests** in your custom data source actions must be wrapped with `errorHandler`:
4007
+
4008
+ - **httpClient from @wix/essentials** (e.g., `httpClient.request(getDummyEntity(...))`)
4009
+ - **Wix APIs** (e.g., `wix/data`, `wix/stores`, `items.get()`, `items.insert()`, `collections.getDataCollection()`)
4010
+ - **httpClient.fetchWithAuth()** calls
4011
+
4012
+ **DO NOT use errorHandler with:**
4013
+
4014
+ - **External API calls** using `fetch()`, `axios.get()`, or other HTTP libraries
4015
+ - **Custom HTTP clients** (e.g., any non-Wix HTTP request library)
4016
+ - **Third-party API calls** using non-Wix HTTP methods
4017
+
4018
+ **EXCEPTION**: SDK actions that you get from the AutoPatterns SDK (e.g., `sdk.getOptimisticActions()`, `sdk.getSchema()`) do NOT need error handling as they are already handled internally.
4019
+
4020
+ ## Why Error Handling is Required
4021
+
4022
+ Custom data sources often make HTTP requests to Wix APIs and services. Without proper error handling:
4023
+
4024
+ - **Unhandled Promise Rejections**: HTTP failures can crash your application
4025
+ - **Poor User Experience**: Users don't get meaningful error messages
4026
+ - **Inconsistent Error Management**: Different parts of your app handle errors differently
4027
+ - **Debugging Difficulties**: Hard to trace and diagnose API failures
4028
+
4029
+ ## Using @wix/essentials errorHandler
4030
+
4031
+ The recommended approach is to use the `errorHandler` from `@wix/essentials` package, which provides consistent error handling patterns across Wix applications.
4032
+
4033
+ ### Installation
4034
+
4035
+ First, ensure `@wix/essentials` is installed in your project:
4036
+
4037
+ ```bash
4038
+ npm install @wix/essentials
4039
+ ```
4040
+
4041
+ ### Basic Error Handling Pattern
4042
+
4043
+ Wrap Wix HTTP requests in your custom data source actions with `errorHandler.withErrorHandler`:
4044
+
4045
+ ```typescript
4046
+ import { errorHandler } from '@wix/essentials';
4047
+
4048
+ // In your custom data source actions
4049
+ actions: {
4050
+ get: async (entityId: string) => {
4051
+ return errorHandler.withErrorHandler(
4052
+ async () => {
4053
+ const response = await httpClient.request(
4054
+ getDummyEntity({ dummyEntityId: entityId })
4055
+ );
4056
+ return response.data.dummyEntity;
4057
+ },
4058
+ {}
4059
+ );
4060
+ },
4061
+ }
4062
+ ```
4063
+
4064
+ ### Examples of HTTP Requests That Need Error Handling
4065
+
4066
+ **httpClient from @wix/essentials:**
4067
+
4068
+ ```typescript
4069
+ return errorHandler.withErrorHandler(async () => {
4070
+ const response = await httpClient.request(
4071
+ getDummyEntity({ dummyEntityId: entityId })
4072
+ );
4073
+ return response.data.dummyEntity;
4074
+ }, {});
4075
+ ```
4076
+
4077
+ **Wix APIs (wix/data, wix/stores):**
4078
+
4079
+ ```typescript
4080
+ return errorHandler.withErrorHandler(async () => {
4081
+ return await items.get(collectionId, entityId);
4082
+ }, {});
4083
+ ```
4084
+
4085
+ **httpClient.fetchWithAuth() calls:**
4086
+
4087
+ ```typescript
4088
+ return errorHandler.withErrorHandler(async () => {
4089
+ const response = await httpClient.fetchWithAuth("/api/data");
4090
+ return await response.json();
4091
+ }, {});
4092
+ ```
4093
+
4094
+ ### Examples of HTTP Requests That Do NOT Need Error Handling
4095
+
4096
+ **External API calls (using fetch, axios, etc.):**
4097
+
4098
+ ```typescript
4099
+ // ✅ CORRECT - No error handling needed for external APIs
4100
+ const response = await fetch("https://api.example.com/data");
4101
+ return await response.json();
4102
+
4103
+ // ✅ CORRECT - No error handling needed for axios
4104
+ const response = await axios.get("https://api.example.com/data");
4105
+ return response.data;
4106
+ ```
4107
+
4108
+ **Third-party HTTP libraries:**
4109
+
4110
+ ```typescript
4111
+ // ✅ CORRECT - No error handling needed for third-party HTTP clients
4112
+ const response = await someThirdPartyHttpClient.get("/data");
4113
+ return response.data;
4114
+ ```
4115
+
4116
+ ## Integration with AutoPatterns Error Handling
4117
+
4118
+ The error handling in your custom data source integrates seamlessly with AutoPatterns' built-in error handling:
4119
+
4120
+ 1. **User-Friendly Messages**: Errors are displayed to users in a consistent format
4121
+ 2. **Retry Mechanisms**: Users can retry failed operations
4122
+ 3. **Loading States**: Proper loading states during HTTP requests
4123
+ 4. **Error Boundaries**: Errors are caught and handled gracefully
4124
+
4125
+ ## Validation Checklist
4126
+
4127
+ Before deploying your custom data source, ensure:
4128
+
4129
+ ✅ **httpClient from @wix/essentials** is wrapped with `errorHandler.withErrorHandler`
4130
+ ✅ **Wix APIs (wix/data, wix/stores, etc)** are wrapped with `errorHandler.withErrorHandler`
4131
+ ✅ **httpClient.fetchWithAuth()** calls are wrapped with `errorHandler.withErrorHandler`
4132
+ ✅ **External API calls are NOT wrapped** with errorHandler (e.g., fetch(), axios, third-party HTTP clients)
4133
+ ✅ **SDK actions are used directly** without error handling (e.g., `sdk.getOptimisticActions()`, `sdk.getSchema()`)
4134
+ ✅ **@wix/essentials** is installed as a dependency
4135
+
4136
+ ---
@@ -174,11 +174,8 @@ Custom bulk actions execute JavaScript code that you define for bulk operations.
174
174
  - Be registered in the `actions` property of your `PatternsWizardOverridesProvider`
175
175
  - Follow JavaScript identifier naming rules (camelCase recommended)
176
176
 
177
- 2. The implementation must return an object with:
178
- - `label`: Text displayed for the action
179
- - `icon`: An Icon component from "@wix/wix-ui-icons-common"
180
- - `onClick`: Handler function for the bulk action
181
- - `hidden` (optional): Boolean to hide the action when true
177
+ 2. The implementation must return a `ResolvedAction`:
178
+ For complete field documentation, see [ResolvedAction Reference](./resolved_action.md).
182
179
 
183
180
  3. The implementation must:
184
181
  - Use the correct type: `CustomBulkActionsActionResolver`
@@ -64,7 +64,7 @@ Custom collection page actions execute JavaScript code that you define for colle
64
64
  ```typescript
65
65
  import { CustomActionCollectionPageActionResolver } from '@wix/auto-patterns';
66
66
  import React from 'react';
67
- import { Download } from '@wix/ui-icons-common';
67
+ import { Download } from '@wix/wix-ui-icons-common';
68
68
 
69
69
  // IMPORTANT: Function name MUST match the action id in your configuration
70
70
  export const exportCollection: CustomActionCollectionPageActionResolver = (params) => {
@@ -184,16 +184,7 @@ Row click actions are configured at the table level using the `onRowClick` prope
184
184
 
185
185
  ⚠️ **CRITICAL**: When you configure `onRowClick` in your TypeScript configuration, you MUST provide a complete working implementation. The Auto Patterns framework cannot function without it.
186
186
 
187
- Custom row click actions use the `CustomActionCollectionPageActionOnRowClickResolver` type and MUST return a `ResolvedAction` object with all required properties:
188
-
189
- #### Required Return Object Structure:
190
- ```typescript
191
- return {
192
- label: string, // REQUIRED: Action label
193
- icon: ReactElement, // REQUIRED: Icon component
194
- onClick: () => void // REQUIRED: Click handler function
195
- };
196
- ```
187
+ Custom row click actions use the `CustomActionCollectionPageActionOnRowClickResolver` type and MUST return a `ResolvedAction`. See [ResolvedAction Reference](./resolved_action.md) for complete field documentation.
197
188
 
198
189
  #### Complete Implementation Example:
199
190
 
@@ -353,7 +344,7 @@ export const quickToggle: CustomActionCollectionPageActionOnRowClickResolver = (
353
344
  - **MANDATORY IMPLEMENTATION**: If you configure `onRowClick` in TypeScript configuration, you MUST provide a complete working implementation - the framework cannot function without it
354
345
  - The action `id` in the configuration MUST exactly match the function name exported from your actions folder
355
346
  - The implementation must use the `CustomActionCollectionPageActionOnRowClickResolver` type
356
- - **Required Return Object**: Must return an object with `label`, `icon`, and `onClick` properties - all are required
347
+ - **Required Return Object**: Must return a `ResolvedAction` object - see [ResolvedAction Reference](./resolved_action.md)
357
348
  - Access the clicked item's data through `actionParams.item`
358
349
  - The implementation must be exported as a named export and registered in your `PatternsWizardOverridesProvider`
359
350
  - When `onRowClick` is configured, the default navigation to entity page is completely disabled
@@ -4,6 +4,7 @@
4
4
 
5
5
  - **Custom overrides are restricted to the defined areas only** - attempting to override or modify any other aspect of `AutoPatternsApp` is prohibited and can cause unexpected behavior
6
6
  - **Always verify override implementation** - when implementing custom overrides, you MUST ensure they are correctly imported and passed to the `PatternsWizardOverridesProvider`
7
+ - **CRITICAL: Error handling for custom actions** - Custom actions that make external API calls (using `fetch()`, `axios`, etc.) should NOT use `errorHandler.withErrorHandler`. Only Wix HTTP requests (httpClient from @wix/essentials, Wix APIs like wix/data and wix/stores, and httpClient.fetchWithAuth()) require errorHandler wrapping. See the "Error Handling for HTTP Requests" section for details.
7
8
 
8
9
  The `PatternsWizardOverridesProvider` allows you to inject custom code to override default behaviors or add additional functionality. Below are the areas where overrides can be applied:
9
10
 
@@ -810,22 +811,7 @@ When implementing custom data sources, you need to map your data source field ty
810
811
  - **Reference fields** → `'REFERENCE'`
811
812
  - **URL fields** → `'URL'`
812
813
 
813
- ### Error Handling
814
814
 
815
- Custom data sources should include proper error handling:
816
-
817
- ```tsx
818
- actions: {
819
- get: async (entityId: string) => {
820
- try {
821
- const result = await yourDataSourceCall(entityId);
822
- return result;
823
- } catch (error) {
824
- throw new Error(`Failed to fetch entity: ${error.message}`);
825
- }
826
- }
827
- }
828
- ```
829
815
 
830
816
  ### Validation Requirements
831
817
 
@@ -55,7 +55,7 @@ export const myMoreAction: CustomEntityPageActionResolver = (params) => {
55
55
 
56
56
  return {
57
57
  label: 'My More Action',
58
- icon: <MyIcon />, // optional
58
+ icon: <MyIcon />, // required
59
59
  onClick: () => {
60
60
  // Your custom logic here
61
61
  },
@@ -75,7 +75,7 @@ export const myMoreAction: CustomEntityPageActionResolver = (params) => {
75
75
  - The implementation must use the `CustomEntityPageActionResolver` type.
76
76
  - The implementation must be exported as a named export (not default export).
77
77
  - The function receives `{ actionParams, sdk }` as parameters.
78
- - The returned object must include at least a `label` and an `onClick` handler (optionally an `icon`).
78
+ - The returned object must be a `ResolvedAction`. See [ResolvedAction Reference](./resolved_action.md) for complete documentation.
79
79
 
80
80
  ---
81
81
 
@@ -86,7 +86,7 @@ export const myMoreAction: CustomEntityPageActionResolver = (params) => {
86
86
  ✓ Custom actions match implementations in overrides
87
87
  ✓ The resolver is exported and registered in the `actions` property of your `PatternsWizardOverridesProvider`
88
88
  ✓ The function signature matches `CustomEntityPageActionResolver`
89
- ✓ The returned object includes `label`, `onClick`, and optionally `icon`
89
+ ✓ The returned object is a `ResolvedAction` (see [ResolvedAction Reference](./resolved_action.md))
90
90
 
91
91
  ---
92
92
 
@@ -96,7 +96,7 @@ View mode actions follow the same resolver patterns as collection page actions:
96
96
  These actions are handled automatically by the AutoPatterns framework using the configuration provided.
97
97
 
98
98
  ### For Custom Actions
99
- Custom actions require resolver implementations:
99
+ Custom actions require resolver implementations that return a `ResolvedAction` object. See [ResolvedAction Reference](./resolved_action.md) for complete field documentation.
100
100
 
101
101
  ```typescript
102
102
  import { CustomEntityPageActionResolver } from '@wix/auto-patterns/types';
@@ -107,7 +107,7 @@ export const duplicateProduct: CustomEntityPageActionResolver = (params) => {
107
107
  const schema = sdk.getSchema(sdk.collectionId);
108
108
  return {
109
109
  label: 'Duplicate Product',
110
- icon: <DuplicateIcon />, // optional
110
+ icon: <DuplicateIcon />, // required
111
111
  onClick: async () => {
112
112
  // Your custom duplication logic here
113
113
  await schema.actions.create({