types_from_serializers 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 942530179ec9019d6555a26ff060ac31188b0e28655fbd8c562133d43e4c91b5
4
- data.tar.gz: 826b1d915ff118d970d1972f91ed76c6fdf85870c37460dad400ffca6f54f568
3
+ metadata.gz: ddc6e7ca4c4edfab72abe33e0a3688871bd8e746f00f0ea00c832e9b4bad700e
4
+ data.tar.gz: cf128002a889f0446b6ddc0c8a212dbbd5885af27c6aee1552a8de9b5f723a22
5
5
  SHA512:
6
- metadata.gz: 1d2350e94ca4c20fff3518a137197d49c1172aa4432d1c8f8ffba419b9bcb98f37de72f2b3982fbe90a5e2c3601a9123a0fc2e6b0bf3a1339800d9cce1681aa8
7
- data.tar.gz: 48eb7d7f7f90c7686a45515f585d536476b8ca8a6cd9d069c461ea6456859b87d7adefb4a0b94b5261f7b9d29b786f3f74c794f636ad000373bde0523a14c2b7
6
+ metadata.gz: 4f05eada087b1d751525c2439ad60918e0179fce0766230d75502e3ad1d8970af74057e1262c89eaf04b372885574b01d645f852b284d56f73bb88eeab6e072e
7
+ data.tar.gz: 98c5830eb74ae87c10313ad07eb4f72f35f444f8f4c75db8e79640200017e67dff65e45464aa24afcfb68fad3261735ee7ae3b9e3a155a090e91160c8bb9fac3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [0.1.3](https://github.com/ElMassimo/types_from_serializers/compare/types_from_serializers@0.1.2...types_from_serializers@0.1.3) (2022-07-12)
2
+
3
+
4
+ ### Features
5
+
6
+ * apply the sql mapping fallback as the default ([64898c4](https://github.com/ElMassimo/types_from_serializers/commit/64898c4e3a3f83ea67294f2200f253cd2a64aea9))
7
+
8
+
9
+
1
10
  ## [0.1.2](https://github.com/ElMassimo/types_from_serializers/compare/types_from_serializers@0.1.1...types_from_serializers@0.1.2) (2022-07-12)
2
11
 
3
12
 
@@ -15,7 +15,11 @@ module TypesFromSerializers
15
15
  :native_types,
16
16
  :sql_to_typescript_type_mapping,
17
17
  keyword_init: true,
18
- )
18
+ ) do
19
+ def unknown_type
20
+ sql_to_typescript_type_mapping.default
21
+ end
22
+ end
19
23
 
20
24
  # Internal: The type metadata for a serializer.
21
25
  SerializerMetadata = Struct.new(
@@ -134,7 +138,7 @@ module TypesFromSerializers
134
138
 
135
139
  def typescript_fields(metadata)
136
140
  (metadata.attributes + metadata.associations).map { |meta|
137
- type = meta.type.is_a?(Class) ? meta.type.typescript_interface_name : meta.type || :unknown
141
+ type = meta.type.is_a?(Class) ? meta.type.typescript_interface_name : meta.type || TypesFromSerializers.config.unknown_type
138
142
  type = meta.many ? "#{type}[]" : type
139
143
  " #{meta.typescript_name}#{"?" if meta.optional}: #{type}"
140
144
  }
@@ -199,6 +203,7 @@ module TypesFromSerializers
199
203
  # Public: Generates code for all serializers in the app.
200
204
  def generate(force: ENV["SERIALIZER_TYPES_FORCE"])
201
205
  @force_generation = force
206
+ config.output_dir.rmtree if force && config.output_dir.exist?
202
207
  generate_index_file
203
208
 
204
209
  loaded_serializers.each do |serializer|
@@ -2,5 +2,5 @@
2
2
 
3
3
  module TypesFromSerializers
4
4
  # Public: This library adheres to semantic versioning.
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.3"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: types_from_serializers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Máximo Mussini