typelizer 0.5.0 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd7dab7ab6fabb3be94f1ca6bd6ea98337ea5b6c52811b413ed28f0804e5bd64
4
- data.tar.gz: e1dc88644daebf2c3c34ded6cee520963c009568f45cde70e60d1276b8a859c2
3
+ metadata.gz: 719de4da27cc15319b98f6d99e12d58d5d52a6b7122de2e5af4e25682ff0cc09
4
+ data.tar.gz: 4b81f4e2ac3efa868c62a56d2a64d39dcedfe3d3a89f27b60d1266ea49977260
5
5
  SHA512:
6
- metadata.gz: a910d1e73e070287d5c01d3d10f7b8c181b81a78474f4cf53f45c774fea5362d1498345a16f495630e10637f4314548266c779893dccb4dad2d8b95c15cf09da
7
- data.tar.gz: 214105e604e21a4901ff437fbf26d8d19886be704c10b8981a26025bfc17fde3046fb1c9e90bf3db0f9a4abd4a954940d6c4168672e58136ff90c9961bcefc38
6
+ metadata.gz: 0fb14ceadab2c34ee2d346cdd3ccaaff5c42b8c867a8bb4b49bf5a5142cbfdaf07cabfb9cbccc647709712fd6fd0a2e917eac8037d01af663c9762b506c66101
7
+ data.tar.gz: a81bd63f919c2f7d7620fc5a13edcb94bfce4099e3a77e3d1096060b8f6a25bb9c0d640ff75259b2afa531b5388d2a362a10985676d878eb3f7f3a16c26c053e
data/CHANGELOG.md CHANGED
@@ -7,11 +7,21 @@ and this project adheres to [Semantic Versioning].
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.5.2] - 2025-10-06
11
+
12
+ - Infer type for `<relation>_ids`. ([@skryukov])
13
+
14
+ ## [0.5.1] - 2025-09-11
15
+
16
+ ### Fixed
17
+
18
+ - Fix type inference when using virtual associations. ([@hkamberovic])
19
+
10
20
  ## [0.5.0] - 2025-09-01
11
21
 
12
22
  ### Added
13
23
 
14
- - Support for multiple output writers: emit several variants (e.g., snake_case and camelCase) in parallel. ([@supdex])
24
+ - Support for multiple output writers: emit several variants (e.g., snake_case and camelCase) in parallel. ([@prog-supdex])
15
25
  - Support for Rails' Attributes API. ([@skryukov])
16
26
 
17
27
  ## [0.4.2] - 2025-06-23
@@ -178,6 +188,7 @@ and this project adheres to [Semantic Versioning].
178
188
 
179
189
  [@davidrunger]: https://github.com/davidrunger
180
190
  [@Envek]: https://github.com/Envek
191
+ [@hkamberovic]: https://github.com/hkamberovic
181
192
  [@kristinemcbride]: https://github.com/kristinemcbride
182
193
  [@nkriege]: https://github.com/nkriege
183
194
  [@NOX73]: https://github.com/NOX73
@@ -185,10 +196,12 @@ and this project adheres to [Semantic Versioning].
185
196
  [@patvice]: https://github.com/patvice
186
197
  [@PedroAugustoRamalhoDuarte]: https://github.com/PedroAugustoRamalhoDuarte
187
198
  [@skryukov]: https://github.com/skryukov
188
- [@supdex]: https://github.com/supdex
199
+ [@prog-supdex]: https://github.com/prog-supdex
189
200
  [@ventsislaf]: https://github.com/ventsislaf
190
201
 
191
- [Unreleased]: https://github.com/skryukov/typelizer/compare/v0.5.0...HEAD
202
+ [Unreleased]: https://github.com/skryukov/typelizer/compare/v0.5.2...HEAD
203
+ [0.5.2]: https://github.com/skryukov/typelizer/compare/v0.5.1...v0.5.2
204
+ [0.5.1]: https://github.com/skryukov/typelizer/compare/v0.5.0...v0.5.1
192
205
  [0.5.0]: https://github.com/skryukov/typelizer/compare/v0.4.2...v0.5.0
193
206
  [0.4.2]: https://github.com/skryukov/typelizer/compare/v0.4.1...v0.4.2
194
207
  [0.4.1]: https://github.com/skryukov/typelizer/compare/v0.4.0...v0.4.1
data/README.md CHANGED
@@ -421,7 +421,7 @@ Typelizer.configure do |config|
421
421
 
422
422
  # List of type names that should be considered global in TypeScript
423
423
  # (i.e. not prefixed with the import path)
424
- config.types_global << %w[Array Date Record File FileList]
424
+ config.types_global = %w[Array Date Record File FileList]
425
425
 
426
426
  # Support TypeScript's Verbatim module syntax option (default: false)
427
427
  # Will change imports and exports of types from default to support this syntax option
@@ -11,6 +11,7 @@ module Typelizer
11
11
  def infer_types(prop)
12
12
  infer_types_for_association(prop) ||
13
13
  infer_types_for_column(prop) ||
14
+ infer_types_for_association_ids(prop) ||
14
15
  infer_types_for_attribute(prop)
15
16
 
16
17
  prop
@@ -63,7 +64,6 @@ module Typelizer
63
64
  column = model_class&.columns_hash&.dig(prop.column_name.to_s)
64
65
  return nil unless column
65
66
 
66
- column = model_class&.columns_hash&.dig(prop.column_name.to_s)
67
67
  prop.multi = !!column.try(:array)
68
68
  case config.null_strategy
69
69
  when :nullable
@@ -85,10 +85,23 @@ module Typelizer
85
85
  prop
86
86
  end
87
87
 
88
+ def infer_types_for_association_ids(prop)
89
+ column_name = prop.column_name.to_s
90
+ return nil unless column_name.end_with?("_ids")
91
+
92
+ base_name = column_name.chomp("_ids").pluralize
93
+ association = model_class&.reflect_on_association(base_name.to_sym)
94
+ return nil unless association
95
+
96
+ prop.type = :number
97
+ prop.multi = true
98
+ prop
99
+ end
100
+
88
101
  def infer_types_for_attribute(prop)
89
102
  return nil unless model_class.respond_to?(:attribute_types)
90
103
 
91
- attribute_type_obj = model_class.attribute_types[prop.column_name.to_s]
104
+ attribute_type_obj = model_class.attribute_types.fetch(prop.column_name.to_s, nil)
92
105
  return nil unless attribute_type_obj
93
106
 
94
107
  if attribute_type_obj.respond_to?(:subtype)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Typelizer
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typelizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Svyatoslav Kryukov