jpie 1.0.0 → 1.0.1

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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/.cursor/rules/release.mdc +62 -0
  3. data/.gitignore +5 -0
  4. data/.rubocop.yml +82 -38
  5. data/Gemfile +12 -10
  6. data/Gemfile.lock +10 -1
  7. data/README.md +675 -1235
  8. data/jpie.gemspec +15 -15
  9. data/kiln/app/resources/user_message_resource.rb +2 -0
  10. data/lib/jpie.rb +0 -1
  11. data/lib/json_api/active_storage/deserialization.rb +32 -22
  12. data/lib/json_api/active_storage/detection.rb +36 -41
  13. data/lib/json_api/active_storage/serialization.rb +13 -11
  14. data/lib/json_api/configuration.rb +4 -5
  15. data/lib/json_api/controllers/base_controller.rb +3 -3
  16. data/lib/json_api/controllers/concerns/controller_helpers/authorization.rb +30 -0
  17. data/lib/json_api/controllers/concerns/controller_helpers/document_meta.rb +20 -0
  18. data/lib/json_api/controllers/concerns/controller_helpers/error_rendering.rb +64 -0
  19. data/lib/json_api/controllers/concerns/controller_helpers/parsing.rb +127 -0
  20. data/lib/json_api/controllers/concerns/controller_helpers/resource_setup.rb +38 -0
  21. data/lib/json_api/controllers/concerns/controller_helpers.rb +11 -215
  22. data/lib/json_api/controllers/concerns/relationships/active_storage_removal.rb +65 -0
  23. data/lib/json_api/controllers/concerns/relationships/events.rb +44 -0
  24. data/lib/json_api/controllers/concerns/relationships/removal.rb +92 -0
  25. data/lib/json_api/controllers/concerns/relationships/response_helpers.rb +55 -0
  26. data/lib/json_api/controllers/concerns/relationships/serialization.rb +72 -0
  27. data/lib/json_api/controllers/concerns/relationships/sorting.rb +114 -0
  28. data/lib/json_api/controllers/concerns/relationships/updating.rb +73 -0
  29. data/lib/json_api/controllers/concerns/relationships_controller/active_storage_removal.rb +67 -0
  30. data/lib/json_api/controllers/concerns/relationships_controller/events.rb +44 -0
  31. data/lib/json_api/controllers/concerns/relationships_controller/removal.rb +92 -0
  32. data/lib/json_api/controllers/concerns/relationships_controller/response_helpers.rb +55 -0
  33. data/lib/json_api/controllers/concerns/relationships_controller/serialization.rb +72 -0
  34. data/lib/json_api/controllers/concerns/relationships_controller/sorting.rb +114 -0
  35. data/lib/json_api/controllers/concerns/relationships_controller/updating.rb +73 -0
  36. data/lib/json_api/controllers/concerns/resource_actions/crud_helpers.rb +93 -0
  37. data/lib/json_api/controllers/concerns/resource_actions/field_validation.rb +114 -0
  38. data/lib/json_api/controllers/concerns/resource_actions/filter_validation.rb +91 -0
  39. data/lib/json_api/controllers/concerns/resource_actions/pagination.rb +51 -0
  40. data/lib/json_api/controllers/concerns/resource_actions/preloading.rb +64 -0
  41. data/lib/json_api/controllers/concerns/resource_actions/resource_loading.rb +71 -0
  42. data/lib/json_api/controllers/concerns/resource_actions/serialization.rb +63 -0
  43. data/lib/json_api/controllers/concerns/resource_actions/type_validation.rb +75 -0
  44. data/lib/json_api/controllers/concerns/resource_actions.rb +51 -602
  45. data/lib/json_api/controllers/relationships_controller.rb +26 -422
  46. data/lib/json_api/errors/parameter_not_allowed.rb +1 -1
  47. data/lib/json_api/railtie.rb +46 -9
  48. data/lib/json_api/resources/active_storage_blob_resource.rb +9 -1
  49. data/lib/json_api/resources/concerns/attributes_dsl.rb +69 -0
  50. data/lib/json_api/resources/concerns/filters_dsl.rb +32 -0
  51. data/lib/json_api/resources/concerns/meta_dsl.rb +23 -0
  52. data/lib/json_api/resources/concerns/model_class_helpers.rb +37 -0
  53. data/lib/json_api/resources/concerns/relationships_dsl.rb +71 -0
  54. data/lib/json_api/resources/concerns/sortable_fields_dsl.rb +36 -0
  55. data/lib/json_api/resources/resource.rb +13 -219
  56. data/lib/json_api/routing.rb +56 -47
  57. data/lib/json_api/serialization/concerns/attributes_deserialization.rb +27 -0
  58. data/lib/json_api/serialization/concerns/attributes_serialization.rb +50 -0
  59. data/lib/json_api/serialization/concerns/deserialization_helpers.rb +115 -0
  60. data/lib/json_api/serialization/concerns/includes_serialization.rb +82 -0
  61. data/lib/json_api/serialization/concerns/links_serialization.rb +33 -0
  62. data/lib/json_api/serialization/concerns/meta_serialization.rb +60 -0
  63. data/lib/json_api/serialization/concerns/model_attributes_transformation.rb +69 -0
  64. data/lib/json_api/serialization/concerns/relationship_processing.rb +119 -0
  65. data/lib/json_api/serialization/concerns/relationships_deserialization.rb +47 -0
  66. data/lib/json_api/serialization/concerns/relationships_serialization.rb +81 -0
  67. data/lib/json_api/serialization/deserializer.rb +10 -346
  68. data/lib/json_api/serialization/serializer.rb +17 -260
  69. data/lib/json_api/support/active_storage_support.rb +10 -13
  70. data/lib/json_api/support/collection_query.rb +14 -370
  71. data/lib/json_api/support/concerns/condition_building.rb +57 -0
  72. data/lib/json_api/support/concerns/nested_filters.rb +130 -0
  73. data/lib/json_api/support/concerns/pagination.rb +30 -0
  74. data/lib/json_api/support/concerns/polymorphic_filters.rb +75 -0
  75. data/lib/json_api/support/concerns/regular_filters.rb +81 -0
  76. data/lib/json_api/support/concerns/sorting.rb +88 -0
  77. data/lib/json_api/support/instrumentation.rb +13 -12
  78. data/lib/json_api/support/param_helpers.rb +9 -6
  79. data/lib/json_api/support/relationship_helpers.rb +4 -2
  80. data/lib/json_api/support/resource_identifier.rb +29 -29
  81. data/lib/json_api/support/responders.rb +5 -5
  82. data/lib/json_api/version.rb +1 -1
  83. metadata +51 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62171c1b27fad940974c76392b5ca259c829cb798e9fd05800fb2fcc4c161da5
4
- data.tar.gz: f870d74a22aea2d9cf754991f540c5e65dceda51196ba93f51ebffc0a6eb5de2
3
+ metadata.gz: a8d19fff52264fdefbdba8d63bae64a532cbd2daddfdcfbfaa9ffd205d028822
4
+ data.tar.gz: c10827822e1638a8e0690a8432709a0cfc7d3fc5d82a845e276d74c66f8761c3
5
5
  SHA512:
6
- metadata.gz: 3b2f514c5b3e1c722b47087805a8c99c8c81bbca4dc6b8fec11efaef88f66f31d8e35fda7d9a8872da87fc50e165830ef3e76f6a74398e61508263d0727acb3f
7
- data.tar.gz: 60e0ebca7e4505952920df86905b142ba051d8720ec29583a119a0d204626f19141f4eeb0c3f26df6828a9751b0ce23908093fcceb14589868829bc1c2aa9b3f
6
+ metadata.gz: 7693f48c7c20c4879478a72e233c092dd4e0a90e1ca038129b3c3d2821d2d07d0cfa50bd73b166c2c5235e2e580869b989fce91928916b2df671e397811002d7
7
+ data.tar.gz: 859af674c3a0eca429e86ed566df855141806b1d26d15f7dacfa2fad5ab93699957a9c30e218199bb04152b6ab865e690c0ed1cf54296ebc9fe58de0fd967dc2
@@ -0,0 +1,62 @@
1
+ ---
2
+ description: Rules for releasing the jpie gem to RubyGems
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # Gem Release Rules
7
+
8
+ ## Core Principles
9
+
10
+ - **OTP Authentication Required**: RubyGems release requires OTP (One-Time Password) codes for authentication
11
+ - **Interactive Release Flow**: The `rake release` command will prompt for an OTP code during push to RubyGems
12
+ - **Cannot be fully automated**: Due to OTP requirements, gem releases require human interaction
13
+ - **Tests and Linting Must Pass**: Both `rspec` and `rubocop` must pass before releasing
14
+
15
+ ## Release Process
16
+
17
+ ### Steps
18
+
19
+ 1. Bump the version in `lib/json_api/version.rb`
20
+ 2. Run tests to ensure everything passes: `bundle exec rspec`
21
+ 3. Run linting to ensure code quality: `bundle exec rubocop`
22
+ 4. Commit the version bump (include `Gemfile.lock` changes)
23
+ 5. Run `bundle exec rake release` which will:
24
+ - Build the gem
25
+ - Create a git tag
26
+ - Push the tag to the remote
27
+ - Push the gem to RubyGems (requires OTP code entry)
28
+
29
+ ### OTP Code Entry
30
+
31
+ When running `rake release`, you will be prompted:
32
+
33
+ ```
34
+ Enter OTP code:
35
+ ```
36
+
37
+ Enter your RubyGems authenticator OTP code to complete the release.
38
+
39
+ ## Implementation Guidelines
40
+
41
+ ### Version Bump
42
+
43
+ ```ruby
44
+ # lib/json_api/version.rb
45
+ module JSONAPI
46
+ VERSION = "x.y.z" # Update patch/minor/major as needed
47
+ end
48
+ ```
49
+
50
+ ### Release Command
51
+
52
+ ```bash
53
+ bundle exec rake release
54
+ ```
55
+
56
+ ## Best Practices
57
+
58
+ - Always run the full test suite (`bundle exec rspec`) before releasing - it must pass
59
+ - Always run linting (`bundle exec rubocop`) before releasing - it must pass
60
+ - Ensure `Gemfile.lock` is committed with version changes
61
+ - Have your authenticator app ready for the OTP prompt
62
+ - Verify the release on rubygems.org after completion
data/.gitignore CHANGED
@@ -19,3 +19,8 @@ spec/dummy/log/*.log.*
19
19
 
20
20
  # dummy app tmp directory
21
21
  spec/dummy/tmp/
22
+
23
+ # SQLite test databases
24
+ spec/dummy/db/*.sqlite3
25
+ spec/dummy/db/*.sqlite3-shm
26
+ spec/dummy/db/*.sqlite3-wal
data/.rubocop.yml CHANGED
@@ -1,57 +1,66 @@
1
- require:
2
- - ./lib/rubocop/cop/custom/hash_value_omission.rb
1
+ plugins:
2
+ - rubocop-rspec
3
+ - rubocop-performance
3
4
 
4
5
  AllCops:
5
6
  NewCops: enable
6
7
  TargetRubyVersion: 3.4
7
8
  SuggestExtensions: false
8
9
  Exclude:
9
- - "vendor/**/*"
10
+ - "bin/**/*"
11
+ - "pkg/**/*"
10
12
  - "tmp/**/*"
11
- - "spec/dummy/**/*"
12
- - "**/*.gemspec"
13
+ - "vendor/**/*"
14
+ - "spec/dummy/db/schema.rb"
15
+ - "spec/dummy/db/migrate/**/*"
16
+ - "spec/dummy/tmp/**/*"
17
+ - "spec/dummy/log/**/*"
13
18
 
19
+ # Gem-specific: ensure dev dependencies are in gemspec
14
20
  Gemspec/DevelopmentDependencies:
15
- Enabled: false
16
-
17
- Metrics/AbcSize:
18
- Enabled: false
19
-
20
- Metrics/BlockLength:
21
- Enabled: false
22
-
23
- Metrics/BlockNesting:
24
- Enabled: false
21
+ Enabled: true
22
+ EnforcedStyle: gemspec
25
23
 
26
- Metrics/ClassLength:
27
- Enabled: false
24
+ # Layout
25
+ Layout/LineLength:
26
+ Max: 120
27
+ AllowedPatterns:
28
+ - "^\\s*#" # Allow long comments
29
+ Exclude:
30
+ - "spec/**/*"
28
31
 
29
- Metrics/CollectionLiteralLength:
30
- Enabled: false
32
+ Layout/MultilineMethodCallIndentation:
33
+ EnforcedStyle: indented
31
34
 
32
- Metrics/CyclomaticComplexity:
33
- Enabled: true
34
- Max: 7
35
+ Layout/FirstArrayElementIndentation:
36
+ EnforcedStyle: consistent
35
37
 
36
- Metrics/MethodLength:
37
- Enabled: true
38
- Max: 10
38
+ Layout/FirstHashElementIndentation:
39
+ EnforcedStyle: consistent
39
40
 
40
- Metrics/ModuleLength:
41
- Enabled: true
42
- Max: 150
41
+ # Metrics - exclude spec and gemspec blocks only
42
+ Metrics/BlockLength:
43
+ Exclude:
44
+ - "spec/**/*"
45
+ - "*.gemspec"
46
+ - "Rakefile"
43
47
 
44
48
  Metrics/ParameterLists:
45
- Enabled: true
46
- Max: 5
47
-
48
- Metrics/PerceivedComplexity:
49
- Enabled: true
50
- Max: 8
49
+ CountKeywordArgs: false
51
50
 
51
+ # Naming - allow DSL methods
52
52
  Naming/PredicatePrefix:
53
- Enabled: false
54
-
53
+ AllowedMethods:
54
+ - is_a?
55
+ - has_key?
56
+ - has_value?
57
+ - has_one
58
+ - has_many
59
+ - has_setter?
60
+ - has_id?
61
+ - has_type?
62
+
63
+ # Style
55
64
  Style/Documentation:
56
65
  Enabled: false
57
66
 
@@ -61,5 +70,40 @@ Style/DocumentationMethod:
61
70
  Style/StringLiterals:
62
71
  EnforcedStyle: double_quotes
63
72
 
64
- Custom/HashValueOmission:
65
- Enabled: true
73
+ Style/StringLiteralsInInterpolation:
74
+ EnforcedStyle: double_quotes
75
+
76
+ Style/FrozenStringLiteralComment:
77
+ EnforcedStyle: always
78
+
79
+ Style/TrailingCommaInArrayLiteral:
80
+ EnforcedStyleForMultiline: consistent_comma
81
+
82
+ Style/TrailingCommaInHashLiteral:
83
+ EnforcedStyleForMultiline: consistent_comma
84
+
85
+ Style/TrailingCommaInArguments:
86
+ EnforcedStyleForMultiline: consistent_comma
87
+
88
+ Style/HashSyntax:
89
+ EnforcedShorthandSyntax: either
90
+
91
+ # Lint - file-specific exclusions
92
+ Lint/UnusedBlockArgument:
93
+ Exclude:
94
+ - "spec/jsonapi/authorization_spec.rb"
95
+
96
+ # RSpec - file-specific exclusions
97
+ RSpec/DescribedClass:
98
+ Exclude:
99
+ - "spec/jsonapi/base_controller_spec.rb"
100
+
101
+ # Allow deeper nesting in complex integration specs
102
+ RSpec/NestedGroups:
103
+ Max: 4
104
+ Exclude:
105
+ - "spec/jsonapi_spec/active_storage_spec.rb"
106
+
107
+ # Allow more memoized helpers in complex specs
108
+ RSpec/MultipleMemoizedHelpers:
109
+ Max: 8
data/Gemfile CHANGED
@@ -8,14 +8,16 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
8
8
  gemspec
9
9
 
10
10
  group :development, :test do
11
- gem 'appraisal', '~> 2.4'
12
- gem 'bundler', '~> 2.0'
13
- gem 'json_schemer', '~> 2.4'
14
- gem 'pundit', '~> 2.3'
15
- gem 'rake', '~> 13.0'
16
- gem 'rspec', '~> 3.12'
17
- gem 'rspec-rails', '~> 6.0'
18
- gem 'rubocop', '~> 1.0'
19
- gem 'rubocop-rails', '~> 2.0'
20
- gem 'sqlite3', '>= 2.1'
11
+ gem "appraisal", "~> 2.4"
12
+ gem "bundler", "~> 2.0"
13
+ gem "json_schemer", "~> 2.4"
14
+ gem "pundit", "~> 2.3"
15
+ gem "rake", "~> 13.0"
16
+ gem "rspec", "~> 3.12"
17
+ gem "rspec-rails", "~> 6.0"
18
+ gem "rubocop", "~> 1.0"
19
+ gem "rubocop-performance", "~> 1.0"
20
+ gem "rubocop-rails", "~> 2.0"
21
+ gem "rubocop-rspec", "~> 3.0"
22
+ gem "sqlite3", ">= 2.1"
21
23
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jpie (0.1.0)
4
+ jpie (1.0.1)
5
5
  actionpack (~> 8.0, >= 8.0.0)
6
6
  rails (~> 8.0, >= 8.0.0)
7
7
 
@@ -251,12 +251,19 @@ GEM
251
251
  rubocop-ast (1.48.0)
252
252
  parser (>= 3.3.7.2)
253
253
  prism (~> 1.4)
254
+ rubocop-performance (1.26.1)
255
+ lint_roller (~> 1.1)
256
+ rubocop (>= 1.75.0, < 2.0)
257
+ rubocop-ast (>= 1.47.1, < 2.0)
254
258
  rubocop-rails (2.34.0)
255
259
  activesupport (>= 4.2.0)
256
260
  lint_roller (~> 1.1)
257
261
  rack (>= 1.1)
258
262
  rubocop (>= 1.75.0, < 2.0)
259
263
  rubocop-ast (>= 1.44.0, < 2.0)
264
+ rubocop-rspec (3.8.0)
265
+ lint_roller (~> 1.1)
266
+ rubocop (~> 1.81)
260
267
  ruby-progressbar (1.13.0)
261
268
  securerandom (0.4.1)
262
269
  simpleidn (0.2.3)
@@ -305,7 +312,9 @@ DEPENDENCIES
305
312
  rspec (~> 3.12)
306
313
  rspec-rails (~> 6.0)
307
314
  rubocop (~> 1.0)
315
+ rubocop-performance (~> 1.0)
308
316
  rubocop-rails (~> 2.0)
317
+ rubocop-rspec (~> 3.0)
309
318
  sqlite3 (>= 2.1)
310
319
 
311
320
  BUNDLED WITH