@wix/auto-patterns 1.17.0 → 1.18.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 (43) hide show
  1. package/dist/cjs/dataSourceAdapters/cms/cmsAdapter.js +0 -2
  2. package/dist/cjs/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
  3. package/dist/cjs/dataSourceAdapters/cms/fetchCmsData.js.map +1 -1
  4. package/dist/cjs/dataSourceAdapters/cms/filterUtils.js.map +1 -1
  5. package/dist/cjs/dataSourceAdapters/cms/sortUtils.js.map +1 -1
  6. package/dist/cjs/hooks/useColumns.js +7 -5
  7. package/dist/cjs/hooks/useColumns.js.map +1 -1
  8. package/dist/cjs/types/types.js.map +1 -1
  9. package/dist/docs/action_cell.md +1 -1
  10. package/dist/docs/app_config_structure.md +65 -1
  11. package/dist/docs/auto-patterns-guide.md +358 -76
  12. package/dist/docs/bulk_actions.md +1 -1
  13. package/dist/docs/collection_page.md +1 -1
  14. package/dist/docs/config_schema.md +184 -0
  15. package/dist/docs/custom_overrides.md +163 -4
  16. package/dist/docs/index.md +5 -7
  17. package/dist/docs/schema_config.md +174 -0
  18. package/dist/docs/sdk_utilities.md +97 -0
  19. package/dist/docs/wix_fqdn_custom_data_source.md +201 -0
  20. package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js +0 -2
  21. package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
  22. package/dist/esm/dataSourceAdapters/cms/fetchCmsData.js.map +1 -1
  23. package/dist/esm/dataSourceAdapters/cms/filterUtils.js.map +1 -1
  24. package/dist/esm/dataSourceAdapters/cms/sortUtils.js.map +1 -1
  25. package/dist/esm/hooks/useColumns.js +3 -1
  26. package/dist/esm/hooks/useColumns.js.map +1 -1
  27. package/dist/esm/types/types.js.map +1 -1
  28. package/dist/types/dataSourceAdapters/cms/cmsAdapter.d.ts.map +1 -1
  29. package/dist/types/dataSourceAdapters/cms/fetchCmsData.d.ts +2 -3
  30. package/dist/types/dataSourceAdapters/cms/fetchCmsData.d.ts.map +1 -1
  31. package/dist/types/dataSourceAdapters/cms/filterUtils.d.ts +3 -4
  32. package/dist/types/dataSourceAdapters/cms/filterUtils.d.ts.map +1 -1
  33. package/dist/types/dataSourceAdapters/cms/sortUtils.d.ts +2 -3
  34. package/dist/types/dataSourceAdapters/cms/sortUtils.d.ts.map +1 -1
  35. package/dist/types/hooks/useColumns.d.ts.map +1 -1
  36. package/dist/types/types/types.d.ts +13 -3
  37. package/dist/types/types/types.d.ts.map +1 -1
  38. package/package.json +4 -4
  39. package/dist/docs/recipe-bulk-operations.md +0 -1352
  40. package/dist/docs/recipe-crud-operations.md +0 -805
  41. package/dist/docs/recipe-customization.md +0 -1703
  42. package/dist/docs/recipe-first-dashboard.md +0 -795
  43. package/dist/docs/sdk_and_schema.md +0 -215
@@ -147,7 +147,10 @@ export interface AppConfig {
147
147
  entityPageId?: string; // ID of the entity page to navigate to when clicking a row
148
148
  collection: {
149
149
  collectionId: string; // ID of the Wix Data collection
150
- entityTypeSource: 'cms'; // Data source type. Always 'cms'
150
+ entityTypeSource: 'cms' | 'custom'; // Data source type.
151
+ custom?: {
152
+ id: string;
153
+ };
151
154
  reflectQueryInUrl?: boolean; // Reflects query state (search, filters, sorting) in the browser URL. Default: false
152
155
  selectAllScope?: 'page' | 'all'; // Controls "Select All" scope. 'all' selects entire collection, 'page' selects only visible items. Default: 'all'
153
156
  selectionUpdateMode?: 'preserve' | 'clear'; // Controls selection behavior when data changes. 'preserve' maintains selections, 'clear' clears them. Default: 'clear'
@@ -434,6 +437,67 @@ type LayoutContent =
434
437
 
435
438
  ---
436
439
 
440
+ ## Filters Configuration Notes
441
+
442
+ To configure filters in a `collectionPage`, add a `filters` property inside the page's component configuration object. Each filter must reference a valid field by its `fieldId`, and the supported types are:
443
+
444
+ * `numberConfig`: used with fields of type `NUMBER`
445
+ * `dateConfig`: used with fields of type `DATETIME`
446
+ * `booleanConfig`: used with fields of type `BOOLEAN`
447
+ * `enumConfig`: used with fields of type `ARRAY` or `ARRAY_STRING`
448
+
449
+ ### Enum Configuration Implementation
450
+
451
+ When implementing enum filters, you must ask the user to provide the possible option values. Never invent or assume enum values. Here's how to properly handle enumConfig:
452
+
453
+ #### Example: User-Provided Enum Implementation
454
+
455
+ 1. First, collect the possible values from the user:
456
+ ```
457
+ User requests: "I need a filter for pet types."
458
+ You ask: "What are the possible values for pet types that should be available in the filter?"
459
+ User responds: "dog, cat, bird, rabbit, fish"
460
+ ```
461
+
462
+ 2. Then, create the `enumConfig` structure:
463
+ ```json
464
+ "enumConfig": {
465
+ "options": [
466
+ { "value": "dog", "label": "Dog" },
467
+ { "value": "cat", "label": "Cat" },
468
+ { "value": "bird", "label": "Bird" },
469
+ { "value": "rabbit", "label": "Rabbit" },
470
+ { "value": "fish", "label": "Fish" }
471
+ ],
472
+ "selectionMode": "multiple",
473
+ "optionType": "checkbox"
474
+ }
475
+ ```
476
+
477
+ Notice how the `label` is derived from the `value` by capitalizing the first letter. The user's exact values become the `value` property.
478
+
479
+ ### Grouping Filters with Section Title
480
+
481
+ * Filters can be grouped by sections using the `sectionTitle` property.
482
+ * If multiple filter items share the same `sectionTitle`, they will be displayed together in a grouped section in the UI.
483
+ * Filters without a `sectionTitle` will appear in a default section or be displayed individually.
484
+ * Grouping helps maintain clarity, especially when dealing with multiple filter options.
485
+
486
+ ### Key Guidelines
487
+
488
+ * **openByDefault**: Automatically expands the filter accordion when the filters panel is opened.
489
+ * **tagLabel**: Specifies the label displayed in a Tag component on the table or grid once the filter is active. For example, if the tagLabel is "Age", the filter display might show: `Age: 7`.
490
+ * **maxInlineFilters**: Limits the number of filters shown inline in the table toolbar. Others are accessible via the panel. Default is 0.
491
+ * **dateConfig.mode**:
492
+
493
+ * `ONLY_PREDEFINED`: user can select only from preset options
494
+ * `ONLY_CUSTOM`: user must select a custom date range manually (no presets)
495
+ * `COMBINE`: both options available
496
+ * **dateConfig.presets** must be omitted if mode is `ONLY_CUSTOM`.
497
+ * **dateConfig.includeTime**: Controls whether time selection is also enabled alongside date (default is `true`).
498
+
499
+ ---
500
+
437
501
  # Pages Configuration
438
502
 
439
503
  ## ⚠️ Critical Page Rules
@@ -580,7 +644,7 @@ Sticky columns allow you to keep specific columns visible while users scroll hor
580
644
 
581
645
  * Must include **exactly one item**.
582
646
  * Each component must have:
583
- * `collection`: Collection configuration with `collectionId` and `entityTypeSource: 'cms'`
647
+ * `collection`: Collection configuration with `collectionId` and `entityTypeSource`
584
648
  * `layout`: Array of layout items that determine what components to render
585
649
 
586
650
  ## Layout Array
@@ -1073,6 +1137,87 @@ interface ToastConfig {
1073
1137
 
1074
1138
  SchemaConfig provides complete collection metadata and server actions. Essential for dynamic operations and accessing collection structure information.
1075
1139
 
1140
+ ### TypeScript Interface Definition
1141
+
1142
+ ```typescript
1143
+ export interface SchemaConfig {
1144
+ id: string;
1145
+ fields: Record<string, Field | undefined>;
1146
+ displayField: string;
1147
+ idField: string;
1148
+ actions: {
1149
+ get: (entityId: string) => Promise<any>;
1150
+ create: (newEntity: Partial<any>) => Promise<any>;
1151
+ update: (updatedEntity: any) => Promise<any>;
1152
+ delete: (entityId: string) => Promise<any>;
1153
+ bulkDelete: (entityIds: string[]) => Promise<any>;
1154
+ find: (
1155
+ query: Query,
1156
+ options?: {
1157
+ searchableFieldIds?: string[];
1158
+ filterFieldMapping?: Record<string, { fieldId: string }>;
1159
+ },
1160
+ ) => Promise<{ items: any[]; total: number }>;
1161
+ };
1162
+ }
1163
+
1164
+ export interface Query {
1165
+ limit: number; // Maximum number of items to return per request (controls page size)
1166
+ offset: number; // Number of items to skip from the beginning (for pagination)
1167
+ page: number; // Current page number (1-based, works with limit for pagination)
1168
+ search?: string; // Text search query applied to searchable fields
1169
+ cursor?: string | null; // Cursor-based pagination token (alternative to offset-based pagination)
1170
+ filters: Record<string, any>; // Field-specific filter conditions (keys = field IDs, values = filter criteria)
1171
+ sort?: { // Sorting configuration for result ordering
1172
+ fieldName: string; // Field ID to sort by (must be sortable per field capabilities)
1173
+ order: 'asc' | 'desc'; // Sort direction
1174
+ }[];
1175
+ }
1176
+ ```
1177
+
1178
+ ### Supporting Type Definitions
1179
+
1180
+ ```typescript
1181
+ export type PatternsFieldType =
1182
+ | 'SHORT_TEXT'
1183
+ | 'LONG_TEXT'
1184
+ | 'NUMBER'
1185
+ | 'BOOLEAN'
1186
+ | 'DATE'
1187
+ | 'DATETIME'
1188
+ | 'URL'
1189
+ | 'ARRAY'
1190
+ | 'REFERENCE'
1191
+ | 'IMAGE';
1192
+
1193
+ interface BaseField {
1194
+ id: string;
1195
+ displayName: string;
1196
+ validation?: {
1197
+ numberRange?: NumberRange;
1198
+ stringLengthRange?: StringLengthRange;
1199
+ required: boolean;
1200
+ };
1201
+ capabilities: {
1202
+ supportedQueryOperators: QueryOperator[];
1203
+ sortable: boolean;
1204
+ };
1205
+ }
1206
+
1207
+ export interface ReferenceField extends BaseField {
1208
+ type: 'REFERENCE';
1209
+ referenceMetadata: {
1210
+ referencedCollectionId: string;
1211
+ };
1212
+ }
1213
+
1214
+ export interface NonReferenceField extends BaseField {
1215
+ type: Exclude<PatternsFieldType, 'REFERENCE'>;
1216
+ }
1217
+
1218
+ export type Field = ReferenceField | NonReferenceField;
1219
+ ```
1220
+
1076
1221
  ### Key Properties
1077
1222
 
1078
1223
  • **id** - `string`
@@ -1092,20 +1237,53 @@ SchemaConfig provides complete collection metadata and server actions. Essential
1092
1237
  • **fields** - `Record<string, Field | undefined>`
1093
1238
  - Complete field definitions with types and metadata
1094
1239
  - Useful for dynamic form generation or validation
1095
- - Example: `schema.fields.name.type === 'TEXT'`
1240
+ - Each field contains type information, validation rules, and capabilities
1241
+ - Example: `schema.fields.name.type === 'SHORT_TEXT'`
1096
1242
 
1097
1243
  • **actions** - Server operation functions
1098
1244
  - Pre-configured API calls for CRUD operations
1099
1245
  - Use with optimistic actions for best UX
1246
+ - All actions return Promises and handle server communication
1100
1247
  - Example: `await schema.actions.update(item)`
1101
1248
 
1102
1249
  ### Available Schema Actions
1103
1250
 
1104
- - schema.actions.create(item) // Create single item
1105
- - schema.actions.update(item) // Update single item
1106
- - schema.actions.delete(itemId) // Delete by ID
1107
- - schema.actions.bulkUpdate(updates) // Update multiple items
1108
- - schema.actions.bulkDelete(itemIds) // Delete multiple items
1251
+ #### Individual Entity Operations
1252
+ - **schema.actions.get(entityId)** - Retrieve a single entity by ID
1253
+ - **schema.actions.create(newEntity)** - Create a new entity
1254
+ - **schema.actions.update(updatedEntity)** - Update an existing entity
1255
+ - **schema.actions.delete(entityId)** - Delete a single entity by ID
1256
+
1257
+ #### Bulk Operations
1258
+ - **schema.actions.bulkDelete(entityIds)** - Delete multiple entities by their IDs
1259
+
1260
+ #### Query Operations
1261
+ - **schema.actions.find(query, options)** - Search and filter entities
1262
+ - `query`: Query object with pagination, filtering, sorting, and search criteria (see Query Interface section)
1263
+ - `options.searchableFieldIds`: Array of field IDs that support text search
1264
+ - `options.filterFieldMapping`: Maps filter IDs to actual field IDs for complex filtering
1265
+ - Returns: `{ items: any[], total: number }`
1266
+
1267
+ ### Field Type Information
1268
+
1269
+ Each field in the `fields` record contains:
1270
+
1271
+ - **id**: Unique field identifier
1272
+ - **displayName**: Human-readable field name
1273
+ - **type**: One of the supported `PatternsFieldType` values
1274
+ - **validation**: Optional validation rules including:
1275
+ - `numberRange`: Min/max values for numeric fields
1276
+ - `stringLengthRange`: Min/max length for text fields
1277
+ - `required`: Whether the field is mandatory
1278
+ - **capabilities**: Field behavior configuration:
1279
+ - `supportedQueryOperators`: Array of operators this field supports for filtering
1280
+ - `sortable`: Whether this field can be used for sorting
1281
+
1282
+ ### Reference Fields
1283
+
1284
+ Reference fields have additional metadata:
1285
+ - **referenceMetadata.referencedCollectionId**: ID of the collection being referenced
1286
+ - Used for establishing relationships between different collections
1109
1287
 
1110
1288
  ### Schema Validation Checklist
1111
1289
 
@@ -1116,74 +1294,19 @@ Before using schema in operations:
1116
1294
  ✓ Use `schema.idField` for ID operations
1117
1295
  ✓ Use `schema.displayField` for UI display
1118
1296
  ✓ Use `schema.actions` for server operations
1297
+ ✓ Check field capabilities before applying filters or sorting
1119
1298
 
1120
1299
  ### Common Usage Patterns
1121
1300
 
1122
1301
  - **ActionCell**: Use `schema.actions.update()` or `schema.actions.delete()` for single item operations
1123
- - **BulkActions**: Use `schema.actions.bulkUpdate()` or `schema.actions.bulkDelete()` for multiple items
1302
+ - **BulkActions**: Use `schema.actions.bulkDelete()` for multiple items
1124
1303
  - **Dynamic UI**: Use `schema.fields` to build forms or validate data
1125
1304
  - **Error Messages**: Use `schema.displayField` to create meaningful user feedback
1126
-
1127
- ---
1128
-
1129
- ## Filters Configuration Notes
1130
-
1131
- To configure filters in a `collectionPage`, add a `filters` property inside the page's component configuration object. Each filter must reference a valid field by its `fieldId`, and the supported types are:
1132
-
1133
- * `numberConfig`: used with fields of type `NUMBER`
1134
- * `dateConfig`: used with fields of type `DATETIME`
1135
- * `booleanConfig`: used with fields of type `BOOLEAN`
1136
- * `enumConfig`: used with fields of type `ARRAY` or `ARRAY_STRING`
1137
-
1138
- ### Enum Configuration Implementation
1139
-
1140
- When implementing enum filters, you must ask the user to provide the possible option values. Never invent or assume enum values. Here's how to properly handle enumConfig:
1141
-
1142
- #### Example: User-Provided Enum Implementation
1143
-
1144
- 1. First, collect the possible values from the user:
1145
- ```
1146
- User requests: "I need a filter for pet types."
1147
- You ask: "What are the possible values for pet types that should be available in the filter?"
1148
- User responds: "dog, cat, bird, rabbit, fish"
1149
- ```
1150
-
1151
- 2. Then, create the `enumConfig` structure:
1152
- ```json
1153
- "enumConfig": {
1154
- "options": [
1155
- { "value": "dog", "label": "Dog" },
1156
- { "value": "cat", "label": "Cat" },
1157
- { "value": "bird", "label": "Bird" },
1158
- { "value": "rabbit", "label": "Rabbit" },
1159
- { "value": "fish", "label": "Fish" }
1160
- ],
1161
- "selectionMode": "multiple",
1162
- "optionType": "checkbox"
1163
- }
1164
- ```
1165
-
1166
- Notice how the `label` is derived from the `value` by capitalizing the first letter. The user's exact values become the `value` property.
1167
-
1168
- ### Grouping Filters with Section Title
1169
-
1170
- * Filters can be grouped by sections using the `sectionTitle` property.
1171
- * If multiple filter items share the same `sectionTitle`, they will be displayed together in a grouped section in the UI.
1172
- * Filters without a `sectionTitle` will appear in a default section or be displayed individually.
1173
- * Grouping helps maintain clarity, especially when dealing with multiple filter options.
1174
-
1175
- ### Key Guidelines
1176
-
1177
- * **openByDefault**: Automatically expands the filter accordion when the filters panel is opened.
1178
- * **tagLabel**: Specifies the label displayed in a Tag component on the table or grid once the filter is active. For example, if the tagLabel is "Age", the filter display might show: `Age: 7`.
1179
- * **maxInlineFilters**: Limits the number of filters shown inline in the table toolbar. Others are accessible via the panel. Default is 0.
1180
- * **dateConfig.mode**:
1181
-
1182
- * `ONLY_PREDEFINED`: user can select only from preset options
1183
- * `ONLY_CUSTOM`: user must select a custom date range manually (no presets)
1184
- * `COMBINE`: both options available
1185
- * **dateConfig.presets** must be omitted if mode is `ONLY_CUSTOM`.
1186
- * **dateConfig.includeTime**: Controls whether time selection is also enabled alongside date (default is `true`).
1305
+ - **Field Validation**: Use `schema.fields[fieldId].validation` for form validation rules
1306
+ - **Query Building**: Use `schema.fields[fieldId].capabilities.supportedQueryOperators` to build dynamic filters
1307
+ - **Data Fetching**: Use `schema.actions.find()` with Query interface for complex data retrieval with pagination, search, and filtering
1308
+ - **Pagination**: Combine `limit`, `offset`, and `page` properties in Query for consistent pagination behavior
1309
+ - **Search Implementation**: Use `search` property with `searchableFieldIds` option for full-text search across multiple fields
1187
1310
 
1188
1311
  ---
1189
1312
 
@@ -1191,7 +1314,7 @@ Notice how the `label` is derived from the `value` by capitalizing the first let
1191
1314
 
1192
1315
  The ActionCell feature adds an interactive action column to collection tables or grid views, enabling users to perform operations on individual entities.
1193
1316
 
1194
- ### Placement and Structure
1317
+ ## Placement and Structure
1195
1318
 
1196
1319
  The ActionCell has a two-level structure:
1197
1320
  * `primaryAction`: A single prominent action shown directly in the table/grid row
@@ -1427,7 +1550,7 @@ AI agents should verify these requirements before generating ActionCell configur
1427
1550
 
1428
1551
  The Bulk Action Toolbar feature enables users to perform operations on multiple selected entities simultaneously in collection tables or grids. When configured, it adds checkboxes to each row and displays a toolbar with bulk actions when items are selected.
1429
1552
 
1430
- ### Placement and Structure
1553
+ ## Placement and Structure
1431
1554
 
1432
1555
  The Bulk Action Toolbar is configured within the table / grid / table-grid switch configuration using the `bulkActionToolbar` property. It has a two-level structure:
1433
1556
  * `primaryActions`: Actions shown directly in the bulk action toolbar
@@ -1982,10 +2105,13 @@ your-page/
1982
2105
  │ ├── index.tsx
1983
2106
  │ ├── name.ts
1984
2107
  │ └── date.ts
1985
- └── customComponents/ // Custom entity page components
2108
+ ├── customComponents/ // Custom entity page components
2109
+ │ ├── index.tsx
2110
+ │ ├── CustomNameField.tsx
2111
+ │ └── InfoCard.tsx
2112
+ └── customDataSources/ // Custom data sources
1986
2113
  ├── index.tsx
1987
- ├── CustomNameField.tsx
1988
- └── InfoCard.tsx
2114
+ └── myCustomDataSource.ts
1989
2115
  ```
1990
2116
 
1991
2117
  ### Importing Overrides in Your Page
@@ -1997,8 +2123,9 @@ import * as modals from './components/modals';
1997
2123
  import * as actions from './components/actions';
1998
2124
  import * as columns from './components/columns';
1999
2125
  import * as components from './components/customComponents';
2126
+ import * as customDataSources from './components/customDataSources';
2000
2127
 
2001
- <PatternsWizardOverridesProvider value={{ modals, actions, columns, components }}>
2128
+ <PatternsWizardOverridesProvider value={{ modals, actions, columns, components, customDataSources }}>
2002
2129
  <AutoPatternsApp configuration={config as AppConfig} />
2003
2130
  </PatternsWizardOverridesProvider>
2004
2131
  ```
@@ -2012,6 +2139,7 @@ For example:
2012
2139
  - Adding a new modal → Update `./components/modals/index.tsx`
2013
2140
  - Adding a new column override → Update `./components/columns/index.tsx`
2014
2141
  - Adding a new custom component → Update `./components/customComponents/index.tsx`
2142
+ - Adding a new custom data source → Update `./components/customDataSources/index.tsx`
2015
2143
 
2016
2144
  Without updating the index files, your implementations won't be available to the `PatternsWizardOverridesProvider`.
2017
2145
 
@@ -2464,4 +2592,158 @@ PatternsWizardOverridesProvider
2464
2592
 
2465
2593
  By using these component overrides, you can tailor the behavior and appearance of your `AutoPatternsApp` to meet specific requirements beyond what the default rendering provides.
2466
2594
 
2595
+ ## Custom Data Sources
2596
+
2597
+ Custom data sources allow you to connect AutoPatternsApp to any data source beyond the default CMS collections. This enables you to integrate with external APIs, custom databases, or any other data sources that require custom implementation.
2598
+
2599
+ ### Configuration Structure
2600
+
2601
+ When implementing a custom data source, you need to modify the `collection` configuration in your AppConfig:
2602
+
2603
+ ```json
2604
+ {
2605
+ "collection": {
2606
+ "collectionId": "myCustomCollection",
2607
+ "entityTypeSource": "custom",
2608
+ "custom": {
2609
+ "id": "myCustomDataSource"
2610
+ }
2611
+ }
2612
+ }
2613
+ ```
2614
+
2615
+ **Key Properties:**
2616
+ - `entityTypeSource`: Must be set to `"custom"` instead of `"cms"`
2617
+ - `custom.id`: A unique identifier for your custom data source implementation
2618
+
2619
+ ### Custom Data Source Override Structure
2620
+
2621
+ Custom data sources are implemented through the `customDataSources` property in your `PatternsWizardOverridesProvider`:
2622
+
2623
+ ```tsx
2624
+ <PatternsWizardOverridesProvider value={{
2625
+ customDataSources: {
2626
+ myCustomDataSource: async (collectionId: string, context: any) => {
2627
+ return customSchemaConfig; // Must return a SchemaConfig object
2628
+ }
2629
+ }
2630
+ }}>
2631
+ <AutoPatternsApp configuration={config as AppConfig} />
2632
+ </PatternsWizardOverridesProvider>
2633
+ ```
2634
+
2635
+ ### Implementation Components
2636
+
2637
+ #### Custom Data Source Function
2638
+
2639
+ You must implement a custom data source function that:
2640
+ - Takes `collectionId` and `context` parameters
2641
+ - Returns a Promise that resolves to a `SchemaConfig` object
2642
+ - The `SchemaConfig` object must include:
2643
+ - **id**: Collection identifier
2644
+ - **fields**: Field definitions with types and metadata
2645
+ - **displayField**: Primary field for displaying items
2646
+ - **idField**: Primary key field name
2647
+ - **actions**: CRUD operation functions that handle:
2648
+ - Individual entity operations (get, create, update, delete)
2649
+ - Bulk operations (bulkDelete)
2650
+ - Query operations with pagination, search, filtering, and sorting
2651
+
2652
+ ### Example Implementation Structure
2653
+
2654
+ ```tsx
2655
+ // customDataSources/myCustomDataSource.ts
2656
+ export const myCustomDataSource = async (collectionId: string, context: any) => {
2657
+ return {
2658
+ id: 'myCustomCollection',
2659
+ fields: {
2660
+ // Field definitions based on your data source schema
2661
+ },
2662
+ displayField: 'name',
2663
+ idField: '_id',
2664
+ actions: {
2665
+ get: async (entityId: string) => { /* Implementation */ },
2666
+ create: async (newEntity: any) => { /* Implementation */ },
2667
+ update: async (updatedEntity: any) => { /* Implementation */ },
2668
+ delete: async (entityId: string) => { /* Implementation */ },
2669
+ bulkDelete: async (entityIds: string[]) => { /* Implementation */ },
2670
+ find: async (query: Query, options?: any) => { /* Implementation */ }
2671
+ }
2672
+ };
2673
+ };
2674
+ ```
2675
+
2676
+ ### Field Type Mapping
2677
+
2678
+ When implementing custom data sources, you need to map your data source field types to AutoPatterns field types:
2679
+
2680
+ - **Text fields** → `'SHORT_TEXT'` or `'LONG_TEXT'`
2681
+ - **Numeric fields** → `'NUMBER'`
2682
+ - **Boolean fields** → `'BOOLEAN'`
2683
+ - **Date fields** → `'DATE'` or `'DATETIME'`
2684
+ - **Image fields** → `'IMAGE'`
2685
+ - **Array fields** → `'ARRAY'`
2686
+ - **Reference fields** → `'REFERENCE'`
2687
+ - **URL fields** → `'URL'`
2688
+
2689
+ ### Error Handling
2690
+
2691
+ Custom data sources should include proper error handling:
2692
+
2693
+ ```tsx
2694
+ actions: {
2695
+ get: async (entityId: string) => {
2696
+ try {
2697
+ const result = await yourDataSourceCall(entityId);
2698
+ return result;
2699
+ } catch (error) {
2700
+ throw new Error(`Failed to fetch entity: ${error.message}`);
2701
+ }
2702
+ }
2703
+ }
2704
+ ```
2705
+
2706
+ ### Validation Requirements
2707
+
2708
+ - **Function Signature**: Custom data source must be a function with signature `(collectionId: string, context: any) => Promise<SchemaConfig>`
2709
+ - **Return Type**: Must return a Promise that resolves to a complete SchemaConfig object
2710
+ - All schema actions must return Promises
2711
+ - Field IDs must match between schema definition and data source responses
2712
+ - The `find` action must support the complete Query interface
2713
+ - Custom data sources must handle pagination, search, and filtering
2714
+ - Error responses should be meaningful and actionable
2715
+
2716
+ ### Folder Structure for Custom Data Sources
2717
+
2718
+ ```
2719
+ your-page/
2720
+ ├── page.tsx // Your main page component
2721
+ ├── MyCollectionConfig.patterns.json // Configuration file
2722
+ └── components/ // Page-specific components folder
2723
+ ├── index.tsx // Exports all overrides for easy importing
2724
+ ├── customDataSources/ // Custom data sources
2725
+ │ ├── index.tsx
2726
+ │ └── myCustomDataSource.ts
2727
+ ├── actions/ // Custom actions
2728
+ │ ├── index.tsx
2729
+ │ └── myCustomAction.tsx
2730
+ └── columns/ // Column overrides
2731
+ ├── index.tsx
2732
+ └── myColumn.tsx
2733
+ ```
2734
+
2735
+ ### Registering Custom Data Sources
2736
+
2737
+ In your page component, import and register your custom data sources:
2738
+
2739
+ ```tsx
2740
+ import * as customDataSources from './components/customDataSources';
2741
+
2742
+ <PatternsWizardOverridesProvider value={{ customDataSources }}>
2743
+ <AutoPatternsApp configuration={config as AppConfig} />
2744
+ </PatternsWizardOverridesProvider>
2745
+ ```
2746
+
2747
+ **Important:** Every time you create a new custom data source, you must add a corresponding export line to the `./components/customDataSources/index.tsx` file. For example, if you create `myDataSource.ts`, you must add `export * from './myDataSource';` to the index file.
2748
+
2467
2749
  ---
@@ -2,7 +2,7 @@
2
2
 
3
3
  The Bulk Action Toolbar feature enables users to perform operations on multiple selected entities simultaneously in collection tables or grids. When configured, it adds checkboxes to each row and displays a toolbar with bulk actions when items are selected.
4
4
 
5
- ### Placement and Structure
5
+ ## Placement and Structure
6
6
 
7
7
  The Bulk Action Toolbar is configured within the table / grid / table-grid switch configuration using the `bulkActionToolbar` property. It has a two-level structure:
8
8
  * `primaryActions`: Actions shown directly in the bulk action toolbar
@@ -12,7 +12,7 @@
12
12
 
13
13
  * Must include **exactly one item**.
14
14
  * Each component must have:
15
- * `collection`: Collection configuration with `collectionId` and `entityTypeSource: 'cms'`
15
+ * `collection`: Collection configuration with `collectionId` and `entityTypeSource`
16
16
  * `layout`: Array of layout items that determine what components to render
17
17
 
18
18
  ## Layout Array