propel_api 0.3.1.6 โ 0.3.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +83 -0
- data/README.md +46 -1
- data/lib/generators/propel_api/controller/controller_generator.rb +13 -7
- data/lib/generators/propel_api/core/named_base.rb +1191 -103
- data/lib/generators/propel_api/install/install_generator.rb +43 -2
- data/lib/generators/propel_api/resource/resource_generator.rb +173 -61
- data/lib/generators/propel_api/templates/concerns/propel_controller_filters_concern.rb +141 -0
- data/lib/generators/propel_api/templates/concerns/propel_model_filters_concern.rb +128 -0
- data/lib/generators/propel_api/templates/controllers/api_controller_propel_facets.rb +1 -0
- data/lib/generators/propel_api/templates/lib/XX_dynamic_scope_generator.rb +360 -0
- data/lib/generators/propel_api/templates/lib/propel_dynamic_scope_generator.rb +474 -0
- data/lib/generators/propel_api/templates/lib/propel_filter_operators.rb +16 -0
- data/lib/generators/propel_api/templates/scaffold/facet_model_template.rb.tt +14 -0
- data/lib/generators/propel_api/templates/seeds/seeds_template.rb.tt +100 -6
- data/lib/generators/propel_api/templates/tests/controller_test_template.rb.tt +9 -0
- data/lib/generators/propel_api/templates/tests/integration_test_template.rb.tt +660 -10
- data/lib/generators/propel_api/templates/tests/model_test_template.rb.tt +7 -0
- data/lib/propel_api.rb +1 -1
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab74f199f5f59a6a62a0f39a8c63960a7b1339b46bd32701219a6249f6cdb5a3
|
4
|
+
data.tar.gz: c4aa9676d91f4400cd54f0aa6d5ce0a022f9b6c893ec7b3124da057f679d8770
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27513e98749a5b837f3f7c1e10280e49155ec5a8113c8319c1b8994e17efaf79cba9c549f74a82982a386fa30d2505d62aeadb84d7bd1af9e0debc9576a52d80
|
7
|
+
data.tar.gz: 8d1c4bc5f35ac31d8d42570c7d0829e488242512631ab5d883a382fddc77bb12f3c94daa36645b6fefbc92ab50ccad455a4464225749b047ca1dbbcc27f53fb0
|
data/CHANGELOG.md
CHANGED
@@ -10,6 +10,89 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
10
10
|
### Planned Features
|
11
11
|
- GraphQL adapter support
|
12
12
|
|
13
|
+
## [0.3.3] - 2025-01-XX
|
14
|
+
|
15
|
+
### ๐ Major Features Added
|
16
|
+
- **Comprehensive Dynamic Filtering System**: Complete implementation of automatic URL query string filtering and scoping using the `has_scope` gem
|
17
|
+
- **Multi-Type Filtering Support**: Full filtering support across all data types (string, numeric, boolean, datetime, date, time)
|
18
|
+
- **Database-Agnostic Implementation**: Works seamlessly across SQLite, PostgreSQL, and MySQL without database-specific code
|
19
|
+
- **Automatic Scope Generation**: Dynamic scope generation based on model column types and filter operators
|
20
|
+
- **Intelligent Facet Integration**: Automatic inclusion of filterable fields in JSON facets for API responses
|
21
|
+
|
22
|
+
### ๐ Advanced Filtering Capabilities
|
23
|
+
- **String Filtering**: Exact match (`_eq`), contains (`_contains`), starts with (`_starts_with`), ends with (`_ends_with`), in list (`_in`)
|
24
|
+
- **Numeric Filtering**: Comparison operators (`_gt`, `_lt`, `_gte`, `_lte`), range filtering (`_range`), in list (`_in`)
|
25
|
+
- **Boolean Filtering**: Multiple value format support (`true`/`false`, `1`/`0`, `yes`/`no`, `on`/`off`)
|
26
|
+
- **DateTime Filtering**: Temporal comparisons (`_before`, `_after`), date extraction (`_year`, `_month`, `_day`), date matching (`_date`)
|
27
|
+
- **Range Filtering**: Support for both array and string formats (e.g., `"150,350"` or `[150, 350]`)
|
28
|
+
|
29
|
+
### ๐ ๏ธ Technical Implementation
|
30
|
+
- **PropelDynamicScopeGenerator**: New generator class for automatic scope creation based on model columns
|
31
|
+
- **PropelModelFiltersConcern**: Model concern for dynamic scope generation and filter parameter validation
|
32
|
+
- **PropelControllerFiltersConcern**: Controller concern for has_scope integration and security validation
|
33
|
+
- **PropelFilterOperators**: Configuration class defining available operators for each data type
|
34
|
+
- **Database-Agnostic Datetime Parsing**: Ruby-based datetime parsing instead of SQL extraction functions
|
35
|
+
|
36
|
+
### ๐ Security & Performance
|
37
|
+
- **Input Validation**: Comprehensive validation of filter parameters against allowed field names and operators
|
38
|
+
- **SQL Injection Protection**: All parameters properly escaped and parameterized
|
39
|
+
- **Multi-Tenancy Integration**: Automatic organization scoping for all filtered queries
|
40
|
+
- **Sensitive Field Filtering**: Automatic exclusion of sensitive fields (passwords, tokens, etc.) from filtering
|
41
|
+
- **Performance Optimization**: Efficient range queries and indexed field prioritization
|
42
|
+
|
43
|
+
### ๐ Enhanced JSON Facet System
|
44
|
+
- **Smart Field Inclusion**: Automatic inclusion of boolean and datetime fields in `:short` facets
|
45
|
+
- **Exclusion Lists**: Configurable exclusion of specific fields (e.g., `created_at`, `updated_at`, `internal_flag`)
|
46
|
+
- **Consistent Serialization**: Ensures filterable fields are available in API responses for client-side filtering
|
47
|
+
|
48
|
+
### ๐งช Comprehensive Testing
|
49
|
+
- **Test-Driven Development**: Complete test suite with 992 tests covering all filtering scenarios
|
50
|
+
- **Fixture-Aware Testing**: Unique test data values to avoid conflicts with fixture data
|
51
|
+
- **Multi-Tenancy Testing**: Proper testing of organization-scoped filtering
|
52
|
+
- **Edge Case Coverage**: Testing of invalid inputs, empty values, and error conditions
|
53
|
+
- **Database Compatibility**: Tests pass across SQLite, PostgreSQL, and MySQL
|
54
|
+
|
55
|
+
### ๐ Documentation & Examples
|
56
|
+
- **Comprehensive API Documentation**: Complete filtering documentation with examples for all operators
|
57
|
+
- **Postman Collection Ready**: Detailed query parameter examples for testing
|
58
|
+
- **Error Handling Guide**: Common error scenarios and troubleshooting tips
|
59
|
+
- **Performance Guidelines**: Optimization recommendations for large datasets
|
60
|
+
|
61
|
+
### ๐ง Configuration & Customization
|
62
|
+
- **Flexible Operator Configuration**: Easy addition of new filter operators via `PropelFilterOperators`
|
63
|
+
- **Customizable Field Exclusions**: Configurable lists for fields to exclude from facets
|
64
|
+
- **Template-Based Generation**: All filtering code generated via ERB templates for easy customization
|
65
|
+
- **Backward Compatibility**: Existing applications continue to work without changes
|
66
|
+
|
67
|
+
### ๐ Bug Fixes
|
68
|
+
- **Template Syntax Errors**: Fixed ERB template syntax issues with `next` vs `return` in select blocks
|
69
|
+
- **Scope Generation Caching**: Resolved issues with cached scopes not updating after template changes
|
70
|
+
- **Datetime Parsing Errors**: Fixed datetime scope generation to handle multiple input formats
|
71
|
+
- **SQL Compatibility**: Resolved SQLite `EXTRACT` function compatibility issues
|
72
|
+
|
73
|
+
## [0.3.2] - 2025-09-15
|
74
|
+
|
75
|
+
### ๐ Critical Bug Fixes
|
76
|
+
- **Generator Destroy/Rollback Functionality**: Fixed critical issues with resource generator destroy and rollback operations
|
77
|
+
- Fixed `propel_api:resource` generator to properly handle destroy operations and rollbacks
|
78
|
+
- Enhanced controller generator with improved destroy and rollback logic
|
79
|
+
- Completely rebuilt and improved `named_base.rb` core infrastructure with comprehensive destroy/rollback support
|
80
|
+
- Added robust error handling and cleanup procedures for failed generator operations
|
81
|
+
- Fixed edge cases where incomplete generator runs could leave orphaned files or partial configurations
|
82
|
+
- Enhanced generator infrastructure to properly track and reverse all file operations and modifications
|
83
|
+
|
84
|
+
### ๐ ๏ธ Generator Infrastructure Improvements
|
85
|
+
- **Enhanced Core Named Base**: Major improvements to the core generator infrastructure
|
86
|
+
- Comprehensive rebuild of generator tracking and rollback mechanisms
|
87
|
+
- Better state management for complex generator operations
|
88
|
+
- Improved error recovery and cleanup procedures
|
89
|
+
- Enhanced file operation tracking for reliable rollbacks
|
90
|
+
- **Resource Generator Robustness**: Significantly improved resource generator reliability
|
91
|
+
- Better handling of partial generation scenarios
|
92
|
+
- Enhanced error reporting and recovery mechanisms
|
93
|
+
- Improved coordination between controller, model, migration, and test generation
|
94
|
+
- More reliable cleanup of generated artifacts during rollbacks
|
95
|
+
|
13
96
|
## [0.3.1.6] - 2025-09-13
|
14
97
|
|
15
98
|
### ๐ง Enhanced Multi-Tenancy Support
|
data/README.md
CHANGED
@@ -1,6 +1,51 @@
|
|
1
1
|
# PropelApi
|
2
2
|
|
3
|
-
A comprehensive Rails generator that creates complete API resources with models, controllers, tests, and realistic seed data. Supports both PropelFacets (JSON Facet) and Graphiti serialization engines with **fixed route insertion
|
3
|
+
A comprehensive Rails generator that creates complete API resources with models, controllers, tests, and realistic seed data. Supports both PropelFacets (JSON Facet) and Graphiti serialization engines with **fixed route insertion**, proper indentation, and **comprehensive dynamic filtering system**.
|
4
|
+
|
5
|
+
## ๐ NEW in v0.3.3: Dynamic Filtering System
|
6
|
+
|
7
|
+
PropelApi now includes a complete automatic URL query string filtering and scoping system using the `has_scope` gem. This provides powerful, database-agnostic filtering across all data types with zero configuration required.
|
8
|
+
|
9
|
+
### Quick Filtering Examples
|
10
|
+
|
11
|
+
```bash
|
12
|
+
# String filtering
|
13
|
+
GET /api/v1/meetings?title_contains=Project&status_in=active,pending
|
14
|
+
|
15
|
+
# Numeric filtering
|
16
|
+
GET /api/v1/meetings?max_participants_gte=50&max_participants_lte=200
|
17
|
+
|
18
|
+
# Boolean filtering
|
19
|
+
GET /api/v1/meetings?recording_enabled_eq=true&ai_research_enabled_eq=false
|
20
|
+
|
21
|
+
# DateTime filtering
|
22
|
+
GET /api/v1/meetings?start_time_after=2024-01-01T00:00:00Z&start_time_before=2024-12-31T23:59:59Z
|
23
|
+
|
24
|
+
# Range filtering
|
25
|
+
GET /api/v1/meetings?max_participants_range=150,350
|
26
|
+
|
27
|
+
# Combined filtering with sorting and pagination
|
28
|
+
GET /api/v1/meetings?title_contains=Project&max_participants_gte=50&order_by=start_time&page=1&limit=20
|
29
|
+
```
|
30
|
+
|
31
|
+
### Supported Filter Operators
|
32
|
+
|
33
|
+
| Data Type | Operators | Examples |
|
34
|
+
|-----------|-----------|----------|
|
35
|
+
| **String** | `_eq`, `_contains`, `_starts_with`, `_ends_with`, `_in` | `name_eq=Acme`, `title_contains=Project` |
|
36
|
+
| **Numeric** | `_eq`, `_gt`, `_lt`, `_gte`, `_lte`, `_range`, `_in` | `max_participants_gte=50`, `price_range=100,500` |
|
37
|
+
| **Boolean** | `_eq` (supports `true`/`false`, `1`/`0`, `yes`/`no`, `on`/`off`) | `recording_enabled_eq=true` |
|
38
|
+
| **DateTime** | `_before`, `_after`, `_year`, `_month`, `_day`, `_date` | `start_time_after=2024-01-01`, `created_at_year=2024` |
|
39
|
+
| **Date** | Same as DateTime | `event_date_after=2024-01-01` |
|
40
|
+
| **Time** | Same as DateTime | `start_time_hour=14` |
|
41
|
+
|
42
|
+
### Automatic Features
|
43
|
+
|
44
|
+
- **Zero Configuration**: Filtering works automatically for all generated resources
|
45
|
+
- **Database Agnostic**: Works with SQLite, PostgreSQL, and MySQL
|
46
|
+
- **Security Built-in**: SQL injection protection and input validation
|
47
|
+
- **Multi-tenancy Ready**: Automatic organization scoping
|
48
|
+
- **Performance Optimized**: Efficient queries with proper indexing support
|
4
49
|
|
5
50
|
## Installation
|
6
51
|
|
@@ -76,19 +76,25 @@ module PropelApi
|
|
76
76
|
validate_attributes_exist unless should_auto_introspect?
|
77
77
|
end
|
78
78
|
|
79
|
+
def check_dependencies_before_destroy
|
80
|
+
# Only check critical dependencies during destroy operations
|
81
|
+
check_for_critical_dependencies if behavior == :revoke
|
82
|
+
end
|
83
|
+
|
79
84
|
def create_controller
|
80
|
-
|
81
|
-
create_propel_controller
|
85
|
+
create_propel_controller_template
|
82
86
|
end
|
83
87
|
|
84
|
-
def
|
85
|
-
# Use shared method from Base class
|
88
|
+
def add_routes
|
86
89
|
create_propel_routes
|
87
90
|
end
|
88
91
|
|
89
|
-
def
|
90
|
-
|
91
|
-
|
92
|
+
def create_controller_test
|
93
|
+
create_propel_controller_test
|
94
|
+
end
|
95
|
+
|
96
|
+
def create_integration_test
|
97
|
+
create_propel_integration_test
|
92
98
|
end
|
93
99
|
|
94
100
|
def show_completion_message
|