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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e3961bc80ddc72831c77e7cf9ddf0959809a49a845f0d778d0c6ac50148cb87
4
- data.tar.gz: e676ddfe4c4c51081075bd5bbb3a66990d8ea469dc60305a550175abe8c43c99
3
+ metadata.gz: e9253a2af8e018bad4fc2015153df9e0f2c5acd8fa6dc1980ee6c5942fd63b0b
4
+ data.tar.gz: 3ddc115f8667dcba81f51ae867323c9852939c019b18e49a29bf5a73d8c0c790
5
5
  SHA512:
6
- metadata.gz: 01e286a9381c3d8f2e00c4085ba491ab4d4332ee3ac0ea2ebd109a7ff53ddb131b43d1c0839a09459884edc0536cd805d5303be2a80143a12998d6b5839dfc14
7
- data.tar.gz: a3687e203f27c34a3243f1422588bd2c79362ef4b7f9c2432ec6ce53493c83c11782f784f8acb4a76d7a611fab6ca7e9422f63560c3053739e3b39c3258d91ed
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) { name.delete_suffix("Serializer") },
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  module TypesFromSerializers
4
4
  # Public: This library adheres to semantic versioning.
5
- VERSION = "2.2.0"
5
+ VERSION = "2.3.0"
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: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Máximo Mussini