@wix/auto-patterns 1.40.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 (82) 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/useDragAndDropBaseProps.js +7 -3
  16. package/dist/cjs/hooks/useDragAndDropBaseProps.js.map +1 -1
  17. package/dist/cjs/providers/AutoPatternsOverridesContext.js +1 -1
  18. package/dist/cjs/providers/AutoPatternsOverridesContext.js.map +1 -1
  19. package/dist/cjs/testkit/enzyme.js +8 -0
  20. package/dist/cjs/testkit/enzyme.js.map +1 -0
  21. package/dist/cjs/testkit/jsdom.js +8 -0
  22. package/dist/cjs/testkit/jsdom.js.map +1 -0
  23. package/dist/cjs/testkit/playwright.js +8 -0
  24. package/dist/cjs/testkit/playwright.js.map +1 -0
  25. package/dist/cjs/testkit/puppeteer.js +8 -0
  26. package/dist/cjs/testkit/puppeteer.js.map +1 -0
  27. package/dist/cjs/types/CollectionPageConfig.js.map +1 -1
  28. package/dist/esm/components/AutoPatternsApp/AutoPatternsApp.uni.driver.js +50 -0
  29. package/dist/esm/components/AutoPatternsApp/AutoPatternsApp.uni.driver.js.map +1 -0
  30. package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +0 -1
  31. package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
  32. package/dist/esm/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.js +37 -0
  33. package/dist/esm/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.js.map +1 -0
  34. package/dist/esm/exports/testkit/enzyme.js +2 -0
  35. package/dist/esm/exports/testkit/enzyme.js.map +1 -0
  36. package/dist/esm/exports/testkit/jsdom.js +2 -0
  37. package/dist/esm/exports/testkit/jsdom.js.map +1 -0
  38. package/dist/esm/exports/testkit/playwright.js +2 -0
  39. package/dist/esm/exports/testkit/playwright.js.map +1 -0
  40. package/dist/esm/exports/testkit/puppeteer.js +2 -0
  41. package/dist/esm/exports/testkit/puppeteer.js.map +1 -0
  42. package/dist/esm/hooks/useDragAndDropBaseProps.js +8 -4
  43. package/dist/esm/hooks/useDragAndDropBaseProps.js.map +1 -1
  44. package/dist/esm/providers/AutoPatternsOverridesContext.js.map +1 -1
  45. package/dist/esm/testkit/enzyme.js +4 -0
  46. package/dist/esm/testkit/enzyme.js.map +1 -0
  47. package/dist/esm/testkit/jsdom.js +4 -0
  48. package/dist/esm/testkit/jsdom.js.map +1 -0
  49. package/dist/esm/testkit/playwright.js +4 -0
  50. package/dist/esm/testkit/playwright.js.map +1 -0
  51. package/dist/esm/testkit/puppeteer.js +4 -0
  52. package/dist/esm/testkit/puppeteer.js.map +1 -0
  53. package/dist/esm/types/CollectionPageConfig.js.map +1 -1
  54. package/dist/types/components/AutoPatternsApp/AutoPatternsApp.uni.driver.d.ts +45 -0
  55. package/dist/types/components/AutoPatternsApp/AutoPatternsApp.uni.driver.d.ts.map +1 -0
  56. package/dist/types/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.d.ts +81 -0
  57. package/dist/types/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.d.ts.map +1 -0
  58. package/dist/types/exports/testkit/enzyme.d.ts +2 -0
  59. package/dist/types/exports/testkit/enzyme.d.ts.map +1 -0
  60. package/dist/types/exports/testkit/jsdom.d.ts +2 -0
  61. package/dist/types/exports/testkit/jsdom.d.ts.map +1 -0
  62. package/dist/types/exports/testkit/playwright.d.ts +2 -0
  63. package/dist/types/exports/testkit/playwright.d.ts.map +1 -0
  64. package/dist/types/exports/testkit/puppeteer.d.ts +2 -0
  65. package/dist/types/exports/testkit/puppeteer.d.ts.map +1 -0
  66. package/dist/types/hooks/useDragAndDropBaseProps.d.ts.map +1 -1
  67. package/dist/types/providers/AutoPatternsOverridesContext.d.ts +1 -0
  68. package/dist/types/providers/AutoPatternsOverridesContext.d.ts.map +1 -1
  69. package/dist/types/testkit/enzyme.d.ts +16 -0
  70. package/dist/types/testkit/enzyme.d.ts.map +1 -0
  71. package/dist/types/testkit/jsdom.d.ts +16 -0
  72. package/dist/types/testkit/jsdom.d.ts.map +1 -0
  73. package/dist/types/testkit/playwright.d.ts +20 -0
  74. package/dist/types/testkit/playwright.d.ts.map +1 -0
  75. package/dist/types/testkit/puppeteer.d.ts +20 -0
  76. package/dist/types/testkit/puppeteer.d.ts.map +1 -0
  77. package/dist/types/types/CollectionPageConfig.d.ts +6 -0
  78. package/dist/types/types/CollectionPageConfig.d.ts.map +1 -1
  79. package/mcp-docs/app_config_structure.md +3 -0
  80. package/mcp-docs/auto-patterns-guide.md +254 -15
  81. package/mcp-docs/error_handling.md +251 -15
  82. package/package.json +43 -15
@@ -340,6 +340,9 @@ export interface AppConfig {
340
340
  * Whether drag and drop is enabled. When enabled, the [schema](./schema_config.md) must support a "move" action.
341
341
  */
342
342
  enabled: boolean;
343
+ dragAndDropCancel?: {
344
+ id?: string; // Optional ID that maps to a dynamic drag-and-drop cancel override function
345
+ };
343
346
  };
344
347
  layout: [ // Array of layout items that define what components to render
345
348
  {
@@ -4735,12 +4738,53 @@ Slots provide a powerful way to enhance collection pages with custom functionali
4735
4738
 
4736
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.
4737
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
+ ```
4738
4782
  ## What Requires Error Handling
4739
4783
 
4740
4784
  **ONLY the following HTTP requests** in your custom data source actions must be wrapped with `errorHandler.withErrorHandler`:
4741
4785
 
4742
4786
  - **httpClient from @wix/essentials** (e.g., `httpClient.request(getDummyEntity(...))`)
4743
- - **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.)
4744
4788
  - **httpClient.fetchWithAuth()** calls
4745
4789
 
4746
4790
  **DO NOT use errorHandler.withErrorHandler with:**
@@ -4878,12 +4922,68 @@ return errorHandler.withErrorHandler(async () => {
4878
4922
  }, {});
4879
4923
  ```
4880
4924
 
4881
- **Wix APIs (wix/data, wix/stores):**
4925
+ **Wix APIs (@wix/data, @wix/stores, @wix/crm, etc.):**
4882
4926
 
4883
4927
  ```typescript
4928
+ import { items } from '@wix/data';
4929
+ import { errorHandler } from '@wix/essentials';
4930
+
4931
+ // ✅ CORRECT: Wix Data API calls wrapped with errorHandler
4884
4932
  return errorHandler.withErrorHandler(async () => {
4885
4933
  return await items.get(collectionId, entityId);
4886
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
+ }, {});
4887
4987
  ```
4888
4988
 
4889
4989
  **httpClient.fetchWithAuth() calls:**
@@ -4931,25 +5031,120 @@ The error handling in your custom data source integrates seamlessly with AutoPat
4931
5031
  **BEFORE implementing ANY custom action or data source, AI agents MUST verify:**
4932
5032
 
4933
5033
  ### ✅ Error Handling Requirements
4934
- - **httpClient from @wix/essentials** is wrapped with `errorHandler.withErrorHandler`
4935
- - **Wix APIs (wix/data, wix/stores, etc)** are wrapped with `errorHandler.withErrorHandler`
4936
- - **httpClient.fetchWithAuth()** calls are wrapped with `errorHandler.withErrorHandler`
4937
- - **External API calls are NOT wrapped** with errorHandler (e.g., fetch(), axios, third-party HTTP clients)
4938
- - **SDK actions are used directly** without error handling (e.g., `sdk.getOptimisticActions()`, `sdk.getSchema()`)
4939
- - **@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
4940
5048
 
4941
5049
  ### ✅ Implementation Checklist
4942
- - **Read this error handling documentation** before implementing any custom action
4943
- - **Identify the type of HTTP request** being made (Wix vs External)
4944
- - **Apply the correct error handling pattern** based on the request type
4945
- - **Test error scenarios** to ensure proper error handling
4946
- - **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
4947
5056
 
4948
5057
  ### ✅ Common Mistakes to Avoid
4949
5058
  - ❌ **NEVER** wrap external API calls (fetch, axios) with errorHandler
4950
5059
  - ❌ **NEVER** wrap SDK methods (sdk.getOptimisticActions) with errorHandler
4951
5060
  - ❌ **NEVER** forget to wrap Wix HTTP requests with errorHandler
4952
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
+ ```
4953
5148
 
4954
5149
  ## Quick Decision Tree for AI Agents
4955
5150
 
@@ -4960,7 +5155,7 @@ The error handling in your custom data source integrates seamlessly with AutoPat
4960
5155
  - **YES** → Go to step 2
4961
5156
 
4962
5157
  2. **What type of HTTP request?**
4963
- - **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**
4964
5159
  - **External APIs** (fetch, axios, third-party) → **NO errorHandler needed**
4965
5160
  - **SDK methods** (sdk.getOptimisticActions, sdk.getSchema) → **NO errorHandler needed**
4966
5161
 
@@ -4969,6 +5164,15 @@ The error handling in your custom data source integrates seamlessly with AutoPat
4969
5164
  - **External requests** are NOT wrapped
4970
5165
  - **SDK methods** are used directly
4971
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
+
4972
5176
  ## Complete Examples for All Custom Action Types
4973
5177
 
4974
5178
  ### ActionCell Custom Actions
@@ -5161,9 +5365,44 @@ export const myCustomDataSource = async (collectionId: string, context: any) =>
5161
5365
  };
5162
5366
  ```
5163
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
+
5164
5403
  ### Actions Using SDK Methods (NO errorHandler needed)
5165
5404
 
5166
- **Example 7: Action using SDK methods (NO errorHandler needed)**
5405
+ **Example 8: Action using SDK methods (NO errorHandler needed)**
5167
5406
  ```typescript
5168
5407
  import { CustomActionCellActionResolver } from '@wix/auto-patterns';
5169
5408
 
@@ -11,12 +11,53 @@
11
11
 
12
12
  **⚠️ 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.
13
13
 
14
+ ## 🚨 GOLDEN RULE: If it's a Wix Library, Wrap it with errorHandler!
15
+
16
+ **Simple Rule for AI Agents:**
17
+ - **ANY Wix SDK call** from libraries with `@wix/` prefix → **ALWAYS wrap with `errorHandler.withErrorHandler`**
18
+ - This includes: `@wix/data`, `@wix/stores`, `@wix/events`, `@wix/bookings`, `@wix/crm`, and ALL other `@wix/*` packages
19
+ - **NO exceptions** - all Wix SDK calls must use error handling
20
+
21
+ ### ❌ DON'T DO THIS (Common Mistake)
22
+
23
+ ```typescript
24
+ import { items } from '@wix/data';
25
+
26
+ // ❌ WRONG - No errorHandler wrapping
27
+ async function getAllPets() {
28
+ try {
29
+ const result = await items.query('WixPets').find();
30
+ return result.items;
31
+ } catch (error) {
32
+ console.error(error);
33
+ throw error;
34
+ }
35
+ }
36
+ ```
37
+
38
+ ### ✅ DO THIS (Correct Pattern)
39
+
40
+ ```typescript
41
+ import { items } from '@wix/data';
42
+ import { errorHandler } from '@wix/essentials';
43
+
44
+ // ✅ CORRECT - Wix SDK call wrapped with errorHandler
45
+ async function getAllPets() {
46
+ return errorHandler.withErrorHandler(
47
+ async () => {
48
+ const result = await items.query('WixPets').find();
49
+ return result.items;
50
+ },
51
+ {}
52
+ );
53
+ }
54
+ ```
14
55
  ## What Requires Error Handling
15
56
 
16
57
  **ONLY the following HTTP requests** in your custom data source actions must be wrapped with `errorHandler.withErrorHandler`:
17
58
 
18
59
  - **httpClient from @wix/essentials** (e.g., `httpClient.request(getDummyEntity(...))`)
19
- - **Wix APIs** (e.g., `wix/data`, `wix/stores`, `items.get()`, `items.insert()`, `collections.getDataCollection()`)
60
+ - **Wix API calls from libraries with `wix/` prefix** (e.g., `@wix/data`, `@wix/stores`, `@wix/events`, `@wix/bookings`, `collections.getDataCollection()`, etc.)
20
61
  - **httpClient.fetchWithAuth()** calls
21
62
 
22
63
  **DO NOT use errorHandler.withErrorHandler with:**
@@ -154,12 +195,68 @@ return errorHandler.withErrorHandler(async () => {
154
195
  }, {});
155
196
  ```
156
197
 
157
- **Wix APIs (wix/data, wix/stores):**
198
+ **Wix APIs (@wix/data, @wix/stores, @wix/crm, etc.):**
158
199
 
159
200
  ```typescript
201
+ import { items } from '@wix/data';
202
+ import { errorHandler } from '@wix/essentials';
203
+
204
+ // ✅ CORRECT: Wix Data API calls wrapped with errorHandler
160
205
  return errorHandler.withErrorHandler(async () => {
161
206
  return await items.get(collectionId, entityId);
162
207
  }, {});
208
+
209
+ // ✅ CORRECT: Query operations wrapped with errorHandler
210
+ return errorHandler.withErrorHandler(async () => {
211
+ return await items.query('WixPets').find();
212
+ }, {});
213
+
214
+ // ✅ CORRECT: Insert operations wrapped with errorHandler
215
+ return errorHandler.withErrorHandler(async () => {
216
+ return await items.insert(collectionId, dataItem);
217
+ }, {});
218
+
219
+ // ✅ CORRECT: Update operations wrapped with errorHandler
220
+ return errorHandler.withErrorHandler(async () => {
221
+ return await items.update(collectionId, dataItem);
222
+ }, {});
223
+
224
+ // ✅ CORRECT: Delete operations wrapped with errorHandler
225
+ return errorHandler.withErrorHandler(async () => {
226
+ return await items.remove(collectionId, itemId);
227
+ }, {});
228
+
229
+ // ✅ CORRECT: Bulk delete operations wrapped with errorHandler
230
+ return errorHandler.withErrorHandler(async () => {
231
+ return await items.bulkRemove(collectionId, itemIds);
232
+ }, {});
233
+ ```
234
+
235
+ **All Other Wix API calls from libraries with `@wix/` prefix:**
236
+
237
+ ```typescript
238
+ import { stores } from '@wix/stores';
239
+ import { events } from '@wix/events';
240
+ import { bookings } from '@wix/bookings';
241
+ import { contacts } from '@wix/crm';
242
+ import { errorHandler } from '@wix/essentials';
243
+
244
+ // ✅ CORRECT: All Wix API calls from @wix/* libraries must be wrapped
245
+ return errorHandler.withErrorHandler(async () => {
246
+ return await stores.queryProducts().find();
247
+ }, {});
248
+
249
+ return errorHandler.withErrorHandler(async () => {
250
+ return await events.queryEvents().find();
251
+ }, {});
252
+
253
+ return errorHandler.withErrorHandler(async () => {
254
+ return await bookings.queryBookings().find();
255
+ }, {});
256
+
257
+ return errorHandler.withErrorHandler(async () => {
258
+ return await contacts.queryContacts().find();
259
+ }, {});
163
260
  ```
164
261
 
165
262
  **httpClient.fetchWithAuth() calls:**
@@ -207,25 +304,120 @@ The error handling in your custom data source integrates seamlessly with AutoPat
207
304
  **BEFORE implementing ANY custom action or data source, AI agents MUST verify:**
208
305
 
209
306
  ### ✅ Error Handling Requirements
210
- - **httpClient from @wix/essentials** is wrapped with `errorHandler.withErrorHandler`
211
- - **Wix APIs (wix/data, wix/stores, etc)** are wrapped with `errorHandler.withErrorHandler`
212
- - **httpClient.fetchWithAuth()** calls are wrapped with `errorHandler.withErrorHandler`
213
- - **External API calls are NOT wrapped** with errorHandler (e.g., fetch(), axios, third-party HTTP clients)
214
- - **SDK actions are used directly** without error handling (e.g., `sdk.getOptimisticActions()`, `sdk.getSchema()`)
215
- - **@wix/essentials** is installed as a dependency
307
+ - **ALL Wix API calls from `@wix/*` libraries** are wrapped with `errorHandler.withErrorHandler`
308
+ - Including: `@wix/data`, `@wix/stores`, `@wix/events`, `@wix/bookings`, `@wix/crm`, and ALL other `@wix/*` packages
309
+ - **httpClient from @wix/essentials** is wrapped with `errorHandler.withErrorHandler`
310
+ - **httpClient.fetchWithAuth()** calls are wrapped with `errorHandler.withErrorHandler`
311
+ - **External API calls are NOT wrapped** with errorHandler (e.g., fetch(), axios, third-party HTTP clients)
312
+ - **SDK actions are used directly** without error handling (e.g., `sdk.getOptimisticActions()`, `sdk.getSchema()`)
313
+ - ✅ **@wix/essentials** is installed as a dependency
314
+
315
+ ### ✅ Correct API Signature Verification
316
+ - ✅ **Check TypeScript/linter errors FIRST** - they tell you when the API is used incorrectly
317
+ - ✅ **Verify imports are correct** - `import { items } from '@wix/data'` (not default imports)
318
+ - ✅ **Use correct method signatures** - refer to the API reference section
319
+ - ✅ **Pass correct parameters** - verify collectionId, itemId, and data structure
320
+ - ✅ **Handle return values correctly** - `.find()` returns `{ items, ... }`, not just items array
216
321
 
217
322
  ### ✅ Implementation Checklist
218
- - **Read this error handling documentation** before implementing any custom action
219
- - **Identify the type of HTTP request** being made (Wix vs External)
220
- - **Apply the correct error handling pattern** based on the request type
221
- - **Test error scenarios** to ensure proper error handling
222
- - **Verify error messages** are user-friendly and actionable
323
+ - **Read this error handling documentation** before implementing any custom action
324
+ - **Identify the type of HTTP request** being made (Wix vs External)
325
+ - **Apply the correct error handling pattern** based on the request type
326
+ - **Test error scenarios** to ensure proper error handling
327
+ - **Verify error messages** are user-friendly and actionable
328
+ - ✅ **Run linter after implementation** to catch any API usage errors
223
329
 
224
330
  ### ✅ Common Mistakes to Avoid
225
331
  - ❌ **NEVER** wrap external API calls (fetch, axios) with errorHandler
226
332
  - ❌ **NEVER** wrap SDK methods (sdk.getOptimisticActions) with errorHandler
227
333
  - ❌ **NEVER** forget to wrap Wix HTTP requests with errorHandler
228
334
  - ❌ **NEVER** implement custom actions without reading this documentation first
335
+ - ❌ **NEVER** use incorrect API signatures (e.g., `items.queryDataItems()` instead of `items.query()`)
336
+ - ❌ **NEVER** ignore TypeScript/linter errors - they indicate incorrect API usage
337
+ - ❌ **NEVER** use try-catch blocks instead of errorHandler for Wix SDK calls
338
+
339
+ ## 🎯 Common Wix SDK API Reference
340
+
341
+ ### @wix/data - Data Items API
342
+
343
+ **ALWAYS use with errorHandler.withErrorHandler:**
344
+
345
+ ```typescript
346
+ import { items } from '@wix/data';
347
+ import { errorHandler } from '@wix/essentials';
348
+
349
+ // Query all items
350
+ errorHandler.withErrorHandler(async () => {
351
+ const result = await items.query('WixPets').find();
352
+ return result.items;
353
+ }, {});
354
+
355
+ // Query with filters
356
+ errorHandler.withErrorHandler(async () => {
357
+ const result = await items.query('WixPets')
358
+ .contains('name', 'fluffy')
359
+ .eq('age', 5)
360
+ .find();
361
+ return result.items;
362
+ }, {});
363
+
364
+ // Get single item by ID
365
+ errorHandler.withErrorHandler(async () => {
366
+ const item = await items.get('WixPets', itemId);
367
+ return item;
368
+ }, {});
369
+
370
+ // Insert new item
371
+ errorHandler.withErrorHandler(async () => {
372
+ const newItem = await items.insert('WixPets', { name: 'Fluffy', age: 5 });
373
+ return newItem;
374
+ }, {});
375
+
376
+ // Update existing item
377
+ errorHandler.withErrorHandler(async () => {
378
+ const updatedItem = await items.update('WixPets', { _id: itemId, name: 'Updated Name' });
379
+ return updatedItem;
380
+ }, {});
381
+
382
+ // Delete single item
383
+ errorHandler.withErrorHandler(async () => {
384
+ await items.remove('WixPets', itemId);
385
+ }, {});
386
+
387
+ // Bulk delete items
388
+ errorHandler.withErrorHandler(async () => {
389
+ await items.bulkRemove('WixPets', [itemId1, itemId2, itemId3]);
390
+ }, {});
391
+ ```
392
+
393
+ ### @wix/essentials - Error Handler
394
+
395
+ ```typescript
396
+ import { errorHandler } from '@wix/essentials';
397
+
398
+ // Basic pattern (recommended)
399
+ errorHandler.withErrorHandler(
400
+ async () => {
401
+ // Your Wix SDK call here
402
+ return await items.query('WixPets').find();
403
+ },
404
+ {
405
+ // Optional: Custom error handling
406
+ handleError: (error) => {
407
+ console.error('Custom error handling:', error);
408
+ throw error; // Re-throw to show error to user
409
+ },
410
+ }
411
+ );
412
+
413
+ // Simple pattern (empty options object)
414
+ errorHandler.withErrorHandler(
415
+ async () => {
416
+ return await items.query('WixPets').find();
417
+ },
418
+ {}
419
+ );
420
+ ```
229
421
 
230
422
  ## Quick Decision Tree for AI Agents
231
423
 
@@ -236,7 +428,7 @@ The error handling in your custom data source integrates seamlessly with AutoPat
236
428
  - **YES** → Go to step 2
237
429
 
238
430
  2. **What type of HTTP request?**
239
- - **Wix APIs** (httpClient, wix/data, wix/stores) → **WRAP with errorHandler.withErrorHandler**
431
+ - **Wix API libraries with `@wix/` prefix** (@wix/data, @wix/stores, @wix/events, @wix/bookings, @wix/crm) → **WRAP with errorHandler.withErrorHandler**
240
432
  - **External APIs** (fetch, axios, third-party) → **NO errorHandler needed**
241
433
  - **SDK methods** (sdk.getOptimisticActions, sdk.getSchema) → **NO errorHandler needed**
242
434
 
@@ -245,6 +437,15 @@ The error handling in your custom data source integrates seamlessly with AutoPat
245
437
  - **External requests** are NOT wrapped
246
438
  - **SDK methods** are used directly
247
439
 
440
+ ## 🚨 TypeScript Error Detection
441
+
442
+ **CRITICAL**: If you see TypeScript/linter errors when using Wix SDK methods:
443
+
444
+ 1. ✅ **Check the import** - Make sure you're importing from the correct package
445
+ 2. ✅ **Check the method signature** - Verify you're using the correct API signature (refer to the API reference above)
446
+ 3. ✅ **Check errorHandler wrapping** - Ensure the call is wrapped with `errorHandler.withErrorHandler`
447
+ 4. ✅ **Run linter** - Read the linter error message carefully; it tells you what's wrong
448
+
248
449
  ## Complete Examples for All Custom Action Types
249
450
 
250
451
  ### ActionCell Custom Actions
@@ -437,9 +638,44 @@ export const myCustomDataSource = async (collectionId: string, context: any) =>
437
638
  };
438
639
  ```
439
640
 
641
+ ### Actions Using Wix API Libraries (REQUIRES errorHandler)
642
+
643
+ **Example 7: Action using Wix API libraries with `wix/` prefix (REQUIRES errorHandler)**
644
+ ```typescript
645
+ import { errorHandler } from '@wix/essentials';
646
+ import { data } from '@wix/data';
647
+ import { stores } from '@wix/stores';
648
+ import { CustomActionCellActionResolver } from '@wix/auto-patterns';
649
+
650
+ export const syncWithWixData: CustomActionCellActionResolver = (params) => {
651
+ const { actionParams, sdk } = params;
652
+ const { item } = actionParams;
653
+
654
+ return {
655
+ label: 'Sync with Wix Data',
656
+ icon: <SyncIcon />,
657
+ onClick: () => {
658
+ // ✅ CORRECT: Wix API library calls wrapped with errorHandler
659
+ errorHandler.withErrorHandler(
660
+ async () => {
661
+ // Using @wix/data library
662
+ const dataResult = await data.query('MyCollection').eq('id', item.id).find();
663
+
664
+ // Using @wix/stores library
665
+ const productResult = await stores.queryProducts().eq('sku', item.sku).find();
666
+
667
+ return { dataResult, productResult };
668
+ },
669
+ {}
670
+ );
671
+ },
672
+ };
673
+ };
674
+ ```
675
+
440
676
  ### Actions Using SDK Methods (NO errorHandler needed)
441
677
 
442
- **Example 7: Action using SDK methods (NO errorHandler needed)**
678
+ **Example 8: Action using SDK methods (NO errorHandler needed)**
443
679
  ```typescript
444
680
  import { CustomActionCellActionResolver } from '@wix/auto-patterns';
445
681