foobara-typescript-remote-command-generator 0.0.7 → 0.0.9

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: 0e689d3af26a2cdbb1700275d5d1533f2830e906fa3da8902b8a8632a7fa233d
4
- data.tar.gz: c4efa338d9bb3ee203a8fb00ec2a5191fd39f4164f85efee8af092af51d4e10e
3
+ metadata.gz: cc6158bda17aa24741a79802c5e0016120801eed6a7f73a4c26eb68040fbd0ed
4
+ data.tar.gz: 8803880e3bd4463b21be3a08b09d33387a43f5d6a497af42cc59b9aa5dd764bb
5
5
  SHA512:
6
- metadata.gz: 55adef696b27cf8841be112e4b5988fa4610e3c859d7ce94522787f92592da1fa6a7c1826b5f79f2f59f90a5f206ad991ac3808cd6e0f8514fe3602eade0a5dc
7
- data.tar.gz: 2a6603509a278a612c1494f6ae5158b138314a1fd7bf06caf7e3f3b7dd26c5c7ebb43cf4a3e8541c72f51b9039732146c603a9d16be31afba5a367a409834236
6
+ metadata.gz: 2c62a4e4597c9774b894747137a834d9a5aaff70269f322e20e93192ee6d34dff8bb88c0cd8a1fd488320eb373b9002d3523d6ee51b48f1887a5f4cedf4cb9ee
7
+ data.tar.gz: ec1a895e62d555c58b1ffe0a2161b4c422dc2222ae0d762da4adfb34631a7d8369a824021fd7fd36242101e281bbc5a7ac97d13fa5f48fdedf751836c905f4a6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.0.9] - 2025-02-21
2
+
3
+ - Fix a bug where we don't use the name of a custom type when we could
4
+
5
+ ## [0.0.8] - 2025-02-21
6
+
7
+ - Make sure entity/detached_entity/model are used properly in several places
8
+
1
9
  ## [0.0.7] - 2025-01-06
2
10
 
3
11
  - Bump Ruby to 3.4.1
@@ -17,6 +17,7 @@ module Foobara
17
17
  include_non_templated_files
18
18
 
19
19
  add_root_manifest_to_set_of_elements_to_generate
20
+ # TODO: allow specifying subset of commands
20
21
  add_all_commands_to_set_of_elements_to_generate
21
22
 
22
23
  each_element_to_generate do
@@ -6,7 +6,7 @@ module Foobara
6
6
  def new(relevant_manifest)
7
7
  return super unless self == AggregateModelGenerator
8
8
 
9
- if relevant_manifest.entity?
9
+ if relevant_manifest.detached_entity?
10
10
  AggregateEntityGenerator.new(relevant_manifest)
11
11
  elsif relevant_manifest.has_associations?
12
12
  super
@@ -26,9 +26,7 @@ module Foobara
26
26
 
27
27
  def model_generators
28
28
  types_depended_on.select(&:model?).map do |model|
29
- # TODO: what about detached_entity? What is the difference in this context between entity and model and
30
- # which is detached_entity more like?
31
- if model.entity?
29
+ if model.detached_entity?
32
30
  Services::AggregateEntityGenerator.new(model)
33
31
  else
34
32
  Services::AggregateModelGenerator.new(model)
@@ -24,7 +24,7 @@ module Foobara
24
24
 
25
25
  def model_generators
26
26
  types_depended_on.select(&:model?).map do |model|
27
- if model.entity?
27
+ if model.detached_entity?
28
28
  Services::UnloadedEntityGenerator.new(model)
29
29
  else
30
30
  Services::AtomModelGenerator.new(model)
@@ -6,7 +6,7 @@ module Foobara
6
6
  def new(relevant_manifest)
7
7
  return super unless self == AtomModelGenerator
8
8
 
9
- if relevant_manifest.entity?
9
+ if relevant_manifest.detached_entity?
10
10
  AtomEntityGenerator.new(relevant_manifest)
11
11
  elsif relevant_manifest.has_associations?
12
12
  super
@@ -26,7 +26,7 @@ module Foobara
26
26
 
27
27
  def model_generators
28
28
  types_depended_on.select(&:model?).map do |model|
29
- if model.entity?
29
+ if model.detached_entity?
30
30
  Services::UnloadedEntityGenerator.new(model)
31
31
  else
32
32
  Services::AtomModelGenerator.new(model)
@@ -19,7 +19,7 @@ module Foobara
19
19
  end
20
20
 
21
21
  def model_generators(type = result_type, initial = true)
22
- if type.entity?
22
+ if type.detached_entity?
23
23
  generator_class = if atom?
24
24
  if initial
25
25
  AtomEntityGenerator
@@ -32,7 +32,13 @@ module Foobara
32
32
  EntityGenerator
33
33
  end
34
34
 
35
- [generator_class.new(type.to_entity)]
35
+ entity = if type.entity?
36
+ type.to_entity
37
+ else
38
+ type.to_detached_entity
39
+ end
40
+
41
+ [generator_class.new(entity)]
36
42
  elsif type.model?
37
43
  generator_class = if atom?
38
44
  AtomModelGenerator
@@ -47,8 +47,9 @@ module Foobara
47
47
  end
48
48
 
49
49
  def model_generators
50
+ # HERE!!!
50
51
  @model_generators ||= begin
51
- only_models = domain_manifest.models.reject(&:entity?)
52
+ only_models = domain_manifest.models.reject(&:detached_entity?)
52
53
 
53
54
  only_models.map do |model_manifest|
54
55
  ModelGenerator.new(model_manifest)
@@ -51,8 +51,7 @@ module Foobara
51
51
 
52
52
  def dependencies
53
53
  # Why don't we need models and custom types?
54
- # what about detached_entity types?
55
- types_depended_on.select(&:entity?)
54
+ types_depended_on.select(&:detached_entity?)
56
55
  end
57
56
 
58
57
  def ts_type_full_path
@@ -9,7 +9,7 @@ module Foobara
9
9
  def new(relevant_manifest)
10
10
  return super unless self == ModelGenerator
11
11
 
12
- if relevant_manifest.entity?
12
+ if relevant_manifest.detached_entity?
13
13
  EntityGenerator.new(relevant_manifest)
14
14
  else
15
15
  super
@@ -8,7 +8,7 @@ module Foobara
8
8
  def new(relevant_manifest)
9
9
  return super unless self == TypeGenerator
10
10
 
11
- if relevant_manifest.entity?
11
+ if relevant_manifest.detached_entity?
12
12
  EntityGenerator.new(relevant_manifest)
13
13
  elsif relevant_manifest.model?
14
14
  ModelGenerator.new(relevant_manifest)
@@ -87,7 +87,7 @@ module Foobara
87
87
  end
88
88
 
89
89
  def model_generators
90
- @model_generators ||= types_depended_on.select(&:model?).map do |model|
90
+ @model_generators ||= types_depended_on.select(&:model?).reject(&:builtin?).map do |model|
91
91
  Services::ModelGenerator.new(model)
92
92
  end
93
93
  end
@@ -222,10 +222,8 @@ module Foobara
222
222
  else
223
223
  if type_declaration.model?
224
224
  model_to_ts_model_name(type_declaration, association_depth:, initial:)
225
- elsif can_convert_type_declaration_to_ts_type?(type_declaration)
226
- type = type_declaration.to_type
227
-
228
- custom_type_to_ts_type_name(type)
225
+ elsif type_declaration.custom?
226
+ custom_type_to_ts_type_name(type_declaration)
229
227
  end
230
228
  end
231
229
  end
@@ -247,22 +245,6 @@ module Foobara
247
245
  end
248
246
  end
249
247
 
250
- def can_convert_type_declaration_to_ts_type?(type_declaration)
251
- type = type_declaration.to_type
252
-
253
- return false if BuiltinTypes.builtin_reference?(type.reference)
254
-
255
- allowed_keys = %w[type one_of allows_nil]
256
-
257
- declaration_data = type.declaration_data
258
-
259
- bad_keys = declaration_data.keys - allowed_keys
260
-
261
- return false unless bad_keys.empty?
262
-
263
- BuiltinTypes.builtin_reference?(declaration_data["type"])
264
- end
265
-
266
248
  def attributes_to_ts_type(attributes, dependency_group:, association_depth: AssociationDepth::AMBIGUOUS)
267
249
  guts = attributes.attribute_declarations.map do |attribute_name, attribute_declaration|
268
250
  " #{attribute_name}#{"?" unless attributes.required?(attribute_name)}: #{
@@ -280,7 +262,7 @@ module Foobara
280
262
  when AssociationDepth::AMBIGUOUS
281
263
  Services::ModelGenerator
282
264
  when AssociationDepth::ATOM
283
- if !initial && model.entity?
265
+ if !initial && model.detached_entity?
284
266
  Services::UnloadedEntityGenerator
285
267
  else
286
268
  Services::AtomModelGenerator
metadata CHANGED
@@ -1,13 +1,13 @@
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.7
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-06 00:00:00.000000000 Z
10
+ date: 2025-02-21 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: foobara
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  - !ruby/object:Gem::Version
135
135
  version: '0'
136
136
  requirements: []
137
- rubygems_version: 3.6.2
137
+ rubygems_version: 3.6.3
138
138
  specification_version: 4
139
139
  summary: Generates remote commands for Typescript from a foobara manifest
140
140
  test_files: []