foobara-typescript-remote-command-generator 0.0.2 → 0.0.4

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: 564885c648194cc9432cd96eafed5cf81109e389ce0bcd63057fb34722840f19
4
- data.tar.gz: a6e684cc076048dd2fe3c1a63a3664d123b1465b267feb68bc53efceffd1d55a
3
+ metadata.gz: 69bd175fc5eecad6f5b353135377fcf15d164fa659e2ca130f641853f4b3c5e3
4
+ data.tar.gz: 38b135625b70aa997cd0744a5b7f1be524212a3257f61f108ed79ee29df6f85d
5
5
  SHA512:
6
- metadata.gz: a8e276a525500326735c507dd78aec433bd14cf7a99a75a4f8f54560fc6fcc1a2dc45c878862549af0a2696bc9732a0a8dc93033fe840606e46cfa3d905dab71
7
- data.tar.gz: 59a0dc1ff1dff0b929bea7896316b91bb2d3f3ac22492fd7b3315bdb5041bfa0941f1dcec9fd50b38f7b790631c31d42dfcd7d4be7071fc90e3e78f21ea4bb63
6
+ metadata.gz: 163591e591ca0094197ee34e5ad97b4ffde5f8ac122cbbeeb3d10fd460035607c32108935f6d144459d8442bfaac9dafe3fd4283753cf8a1c20d2786d1168fcc
7
+ data.tar.gz: 9af4d1233e5c649b8e8ced9a6063c9ba1dafb729279308b49bedb570e6ee996aa81feb55e9bd5e313e8a389ad679ea0c89be71024c8e4fc55f6f9e45758e8905
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [0.0.4] - 2024-08-22
2
+
3
+ - Add type generators to command result generator
4
+ - Add type generators to domain generator
5
+ - Attempt to fix botched nested type paths
6
+
1
7
  ## [0.0.2] - 2024-08-21
2
8
 
3
9
  - Add a TypeGenerator for custom non-model types
@@ -17,7 +17,7 @@ module Foobara
17
17
  end
18
18
 
19
19
  def target_path
20
- [*domain.scoped_full_path, "types", entity_name, "Aggregate.ts"]
20
+ [*super[..-2], "Aggregate.ts"]
21
21
  end
22
22
 
23
23
  def template_path
@@ -17,7 +17,7 @@ module Foobara
17
17
  end
18
18
 
19
19
  def target_path
20
- [*domain.scoped_full_path, "types", model_name, "Aggregate.ts"]
20
+ [*super[..-2], "Aggregate.ts"]
21
21
  end
22
22
 
23
23
  def template_path
@@ -15,7 +15,7 @@ module Foobara
15
15
  end
16
16
 
17
17
  def target_path
18
- [*domain.scoped_full_path, "types", entity_name, "Atom.ts"]
18
+ [*super[..-2], "Atom.ts"]
19
19
  end
20
20
 
21
21
  def template_path
@@ -17,7 +17,7 @@ module Foobara
17
17
  end
18
18
 
19
19
  def target_path
20
- [*domain.scoped_full_path, "types", model_name, "Atom.ts"]
20
+ [*super[..-2], "Atom.ts"]
21
21
  end
22
22
 
23
23
  def template_path
@@ -53,6 +53,22 @@ module Foobara
53
53
  end
54
54
  end
55
55
 
56
+ def type_generators
57
+ @type_generators ||= begin
58
+ type = result_type
59
+ type = type.to_type if result_type.is_a?(Manifest::TypeDeclaration)
60
+
61
+ if !type.builtin? && !type.model?
62
+ # TODO: Test this!!
63
+ # :nocov:
64
+ [TypeGenerator.new(type)]
65
+ # :nocov:
66
+ else
67
+ []
68
+ end
69
+ end
70
+ end
71
+
56
72
  def atom?
57
73
  serializers&.any? { |s| s == "Foobara::CommandConnectors::Serializers::AtomicSerializer" }
58
74
  end
@@ -72,7 +88,7 @@ module Foobara
72
88
  end
73
89
 
74
90
  def dependencies
75
- model_generators
91
+ model_generators + type_generators
76
92
  end
77
93
  end
78
94
  end
@@ -34,6 +34,18 @@ module Foobara
34
34
  end
35
35
  end
36
36
 
37
+ def type_generators
38
+ @type_generators ||= begin
39
+ # TODO: create a Manifest::Domain#custom_types
40
+ only_custom_types = domain_manifest.types.reject(&:model?)
41
+ only_custom_types.reject!(&:builtin?)
42
+
43
+ only_custom_types.map do |type|
44
+ TypeGenerator.new(type)
45
+ end
46
+ end
47
+ end
48
+
37
49
  def model_generators
38
50
  @model_generators ||= begin
39
51
  only_models = domain_manifest.models.reject(&:entity?)
@@ -45,7 +57,7 @@ module Foobara
45
57
  end
46
58
 
47
59
  def dependencies
48
- [*command_generators, *model_generators, *entity_generators, *organization]
60
+ [*command_generators, *model_generators, *entity_generators, *type_generators, *organization]
49
61
  end
50
62
 
51
63
  def domain_name
@@ -7,7 +7,7 @@ module Foobara
7
7
  alias entity_manifest relevant_manifest
8
8
 
9
9
  def target_path
10
- [*domain.scoped_full_path, "types", entity_name, "Ambiguous.ts"]
10
+ [*super[..-2], "Ambiguous.ts"]
11
11
  end
12
12
 
13
13
  def template_path
@@ -18,6 +18,10 @@ module Foobara
18
18
  model_name(...)
19
19
  end
20
20
 
21
+ def entity_short_name
22
+ model_short_name
23
+ end
24
+
21
25
  def primary_key_name
22
26
  primary_key_attribute
23
27
  end
@@ -5,7 +5,9 @@ module Foobara
5
5
  class Services
6
6
  class EntityVariantsGenerator < EntityGenerator
7
7
  def target_path
8
- [*domain.scoped_full_path, "types", "#{model_name}.ts"]
8
+ *prefix, _entity_name, _file = super
9
+
10
+ [*prefix, "#{entity_short_name}.ts"]
9
11
  end
10
12
 
11
13
  def template_path
@@ -50,6 +50,7 @@ module Foobara
50
50
  end
51
51
 
52
52
  def dependencies
53
+ # Why don't we need models and custom types?
53
54
  types_depended_on.select(&:entity?)
54
55
  end
55
56
 
@@ -5,7 +5,7 @@ module Foobara
5
5
  class Services
6
6
  class LoadedEntityGenerator < EntityGenerator
7
7
  def target_path
8
- [*domain.scoped_full_path, "types", entity_name, "Loaded.ts"]
8
+ [*super[..-2], "Loaded.ts"]
9
9
  end
10
10
 
11
11
  def template_path
@@ -20,13 +20,21 @@ module Foobara
20
20
  alias model_manifest relevant_manifest
21
21
 
22
22
  def target_path
23
- [*domain.scoped_full_path, "types", model_name, "#{model_name}.ts"]
23
+ [*domain.scoped_full_path, "Types", *model_prefix, model_short_name, "#{model_short_name}.ts"]
24
+ end
25
+
26
+ def model_short_name
27
+ type_short_name
24
28
  end
25
29
 
26
30
  def template_path
27
31
  ["Model", "Model.ts.erb"]
28
32
  end
29
33
 
34
+ def model_prefix
35
+ type_prefix
36
+ end
37
+
30
38
  def model_name(points = nil)
31
39
  type_name(points)
32
40
  end
@@ -3,7 +3,22 @@ module Foobara
3
3
  class Services
4
4
  class ModelManifestGenerator < ManifestGenerator
5
5
  def target_path
6
- [*domain.scoped_full_path, "types", model_name, "manifest.json"]
6
+ [*domain.scoped_full_path, "Types", *model_prefix, scoped_short_name, "manifest.json"]
7
+ end
8
+
9
+ # TODO: DRY this up
10
+ def model_prefix
11
+ path = scoped_prefix
12
+
13
+ if path && !path.empty?
14
+ if path.first == "Types"
15
+ path[1..]
16
+ else
17
+ path
18
+ end
19
+ else
20
+ []
21
+ end
7
22
  end
8
23
  end
9
24
  end
@@ -3,7 +3,7 @@ module Foobara
3
3
  class Services
4
4
  class ModelVariantsGenerator < ModelGenerator
5
5
  def target_path
6
- [*domain.scoped_full_path, "types", "#{model_name}.ts"]
6
+ [*domain.scoped_full_path, "Types", *model_prefix, "#{scoped_short_name}.ts"]
7
7
  end
8
8
 
9
9
  def template_path
@@ -21,13 +21,31 @@ module Foobara
21
21
  alias type_manifest relevant_manifest
22
22
 
23
23
  def target_path
24
- [*domain.scoped_full_path, "types", "#{type_name}.ts"]
24
+ [*domain.scoped_full_path, "Types", *type_prefix, "#{type_short_name}.ts"]
25
+ end
26
+
27
+ def type_short_name
28
+ scoped_short_name
25
29
  end
26
30
 
27
31
  def template_path
28
32
  ["Type", "Type.ts.erb"]
29
33
  end
30
34
 
35
+ def type_prefix
36
+ path = scoped_prefix
37
+
38
+ if path && !path.empty?
39
+ if path.first == "Types"
40
+ path[1..]
41
+ else
42
+ path
43
+ end
44
+ else
45
+ []
46
+ end
47
+ end
48
+
31
49
  def scoped_full_path(points = nil)
32
50
  full_path = type_manifest.scoped_full_path
33
51
 
@@ -3,7 +3,7 @@ module Foobara
3
3
  class Services
4
4
  class UnloadedEntityGenerator < EntityGenerator
5
5
  def target_path
6
- [*domain.scoped_full_path, "types", entity_name, "Unloaded.ts"]
6
+ [*super[..-2], "Unloaded.ts"]
7
7
  end
8
8
 
9
9
  def template_path
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-typescript-remote-command-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi