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 +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/types_from_serializers/generator.rb +7 -2
- data/lib/types_from_serializers/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddc6e7ca4c4edfab72abe33e0a3688871bd8e746f00f0ea00c832e9b4bad700e
|
4
|
+
data.tar.gz: cf128002a889f0446b6ddc0c8a212dbbd5885af27c6aee1552a8de9b5f723a22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 ||
|
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|
|