@wix/auto-patterns 1.33.0 → 1.35.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.
@@ -0,0 +1,98 @@
1
+ # Getting Started
2
+ *Build your first dashboard page on Patterns using Cursor.*
3
+
4
+ ## Library Installations
5
+ Run the following command to install the library and its peer dependencies:
6
+ ```bash
7
+ yarn add @wix/auto-patterns @wix/patterns @wix/design-system react-router-dom
8
+ ```
9
+
10
+ ## MCP Installations
11
+
12
+ * [Install Business Schema MCP in Cursor](cursor://anysphere.cursor-deeplink/mcp/install?name=business-schema&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyJAd2l4L2J1c2luZXNzLXNjaGVtYS1tY3AiXX0%3D)
13
+ * [Install Auto Patterns MCP in Cursor](cursor://anysphere.cursor-deeplink/mcp/install?name=auto-patterns&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyJAd2l4L2F1dG8tcGF0dGVybnMtbWNwIl19)
14
+
15
+ ## Working with Auto Patterns
16
+ A typical usage of Auto Patterns is to render a `AutoPatternsApp` component with a configuration object. You don't need to do it manually, but generate it through Cursor's chat.
17
+ You can write a prompt like this:
18
+ ```
19
+ I want a dashboard page for sessions, use wix.bookings.v1.sessions fqdn for that.
20
+ ```
21
+
22
+ Then Cursor will retrieve the schema for the `wix.bookings.v1.sessions` FQDN and create an Auto Patterns configuration with custom data source.
23
+
24
+ Then, you can run your app and see the results.
25
+ According to the results, you can ask Cursor to improve the configuration.
26
+ For example, you can ask Cursor to add specific filters, actions, or custom columns.
27
+
28
+ ## Handling Translations
29
+ You should provide translated values everywhere you configure or render text content, just like you do in the rest of your app.
30
+
31
+ Example to properties in the configuration that need a translated content:
32
+ - Page titles
33
+ - Column names
34
+ - Action labels
35
+
36
+ Code Example: (props that are not relevant to translation are omitted)
37
+ ```ts
38
+ import { AppConfig, AutoPatternsApp } from '@wix/auto-patterns';
39
+ import { useTranslation } from 'react-i18next';
40
+
41
+ const MyPage = () => {
42
+ const { t } = useTranslation();
43
+
44
+ const config: AppConfig = {
45
+ pages: [
46
+ {
47
+ id: 'wixPets-collection',
48
+ type: 'collectionPage',
49
+ collectionPage: {
50
+ title: { text: t('pages.pets.title') },
51
+ actions: {
52
+ primaryActions: {
53
+ type: 'action',
54
+ action: {
55
+ item: {
56
+ id: 'createPet',
57
+ label: t('actions.create'),
58
+ type: 'create',
59
+ create: { mode: 'page', page: { id: 'wixPets-entity' } },
60
+ },
61
+ },
62
+ },
63
+ },
64
+ components: [
65
+ {
66
+ type: 'collection',
67
+ entityPageId: 'wixPets-entity',
68
+ layout: [
69
+ {
70
+ type: 'Table',
71
+ table: {
72
+ columns: [
73
+ { id: 'name', name: t('columns.name') },
74
+ { id: 'age', name: t('columns.age') },
75
+ { id: 'owner', name: t('columns.owner') },
76
+ ],
77
+ },
78
+ },
79
+ ],
80
+ },
81
+ ],
82
+ },
83
+ },
84
+ {
85
+ id: 'wixPets-entity',
86
+ type: 'entityPage',
87
+ entityPage: {
88
+ title: { text: t('pages.pets.detailsTitle') },
89
+ },
90
+ },
91
+ ],
92
+ };
93
+
94
+ return <AutoPatternsApp configuration={config} />;
95
+ };
96
+
97
+ export default MyPage;
98
+ ```
@@ -0,0 +1,54 @@
1
+ # Auto Patterns Overview
2
+
3
+ ## What is Auto Patterns?
4
+
5
+ Auto Patterns is our AI-oriented library that lets anyone (Devs, PMs, UX) create rich dashboards with ease using Cursor.
6
+
7
+ ## Key Concepts
8
+
9
+ ### Configuration-Driven Development
10
+ Instead of manually building collection pages, entity forms, and data management interfaces, Auto Patterns allows you to define everything through a TypeScript configuration object that conforms to the `AppConfig` interface. This approach:
11
+
12
+ - Reduces development time
13
+ - Makes experience intuitive and expected
14
+ - Minimizes bugs
15
+ - Simplifies maintenance
16
+
17
+ ### Relationship with @wix/patterns
18
+ Auto Patterns serves as a **configuration layer** on top of `@wix/patterns` by:
19
+
20
+ - **Configuration-driven approach**: Instead of imperatively composing `@wix/patterns` components, you define behavior through TypeScript configuration objects
21
+ - **Pre-built component combinations**: Uses existing `@wix/patterns` components like `CollectionPage`, `Table`, `Grid`, and `EntityPage`, but configures them automatically based on your AppConfig
22
+ - **Simplified integration**: Handles the wiring between `@wix/patterns` components, hooks, and providers so you don't need to set them up manually
23
+ - **Declarative API**: Transforms complex component composition patterns into simple configuration properties
24
+
25
+ ## When to Use Auto Patterns
26
+
27
+ ### Perfect For:
28
+ - **Collection management pages** (lists, tables, grids)
29
+ - **Entity detail/edit pages** (forms, CRUD operations)
30
+ - **Teams standardizing** UI patterns across applications
31
+
32
+ ## Core Components
33
+
34
+ ### AutoPatternsApp
35
+ The main component that renders your entire application based on configuration:
36
+
37
+ ```tsx
38
+ import { AutoPatternsApp } from '@wix/auto-patterns';
39
+ import { config } from './myConfig.patterns';
40
+
41
+ const MyPage = () => (
42
+ <AutoPatternsApp configuration={config} />
43
+ );
44
+ ```
45
+
46
+ ### AppConfig Structure
47
+ The heart of Auto Patterns - a TypeScript configuration that defines:
48
+
49
+ - **Pages**: Collection pages (lists/tables) and entity pages (forms)
50
+ - **Data sources**: FQDN-based Wix entities, Wix Data Collections (CMS) or custom data sources
51
+ - **Actions**: Create, edit, delete, and custom operations
52
+ - **Filters**: Search and filtering capabilities
53
+ - **Layouts**: Table, grid, and form layouts
54
+ - **Customizations**: Column overrides, custom components, and styling
@@ -0,0 +1,11 @@
1
+ apiDoc:
2
+ title: Auto Patterns
3
+ description: Auto Patterns documentation
4
+ category: fe-guild
5
+ markdownOnlyAutoUpdate: true
6
+ gitUrl: https://github.com/wix-private/auto-cairo/
7
+ docs:
8
+ - file: ./GETTING_STARTED.md
9
+ title: Getting Started
10
+ - file: ./OVERVIEW.md
11
+ title: Overview
@@ -40,6 +40,7 @@ Both properties are optional, but at least one should be provided for the Action
40
40
  - Browser interactions (alerts, downloads)
41
41
  - Complex operations
42
42
  - ⚠️ Requires implementation: Must register action in overrides
43
+ - ⚠️ **CRITICAL: Error Handling Required** - When implementing custom actions that make HTTP requests, you MUST read the "Error Handling for HTTP Requests" section and apply the correct error handling patterns. Wix HTTP requests require `errorHandler.withErrorHandler`, while external API calls should NOT use errorHandler.
43
44
 
44
45
  ### Action Appearance: The `skin` Property
45
46
 
@@ -139,7 +140,7 @@ Custom actions execute JavaScript code that you define. These actions receive pa
139
140
  },
140
141
  successToast: 'Pet details downloaded',
141
142
  errorToast: (err, {retry}) => ({
142
- message: 'Download failed',
143
+ text: 'Download failed',
143
144
  action: { text: 'Retry', onClick: retry }
144
145
  })
145
146
  });
@@ -149,6 +150,53 @@ Custom actions execute JavaScript code that you define. These actions receive pa
149
150
  };
150
151
  ```
151
152
 
153
+ **⚠️ CRITICAL: Error Handling for HTTP Requests**
154
+
155
+ The example above uses SDK methods which don't require error handling. However, if your custom action makes HTTP requests, you MUST follow the error handling patterns:
156
+
157
+ **For Wix HTTP requests (httpClient, wix/data, wix/stores):**
158
+ ```typescript
159
+ import { errorHandler } from '@wix/essentials';
160
+
161
+ export const myAction: CustomActionCellSecondaryActionResolver = (params) => {
162
+ return {
163
+ label: 'My Action',
164
+ icon: <MyIcon />,
165
+ onClick: () => {
166
+ // ✅ CORRECT: Wix API call wrapped with errorHandler
167
+ errorHandler.withErrorHandler(
168
+ async () => {
169
+ const response = await httpClient.request(
170
+ myWixApiCall({ data: params.actionParams.item })
171
+ );
172
+ return response.data;
173
+ },
174
+ {}
175
+ );
176
+ },
177
+ };
178
+ };
179
+ ```
180
+
181
+ **For External API requests (fetch, axios, third-party):**
182
+ ```typescript
183
+ export const myAction: CustomActionCellSecondaryActionResolver = (params) => {
184
+ return {
185
+ label: 'My Action',
186
+ icon: <MyIcon />,
187
+ onClick: () => {
188
+ // ✅ CORRECT: External API call - NO errorHandler needed
189
+ fetch('https://api.external-service.com/endpoint', {
190
+ method: 'POST',
191
+ body: JSON.stringify(params.actionParams.item)
192
+ });
193
+ },
194
+ };
195
+ };
196
+ ```
197
+
198
+ **Read the "Error Handling for HTTP Requests" section for complete guidance.**
199
+
152
200
  3. Export your action in `actions/index.tsx`:
153
201
  ```typescript
154
202
  import { downloadPetDetails } from './downloadPetDetails';
@@ -209,7 +257,7 @@ Custom actions execute JavaScript code that you define. These actions receive pa
209
257
  - Enable analytics tracking for user interactions
210
258
 
211
259
  2. The implementation must return a `ResolvedAction` object with:
212
- - `label`: Text displayed for the action
260
+ - `label`: Text displayed for the action
213
261
  - `icon`: An Icon component from "@wix/wix-ui-icons-common"
214
262
  - `onClick`: Handler function for the action
215
263
  - `biName`: Business intelligence name for analytics tracking. Must match the `biName` in your action configuration (required)