foobara-typescript-react-command-form-generator 0.0.10 → 0.0.12

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: 2d7c7f198d85e6df346ff8e9c79223a9800229515015fd453113d361ae1cb39e
4
- data.tar.gz: 9459d9006a463ad36994ec0414b471bd8032403d80d2285c495083f0ad038676
3
+ metadata.gz: 89eda43a93ac1f7704e90f6505078d6dca634f8e327836ad27559cfdfd3abc05
4
+ data.tar.gz: 04befdc1aabc41b17ede232116cb34382a187e414b1da4194a1a16f91eed1dd8
5
5
  SHA512:
6
- metadata.gz: 3591a8eea3c09f47c0de440b8b12d17830e2a95b307bf0d53f0db69591fdc69d11a010c76a1b0b4da765bd7de432dc6f9f9f54ea44c1a9392816044b2729cf2d
7
- data.tar.gz: f4f32288a3b7b18b9ca44bd493862e56f4b9f3be5f729bbfddd78d5f4cc30422ac8f1d1333f079864a790c1e9532a3d1a74862b4e1cdffbef979e435921c9062
6
+ metadata.gz: d3f84bb2d7d26485ab18b697f1bc90354632a7f94f89a4800252f50dc90601970e48753b4712be5af5727ee17fe921d57b9f79f42e6abf173acf1f3e3dd54b3d
7
+ data.tar.gz: 916539dcd2b832027969f7c191a67e9bc5878a32a60d7210b30d919ea569da2930cb9d556301c59fbd70a7a365f2b963a5aa1deb028ce83835cadc24d094a63b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## [0.0.12] - 2025-04-15
2
+
3
+ - Fix non-camelized get/set useState names for nested types
4
+ - Do not include Model/Entity classes in inputs types to simplify things for now
5
+
6
+ ## [0.0.11] - 2025-04-08
7
+
8
+ - Print out stringified errors for unexpected errors
9
+ - Cast e.target.value with parseInt/parseFloat when appropriate
10
+
1
11
  ## [0.0.10] - 2025-04-08
2
12
 
3
13
  - Do not double up hashes on Outcome import
@@ -36,11 +36,16 @@ module Foobara
36
36
  return @type_generators if defined?(@type_generators)
37
37
 
38
38
  generators = if type_declaration.entity?
39
- generator_class = RemoteGenerator::Services::UnloadedEntityGenerator
40
- [generator_class.new(type_declaration.to_entity)]
39
+ # For now, we'll not bother with entity/model classes in the inputs.
40
+ # This simplifies things a bit re: form generation and setting UI
41
+ # inputs into the inputs value.
42
+ type_generators(type_declaration.to_type.primary_key_type, false)
43
+ # generator_class = RemoteGenerator::Services::UnloadedEntityGenerator
44
+ # [generator_class.new(type_declaration.to_entity)]
41
45
  elsif type_declaration.model?
42
- generator_class = RemoteGenerator::Services::AtomModelGenerator
43
- [generator_class.new(type_declaration.to_model)]
46
+ type_generators(type_declaration.to_type.attributes_type, false)
47
+ # generator_class = RemoteGenerator::Services::AtomModelGenerator
48
+ # [generator_class.new(type_declaration.to_model)]
44
49
  elsif type_declaration.type.to_sym == :attributes
45
50
  type_declaration.attribute_declarations.values.map do |attribute_declaration|
46
51
  type_generators(attribute_declaration, false)
@@ -198,7 +203,7 @@ module Foobara
198
203
  first, *rest = path
199
204
 
200
205
  first = Util.camelize(first)
201
- rest = rest.map { |part| Util.camelize(part) }
206
+ rest = rest.map { |part| Util.classify(part) }
202
207
 
203
208
  [first, *rest].join
204
209
  end
@@ -242,10 +247,23 @@ module Foobara
242
247
  #{one_of.map { |value| "<option value=\"#{value}\">#{value}</option>" }.join}
243
248
  </select>"
244
249
  else
250
+ type = type_declaration.to_type
251
+
252
+ cast_value = if type.name.to_s == "integer" || type.extends_symbol?(:integer)
253
+ "parseInt(e.target.value)"
254
+ elsif type.name.to_s == "float" || type.extends_symbol?(:float)
255
+ # TODO: test this path
256
+ # :nocov:
257
+ "parseFloat(e.target.value)"
258
+ # :nocov:
259
+ else
260
+ "e.target.value"
261
+ end
262
+
245
263
  "<input
246
264
  #{"type=\"password\"" if sensitive?}
247
265
  value={#{name} ?? \"\"}
248
- onChange={(e) => { set#{name_upcase}(e.target.value) }}
266
+ onChange={(e) => { set#{name_upcase}(#{cast_value}) }}
249
267
  placeholder=\"#{name_english}\"
250
268
  />"
251
269
  end
@@ -6,6 +6,7 @@ import { <%= command_name %> } from "<%= path_to_root %><%= command_generator.im
6
6
  <% unless empty_inputs? %>
7
7
  import <%= inputs_class_name %> from "<%= path_to_root %><%= command_generator.import_path %>/Inputs"
8
8
  <% end %>
9
+ <%# TODO: why isn't the result type handled via dependency_roots to avoid collisions with other types? %>
9
10
  import <%= result_class_name %> from "<%= path_to_root %><%= command_generator.import_path %>/Result"
10
11
  import { Error as <%= error_class_name %> } from "<%= path_to_root %><%= command_generator.import_path %>/Errors"
11
12
 
@@ -60,7 +61,7 @@ export default function <%= command_name %>Form (): JSX.Element {
60
61
  setResult(null)
61
62
  }
62
63
  } catch (error) {
63
- setError('Error executing command')
64
+ setError(`Error executing command: ${JSON.stringify(error)}`)
64
65
  setResult(null)
65
66
  }
66
67
  })
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-typescript-react-command-form-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-09 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: foobara-typescript-remote-command-generator
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  requirements: []
63
- rubygems_version: 3.6.2
63
+ rubygems_version: 3.6.7
64
64
  specification_version: 4
65
65
  summary: Generates Typescript React forms for Foobara remote commands
66
66
  test_files: []