encoded_id-rails 1.0.0.rc1 → 1.0.0.rc7
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 +97 -18
- data/LICENSE.txt +1 -1
- data/README.md +81 -473
- data/context/encoded_id-rails.md +651 -0
- data/context/encoded_id.md +437 -0
- data/lib/encoded_id/rails/active_record_finders.rb +54 -0
- data/lib/encoded_id/rails/annotated_id.rb +14 -9
- data/lib/encoded_id/rails/annotated_id_parser.rb +9 -1
- data/lib/encoded_id/rails/coder.rb +55 -10
- data/lib/encoded_id/rails/composite_id_base.rb +39 -0
- data/lib/encoded_id/rails/configuration.rb +66 -10
- data/lib/encoded_id/rails/encoder_methods.rb +30 -7
- data/lib/encoded_id/rails/finder_methods.rb +11 -0
- data/lib/encoded_id/rails/model.rb +60 -7
- data/lib/encoded_id/rails/path_param.rb +8 -0
- data/lib/encoded_id/rails/persists.rb +55 -9
- data/lib/encoded_id/rails/query_methods.rb +21 -4
- data/lib/encoded_id/rails/railtie.rb +13 -0
- data/lib/encoded_id/rails/salt.rb +8 -0
- data/lib/encoded_id/rails/slugged_id.rb +14 -9
- data/lib/encoded_id/rails/slugged_id_parser.rb +9 -1
- data/lib/encoded_id/rails/slugged_path_param.rb +8 -0
- data/lib/encoded_id/rails.rb +11 -6
- data/lib/generators/encoded_id/rails/install_generator.rb +36 -2
- data/lib/generators/encoded_id/rails/templates/{encoded_id.rb → hashids_encoded_id.rb} +49 -5
- data/lib/generators/encoded_id/rails/templates/sqids_encoded_id.rb +116 -0
- metadata +16 -24
- data/.devcontainer/Dockerfile +0 -17
- data/.devcontainer/compose.yml +0 -10
- data/.devcontainer/devcontainer.json +0 -12
- data/.standard.yml +0 -3
- data/Appraisals +0 -9
- data/Gemfile +0 -24
- data/Rakefile +0 -20
- data/Steepfile +0 -4
- data/gemfiles/.bundle/config +0 -2
- data/gemfiles/rails_7.2.gemfile +0 -19
- data/gemfiles/rails_8.0.gemfile +0 -19
- data/lib/encoded_id/rails/version.rb +0 -7
- data/rbs_collection.yaml +0 -24
- data/sig/encoded_id/rails.rbs +0 -141
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1ef8577374a192378855b9f20acd2885770b3e49d379e3051a187db83f7de497
|
|
4
|
+
data.tar.gz: 9f574a5e8336f3588bf55c1cb9f69f8b47bcfd46a689bc007abd6f7e0143b8e6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 33157300365c009da10a1a035d88aeeff2e021cace89194ab779a0ec598dd8acb6614444143f01efc3982ff68f320ce1cc2511909ca57ff1a18c712569510256
|
|
7
|
+
data.tar.gz: '08879af617396021978d6b5a46833841a8362eca06a74d151cc36934200188526c5bacac5c57cd5abf84ee8e8816e31d7ae50277a5dae756608dca1c0c5f141c'
|
data/CHANGELOG.md
CHANGED
|
@@ -1,31 +1,110 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
- nothing yet
|
|
4
|
+
|
|
5
|
+
## [1.0.0] - unreleased
|
|
6
|
+
|
|
7
|
+
- First stable release!
|
|
8
|
+
|
|
9
|
+
**Important!!: `:sqids` are not compatible with `:hashids`, DO NOT CHANGE FROM ONE TO THE OTHER AFTER GOING LIVE.**
|
|
10
|
+
|
|
11
|
+
## [1.0.0.rc7] - 2025-11-19
|
|
12
|
+
|
|
13
|
+
### Breaking changes
|
|
14
|
+
|
|
15
|
+
- `ReversibleId` now no longer downcases the encodedid input string by default on decode, ie the `decode` option `downcase` is now `false`. This can be configured via the Rails configuration `downcase_on_decode` option. In a future release the `downcase` option will be removed.
|
|
16
|
+
- The default encoding engine is now `:sqids` to reflect the official "deprecated" status of `Hashid`s (see https://sqids.org/faq#why-hashids)
|
|
17
|
+
- Ruby < 3.2 support dropped. The minimum supported Ruby version is now 3.2.0
|
|
18
|
+
- `Encoders` classes no longer expose `encode_hex` and `decode_hex` as they worked differently to the similarly named methods on ReversibleId
|
|
19
|
+
- Rails generator now needs you to specify which encoding algorithm you are using
|
|
20
|
+
|
|
21
|
+
### Added (Rails integration)
|
|
22
|
+
|
|
23
|
+
- `encoded_id_options` class method to override `encoded_id` configuration on a model by model basis
|
|
24
|
+
- Blocklist application "modes". User can decide if the blocklist checks should be applied in situations
|
|
25
|
+
where very long encoded IDs are likely and hence block word collisions are undesirably likely.
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- Blocklists are now pre-filtered to the encoder alphabet to avoid testing words which cannot be created by that alphabet anyway.
|
|
30
|
+
- Updates to inline RBS type signatures
|
|
31
|
+
- Documentation updates
|
|
32
|
+
|
|
33
|
+
## [1.0.0.rc6] - 2025-11-17
|
|
4
34
|
|
|
5
35
|
### Breaking changes
|
|
6
36
|
|
|
7
|
-
-
|
|
8
|
-
- `#encoded_id` now defaults to returning an 'annotated' ID, one in which a prefix is added to the encoded ID to indicate
|
|
9
|
-
the 'type' of the record the ID represents. This can be disabled. IDs generated by older versions of this gem will
|
|
10
|
-
decode correctly. But not that IDs generated by this version onwards will not decode correctly by older versions of this
|
|
11
|
-
gem so make sure to disable annotation if you need to support older versions of this gem.
|
|
12
|
-
- `#name_for_encoded_id_slug` no longer provides a default implementation, it is up to the user to define this method,
|
|
13
|
-
or configure the gem to use a different method name.
|
|
14
|
-
- `#slugged_encoded_id` no longer takes a `with:` parameter. To specify the name of the method to call to generate the
|
|
15
|
-
slug, use the `slug_value_method_name` configuration option.
|
|
37
|
+
- Empty array inputs will now raise `InvalidInputError`
|
|
16
38
|
|
|
17
39
|
### Added
|
|
18
40
|
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
41
|
+
- Added support for [Sqids](https://sqids.org) as an alternative ID encoding engine. The default remains HashIds for backward compatibility.
|
|
42
|
+
- New encoder abstraction layer allows switching between HashIds and Sqids via the `encoder: :sqids` or `encoder: :hashids` parameter to `ReversibleId.new`.
|
|
43
|
+
- Support for blocklists in both HashIds and Sqids encoders to prevent generating IDs containing specific words. Use the `blocklist` parameter with a `Set` or `Array` of strings to `ReversibleId.new`. For Hashids encodings, an error will be raised if a generated ID contains a blocklisted word. For Sqids a new ID is generated that does not contain the block word.
|
|
44
|
+
|
|
45
|
+
### Added (Rails integration)
|
|
46
|
+
|
|
47
|
+
- Merged `encoded_id-rails` gem into the monorepo
|
|
48
|
+
- Support for configuring the encoder and blocklist options in Rails through the configuration class
|
|
49
|
+
- `#encoded_id` now defaults to returning an 'annotated' ID, one in which a prefix is added to the encoded ID to indicate the 'type' of the record the ID represents. This can be disabled. IDs generated by older versions of this gem will decode correctly. But note that IDs generated by this version onwards will not decode correctly by older versions of this gem so make sure to disable annotation if you need to support older versions of this gem.
|
|
50
|
+
- New `EncodedId::Rails::Persists` module which adds hooks to the model to persist the encoded ID to the DB (see docs).
|
|
51
|
+
- `#encoded_id_hash` has been added to return only the encoded ID without an annotation prefix. If annotation is disabled, this method is basically an alias to `#encoded_id`.
|
|
52
|
+
- `.find_all_by_encoded_id` has been added to return all records matching the given encoded ID. This will return all matching records whose IDs are encoded in the encoded_id. Missing records are ignored.
|
|
53
|
+
- `.find_all_by_encoded_id!` like `.find_all_by_encoded_id` but raises an `ActiveRecord::RecordNotFound` exception if *any* of the records are not found.
|
|
54
|
+
- `Configuration#model_to_param_returns_encoded_id` to allow `EncodedId::Rails::Model` inclusion to also bring in `EncodedId::Rails::PathParam` automatically.
|
|
25
55
|
|
|
26
|
-
###
|
|
56
|
+
### Changed (Rails integration)
|
|
57
|
+
|
|
58
|
+
- `#name_for_encoded_id_slug` no longer provides a default implementation, it is up to the user to define this method, or configure the gem to use a different method name.
|
|
59
|
+
- `#slugged_encoded_id` no longer takes a `with:` parameter. To specify the name of the method to call to generate the slug, use the `slug_value_method_name` configuration option.
|
|
60
|
+
|
|
61
|
+
### Fixed (Rails integration)
|
|
27
62
|
|
|
28
63
|
- `#decode_encoded_id` now raises if the encoded ID is not a string.
|
|
64
|
+
- Handle more cases where a record held onto a memoized `encoded_id` even though its `id` had changed
|
|
65
|
+
|
|
66
|
+
## [1.0.0.rc5] - 2025-04-09
|
|
67
|
+
|
|
68
|
+
- `encoded_id` now uses its own implementation of `hashids` which is more efficient and has a smaller memory footprint. This massively reduces the GC churn in high-throughput applications. This is an implementation based on the original `hashids` gem but with many optimisations and improvements. Functionally it is identical to the original `hashids` gem.
|
|
69
|
+
|
|
70
|
+
## [1.0.0.rc4] - 2024-04-29
|
|
71
|
+
|
|
72
|
+
- Add an optional `max_inputs_per_id` argument to `ReversibleId`, thanks to [@avcwisesa](https://github.com/avcwisesa)
|
|
73
|
+
- The option `split_with:` can also now be set to nil to disable splitting of the encoded ID string
|
|
74
|
+
|
|
75
|
+
## [1.0.0.rc3] - 2023-10-23
|
|
76
|
+
|
|
77
|
+
- Add an optional `max_length` argument to `ReversibleId`, thanks to [@jugglebird](https://github.com/jugglebird)
|
|
78
|
+
- Alphabet validations to prevent whitespace and null chars
|
|
79
|
+
- Add `Alphabet#to_a`, `Alphabet#to_s`, `Alphabet#size` and a custom `Alphabet#inspect`
|
|
80
|
+
- Fixes to input validations
|
|
81
|
+
- hashids are case-sensitive, as are `Alphabet`s, however `ReversibleId` was always `downcase`ing the encodedid input string on decode. A new option has been added to `decode` and `decode_hex`, `downcase`, which defaults to `true`. Thus, the default behaviour is unchanged, but you can opt out to allow mixed case encodedid decode. *Note:* In V2 this will default to `false`.
|
|
82
|
+
|
|
83
|
+
## [1.0.0.rc2] - 2023-08-07
|
|
84
|
+
|
|
85
|
+
- `Alphabet` now has `#include?` and `#unique_charaters` methods
|
|
86
|
+
|
|
87
|
+
## [1.0.0.rc1] - 2023-08-06
|
|
88
|
+
|
|
89
|
+
- Improved RBS definitions
|
|
90
|
+
- Improved test coverage
|
|
91
|
+
|
|
92
|
+
## [0.4.0] - 2022-12-04
|
|
93
|
+
|
|
94
|
+
- Support custom 'split' character which must not be in the alphabet
|
|
95
|
+
- Ability to provide a custom character equivalence mapping
|
|
96
|
+
|
|
97
|
+
## [0.3.0] - 2022-10-12
|
|
98
|
+
|
|
99
|
+
- Fix splitting of encoded ID string
|
|
100
|
+
- Checks that integer values to be encoded are positive
|
|
101
|
+
- Experimental support for encoding hex strings
|
|
102
|
+
|
|
103
|
+
## [0.1.0] - 2022-10-11
|
|
104
|
+
|
|
105
|
+
- Initial release
|
|
106
|
+
|
|
107
|
+
## Rails Integration History
|
|
29
108
|
|
|
30
109
|
## [0.6.2] - 2023-02-09
|
|
31
110
|
|
|
@@ -64,4 +143,4 @@
|
|
|
64
143
|
|
|
65
144
|
## [0.1.0] - 2022-11-17
|
|
66
145
|
|
|
67
|
-
- Initial release
|
|
146
|
+
- Initial release of Rails integration
|
data/LICENSE.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2022 Stephen Ierodiaconou
|
|
3
|
+
Copyright (c) 2022-2024 Stephen Ierodiaconou
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|