@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.
- package/dist/cjs/components/AutoPatternsApp/AutoPatternsApp.uni.driver.js +57 -0
- package/dist/cjs/components/AutoPatternsApp/AutoPatternsApp.uni.driver.js.map +1 -0
- package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +0 -1
- package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.js +42 -0
- package/dist/cjs/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.js.map +1 -0
- package/dist/cjs/exports/testkit/enzyme.js +10 -0
- package/dist/cjs/exports/testkit/enzyme.js.map +1 -0
- package/dist/cjs/exports/testkit/jsdom.js +10 -0
- package/dist/cjs/exports/testkit/jsdom.js.map +1 -0
- package/dist/cjs/exports/testkit/playwright.js +10 -0
- package/dist/cjs/exports/testkit/playwright.js.map +1 -0
- package/dist/cjs/exports/testkit/puppeteer.js +10 -0
- package/dist/cjs/exports/testkit/puppeteer.js.map +1 -0
- package/dist/cjs/hooks/useActionCell.js +14 -8
- package/dist/cjs/hooks/useActionCell.js.map +1 -1
- package/dist/cjs/hooks/useDragAndDropBaseProps.js +7 -3
- package/dist/cjs/hooks/useDragAndDropBaseProps.js.map +1 -1
- package/dist/cjs/providers/AutoPatternsOverridesContext.js +1 -1
- package/dist/cjs/providers/AutoPatternsOverridesContext.js.map +1 -1
- package/dist/cjs/testkit/enzyme.js +8 -0
- package/dist/cjs/testkit/enzyme.js.map +1 -0
- package/dist/cjs/testkit/jsdom.js +8 -0
- package/dist/cjs/testkit/jsdom.js.map +1 -0
- package/dist/cjs/testkit/playwright.js +8 -0
- package/dist/cjs/testkit/playwright.js.map +1 -0
- package/dist/cjs/testkit/puppeteer.js +8 -0
- package/dist/cjs/testkit/puppeteer.js.map +1 -0
- package/dist/cjs/types/CollectionPageConfig.js.map +1 -1
- package/dist/cjs/types/actions/actionCell.js.map +1 -1
- package/dist/esm/components/AutoPatternsApp/AutoPatternsApp.uni.driver.js +50 -0
- package/dist/esm/components/AutoPatternsApp/AutoPatternsApp.uni.driver.js.map +1 -0
- package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +0 -1
- package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.js +37 -0
- package/dist/esm/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.js.map +1 -0
- package/dist/esm/exports/testkit/enzyme.js +2 -0
- package/dist/esm/exports/testkit/enzyme.js.map +1 -0
- package/dist/esm/exports/testkit/jsdom.js +2 -0
- package/dist/esm/exports/testkit/jsdom.js.map +1 -0
- package/dist/esm/exports/testkit/playwright.js +2 -0
- package/dist/esm/exports/testkit/playwright.js.map +1 -0
- package/dist/esm/exports/testkit/puppeteer.js +2 -0
- package/dist/esm/exports/testkit/puppeteer.js.map +1 -0
- package/dist/esm/hooks/useActionCell.js +14 -8
- package/dist/esm/hooks/useActionCell.js.map +1 -1
- package/dist/esm/hooks/useDragAndDropBaseProps.js +8 -4
- package/dist/esm/hooks/useDragAndDropBaseProps.js.map +1 -1
- package/dist/esm/providers/AutoPatternsOverridesContext.js.map +1 -1
- package/dist/esm/testkit/enzyme.js +4 -0
- package/dist/esm/testkit/enzyme.js.map +1 -0
- package/dist/esm/testkit/jsdom.js +4 -0
- package/dist/esm/testkit/jsdom.js.map +1 -0
- package/dist/esm/testkit/playwright.js +4 -0
- package/dist/esm/testkit/playwright.js.map +1 -0
- package/dist/esm/testkit/puppeteer.js +4 -0
- package/dist/esm/testkit/puppeteer.js.map +1 -0
- package/dist/esm/types/CollectionPageConfig.js.map +1 -1
- package/dist/esm/types/actions/actionCell.js.map +1 -1
- package/dist/types/components/AutoPatternsApp/AutoPatternsApp.uni.driver.d.ts +45 -0
- package/dist/types/components/AutoPatternsApp/AutoPatternsApp.uni.driver.d.ts.map +1 -0
- package/dist/types/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.d.ts +81 -0
- package/dist/types/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.d.ts.map +1 -0
- package/dist/types/exports/testkit/enzyme.d.ts +2 -0
- package/dist/types/exports/testkit/enzyme.d.ts.map +1 -0
- package/dist/types/exports/testkit/jsdom.d.ts +2 -0
- package/dist/types/exports/testkit/jsdom.d.ts.map +1 -0
- package/dist/types/exports/testkit/playwright.d.ts +2 -0
- package/dist/types/exports/testkit/playwright.d.ts.map +1 -0
- package/dist/types/exports/testkit/puppeteer.d.ts +2 -0
- package/dist/types/exports/testkit/puppeteer.d.ts.map +1 -0
- package/dist/types/hooks/useActionCell.d.ts.map +1 -1
- package/dist/types/hooks/useDragAndDropBaseProps.d.ts.map +1 -1
- package/dist/types/providers/AutoPatternsOverridesContext.d.ts +1 -0
- package/dist/types/providers/AutoPatternsOverridesContext.d.ts.map +1 -1
- package/dist/types/testkit/enzyme.d.ts +16 -0
- package/dist/types/testkit/enzyme.d.ts.map +1 -0
- package/dist/types/testkit/jsdom.d.ts +16 -0
- package/dist/types/testkit/jsdom.d.ts.map +1 -0
- package/dist/types/testkit/playwright.d.ts +20 -0
- package/dist/types/testkit/playwright.d.ts.map +1 -0
- package/dist/types/testkit/puppeteer.d.ts +20 -0
- package/dist/types/testkit/puppeteer.d.ts.map +1 -0
- package/dist/types/types/CollectionPageConfig.d.ts +6 -0
- package/dist/types/types/CollectionPageConfig.d.ts.map +1 -1
- package/dist/types/types/actions/actionCell.d.ts +13 -1
- package/dist/types/types/actions/actionCell.d.ts.map +1 -1
- package/mcp-docs/action_cell.md +66 -8
- package/mcp-docs/app_config_structure.md +53 -43
- package/mcp-docs/auto-patterns-guide.md +370 -66
- package/mcp-docs/error_handling.md +251 -15
- package/package.json +43 -15
|
@@ -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
|
|
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
|
-
- **
|
|
211
|
-
-
|
|
212
|
-
- **httpClient
|
|
213
|
-
- **
|
|
214
|
-
- **
|
|
215
|
-
-
|
|
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
|
|
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
|
|
678
|
+
**Example 8: Action using SDK methods (NO errorHandler needed)**
|
|
443
679
|
```typescript
|
|
444
680
|
import { CustomActionCellActionResolver } from '@wix/auto-patterns';
|
|
445
681
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/auto-patterns",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.41.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Matvey Oklander",
|
|
@@ -10,6 +10,33 @@
|
|
|
10
10
|
"module": "dist/esm/index.js",
|
|
11
11
|
"sideEffects": false,
|
|
12
12
|
"types": "dist/types/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"require": "./dist/cjs/index.js",
|
|
16
|
+
"import": "./dist/esm/index.js",
|
|
17
|
+
"types": "./dist/types/index.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./testkit/enzyme": {
|
|
20
|
+
"require": "./dist/cjs/exports/testkit/enzyme.js",
|
|
21
|
+
"import": "./dist/esm/exports/testkit/enzyme.js",
|
|
22
|
+
"types": "./dist/types/exports/testkit/enzyme.d.ts"
|
|
23
|
+
},
|
|
24
|
+
"./testkit/jsdom": {
|
|
25
|
+
"require": "./dist/cjs/exports/testkit/jsdom.js",
|
|
26
|
+
"import": "./dist/esm/exports/testkit/jsdom.js",
|
|
27
|
+
"types": "./dist/types/exports/testkit/jsdom.d.ts"
|
|
28
|
+
},
|
|
29
|
+
"./testkit/playwright": {
|
|
30
|
+
"require": "./dist/cjs/exports/testkit/playwright.js",
|
|
31
|
+
"import": "./dist/esm/exports/testkit/playwright.js",
|
|
32
|
+
"types": "./dist/types/exports/testkit/playwright.d.ts"
|
|
33
|
+
},
|
|
34
|
+
"./testkit/puppeteer": {
|
|
35
|
+
"require": "./dist/cjs/exports/testkit/puppeteer.js",
|
|
36
|
+
"import": "./dist/esm/exports/testkit/puppeteer.js",
|
|
37
|
+
"types": "./dist/types/exports/testkit/puppeteer.d.ts"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
13
40
|
"files": [
|
|
14
41
|
"dist/cjs",
|
|
15
42
|
"dist/esm",
|
|
@@ -36,8 +63,9 @@
|
|
|
36
63
|
},
|
|
37
64
|
"dependencies": {
|
|
38
65
|
"@babel/runtime": "^7.28.4",
|
|
39
|
-
"@wix/data": "^1.0.
|
|
40
|
-
"@wix/wix-ui-icons-common": "^3.
|
|
66
|
+
"@wix/data": "^1.0.316",
|
|
67
|
+
"@wix/wix-ui-icons-common": "^3.100.0",
|
|
68
|
+
"@wix/wix-ui-test-utils": "^1.3.3",
|
|
41
69
|
"lodash": "^4.17.21"
|
|
42
70
|
},
|
|
43
71
|
"publishConfig": {
|
|
@@ -50,23 +78,23 @@
|
|
|
50
78
|
"@types/lodash": "^4.17.20",
|
|
51
79
|
"@types/node": "^16.18.126",
|
|
52
80
|
"@types/node-fetch": "^2.6.13",
|
|
53
|
-
"@types/react": "^16.14.
|
|
54
|
-
"@wix/crm": "^1.0.
|
|
55
|
-
"@wix/design-system": "^1.
|
|
56
|
-
"@wix/eslint-config-yoshi": "^6.
|
|
81
|
+
"@types/react": "^16.14.67",
|
|
82
|
+
"@wix/crm": "^1.0.1117",
|
|
83
|
+
"@wix/design-system": "^1.223.0",
|
|
84
|
+
"@wix/eslint-config-yoshi": "^6.161.0",
|
|
57
85
|
"@wix/fe-essentials-standalone": "^1.1380.0",
|
|
58
|
-
"@wix/jest-yoshi-preset": "^6.
|
|
59
|
-
"@wix/patterns": "^1.
|
|
86
|
+
"@wix/jest-yoshi-preset": "^6.161.0",
|
|
87
|
+
"@wix/patterns": "^1.294.0",
|
|
60
88
|
"@wix/sdk": "^1.17.1",
|
|
61
89
|
"@wix/sdk-testkit": ">=0.1.9",
|
|
62
|
-
"@wix/wix-data-items-common": "^1.0.
|
|
63
|
-
"@wix/wix-data-items-sdk": "^1.0.
|
|
64
|
-
"@wix/yoshi-flow-library": "^6.
|
|
65
|
-
"@wix/yoshi-style-dependencies": "^6.
|
|
90
|
+
"@wix/wix-data-items-common": "^1.0.255",
|
|
91
|
+
"@wix/wix-data-items-sdk": "^1.0.450",
|
|
92
|
+
"@wix/yoshi-flow-library": "^6.161.0",
|
|
93
|
+
"@wix/yoshi-style-dependencies": "^6.161.0",
|
|
66
94
|
"chance": "^1.1.13",
|
|
67
95
|
"date-fns": "^2.30.0",
|
|
68
96
|
"express": "^4.21.2",
|
|
69
|
-
"fetch-mock": "^12.5.
|
|
97
|
+
"fetch-mock": "^12.5.5",
|
|
70
98
|
"jest": "^27.5.1",
|
|
71
99
|
"node-fetch": "^2.7.0",
|
|
72
100
|
"react": "16.14.0",
|
|
@@ -125,5 +153,5 @@
|
|
|
125
153
|
"wallaby": {
|
|
126
154
|
"autoDetect": true
|
|
127
155
|
},
|
|
128
|
-
"falconPackageHash": "
|
|
156
|
+
"falconPackageHash": "22d551f0337bd0d5e5de5a5cb32af3a84c6f8c8e1139cb9d4dbcd3f1"
|
|
129
157
|
}
|