@wix/auto-patterns 1.39.0 → 1.41.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 (92) hide show
  1. package/dist/cjs/components/AutoPatternsApp/AutoPatternsApp.uni.driver.js +57 -0
  2. package/dist/cjs/components/AutoPatternsApp/AutoPatternsApp.uni.driver.js.map +1 -0
  3. package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +0 -1
  4. package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
  5. package/dist/cjs/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.js +42 -0
  6. package/dist/cjs/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.js.map +1 -0
  7. package/dist/cjs/exports/testkit/enzyme.js +10 -0
  8. package/dist/cjs/exports/testkit/enzyme.js.map +1 -0
  9. package/dist/cjs/exports/testkit/jsdom.js +10 -0
  10. package/dist/cjs/exports/testkit/jsdom.js.map +1 -0
  11. package/dist/cjs/exports/testkit/playwright.js +10 -0
  12. package/dist/cjs/exports/testkit/playwright.js.map +1 -0
  13. package/dist/cjs/exports/testkit/puppeteer.js +10 -0
  14. package/dist/cjs/exports/testkit/puppeteer.js.map +1 -0
  15. package/dist/cjs/hooks/useActionCell.js +14 -8
  16. package/dist/cjs/hooks/useActionCell.js.map +1 -1
  17. package/dist/cjs/hooks/useDragAndDropBaseProps.js +7 -3
  18. package/dist/cjs/hooks/useDragAndDropBaseProps.js.map +1 -1
  19. package/dist/cjs/providers/AutoPatternsOverridesContext.js +1 -1
  20. package/dist/cjs/providers/AutoPatternsOverridesContext.js.map +1 -1
  21. package/dist/cjs/testkit/enzyme.js +8 -0
  22. package/dist/cjs/testkit/enzyme.js.map +1 -0
  23. package/dist/cjs/testkit/jsdom.js +8 -0
  24. package/dist/cjs/testkit/jsdom.js.map +1 -0
  25. package/dist/cjs/testkit/playwright.js +8 -0
  26. package/dist/cjs/testkit/playwright.js.map +1 -0
  27. package/dist/cjs/testkit/puppeteer.js +8 -0
  28. package/dist/cjs/testkit/puppeteer.js.map +1 -0
  29. package/dist/cjs/types/CollectionPageConfig.js.map +1 -1
  30. package/dist/cjs/types/actions/actionCell.js.map +1 -1
  31. package/dist/esm/components/AutoPatternsApp/AutoPatternsApp.uni.driver.js +50 -0
  32. package/dist/esm/components/AutoPatternsApp/AutoPatternsApp.uni.driver.js.map +1 -0
  33. package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +0 -1
  34. package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
  35. package/dist/esm/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.js +37 -0
  36. package/dist/esm/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.js.map +1 -0
  37. package/dist/esm/exports/testkit/enzyme.js +2 -0
  38. package/dist/esm/exports/testkit/enzyme.js.map +1 -0
  39. package/dist/esm/exports/testkit/jsdom.js +2 -0
  40. package/dist/esm/exports/testkit/jsdom.js.map +1 -0
  41. package/dist/esm/exports/testkit/playwright.js +2 -0
  42. package/dist/esm/exports/testkit/playwright.js.map +1 -0
  43. package/dist/esm/exports/testkit/puppeteer.js +2 -0
  44. package/dist/esm/exports/testkit/puppeteer.js.map +1 -0
  45. package/dist/esm/hooks/useActionCell.js +14 -8
  46. package/dist/esm/hooks/useActionCell.js.map +1 -1
  47. package/dist/esm/hooks/useDragAndDropBaseProps.js +8 -4
  48. package/dist/esm/hooks/useDragAndDropBaseProps.js.map +1 -1
  49. package/dist/esm/providers/AutoPatternsOverridesContext.js.map +1 -1
  50. package/dist/esm/testkit/enzyme.js +4 -0
  51. package/dist/esm/testkit/enzyme.js.map +1 -0
  52. package/dist/esm/testkit/jsdom.js +4 -0
  53. package/dist/esm/testkit/jsdom.js.map +1 -0
  54. package/dist/esm/testkit/playwright.js +4 -0
  55. package/dist/esm/testkit/playwright.js.map +1 -0
  56. package/dist/esm/testkit/puppeteer.js +4 -0
  57. package/dist/esm/testkit/puppeteer.js.map +1 -0
  58. package/dist/esm/types/CollectionPageConfig.js.map +1 -1
  59. package/dist/esm/types/actions/actionCell.js.map +1 -1
  60. package/dist/types/components/AutoPatternsApp/AutoPatternsApp.uni.driver.d.ts +45 -0
  61. package/dist/types/components/AutoPatternsApp/AutoPatternsApp.uni.driver.d.ts.map +1 -0
  62. package/dist/types/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.d.ts +81 -0
  63. package/dist/types/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.d.ts.map +1 -0
  64. package/dist/types/exports/testkit/enzyme.d.ts +2 -0
  65. package/dist/types/exports/testkit/enzyme.d.ts.map +1 -0
  66. package/dist/types/exports/testkit/jsdom.d.ts +2 -0
  67. package/dist/types/exports/testkit/jsdom.d.ts.map +1 -0
  68. package/dist/types/exports/testkit/playwright.d.ts +2 -0
  69. package/dist/types/exports/testkit/playwright.d.ts.map +1 -0
  70. package/dist/types/exports/testkit/puppeteer.d.ts +2 -0
  71. package/dist/types/exports/testkit/puppeteer.d.ts.map +1 -0
  72. package/dist/types/hooks/useActionCell.d.ts.map +1 -1
  73. package/dist/types/hooks/useDragAndDropBaseProps.d.ts.map +1 -1
  74. package/dist/types/providers/AutoPatternsOverridesContext.d.ts +1 -0
  75. package/dist/types/providers/AutoPatternsOverridesContext.d.ts.map +1 -1
  76. package/dist/types/testkit/enzyme.d.ts +16 -0
  77. package/dist/types/testkit/enzyme.d.ts.map +1 -0
  78. package/dist/types/testkit/jsdom.d.ts +16 -0
  79. package/dist/types/testkit/jsdom.d.ts.map +1 -0
  80. package/dist/types/testkit/playwright.d.ts +20 -0
  81. package/dist/types/testkit/playwright.d.ts.map +1 -0
  82. package/dist/types/testkit/puppeteer.d.ts +20 -0
  83. package/dist/types/testkit/puppeteer.d.ts.map +1 -0
  84. package/dist/types/types/CollectionPageConfig.d.ts +6 -0
  85. package/dist/types/types/CollectionPageConfig.d.ts.map +1 -1
  86. package/dist/types/types/actions/actionCell.d.ts +13 -1
  87. package/dist/types/types/actions/actionCell.d.ts.map +1 -1
  88. package/mcp-docs/action_cell.md +66 -8
  89. package/mcp-docs/app_config_structure.md +53 -43
  90. package/mcp-docs/auto-patterns-guide.md +370 -66
  91. package/mcp-docs/error_handling.md +251 -15
  92. package/package.json +43 -15
@@ -248,52 +248,16 @@ export interface AppConfig {
248
248
  };
249
249
  actionCell?: {
250
250
  primaryAction?: {
251
- item: {
252
- id: string; // Unique identifier for the action
253
- type: 'update' | 'delete' | 'custom'; // Action type
254
- label?: string; // Text displayed for the action
255
- skin?: string; // Visual appearance of the action button (see Action Button Skin Values section)
256
- biName: string; // MANDATORY: Business intelligence name for analytics tracking
257
- disabled?: boolean; // Whether the action is disabled
258
- tooltip?: string; // Tooltip text shown on hover
259
- update?: { // Required when type is 'update'
260
- mode: 'page'; // Update mode
261
- page?: { // Required when mode is 'page'
262
- id: string; // Entity page ID to navigate to
263
- };
264
- };
265
- delete?: { // Required when type is 'delete'
266
- mode: 'modal'; // Currently only 'modal' is supported
267
- modal: {
268
- title?: {
269
- text: string; // Modal title
270
- };
271
- description?: {
272
- text: string; // Modal description
273
- };
274
- actions?: {
275
- submit?: {
276
- text: string; // Submit button text
277
- };
278
- cancel?: {
279
- text: string; // Cancel button text
280
- };
281
- };
282
- feedback?: {
283
- successToast?: {
284
- text: string; // Success message
285
- };
286
- errorToast?: {
287
- text: string; // Error message
288
- };
289
- };
290
- };
291
- };
292
- };
251
+ // Single primary action configuration
252
+ item: ActionItem;
293
253
  alwaysVisible?: boolean; // Whether to always show the primary action (not just on hover)
254
+ } | {
255
+ // Multiple primary actions configuration
256
+ items: ActionItem[];
257
+ alwaysVisible?: boolean; // Whether to always show the primary actions (not just on hover)
294
258
  };
295
259
  secondaryActions?: {
296
- items: {}[]; // Array of action configurations, same structure as primaryAction.item, can include dividers
260
+ items: ActionItem[]; // Array of action configurations, can include dividers
297
261
  inlineCount?: number; // How many secondary actions to show inline before showing popover
298
262
  inlineAlwaysVisible?: boolean; // Whether to always show inline actions (not just on hover)
299
263
  };
@@ -376,6 +340,9 @@ export interface AppConfig {
376
340
  * Whether drag and drop is enabled. When enabled, the [schema](./schema_config.md) must support a "move" action.
377
341
  */
378
342
  enabled: boolean;
343
+ dragAndDropCancel?: {
344
+ id?: string; // Optional ID that maps to a dynamic drag-and-drop cancel override function
345
+ };
379
346
  };
380
347
  layout: [ // Array of layout items that define what components to render
381
348
  {
@@ -522,6 +489,49 @@ export interface AppConfig {
522
489
  }[];
523
490
  }
524
491
 
492
+ type ActionItem = {
493
+ id: string; // Unique identifier for the action
494
+ type: 'update' | 'delete' | 'custom'; // Action type
495
+ label?: string; // Text displayed for the action
496
+ skin?: string; // Visual appearance of the action button (see Action Button Skin Values section)
497
+ biName: string; // MANDATORY: Business intelligence name for analytics tracking
498
+ disabled?: boolean; // Whether the action is disabled
499
+ tooltip?: string; // Tooltip text shown on hover
500
+ update?: { // Required when type is 'update'
501
+ mode: 'page'; // Update mode
502
+ page?: { // Required when mode is 'page'
503
+ id: string; // Entity page ID to navigate to
504
+ };
505
+ };
506
+ delete?: { // Required when type is 'delete'
507
+ mode: 'modal'; // Currently only 'modal' is supported
508
+ modal: {
509
+ title?: {
510
+ text: string; // Modal title
511
+ };
512
+ description?: {
513
+ text: string; // Modal description
514
+ };
515
+ actions?: {
516
+ submit?: {
517
+ text: string; // Submit button text
518
+ };
519
+ cancel?: {
520
+ text: string; // Cancel button text
521
+ };
522
+ };
523
+ feedback?: {
524
+ successToast?: {
525
+ text: string; // Success message
526
+ };
527
+ errorToast?: {
528
+ text: string; // Error message
529
+ };
530
+ };
531
+ };
532
+ };
533
+ };
534
+
525
535
  type LayoutContent =
526
536
  | {
527
537
  type: 'field';
@@ -1607,12 +1617,54 @@ The ActionCell feature adds an interactive action column to collection tables or
1607
1617
 
1608
1618
  ## Placement and Structure
1609
1619
 
1610
- The ActionCell has a two-level structure:
1611
- * `primaryAction`: A single prominent action shown directly in the table/grid row
1620
+ The ActionCell has a flexible structure supporting both single and multiple primary actions:
1621
+ * `primaryAction`: Type: `ActionCellPrimaryAction | ActionCellPrimaryActions` - Can be either a single action or multiple actions shown directly in the table/grid row
1622
+ - **Single Primary Action** (`ActionCellPrimaryAction`): `{ item: ActionCellItemConfig, alwaysVisible?: boolean }`
1623
+ - **Multiple Primary Actions** (`ActionCellPrimaryActions`): `{ items: ActionCellItemConfig[], alwaysVisible?: boolean }`
1612
1624
  * `secondaryActions`: Additional actions shown in a dropdown menu
1613
1625
 
1614
1626
  Both properties are optional, but at least one should be provided for the ActionCell to be useful.
1615
1627
 
1628
+ ### Multiple Primary Actions
1629
+
1630
+ **New Feature**: Primary actions now support both single and multiple action configurations:
1631
+
1632
+ #### Single Primary Action Configuration
1633
+ ```json
1634
+ {
1635
+ "primaryAction": {
1636
+ "item": {
1637
+ "id": "editItem",
1638
+ "type": "update",
1639
+ "label": "Edit",
1640
+ "biName": "edit-item-action"
1641
+ },
1642
+ "alwaysVisible": false
1643
+ }
1644
+ }
1645
+ ```
1646
+
1647
+ #### Multiple Primary Actions Configuration
1648
+ ```json
1649
+ {
1650
+ "primaryAction": {
1651
+ "items": [
1652
+ {
1653
+ "id": "editItem",
1654
+ "type": "update",
1655
+ "label": "Edit"
1656
+ },
1657
+ {
1658
+ "id": "quickApprove",
1659
+ "type": "custom",
1660
+ "label": "Approve"
1661
+ }
1662
+ ],
1663
+ "alwaysVisible": true
1664
+ }
1665
+ }
1666
+ ```
1667
+
1616
1668
  ### Primary Action Visibility Control
1617
1669
 
1618
1670
  **New Feature**: Primary actions now support visibility control through the `alwaysVisible` property. By default, primary actions follow standard table interaction patterns (typically visible on hover), but you can configure them to be always visible for improved accessibility and user discovery.
@@ -1880,25 +1932,37 @@ Follow this decision process when implementing ActionCell:
1880
1932
  - Delete entities? → Use `delete` actions
1881
1933
  - Custom operations? → Use `custom` actions
1882
1934
 
1883
- 2. **Primary vs Secondary**: Choose the most common/important action as primary:
1884
- - Most common operation (typically Edit) → Place in `primaryAction.item`
1935
+ 2. **Primary vs Secondary**: Choose the most common/important actions as primary:
1936
+ - **Single Primary Action**: Most common operation (typically Edit) → Place in `primaryAction.item`
1937
+ - **Multiple Primary Actions**: 2-3 most common operations → Place in `primaryAction.items` array
1885
1938
  - Less common operations → Place in `secondaryActions.items` array
1886
1939
 
1887
- 3. **Primary Action Visibility Strategy**:
1940
+ 3. **Single vs Multiple Primary Actions**:
1941
+ - **Use Single Primary Action** when:
1942
+ - You have one dominant action (e.g., "Edit" for most entities)
1943
+ - Space is limited or you want a clean, minimal interface
1944
+ - The action is contextually obvious
1945
+ - **Use Multiple Primary Actions** when:
1946
+ - You have 2-3 equally important actions (e.g., "Edit", "Approve", "Reject")
1947
+ - Users frequently need to perform multiple actions in sequence
1948
+ - Actions are complementary and often used together
1949
+ - You want to reduce clicks by avoiding secondary menus
1950
+
1951
+ 4. **Primary Action Visibility Strategy**:
1888
1952
  - **Standard Visibility** (`alwaysVisible: false` or omitted): Use for most cases where actions appear on interaction
1889
1953
  - **Always Visible** (`alwaysVisible: true`): Use for critical actions that need constant visibility or when user discovery is important
1890
1954
 
1891
- 4. **Inline Secondary Actions Strategy**:
1955
+ 5. **Inline Secondary Actions Strategy**:
1892
1956
  - **Action Prioritization**: Order `secondaryActions.items` by frequency of use (most used first)
1893
1957
  - **Inline Count**: Use `inlineCount: 1-3` for optimal UX (avoid cluttering)
1894
1958
  - **Visibility Control**:
1895
1959
  - Use `inlineAlwaysVisible: false` (default) for cleaner visual appearance
1896
1960
  - Use `inlineAlwaysVisible: true` only for critical actions requiring constant visibility
1897
1961
 
1898
- 5. **Update Action Mode**:
1962
+ 6. **Update Action Mode**:
1899
1963
  - Complex, full-entity edits → Use `mode: "page"` to navigate to entity page
1900
1964
 
1901
- 6. **Custom Implementation**:
1965
+ 7. **Custom Implementation**:
1902
1966
  - For `custom` actions, you must provide implementations in your code and register them with `AutoPatternsOverridesProvider`
1903
1967
 
1904
1968
  ### ActionCell Validation Checklist
@@ -1912,8 +1976,12 @@ AI agents should verify these requirements before generating ActionCell configur
1912
1976
  ✓ Delete action has a modal configuration
1913
1977
  ✓ Custom actions match implementations in overrides
1914
1978
  ✓ At least one of `primaryAction` or `secondaryActions` is provided
1979
+ ✓ Primary action configuration is valid (Type: `ActionCellPrimaryAction | ActionCellPrimaryActions`):
1980
+ - Single primary action (`ActionCellPrimaryAction`): `{ item: ActionCellItemConfig, alwaysVisible?: boolean }`
1981
+ - Multiple primary actions (`ActionCellPrimaryActions`): `{ items: ActionCellItemConfig[], alwaysVisible?: boolean }`
1915
1982
  ✓ `alwaysVisible` property on primary actions (if specified) is a boolean value
1916
1983
  ✓ Primary action visibility is properly considered for UX (use `alwaysVisible: true` for critical actions)
1984
+ ✓ Multiple primary actions are limited to 2-3 actions for optimal UX
1917
1985
  ✓ `inlineCount` (if specified) is a non-negative number ≤ total secondary actions count
1918
1986
  ✓ `inlineAlwaysVisible` (if specified) is a boolean value
1919
1987
  ✓ Inline secondary actions configuration is applied only when secondary actions exist
@@ -4670,12 +4738,53 @@ Slots provide a powerful way to enhance collection pages with custom functionali
4670
4738
 
4671
4739
  **⚠️ 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.
4672
4740
 
4741
+ ## 🚨 GOLDEN RULE: If it's a Wix Library, Wrap it with errorHandler!
4742
+
4743
+ **Simple Rule for AI Agents:**
4744
+ - **ANY Wix SDK call** from libraries with `@wix/` prefix → **ALWAYS wrap with `errorHandler.withErrorHandler`**
4745
+ - This includes: `@wix/data`, `@wix/stores`, `@wix/events`, `@wix/bookings`, `@wix/crm`, and ALL other `@wix/*` packages
4746
+ - **NO exceptions** - all Wix SDK calls must use error handling
4747
+
4748
+ ### ❌ DON'T DO THIS (Common Mistake)
4749
+
4750
+ ```typescript
4751
+ import { items } from '@wix/data';
4752
+
4753
+ // ❌ WRONG - No errorHandler wrapping
4754
+ async function getAllPets() {
4755
+ try {
4756
+ const result = await items.query('WixPets').find();
4757
+ return result.items;
4758
+ } catch (error) {
4759
+ console.error(error);
4760
+ throw error;
4761
+ }
4762
+ }
4763
+ ```
4764
+
4765
+ ### ✅ DO THIS (Correct Pattern)
4766
+
4767
+ ```typescript
4768
+ import { items } from '@wix/data';
4769
+ import { errorHandler } from '@wix/essentials';
4770
+
4771
+ // ✅ CORRECT - Wix SDK call wrapped with errorHandler
4772
+ async function getAllPets() {
4773
+ return errorHandler.withErrorHandler(
4774
+ async () => {
4775
+ const result = await items.query('WixPets').find();
4776
+ return result.items;
4777
+ },
4778
+ {}
4779
+ );
4780
+ }
4781
+ ```
4673
4782
  ## What Requires Error Handling
4674
4783
 
4675
4784
  **ONLY the following HTTP requests** in your custom data source actions must be wrapped with `errorHandler.withErrorHandler`:
4676
4785
 
4677
4786
  - **httpClient from @wix/essentials** (e.g., `httpClient.request(getDummyEntity(...))`)
4678
- - **Wix APIs** (e.g., `wix/data`, `wix/stores`, `items.get()`, `items.insert()`, `collections.getDataCollection()`)
4787
+ - **Wix API calls from libraries with `wix/` prefix** (e.g., `@wix/data`, `@wix/stores`, `@wix/events`, `@wix/bookings`, `collections.getDataCollection()`, etc.)
4679
4788
  - **httpClient.fetchWithAuth()** calls
4680
4789
 
4681
4790
  **DO NOT use errorHandler.withErrorHandler with:**
@@ -4813,12 +4922,68 @@ return errorHandler.withErrorHandler(async () => {
4813
4922
  }, {});
4814
4923
  ```
4815
4924
 
4816
- **Wix APIs (wix/data, wix/stores):**
4925
+ **Wix APIs (@wix/data, @wix/stores, @wix/crm, etc.):**
4817
4926
 
4818
4927
  ```typescript
4928
+ import { items } from '@wix/data';
4929
+ import { errorHandler } from '@wix/essentials';
4930
+
4931
+ // ✅ CORRECT: Wix Data API calls wrapped with errorHandler
4819
4932
  return errorHandler.withErrorHandler(async () => {
4820
4933
  return await items.get(collectionId, entityId);
4821
4934
  }, {});
4935
+
4936
+ // ✅ CORRECT: Query operations wrapped with errorHandler
4937
+ return errorHandler.withErrorHandler(async () => {
4938
+ return await items.query('WixPets').find();
4939
+ }, {});
4940
+
4941
+ // ✅ CORRECT: Insert operations wrapped with errorHandler
4942
+ return errorHandler.withErrorHandler(async () => {
4943
+ return await items.insert(collectionId, dataItem);
4944
+ }, {});
4945
+
4946
+ // ✅ CORRECT: Update operations wrapped with errorHandler
4947
+ return errorHandler.withErrorHandler(async () => {
4948
+ return await items.update(collectionId, dataItem);
4949
+ }, {});
4950
+
4951
+ // ✅ CORRECT: Delete operations wrapped with errorHandler
4952
+ return errorHandler.withErrorHandler(async () => {
4953
+ return await items.remove(collectionId, itemId);
4954
+ }, {});
4955
+
4956
+ // ✅ CORRECT: Bulk delete operations wrapped with errorHandler
4957
+ return errorHandler.withErrorHandler(async () => {
4958
+ return await items.bulkRemove(collectionId, itemIds);
4959
+ }, {});
4960
+ ```
4961
+
4962
+ **All Other Wix API calls from libraries with `@wix/` prefix:**
4963
+
4964
+ ```typescript
4965
+ import { stores } from '@wix/stores';
4966
+ import { events } from '@wix/events';
4967
+ import { bookings } from '@wix/bookings';
4968
+ import { contacts } from '@wix/crm';
4969
+ import { errorHandler } from '@wix/essentials';
4970
+
4971
+ // ✅ CORRECT: All Wix API calls from @wix/* libraries must be wrapped
4972
+ return errorHandler.withErrorHandler(async () => {
4973
+ return await stores.queryProducts().find();
4974
+ }, {});
4975
+
4976
+ return errorHandler.withErrorHandler(async () => {
4977
+ return await events.queryEvents().find();
4978
+ }, {});
4979
+
4980
+ return errorHandler.withErrorHandler(async () => {
4981
+ return await bookings.queryBookings().find();
4982
+ }, {});
4983
+
4984
+ return errorHandler.withErrorHandler(async () => {
4985
+ return await contacts.queryContacts().find();
4986
+ }, {});
4822
4987
  ```
4823
4988
 
4824
4989
  **httpClient.fetchWithAuth() calls:**
@@ -4866,25 +5031,120 @@ The error handling in your custom data source integrates seamlessly with AutoPat
4866
5031
  **BEFORE implementing ANY custom action or data source, AI agents MUST verify:**
4867
5032
 
4868
5033
  ### ✅ Error Handling Requirements
4869
- - **httpClient from @wix/essentials** is wrapped with `errorHandler.withErrorHandler`
4870
- - **Wix APIs (wix/data, wix/stores, etc)** are wrapped with `errorHandler.withErrorHandler`
4871
- - **httpClient.fetchWithAuth()** calls are wrapped with `errorHandler.withErrorHandler`
4872
- - **External API calls are NOT wrapped** with errorHandler (e.g., fetch(), axios, third-party HTTP clients)
4873
- - **SDK actions are used directly** without error handling (e.g., `sdk.getOptimisticActions()`, `sdk.getSchema()`)
4874
- - **@wix/essentials** is installed as a dependency
5034
+ - **ALL Wix API calls from `@wix/*` libraries** are wrapped with `errorHandler.withErrorHandler`
5035
+ - Including: `@wix/data`, `@wix/stores`, `@wix/events`, `@wix/bookings`, `@wix/crm`, and ALL other `@wix/*` packages
5036
+ - **httpClient from @wix/essentials** is wrapped with `errorHandler.withErrorHandler`
5037
+ - **httpClient.fetchWithAuth()** calls are wrapped with `errorHandler.withErrorHandler`
5038
+ - **External API calls are NOT wrapped** with errorHandler (e.g., fetch(), axios, third-party HTTP clients)
5039
+ - **SDK actions are used directly** without error handling (e.g., `sdk.getOptimisticActions()`, `sdk.getSchema()`)
5040
+ - ✅ **@wix/essentials** is installed as a dependency
5041
+
5042
+ ### ✅ Correct API Signature Verification
5043
+ - ✅ **Check TypeScript/linter errors FIRST** - they tell you when the API is used incorrectly
5044
+ - ✅ **Verify imports are correct** - `import { items } from '@wix/data'` (not default imports)
5045
+ - ✅ **Use correct method signatures** - refer to the API reference section
5046
+ - ✅ **Pass correct parameters** - verify collectionId, itemId, and data structure
5047
+ - ✅ **Handle return values correctly** - `.find()` returns `{ items, ... }`, not just items array
4875
5048
 
4876
5049
  ### ✅ Implementation Checklist
4877
- - **Read this error handling documentation** before implementing any custom action
4878
- - **Identify the type of HTTP request** being made (Wix vs External)
4879
- - **Apply the correct error handling pattern** based on the request type
4880
- - **Test error scenarios** to ensure proper error handling
4881
- - **Verify error messages** are user-friendly and actionable
5050
+ - **Read this error handling documentation** before implementing any custom action
5051
+ - **Identify the type of HTTP request** being made (Wix vs External)
5052
+ - **Apply the correct error handling pattern** based on the request type
5053
+ - **Test error scenarios** to ensure proper error handling
5054
+ - **Verify error messages** are user-friendly and actionable
5055
+ - ✅ **Run linter after implementation** to catch any API usage errors
4882
5056
 
4883
5057
  ### ✅ Common Mistakes to Avoid
4884
5058
  - ❌ **NEVER** wrap external API calls (fetch, axios) with errorHandler
4885
5059
  - ❌ **NEVER** wrap SDK methods (sdk.getOptimisticActions) with errorHandler
4886
5060
  - ❌ **NEVER** forget to wrap Wix HTTP requests with errorHandler
4887
5061
  - ❌ **NEVER** implement custom actions without reading this documentation first
5062
+ - ❌ **NEVER** use incorrect API signatures (e.g., `items.queryDataItems()` instead of `items.query()`)
5063
+ - ❌ **NEVER** ignore TypeScript/linter errors - they indicate incorrect API usage
5064
+ - ❌ **NEVER** use try-catch blocks instead of errorHandler for Wix SDK calls
5065
+
5066
+ ## 🎯 Common Wix SDK API Reference
5067
+
5068
+ ### @wix/data - Data Items API
5069
+
5070
+ **ALWAYS use with errorHandler.withErrorHandler:**
5071
+
5072
+ ```typescript
5073
+ import { items } from '@wix/data';
5074
+ import { errorHandler } from '@wix/essentials';
5075
+
5076
+ // Query all items
5077
+ errorHandler.withErrorHandler(async () => {
5078
+ const result = await items.query('WixPets').find();
5079
+ return result.items;
5080
+ }, {});
5081
+
5082
+ // Query with filters
5083
+ errorHandler.withErrorHandler(async () => {
5084
+ const result = await items.query('WixPets')
5085
+ .contains('name', 'fluffy')
5086
+ .eq('age', 5)
5087
+ .find();
5088
+ return result.items;
5089
+ }, {});
5090
+
5091
+ // Get single item by ID
5092
+ errorHandler.withErrorHandler(async () => {
5093
+ const item = await items.get('WixPets', itemId);
5094
+ return item;
5095
+ }, {});
5096
+
5097
+ // Insert new item
5098
+ errorHandler.withErrorHandler(async () => {
5099
+ const newItem = await items.insert('WixPets', { name: 'Fluffy', age: 5 });
5100
+ return newItem;
5101
+ }, {});
5102
+
5103
+ // Update existing item
5104
+ errorHandler.withErrorHandler(async () => {
5105
+ const updatedItem = await items.update('WixPets', { _id: itemId, name: 'Updated Name' });
5106
+ return updatedItem;
5107
+ }, {});
5108
+
5109
+ // Delete single item
5110
+ errorHandler.withErrorHandler(async () => {
5111
+ await items.remove('WixPets', itemId);
5112
+ }, {});
5113
+
5114
+ // Bulk delete items
5115
+ errorHandler.withErrorHandler(async () => {
5116
+ await items.bulkRemove('WixPets', [itemId1, itemId2, itemId3]);
5117
+ }, {});
5118
+ ```
5119
+
5120
+ ### @wix/essentials - Error Handler
5121
+
5122
+ ```typescript
5123
+ import { errorHandler } from '@wix/essentials';
5124
+
5125
+ // Basic pattern (recommended)
5126
+ errorHandler.withErrorHandler(
5127
+ async () => {
5128
+ // Your Wix SDK call here
5129
+ return await items.query('WixPets').find();
5130
+ },
5131
+ {
5132
+ // Optional: Custom error handling
5133
+ handleError: (error) => {
5134
+ console.error('Custom error handling:', error);
5135
+ throw error; // Re-throw to show error to user
5136
+ },
5137
+ }
5138
+ );
5139
+
5140
+ // Simple pattern (empty options object)
5141
+ errorHandler.withErrorHandler(
5142
+ async () => {
5143
+ return await items.query('WixPets').find();
5144
+ },
5145
+ {}
5146
+ );
5147
+ ```
4888
5148
 
4889
5149
  ## Quick Decision Tree for AI Agents
4890
5150
 
@@ -4895,7 +5155,7 @@ The error handling in your custom data source integrates seamlessly with AutoPat
4895
5155
  - **YES** → Go to step 2
4896
5156
 
4897
5157
  2. **What type of HTTP request?**
4898
- - **Wix APIs** (httpClient, wix/data, wix/stores) → **WRAP with errorHandler.withErrorHandler**
5158
+ - **Wix API libraries with `@wix/` prefix** (@wix/data, @wix/stores, @wix/events, @wix/bookings, @wix/crm) → **WRAP with errorHandler.withErrorHandler**
4899
5159
  - **External APIs** (fetch, axios, third-party) → **NO errorHandler needed**
4900
5160
  - **SDK methods** (sdk.getOptimisticActions, sdk.getSchema) → **NO errorHandler needed**
4901
5161
 
@@ -4904,6 +5164,15 @@ The error handling in your custom data source integrates seamlessly with AutoPat
4904
5164
  - **External requests** are NOT wrapped
4905
5165
  - **SDK methods** are used directly
4906
5166
 
5167
+ ## 🚨 TypeScript Error Detection
5168
+
5169
+ **CRITICAL**: If you see TypeScript/linter errors when using Wix SDK methods:
5170
+
5171
+ 1. ✅ **Check the import** - Make sure you're importing from the correct package
5172
+ 2. ✅ **Check the method signature** - Verify you're using the correct API signature (refer to the API reference above)
5173
+ 3. ✅ **Check errorHandler wrapping** - Ensure the call is wrapped with `errorHandler.withErrorHandler`
5174
+ 4. ✅ **Run linter** - Read the linter error message carefully; it tells you what's wrong
5175
+
4907
5176
  ## Complete Examples for All Custom Action Types
4908
5177
 
4909
5178
  ### ActionCell Custom Actions
@@ -5096,9 +5365,44 @@ export const myCustomDataSource = async (collectionId: string, context: any) =>
5096
5365
  };
5097
5366
  ```
5098
5367
 
5368
+ ### Actions Using Wix API Libraries (REQUIRES errorHandler)
5369
+
5370
+ **Example 7: Action using Wix API libraries with `wix/` prefix (REQUIRES errorHandler)**
5371
+ ```typescript
5372
+ import { errorHandler } from '@wix/essentials';
5373
+ import { data } from '@wix/data';
5374
+ import { stores } from '@wix/stores';
5375
+ import { CustomActionCellActionResolver } from '@wix/auto-patterns';
5376
+
5377
+ export const syncWithWixData: CustomActionCellActionResolver = (params) => {
5378
+ const { actionParams, sdk } = params;
5379
+ const { item } = actionParams;
5380
+
5381
+ return {
5382
+ label: 'Sync with Wix Data',
5383
+ icon: <SyncIcon />,
5384
+ onClick: () => {
5385
+ // ✅ CORRECT: Wix API library calls wrapped with errorHandler
5386
+ errorHandler.withErrorHandler(
5387
+ async () => {
5388
+ // Using @wix/data library
5389
+ const dataResult = await data.query('MyCollection').eq('id', item.id).find();
5390
+
5391
+ // Using @wix/stores library
5392
+ const productResult = await stores.queryProducts().eq('sku', item.sku).find();
5393
+
5394
+ return { dataResult, productResult };
5395
+ },
5396
+ {}
5397
+ );
5398
+ },
5399
+ };
5400
+ };
5401
+ ```
5402
+
5099
5403
  ### Actions Using SDK Methods (NO errorHandler needed)
5100
5404
 
5101
- **Example 7: Action using SDK methods (NO errorHandler needed)**
5405
+ **Example 8: Action using SDK methods (NO errorHandler needed)**
5102
5406
  ```typescript
5103
5407
  import { CustomActionCellActionResolver } from '@wix/auto-patterns';
5104
5408