@wix/auto-patterns 1.16.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 (65) hide show
  1. package/dist/cjs/components/AutoPatternsRoute/AutoPatternsRoutes.js +4 -4
  2. package/dist/cjs/components/AutoPatternsRoute/AutoPatternsRoutes.js.map +1 -1
  3. package/dist/cjs/dataSourceAdapters/cms/cmsAdapter.js +0 -2
  4. package/dist/cjs/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
  5. package/dist/cjs/dataSourceAdapters/cms/fetchCmsData.js.map +1 -1
  6. package/dist/cjs/dataSourceAdapters/cms/filterUtils.js.map +1 -1
  7. package/dist/cjs/dataSourceAdapters/cms/sortUtils.js.map +1 -1
  8. package/dist/cjs/hooks/useColumns.js +7 -5
  9. package/dist/cjs/hooks/useColumns.js.map +1 -1
  10. package/dist/cjs/hooks/useNavigationUtils.js +2 -2
  11. package/dist/cjs/hooks/useNavigationUtils.js.map +1 -1
  12. package/dist/cjs/types/actions/base.js.map +1 -1
  13. package/dist/cjs/types/types.js.map +1 -1
  14. package/dist/cjs/utils/actions/resolveAction.js +2 -1
  15. package/dist/cjs/utils/actions/resolveAction.js.map +1 -1
  16. package/dist/cjs/utils/actions/types.js.map +1 -1
  17. package/dist/docs/action_cell.md +20 -1
  18. package/dist/docs/app_config_structure.md +66 -1
  19. package/dist/docs/auto-patterns-guide.md +378 -76
  20. package/dist/docs/bulk_actions.md +1 -1
  21. package/dist/docs/collection_page.md +1 -1
  22. package/dist/docs/config_schema.md +184 -0
  23. package/dist/docs/custom_overrides.md +163 -4
  24. package/dist/docs/index.md +5 -7
  25. package/dist/docs/schema_config.md +174 -0
  26. package/dist/docs/sdk_utilities.md +97 -0
  27. package/dist/docs/wix_fqdn_custom_data_source.md +201 -0
  28. package/dist/esm/components/AutoPatternsRoute/AutoPatternsRoutes.js +1 -1
  29. package/dist/esm/components/AutoPatternsRoute/AutoPatternsRoutes.js.map +1 -1
  30. package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js +0 -2
  31. package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
  32. package/dist/esm/dataSourceAdapters/cms/fetchCmsData.js.map +1 -1
  33. package/dist/esm/dataSourceAdapters/cms/filterUtils.js.map +1 -1
  34. package/dist/esm/dataSourceAdapters/cms/sortUtils.js.map +1 -1
  35. package/dist/esm/hooks/useColumns.js +3 -1
  36. package/dist/esm/hooks/useColumns.js.map +1 -1
  37. package/dist/esm/hooks/useNavigationUtils.js +1 -1
  38. package/dist/esm/hooks/useNavigationUtils.js.map +1 -1
  39. package/dist/esm/types/actions/base.js.map +1 -1
  40. package/dist/esm/types/types.js.map +1 -1
  41. package/dist/esm/utils/actions/resolveAction.js +2 -1
  42. package/dist/esm/utils/actions/resolveAction.js.map +1 -1
  43. package/dist/esm/utils/actions/types.js.map +1 -1
  44. package/dist/types/dataSourceAdapters/cms/cmsAdapter.d.ts.map +1 -1
  45. package/dist/types/dataSourceAdapters/cms/fetchCmsData.d.ts +2 -3
  46. package/dist/types/dataSourceAdapters/cms/fetchCmsData.d.ts.map +1 -1
  47. package/dist/types/dataSourceAdapters/cms/filterUtils.d.ts +3 -4
  48. package/dist/types/dataSourceAdapters/cms/filterUtils.d.ts.map +1 -1
  49. package/dist/types/dataSourceAdapters/cms/sortUtils.d.ts +2 -3
  50. package/dist/types/dataSourceAdapters/cms/sortUtils.d.ts.map +1 -1
  51. package/dist/types/hooks/useColumns.d.ts.map +1 -1
  52. package/dist/types/types/actions/base.d.ts +1 -0
  53. package/dist/types/types/actions/base.d.ts.map +1 -1
  54. package/dist/types/types/types.d.ts +13 -3
  55. package/dist/types/types/types.d.ts.map +1 -1
  56. package/dist/types/utils/actions/resolveAction.d.ts +1 -0
  57. package/dist/types/utils/actions/resolveAction.d.ts.map +1 -1
  58. package/dist/types/utils/actions/types.d.ts +1 -0
  59. package/dist/types/utils/actions/types.d.ts.map +1 -1
  60. package/package.json +19 -18
  61. package/dist/docs/recipe-bulk-operations.md +0 -1352
  62. package/dist/docs/recipe-crud-operations.md +0 -786
  63. package/dist/docs/recipe-customization.md +0 -1702
  64. package/dist/docs/recipe-first-dashboard.md +0 -794
  65. 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'
@@ -204,6 +207,7 @@ export interface AppConfig {
204
207
  id: string; // Unique identifier for the action
205
208
  type: 'update' | 'delete' | 'custom'; // Action type
206
209
  label?: string; // Text displayed for the action
210
+ skin?: string; // Visual appearance of the action button (see Action Button Skin Values section)
207
211
  disabled?: boolean; // Whether the action is disabled
208
212
  tooltip?: string; // Tooltip text shown on hover
209
213
  update?: { // Required when type is 'update'
@@ -433,6 +437,67 @@ type LayoutContent =
433
437
 
434
438
  ---
435
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
+
436
501
  # Pages Configuration
437
502
 
438
503
  ## ⚠️ Critical Page Rules
@@ -579,7 +644,7 @@ Sticky columns allow you to keep specific columns visible while users scroll hor
579
644
 
580
645
  * Must include **exactly one item**.
581
646
  * Each component must have:
582
- * `collection`: Collection configuration with `collectionId` and `entityTypeSource: 'cms'`
647
+ * `collection`: Collection configuration with `collectionId` and `entityTypeSource`
583
648
  * `layout`: Array of layout items that determine what components to render
584
649
 
585
650
  ## Layout Array
@@ -1072,6 +1137,87 @@ interface ToastConfig {
1072
1137
 
1073
1138
  SchemaConfig provides complete collection metadata and server actions. Essential for dynamic operations and accessing collection structure information.
1074
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
+
1075
1221
  ### Key Properties
1076
1222
 
1077
1223
  • **id** - `string`
@@ -1091,20 +1237,53 @@ SchemaConfig provides complete collection metadata and server actions. Essential
1091
1237
  • **fields** - `Record<string, Field | undefined>`
1092
1238
  - Complete field definitions with types and metadata
1093
1239
  - Useful for dynamic form generation or validation
1094
- - Example: `schema.fields.name.type === 'TEXT'`
1240
+ - Each field contains type information, validation rules, and capabilities
1241
+ - Example: `schema.fields.name.type === 'SHORT_TEXT'`
1095
1242
 
1096
1243
  • **actions** - Server operation functions
1097
1244
  - Pre-configured API calls for CRUD operations
1098
1245
  - Use with optimistic actions for best UX
1246
+ - All actions return Promises and handle server communication
1099
1247
  - Example: `await schema.actions.update(item)`
1100
1248
 
1101
1249
  ### Available Schema Actions
1102
1250
 
1103
- - schema.actions.create(item) // Create single item
1104
- - schema.actions.update(item) // Update single item
1105
- - schema.actions.delete(itemId) // Delete by ID
1106
- - schema.actions.bulkUpdate(updates) // Update multiple items
1107
- - 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
1108
1287
 
1109
1288
  ### Schema Validation Checklist
1110
1289
 
@@ -1115,74 +1294,19 @@ Before using schema in operations:
1115
1294
  ✓ Use `schema.idField` for ID operations
1116
1295
  ✓ Use `schema.displayField` for UI display
1117
1296
  ✓ Use `schema.actions` for server operations
1297
+ ✓ Check field capabilities before applying filters or sorting
1118
1298
 
1119
1299
  ### Common Usage Patterns
1120
1300
 
1121
1301
  - **ActionCell**: Use `schema.actions.update()` or `schema.actions.delete()` for single item operations
1122
- - **BulkActions**: Use `schema.actions.bulkUpdate()` or `schema.actions.bulkDelete()` for multiple items
1302
+ - **BulkActions**: Use `schema.actions.bulkDelete()` for multiple items
1123
1303
  - **Dynamic UI**: Use `schema.fields` to build forms or validate data
1124
1304
  - **Error Messages**: Use `schema.displayField` to create meaningful user feedback
1125
-
1126
- ---
1127
-
1128
- ## Filters Configuration Notes
1129
-
1130
- 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:
1131
-
1132
- * `numberConfig`: used with fields of type `NUMBER`
1133
- * `dateConfig`: used with fields of type `DATETIME`
1134
- * `booleanConfig`: used with fields of type `BOOLEAN`
1135
- * `enumConfig`: used with fields of type `ARRAY` or `ARRAY_STRING`
1136
-
1137
- ### Enum Configuration Implementation
1138
-
1139
- 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:
1140
-
1141
- #### Example: User-Provided Enum Implementation
1142
-
1143
- 1. First, collect the possible values from the user:
1144
- ```
1145
- User requests: "I need a filter for pet types."
1146
- You ask: "What are the possible values for pet types that should be available in the filter?"
1147
- User responds: "dog, cat, bird, rabbit, fish"
1148
- ```
1149
-
1150
- 2. Then, create the `enumConfig` structure:
1151
- ```json
1152
- "enumConfig": {
1153
- "options": [
1154
- { "value": "dog", "label": "Dog" },
1155
- { "value": "cat", "label": "Cat" },
1156
- { "value": "bird", "label": "Bird" },
1157
- { "value": "rabbit", "label": "Rabbit" },
1158
- { "value": "fish", "label": "Fish" }
1159
- ],
1160
- "selectionMode": "multiple",
1161
- "optionType": "checkbox"
1162
- }
1163
- ```
1164
-
1165
- Notice how the `label` is derived from the `value` by capitalizing the first letter. The user's exact values become the `value` property.
1166
-
1167
- ### Grouping Filters with Section Title
1168
-
1169
- * Filters can be grouped by sections using the `sectionTitle` property.
1170
- * If multiple filter items share the same `sectionTitle`, they will be displayed together in a grouped section in the UI.
1171
- * Filters without a `sectionTitle` will appear in a default section or be displayed individually.
1172
- * Grouping helps maintain clarity, especially when dealing with multiple filter options.
1173
-
1174
- ### Key Guidelines
1175
-
1176
- * **openByDefault**: Automatically expands the filter accordion when the filters panel is opened.
1177
- * **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`.
1178
- * **maxInlineFilters**: Limits the number of filters shown inline in the table toolbar. Others are accessible via the panel. Default is 0.
1179
- * **dateConfig.mode**:
1180
-
1181
- * `ONLY_PREDEFINED`: user can select only from preset options
1182
- * `ONLY_CUSTOM`: user must select a custom date range manually (no presets)
1183
- * `COMBINE`: both options available
1184
- * **dateConfig.presets** must be omitted if mode is `ONLY_CUSTOM`.
1185
- * **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
1186
1310
 
1187
1311
  ---
1188
1312
 
@@ -1190,7 +1314,7 @@ Notice how the `label` is derived from the `value` by capitalizing the first let
1190
1314
 
1191
1315
  The ActionCell feature adds an interactive action column to collection tables or grid views, enabling users to perform operations on individual entities.
1192
1316
 
1193
- ### Placement and Structure
1317
+ ## Placement and Structure
1194
1318
 
1195
1319
  The ActionCell has a two-level structure:
1196
1320
  * `primaryAction`: A single prominent action shown directly in the table/grid row
@@ -1225,6 +1349,22 @@ Both properties are optional, but at least one should be provided for the Action
1225
1349
  - Complex operations
1226
1350
  - ⚠️ Requires implementation: Must register action in overrides
1227
1351
 
1352
+ ### Action Appearance: The `skin` Property
1353
+
1354
+ All action types support the optional `skin` property to customize the visual appearance of action buttons. The skin determines the button's color scheme and visual emphasis.
1355
+
1356
+ #### Skin Values by Action Type:
1357
+
1358
+ **Primary Actions** support these skin values:
1359
+ - `"standard"` - Default appearance (blue primary button)
1360
+ - `"inverted"` - Inverted color scheme
1361
+ - `"premium"` - Premium styling for premium features
1362
+
1363
+ **Secondary Actions** support these skin values:
1364
+ - `"dark"` - Dark appearance
1365
+ - `"destructive"` - Red appearance for dangerous actions (ideal for delete operations)
1366
+ - `"premium"` - Premium styling for premium features
1367
+
1228
1368
  ### Type Selection Decision Tree
1229
1369
 
1230
1370
  When choosing an action type, follow this decision process:
@@ -1400,6 +1540,9 @@ AI agents should verify these requirements before generating ActionCell configur
1400
1540
  ✓ `inlineCount` (if specified) is a non-negative number ≤ total secondary actions count
1401
1541
  ✓ `inlineAlwaysVisible` (if specified) is a boolean value
1402
1542
  ✓ Inline secondary actions configuration is applied only when secondary actions exist
1543
+ ✓ `skin` property (if specified) uses valid skin values:
1544
+ - Primary actions: `"standard"`, `"inverted"`, `"premium"`
1545
+ - Secondary actions: `"dark"`, `"destructive"`, `"premium"`
1403
1546
 
1404
1547
  ---
1405
1548
 
@@ -1407,7 +1550,7 @@ AI agents should verify these requirements before generating ActionCell configur
1407
1550
 
1408
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.
1409
1552
 
1410
- ### Placement and Structure
1553
+ ## Placement and Structure
1411
1554
 
1412
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:
1413
1556
  * `primaryActions`: Actions shown directly in the bulk action toolbar
@@ -1962,10 +2105,13 @@ your-page/
1962
2105
  │ ├── index.tsx
1963
2106
  │ ├── name.ts
1964
2107
  │ └── date.ts
1965
- └── 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
1966
2113
  ├── index.tsx
1967
- ├── CustomNameField.tsx
1968
- └── InfoCard.tsx
2114
+ └── myCustomDataSource.ts
1969
2115
  ```
1970
2116
 
1971
2117
  ### Importing Overrides in Your Page
@@ -1977,8 +2123,9 @@ import * as modals from './components/modals';
1977
2123
  import * as actions from './components/actions';
1978
2124
  import * as columns from './components/columns';
1979
2125
  import * as components from './components/customComponents';
2126
+ import * as customDataSources from './components/customDataSources';
1980
2127
 
1981
- <PatternsWizardOverridesProvider value={{ modals, actions, columns, components }}>
2128
+ <PatternsWizardOverridesProvider value={{ modals, actions, columns, components, customDataSources }}>
1982
2129
  <AutoPatternsApp configuration={config as AppConfig} />
1983
2130
  </PatternsWizardOverridesProvider>
1984
2131
  ```
@@ -1992,6 +2139,7 @@ For example:
1992
2139
  - Adding a new modal → Update `./components/modals/index.tsx`
1993
2140
  - Adding a new column override → Update `./components/columns/index.tsx`
1994
2141
  - Adding a new custom component → Update `./components/customComponents/index.tsx`
2142
+ - Adding a new custom data source → Update `./components/customDataSources/index.tsx`
1995
2143
 
1996
2144
  Without updating the index files, your implementations won't be available to the `PatternsWizardOverridesProvider`.
1997
2145
 
@@ -2444,4 +2592,158 @@ PatternsWizardOverridesProvider
2444
2592
 
2445
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.
2446
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
+
2447
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