types_from_serializers 2.2.0 → 2.3.0
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 +10 -5
- 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: e9253a2af8e018bad4fc2015153df9e0f2c5acd8fa6dc1980ee6c5942fd63b0b
|
4
|
+
data.tar.gz: 3ddc115f8667dcba81f51ae867323c9852939c019b18e49a29bf5a73d8c0c790
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dc521ddba354a4443a907597ba1b5c4d6093c156b6685e0ac683bcc922f2414e3380f00ba8e2ae5e96587dd519efd738304ec98d93643d6859d1dc6047be1ca
|
7
|
+
data.tar.gz: f69cf927cc528364a62c2a96ffbdcf54dff910700d80a89e8109bdb1d4c208bf9cfce6221c43c04bc914a5cd4c284a3854e2504122bef256365c6f4c654c5f0c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# [2.3.0](https://github.com/ElMassimo/types_from_serializers/compare/types_from_serializers@2.2.0...types_from_serializers@2.3.0) (2024-08-23)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* generate types for inline serializers, exclude them from the index ([1c3657c](https://github.com/ElMassimo/types_from_serializers/commit/1c3657c61a1bc891f3219f6eaf8557cd3cd6344a)), closes [#19](https://github.com/ElMassimo/types_from_serializers/issues/19)
|
7
|
+
|
8
|
+
|
9
|
+
|
1
10
|
# [2.2.0](https://github.com/ElMassimo/types_from_serializers/compare/types_from_serializers@2.1.0...types_from_serializers@2.2.0) (2024-08-23)
|
2
11
|
|
3
12
|
|
@@ -38,6 +38,11 @@ module TypesFromSerializers
|
|
38
38
|
TypesFromSerializers.config.name_from_serializer.call(name).gsub("::", "/")
|
39
39
|
end
|
40
40
|
|
41
|
+
# Internal: If the serializer was defined inside a file.
|
42
|
+
def inline_serializer?
|
43
|
+
name.include?("Serializer::")
|
44
|
+
end
|
45
|
+
|
41
46
|
# Internal: The TypeScript properties of the serialzeir interface.
|
42
47
|
def ts_properties
|
43
48
|
@ts_properties ||= begin
|
@@ -312,9 +317,7 @@ module TypesFromSerializers
|
|
312
317
|
# Internal: Checks if it should avoid generating an interface.
|
313
318
|
def skip_serializer?(serializer)
|
314
319
|
serializer.name.in?(config.base_serializers) ||
|
315
|
-
config.skip_serializer_if.call(serializer)
|
316
|
-
# NOTE: Ignore inline serializers.
|
317
|
-
serializer.ts_name.include?("Serializer")
|
320
|
+
config.skip_serializer_if.call(serializer)
|
318
321
|
end
|
319
322
|
|
320
323
|
# Internal: Returns an object compatible with FileUpdateChecker.
|
@@ -362,7 +365,9 @@ module TypesFromSerializers
|
|
362
365
|
output_dir: root.join(defined?(ViteRuby) ? ViteRuby.config.source_code_dir : "app/frontend").join("types/serializers"),
|
363
366
|
|
364
367
|
# Remove the serializer suffix from the class name.
|
365
|
-
name_from_serializer: ->(name) {
|
368
|
+
name_from_serializer: ->(name) {
|
369
|
+
name.split("::").map { |n| n.delete_suffix("Serializer") }.join("::")
|
370
|
+
},
|
366
371
|
|
367
372
|
# Types that don't need to be imported in TypeScript.
|
368
373
|
global_types: [
|
@@ -420,7 +425,7 @@ module TypesFromSerializers
|
|
420
425
|
<<~TS
|
421
426
|
//
|
422
427
|
// DO NOT MODIFY: This file was automatically generated by TypesFromSerializers.
|
423
|
-
#{serializers.map { |s|
|
428
|
+
#{serializers.reject(&:inline_serializer?).map { |s|
|
424
429
|
"export type { default as #{s.ts_name} } from './#{s.ts_filename}'"
|
425
430
|
}.join("\n")}
|
426
431
|
TS
|