jpie 1.0.0 → 1.0.2

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 (76) 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 +13 -10
  6. data/Gemfile.lock +18 -1
  7. data/README.md +675 -1235
  8. data/Rakefile +22 -0
  9. data/jpie.gemspec +15 -15
  10. data/kiln/app/resources/user_message_resource.rb +2 -0
  11. data/lib/jpie.rb +0 -1
  12. data/lib/json_api/active_storage/deserialization.rb +32 -22
  13. data/lib/json_api/active_storage/detection.rb +36 -41
  14. data/lib/json_api/active_storage/serialization.rb +13 -11
  15. data/lib/json_api/configuration.rb +4 -5
  16. data/lib/json_api/controllers/base_controller.rb +3 -3
  17. data/lib/json_api/controllers/concerns/controller_helpers/authorization.rb +30 -0
  18. data/lib/json_api/controllers/concerns/controller_helpers/document_meta.rb +20 -0
  19. data/lib/json_api/controllers/concerns/controller_helpers/error_rendering.rb +64 -0
  20. data/lib/json_api/controllers/concerns/controller_helpers/parsing.rb +127 -0
  21. data/lib/json_api/controllers/concerns/controller_helpers/resource_setup.rb +38 -0
  22. data/lib/json_api/controllers/concerns/controller_helpers.rb +11 -215
  23. data/lib/json_api/controllers/concerns/relationships/active_storage_removal.rb +65 -0
  24. data/lib/json_api/controllers/concerns/relationships/events.rb +44 -0
  25. data/lib/json_api/controllers/concerns/relationships/removal.rb +92 -0
  26. data/lib/json_api/controllers/concerns/relationships/response_helpers.rb +55 -0
  27. data/lib/json_api/controllers/concerns/relationships/serialization.rb +72 -0
  28. data/lib/json_api/controllers/concerns/relationships/sorting.rb +114 -0
  29. data/lib/json_api/controllers/concerns/relationships/updating.rb +73 -0
  30. data/lib/json_api/controllers/concerns/resource_actions/crud_helpers.rb +93 -0
  31. data/lib/json_api/controllers/concerns/resource_actions/field_validation.rb +114 -0
  32. data/lib/json_api/controllers/concerns/resource_actions/filter_validation.rb +91 -0
  33. data/lib/json_api/controllers/concerns/resource_actions/pagination.rb +51 -0
  34. data/lib/json_api/controllers/concerns/resource_actions/preloading.rb +64 -0
  35. data/lib/json_api/controllers/concerns/resource_actions/resource_loading.rb +71 -0
  36. data/lib/json_api/controllers/concerns/resource_actions/serialization.rb +63 -0
  37. data/lib/json_api/controllers/concerns/resource_actions/type_validation.rb +75 -0
  38. data/lib/json_api/controllers/concerns/resource_actions.rb +51 -602
  39. data/lib/json_api/controllers/relationships_controller.rb +26 -422
  40. data/lib/json_api/errors/parameter_not_allowed.rb +1 -1
  41. data/lib/json_api/railtie.rb +46 -9
  42. data/lib/json_api/resources/concerns/attributes_dsl.rb +69 -0
  43. data/lib/json_api/resources/concerns/filters_dsl.rb +32 -0
  44. data/lib/json_api/resources/concerns/meta_dsl.rb +23 -0
  45. data/lib/json_api/resources/concerns/model_class_helpers.rb +37 -0
  46. data/lib/json_api/resources/concerns/relationships_dsl.rb +71 -0
  47. data/lib/json_api/resources/concerns/sortable_fields_dsl.rb +36 -0
  48. data/lib/json_api/resources/resource.rb +13 -219
  49. data/lib/json_api/routing.rb +56 -47
  50. data/lib/json_api/serialization/concerns/attributes_deserialization.rb +27 -0
  51. data/lib/json_api/serialization/concerns/attributes_serialization.rb +50 -0
  52. data/lib/json_api/serialization/concerns/deserialization_helpers.rb +115 -0
  53. data/lib/json_api/serialization/concerns/includes_serialization.rb +82 -0
  54. data/lib/json_api/serialization/concerns/links_serialization.rb +33 -0
  55. data/lib/json_api/serialization/concerns/meta_serialization.rb +60 -0
  56. data/lib/json_api/serialization/concerns/model_attributes_transformation.rb +69 -0
  57. data/lib/json_api/serialization/concerns/relationship_processing.rb +119 -0
  58. data/lib/json_api/serialization/concerns/relationships_deserialization.rb +47 -0
  59. data/lib/json_api/serialization/concerns/relationships_serialization.rb +81 -0
  60. data/lib/json_api/serialization/deserializer.rb +10 -346
  61. data/lib/json_api/serialization/serializer.rb +17 -260
  62. data/lib/json_api/support/active_storage_support.rb +10 -13
  63. data/lib/json_api/support/collection_query.rb +14 -370
  64. data/lib/json_api/support/concerns/condition_building.rb +57 -0
  65. data/lib/json_api/support/concerns/nested_filters.rb +130 -0
  66. data/lib/json_api/support/concerns/pagination.rb +30 -0
  67. data/lib/json_api/support/concerns/polymorphic_filters.rb +75 -0
  68. data/lib/json_api/support/concerns/regular_filters.rb +81 -0
  69. data/lib/json_api/support/concerns/sorting.rb +88 -0
  70. data/lib/json_api/support/instrumentation.rb +13 -12
  71. data/lib/json_api/support/param_helpers.rb +9 -6
  72. data/lib/json_api/support/relationship_helpers.rb +4 -2
  73. data/lib/json_api/support/resource_identifier.rb +29 -29
  74. data/lib/json_api/support/responders.rb +5 -5
  75. data/lib/json_api/version.rb +1 -1
  76. metadata +44 -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: ecbe7000fb7dd1053c155ec2f9de3866bd3eb3138e4509dc5e8d226bcdbb054a
4
+ data.tar.gz: 07e03b20414abbfe7fb849fd5dd99f5390633ff9498bad3d064b5ed3894973a2
5
5
  SHA512:
6
- metadata.gz: 3b2f514c5b3e1c722b47087805a8c99c8c81bbca4dc6b8fec11efaef88f66f31d8e35fda7d9a8872da87fc50e165830ef3e76f6a74398e61508263d0727acb3f
7
- data.tar.gz: 60e0ebca7e4505952920df86905b142ba051d8720ec29583a119a0d204626f19141f4eeb0c3f26df6828a9751b0ce23908093fcceb14589868829bc1c2aa9b3f
6
+ metadata.gz: dc63cd8358e5a678bdd69e230f4a5842cf11ff0268006b615d0c5de7570d8da0ec9f83f7da40d2fc8d0758629fae95dfdde13eb34ef2ae384f1b764a6ac99857
7
+ data.tar.gz: ea527ed50fd384b5cd0e8f21a3cf1d5b23d7121f11b8ad712a5d44cf4adbdd1dfef56e8f2a50da3f34fe42698ef27ff538d59086c5575e70bc0ca9359b261a95
@@ -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,17 @@ 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 "simplecov", "~> 0.22", require: false
23
+ gem "sqlite3", ">= 2.1"
21
24
  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.2)
5
5
  actionpack (~> 8.0, >= 8.0.0)
6
6
  rails (~> 8.0, >= 8.0.0)
7
7
 
@@ -95,6 +95,7 @@ GEM
95
95
  crass (1.0.6)
96
96
  date (3.5.0)
97
97
  diff-lcs (1.6.2)
98
+ docile (1.4.1)
98
99
  drb (2.2.3)
99
100
  erb (6.0.0)
100
101
  erubi (1.13.1)
@@ -251,14 +252,27 @@ GEM
251
252
  rubocop-ast (1.48.0)
252
253
  parser (>= 3.3.7.2)
253
254
  prism (~> 1.4)
255
+ rubocop-performance (1.26.1)
256
+ lint_roller (~> 1.1)
257
+ rubocop (>= 1.75.0, < 2.0)
258
+ rubocop-ast (>= 1.47.1, < 2.0)
254
259
  rubocop-rails (2.34.0)
255
260
  activesupport (>= 4.2.0)
256
261
  lint_roller (~> 1.1)
257
262
  rack (>= 1.1)
258
263
  rubocop (>= 1.75.0, < 2.0)
259
264
  rubocop-ast (>= 1.44.0, < 2.0)
265
+ rubocop-rspec (3.8.0)
266
+ lint_roller (~> 1.1)
267
+ rubocop (~> 1.81)
260
268
  ruby-progressbar (1.13.0)
261
269
  securerandom (0.4.1)
270
+ simplecov (0.22.0)
271
+ docile (~> 1.1)
272
+ simplecov-html (~> 0.11)
273
+ simplecov_json_formatter (~> 0.1)
274
+ simplecov-html (0.13.2)
275
+ simplecov_json_formatter (0.1.4)
262
276
  simpleidn (0.2.3)
263
277
  sqlite3 (2.8.0-aarch64-linux-gnu)
264
278
  sqlite3 (2.8.0-aarch64-linux-musl)
@@ -305,7 +319,10 @@ DEPENDENCIES
305
319
  rspec (~> 3.12)
306
320
  rspec-rails (~> 6.0)
307
321
  rubocop (~> 1.0)
322
+ rubocop-performance (~> 1.0)
308
323
  rubocop-rails (~> 2.0)
324
+ rubocop-rspec (~> 3.0)
325
+ simplecov (~> 0.22)
309
326
  sqlite3 (>= 2.1)
310
327
 
311
328
  BUNDLED WITH