skyward-api 0.2.0 → 0.4.0

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.
@@ -45,22 +45,29 @@ module Skyward::API::CLI::Serve
45
45
  )
46
46
  end
47
47
 
48
+ # Without rbs-inline, generate is nil, and sig/generated is used as it is.
48
49
  # @rbs directory: String
49
50
  # @rbs build: ^(String config) -> Skyward::API::_RackApp
50
51
  # @rbs clock: ^() -> Float
51
52
  # @rbs apis: ^() -> Array[singleton(Skyward::API)]
52
53
  # @rbs features: Array[String]
53
54
  # @rbs loaders: ^() -> Array[Zeitwerk::Loader]
55
+ # @rbs generate: (^() -> String?)?
56
+ # @rbs every: ^(Float interval) { () -> void } -> void
54
57
  # @rbs return: Reloader
55
- def reloader(directory, build:, clock:, apis:, features:, loaders:)
56
- Reloader.new(
58
+ def reloader(directory, build:, clock:, apis:, features:, loaders:, generate:, every:)
59
+ reloader = Reloader.new(
57
60
  watch: -> { watch(directory) },
58
61
  load: lambda do
59
62
  unload(directory, apis: apis.call, features:, loaders: loaders.call)
60
63
  build.call(File.join(directory, CONFIG))
61
64
  end,
65
+ generate: generate || -> {},
62
66
  clock:
63
67
  )
68
+ # So the editor's Steep checks the types just written, before any request.
69
+ every.call(Reloader::INTERVAL) { reloader.regenerate } if generate
70
+ reloader
64
71
  end
65
72
 
66
73
  # @rbs directory: String
@@ -4,6 +4,11 @@
4
4
  # doesn't depend on it, and Falcon brings it.
5
5
  require "skyward/api"
6
6
 
7
+ rbs_inline = Skyward::Core::CLI::Executable.find("rbs-inline", feature: "rbs/inline")
8
+
9
+ capture = Skyward::Core::CLI::Executable::CAPTURE
10
+ generate = rbs_inline && -> { Skyward::Core::Signatures::Inline.generate(Dir.pwd, rbs_inline:, capture:) }
11
+
7
12
  run Skyward::API::CLI::Serve.reloader(
8
13
  Dir.pwd,
9
14
  build: ->(config) { Rack::Builder.parse_file(config) },
@@ -12,5 +17,15 @@ run Skyward::API::CLI::Serve.reloader(
12
17
  features: $LOADED_FEATURES,
13
18
  # Zeitwerk has no public list of its loaders, and ObjectSpace would go on
14
19
  # finding the ones serve unregisters until they're garbage collected.
15
- loaders: -> { Zeitwerk::Registry.loaders.enum_for(:each).to_a }
20
+ loaders: -> { Zeitwerk::Registry.loaders.enum_for(:each).to_a },
21
+ generate:,
22
+ # Ruby ends the thread when Falcon's worker exits.
23
+ every: lambda do |interval, &tick|
24
+ Thread.new do
25
+ loop do
26
+ sleep(interval)
27
+ tick.call
28
+ end
29
+ end
30
+ end
16
31
  )
@@ -3,11 +3,19 @@
3
3
  require "json"
4
4
  require "skyward/api"
5
5
 
6
+ generate = lambda do
7
+ Skyward::Core::Signatures::Inline.generate(
8
+ Dir.pwd,
9
+ rbs_inline: Skyward::Core::CLI::Executable.find("rbs-inline", feature: "rbs/inline"),
10
+ capture: Skyward::Core::CLI::Executable::CAPTURE
11
+ )
12
+ end
13
+
6
14
  Skyward::Core::CLI.register("serve", "Serve config.ru with Falcon in development, on PORT (default 9292)") do |_args|
7
15
  Skyward::API::CLI::Serve.run(
8
16
  Dir.pwd,
9
17
  env: ENV.to_h,
10
- falcon: Skyward::API::CLI::Executable.find("falcon"),
18
+ falcon: Skyward::Core::CLI::Executable.find("falcon"),
11
19
  kernel: Kernel
12
20
  )
13
21
  end
@@ -18,21 +26,20 @@ Skyward::Core::CLI.register("check", "Check signatures, boot app.rb in strict mo
18
26
  exit Skyward::API::CLI::Check.run(
19
27
  Dir.pwd,
20
28
  out: $stdout,
21
- capture: lambda do |env, command, chdir|
22
- # RBS doesn't list the [:child, :out] spelling of this redirect.
23
- output = IO.popen(env, command, chdir:, err: [:child, 1], &:read)
24
- # RBS doesn't declare Process.last_status, set by the popen above.
25
- [output, Process.last_status.success?] # steep:ignore NoMethod
26
- end,
27
- rbs_inline: Skyward::API::CLI::Executable.find("rbs-inline", feature: "rbs/inline"),
28
- steep: Skyward::API::CLI::Executable.find("steep")
29
+ capture: Skyward::Core::CLI::Executable::CAPTURE,
30
+ rbs_inline: Skyward::Core::CLI::Executable.find("rbs-inline", feature: "rbs/inline"),
31
+ steep: Skyward::Core::CLI::Executable.find("steep")
29
32
  )
30
33
  end
31
34
 
32
35
  Skyward::Core::CLI.register("routes", "Print every route with its handler and signature") do |_args|
33
- Skyward::API::CLI::AppFile.run(Dir.pwd, out: $stdout, kernel: Kernel) { |app| Skyward::API::CLI::Routes.table(app.endpoints) }
36
+ Skyward::API::CLI::AppFile.run(Dir.pwd, out: $stdout, kernel: Kernel, generate:) do |app|
37
+ Skyward::API::CLI::Routes.table(app.endpoints)
38
+ end
34
39
  end
35
40
 
36
41
  Skyward::Core::CLI.register("openapi", "Write the OpenAPI document to stdout") do |_args|
37
- Skyward::API::CLI::AppFile.run(Dir.pwd, out: $stdout, kernel: Kernel) { |app| "#{JSON.pretty_generate(app.openapi)}\n" }
42
+ Skyward::API::CLI::AppFile.run(Dir.pwd, out: $stdout, kernel: Kernel, generate:) do |app|
43
+ "#{JSON.pretty_generate(app.openapi)}\n"
44
+ end
38
45
  end
@@ -95,12 +95,16 @@ module Skyward::API::Endpoints::Declarations
95
95
  problem = problem_with(path, to)
96
96
  raise ArgumentError, "#{self} #{verb.upcase} #{path.inspect}: #{problem}" if problem
97
97
 
98
+ # The caller of get, post, put, patch or delete, which is the app's declaration.
99
+ location = caller_locations(2, 1)&.first
98
100
  route = Skyward::API::Endpoints::Route.new(
99
101
  verb:,
100
102
  path: path.dup.freeze,
101
103
  to:,
102
104
  summary: summary.dup.freeze,
103
- description: description.dup.freeze
105
+ description: description.dup.freeze,
106
+ file: location&.path,
107
+ line: location&.lineno
104
108
  )
105
109
  @routes = [*routes, route].freeze
106
110
  end
@@ -8,6 +8,8 @@ module Skyward::API::Endpoints
8
8
  :path, #: String
9
9
  :to, #: Symbol
10
10
  :summary, #: String?
11
- :description #: String?
11
+ :description, #: String?
12
+ :file, #: String?
13
+ :line #: Integer?
12
14
  )
13
15
  end
@@ -38,10 +38,15 @@ module Skyward::API::Inputs::Coercer
38
38
  # none of them.
39
39
  MISFIT = Invalid.new(errors: [Error.new(at: "", message: "doesn't fit")]) #: Invalid
40
40
 
41
- # INTEGER, DATE and TIME match a String's bytes, because a path parameter
42
- # can be any bytes, and Regexp#match raises on a String that isn't UTF-8.
41
+ # INTEGER, DECIMAL, DATE and TIME match a String's bytes, because a path
42
+ # parameter can be any bytes, and Regexp#match raises on a String that isn't
43
+ # UTF-8.
43
44
  INTEGER = /\A-?\d+\z/ #: Regexp
44
45
 
46
+ # No exponent, NaN or Infinity: "1e1000000000" is short, but written without
47
+ # an exponent it's a billion digits long.
48
+ DECIMAL = /\A-?\d+(?:\.\d+)?\z/ #: Regexp
49
+
45
50
  BOOLEANS = { "true" => true, "false" => false, "1" => true, "0" => false }.freeze #: Hash[String, bool]
46
51
 
47
52
  DATE = /\A(\d{4})-(\d{2})-(\d{2})\z/ #: Regexp
@@ -60,10 +65,22 @@ module Skyward::API::Inputs::Coercer
60
65
  bool: "bool",
61
66
  date: "Date",
62
67
  time: "Time",
68
+ decimal: "BigDecimal",
63
69
  untyped: "untyped"
64
70
  }.freeze #: Hash[Skyward::Core::Types::scalar, String]
65
71
 
66
- FORMATS = { date: "Date (YYYY-MM-DD)", time: "Time (ISO 8601)" }.freeze #: Hash[Skyward::Core::Types::scalar, String]
72
+ FORMATS = {
73
+ date: "Date (YYYY-MM-DD)",
74
+ time: "Time (ISO 8601)",
75
+ decimal: 'BigDecimal (a decimal string, such as "12.50")'
76
+ }.freeze #: Hash[Skyward::Core::Types::scalar, String]
77
+
78
+ # A Hash[String, T] says its keys are Strings, so an untyped value it holds
79
+ # keeps the JSON's String keys at every level.
80
+ AS_PARSED = [
81
+ Skyward::Core::Types::Scalar.new(name: :untyped),
82
+ Skyward::Core::Types::Nullable.new(type: Skyward::Core::Types::Scalar.new(name: :untyped))
83
+ ].freeze #: Array[Skyward::Core::Types::t]
67
84
 
68
85
  # Path and query values are Strings, so with strings: true a coercer parses them.
69
86
  # @rbs type: Skyward::Core::Types::t
@@ -113,11 +130,14 @@ module Skyward::API::Inputs::Coercer
113
130
  when Skyward::Core::Types::Enum then enum(type.symbols, expected)
114
131
  when Skyward::Core::Types::Nullable then nullable(build(type.type, strings, member, unions))
115
132
  when Skyward::Core::Types::ArrayOf then array(build(type.type, strings, member, unions), strings, limit, expected)
116
- when Skyward::Core::Types::HashOf then hash_of(build(type.type, strings, member, unions), limit, expected)
133
+ when Skyward::Core::Types::HashOf
134
+ value = AS_PARSED.include?(type.type) ? as_parsed : build(type.type, strings, member, unions)
135
+ hash_of(value, limit, expected)
117
136
  when Skyward::Core::Types::Record then object(fields(type, strings, member, unions), limit, expected, &:itself)
118
137
  when Skyward::Core::Types::Named
119
138
  klass = type.klass
120
139
  object(fields(type, strings, member, unions), limit, expected) { |values| klass.new(**values) }
140
+ when Skyward::Core::Types::Refined then build(type.type, strings, member, unions)
121
141
  # Equal unions share one coercer, which is what lets one remember its results.
122
142
  else unions[[type, member]] ||= union(type.types.map { |one| build(one, strings, true, unions) }, member, expected)
123
143
  end
@@ -148,6 +168,7 @@ module Skyward::API::Inputs::Coercer
148
168
  when :string then ->(raw) { Ok.new(value: raw) if raw.is_a?(String) }
149
169
  when :date then ->(raw) { date(raw) }
150
170
  when :time then ->(raw) { time(raw) }
171
+ when :decimal then ->(raw) { decimal(raw) }
151
172
  else ->(raw) { Ok.new(value: strings ? last(raw) : symbolized(raw)) }
152
173
  end
153
174
  end
@@ -158,6 +179,9 @@ module Skyward::API::Inputs::Coercer
158
179
  # @rbs return: String?
159
180
  def last(raw) = raw.is_a?(Array) ? raw.last : raw
160
181
 
182
+ # @rbs return: coercer
183
+ def as_parsed = ->(raw, _at, _seen) { Ok.new(value: raw) }
184
+
161
185
  # @rbs raw: untyped
162
186
  # @rbs return: untyped
163
187
  def symbolized(raw)
@@ -224,6 +248,14 @@ module Skyward::API::Inputs::Coercer
224
248
  Ok.new(value: Time.new(on.year, on.month, on.day, hour.to_i, minute.to_i, seconds, zone))
225
249
  end
226
250
 
251
+ # A JSON number isn't one, because JSON.parse has already made it a Float,
252
+ # which may have lost digits.
253
+ # @rbs raw: untyped
254
+ # @rbs return: Ok?
255
+ def decimal(raw)
256
+ Ok.new(value: BigDecimal(raw)) if raw.is_a?(String) && DECIMAL.match?(raw.b)
257
+ end
258
+
227
259
  # @rbs value: Skyward::Core::Types::literal
228
260
  # @rbs strings: bool
229
261
  # @rbs expected: String?
@@ -411,6 +443,7 @@ module Skyward::API::Inputs::Coercer
411
443
  fields = type.fields.map { |field| "#{"?" unless field.required}#{field.name}: #{written(field.type)}" }
412
444
  "{ #{fields.join(", ")} }"
413
445
  when Skyward::Core::Types::Named then type.name
446
+ when Skyward::Core::Types::Refined then written(type.type)
414
447
  else type.types.map { |member| written(member) }.join(" | ")
415
448
  end
416
449
  end
@@ -36,6 +36,7 @@ module Skyward::API::OpenAPI
36
36
  bool: { type: "boolean" },
37
37
  date: { type: "string", format: "date" },
38
38
  time: { type: "string", format: "date-time" },
39
+ decimal: { type: "string", format: "decimal" },
39
40
  untyped: {} #: schema
40
41
  }.freeze #: Hash[Skyward::Core::Types::scalar, schema]
41
42
 
@@ -345,6 +346,7 @@ module Skyward::API::OpenAPI
345
346
  when Skyward::Core::Types::HashOf then { type: "object", additionalProperties: schema(type.type, form, names) }
346
347
  when Skyward::Core::Types::Record then object(type.fields, form, names)
347
348
  when Skyward::Core::Types::Named then { "$ref": "#/components/schemas/#{names.fetch(type.klass)}" }
349
+ when Skyward::Core::Types::Refined then schema(type.type, form, names)
348
350
  else { oneOf: type.types.map { |member| schema(member, form, names) } }
349
351
  end
350
352
  end
@@ -32,6 +32,7 @@ module Skyward::API::Serializer::Writers
32
32
  when Skyward::Core::Types::Record then record(type.fields)
33
33
  when Skyward::Core::Types::Named then named(type)
34
34
  when Skyward::Core::Types::Union then union(type.types.map { |member| writer(member) })
35
+ when Skyward::Core::Types::Refined then writer(type.type)
35
36
  end
36
37
  end
37
38
 
@@ -83,11 +84,13 @@ module Skyward::API::Serializer::Writers
83
84
  def scalar(name)
84
85
  case name
85
86
  when :integer then checked("Integer", ->(value) { value.is_a?(Integer) }, ->(value, _) { value })
86
- when :float then checked("Float", ->(value) { value.is_a?(Float) }, ->(value, _) { value })
87
+ when :float then checked("Float", ->(value) { value.is_a?(Float) && value.finite? }, ->(value, _) { value })
87
88
  when :string then checked("String", ->(value) { value.is_a?(String) }, ->(value, _) { value })
88
89
  when :bool then checked("bool", ->(value) { [true, false].include?(value) }, ->(value, _) { value })
89
90
  when :date then checked("Date", ->(value) { value.is_a?(Date) }, ->(value, _) { date(value) })
90
91
  when :time then checked("Time", ->(value) { value.is_a?(Time) }, ->(value, _) { time(value) })
92
+ when :decimal
93
+ checked("BigDecimal", ->(value) { value.is_a?(BigDecimal) && value.finite? }, ->(value, _) { decimal(value) })
91
94
  when :untyped then Writer.new(name: "untyped", fits: ->(_) { true }, write: ->(value, at) { untyped(value, at) })
92
95
  end
93
96
  end
@@ -188,6 +191,12 @@ module Skyward::API::Serializer::Writers
188
191
  # @rbs return: String
189
192
  def time(value) = value.getutc.iso8601(6)
190
193
 
194
+ # A String, so a client that reads JSON numbers as doubles keeps every digit,
195
+ # and "F" so it never has an exponent.
196
+ # @rbs value: BigDecimal
197
+ # @rbs return: String
198
+ def decimal(value) = value.to_s("F")
199
+
191
200
  # @rbs value: untyped
192
201
  # @rbs at: String
193
202
  # @rbs return: untyped
@@ -197,6 +206,7 @@ module Skyward::API::Serializer::Writers
197
206
  when Symbol then value.name
198
207
  when Date then date(value)
199
208
  when Time then time(value)
209
+ when BigDecimal then value.finite? ? decimal(value) : misfit("BigDecimal", value, at)
200
210
  when Hash then object(value.map { |key, item| [key, untyped(item, "#{at}.#{key}")] })
201
211
  when Array then items(value.each_with_index.map { |item, index| untyped(item, "#{at}[#{index}]") })
202
212
  else value.respond_to?(:to_h) ? untyped(value.to_h, at) : misfit("something with to_h", value, at)
@@ -223,6 +233,7 @@ module Skyward::API::Serializer::Writers
223
233
  got =
224
234
  case value
225
235
  when nil, true, false, Symbol, Integer, Float then value.inspect
236
+ when BigDecimal then decimal(value)
226
237
  else value.class.inspect
227
238
  end
228
239
  Misfit.new(at:, expected:, got:)
@@ -65,11 +65,11 @@ class Skyward::API::Serializer
65
65
  end
66
66
  end
67
67
 
68
- # Untyped code can return any response value.
68
+ # Untyped code can return any response value, or a Rack triple.
69
69
  # @rbs return: Writers::Writer
70
70
  def untyped
71
71
  writer = Writers.writer(UNTYPED)
72
- responses = [created(writer), *RESPONSES.map { |klass| response(klass) }, ok(writer)]
72
+ responses = [created(writer), *RESPONSES.map { |klass| response(klass) }, untyped_rack, ok(writer)]
73
73
  Writers.union(responses).with(name: "untyped")
74
74
  end
75
75
 
@@ -105,11 +105,29 @@ class Skyward::API::Serializer
105
105
 
106
106
  # @rbs return: Writers::Writer
107
107
  def rack
108
- Writers.checked(
109
- "Skyward::API::rack",
110
- ->(given) { given.is_a?(Array) && given.size == 3 && given[0].is_a?(Integer) && given[1].is_a?(Hash) },
111
- ->(given, _) { given }
112
- )
108
+ rack_writer(->(given) { given.is_a?(Array) && given.size == 3 && given[0].is_a?(Integer) && given[1].is_a?(Hash) })
109
+ end
110
+
111
+ # Nothing typed says an untyped value is a triple, so it must have a status HTTP has and a body Rack can send.
112
+ # @rbs return: Writers::Writer
113
+ def untyped_rack
114
+ rack_writer(->(given) { triple?(given) })
115
+ end
116
+
117
+ # @rbs fits: ^(untyped) -> bool
118
+ # @rbs return: Writers::Writer
119
+ def rack_writer(fits)
120
+ Writers.checked("Skyward::API::rack", fits, ->(given, _) { given })
121
+ end
122
+
123
+ # @rbs given: untyped
124
+ # @rbs return: bool
125
+ def triple?(given)
126
+ return false unless given.is_a?(Array) && given.size == 3
127
+
128
+ status, headers, body = given
129
+ status.is_a?(Integer) && status.between?(100, 599) && headers.is_a?(Hash) &&
130
+ (body.respond_to?(:each) || body.respond_to?(:call))
113
131
  end
114
132
 
115
133
  # @rbs problem: Problem
@@ -4,7 +4,7 @@ module Skyward
4
4
  class API
5
5
  # x-release-please-start-version
6
6
 
7
- VERSION = "0.2.0" #: String
7
+ VERSION = "0.4.0" #: String
8
8
 
9
9
  # x-release-please-end
10
10
  end
data/lib/skyward/api.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "bigdecimal"
3
4
  require "securerandom"
4
5
  require "skyward/core"
5
6
  require "zeitwerk"
@@ -15,6 +15,21 @@ module Skyward::API::Assembly::Boot
15
15
  # untyped, which is what rbs-inline writes for a method with no annotations.
16
16
  ANY: RBS::Types::Bases::Any
17
17
 
18
+ class Refusal < Data
19
+ attr_reader problem(): String
20
+
21
+ attr_reader spots(): Array[Skyward::Core::Diagnostics::Spot]
22
+
23
+ attr_reader hint(): String?
24
+
25
+ def self.new: (String problem, Array[Skyward::Core::Diagnostics::Spot] spots, String? hint) -> instance
26
+ | (problem: String, spots: Array[Skyward::Core::Diagnostics::Spot], hint: String?) -> instance
27
+
28
+ def self.members: () -> [ :problem, :spots, :hint ]
29
+
30
+ def members: () -> [ :problem, :spots, :hint ]
31
+ end
32
+
18
33
  # @rbs (Array[Skyward::API::Assembly::Builder::Mount] mounts,
19
34
  # providers: Hash[Symbol, Skyward::API::_Provider & Object], reader: Skyward::Core::Types::Reader,
20
35
  # max_body_size: Integer, strict: bool) ->
@@ -36,16 +51,39 @@ module Skyward::API::Assembly::Boot
36
51
 
37
52
  # @rbs mount: Skyward::API::Assembly::Builder::Mount
38
53
  # @rbs route: Skyward::API::Endpoints::Route
39
- # @rbs built: Array[Skyward::API::Routing::Router::Endpoint]
54
+ # @rbs built: Array[[Skyward::API::Endpoints::Route, Skyward::API::Routing::Router::Endpoint]]
40
55
  # @rbs providers: Hash[Symbol, Skyward::API::Routing::Router::Provider]
41
56
  # @rbs reader: Skyward::Core::Types::Reader
42
57
  # @rbs max_body_size: Integer
43
58
  # @rbs return: Skyward::API::Routing::Router::Endpoint
44
- def boot: (Skyward::API::Assembly::Builder::Mount mount, Skyward::API::Endpoints::Route route, Array[Skyward::API::Routing::Router::Endpoint] built, Hash[Symbol, Skyward::API::Routing::Router::Provider] providers, Skyward::Core::Types::Reader reader, Integer max_body_size) -> Skyward::API::Routing::Router::Endpoint
59
+ def boot: (Skyward::API::Assembly::Builder::Mount mount, Skyward::API::Endpoints::Route route, Array[[ Skyward::API::Endpoints::Route, Skyward::API::Routing::Router::Endpoint ]] built, Hash[Symbol, Skyward::API::Routing::Router::Provider] providers, Skyward::Core::Types::Reader reader, Integer max_body_size) -> Skyward::API::Routing::Router::Endpoint
60
+
61
+ # Core's own errors carry their excerpt in their message, already indented,
62
+ # so every line but an excerpt's is indented under the label.
63
+ # @rbs label: String
64
+ # @rbs refusal: Refusal
65
+ # @rbs return: String
66
+ def explained: (String label, Refusal refusal) -> String
67
+
68
+ # @rbs problem: String
69
+ # @rbs spots: Array[Skyward::Core::Diagnostics::Spot?]
70
+ # @rbs hint: String?
71
+ # @rbs return: Refusal
72
+ def refused: (String problem, ?spots: Array[Skyward::Core::Diagnostics::Spot?], ?hint: String?) -> Refusal
45
73
 
46
74
  # @rbs route: Skyward::API::Endpoints::Route
47
- # @rbs return: String?
48
- def summary: (Skyward::API::Endpoints::Route route) -> String?
75
+ # @rbs key: Symbol
76
+ # @rbs return: Skyward::Core::Diagnostics::Spot?
77
+ def argument: (Skyward::API::Endpoints::Route route, Symbol key) -> Skyward::Core::Diagnostics::Spot?
78
+
79
+ # @rbs route: Skyward::API::Endpoints::Route
80
+ # @rbs part: String
81
+ # @rbs return: Skyward::Core::Diagnostics::Spot?
82
+ def in_path: (Skyward::API::Endpoints::Route route, String part) -> Skyward::Core::Diagnostics::Spot?
83
+
84
+ # @rbs route: Skyward::API::Endpoints::Route
85
+ # @rbs return: Refusal?
86
+ def summary: (Skyward::API::Endpoints::Route route) -> Refusal?
49
87
 
50
88
  # @rbs prefix: String
51
89
  # @rbs path: String
@@ -56,11 +94,12 @@ module Skyward::API::Assembly::Boot
56
94
  # @rbs return: Array[String | Symbol]
57
95
  def pattern: (String path) -> Array[String | Symbol]
58
96
 
97
+ # @rbs route: Skyward::API::Endpoints::Route
59
98
  # @rbs verb: String
60
99
  # @rbs pattern: Array[String | Symbol]
61
- # @rbs built: Array[Skyward::API::Routing::Router::Endpoint]
62
- # @rbs return: String?
63
- def shadowing: (String verb, Array[String | Symbol] pattern, Array[Skyward::API::Routing::Router::Endpoint] built) -> String?
100
+ # @rbs built: Array[[Skyward::API::Endpoints::Route, Skyward::API::Routing::Router::Endpoint]]
101
+ # @rbs return: Refusal?
102
+ def shadowing: (Skyward::API::Endpoints::Route route, String verb, Array[String | Symbol] pattern, Array[[ Skyward::API::Endpoints::Route, Skyward::API::Routing::Router::Endpoint ]] built) -> Refusal?
64
103
 
65
104
  # A path parameter matches any segment but an empty one, which only the root path has.
66
105
  # @rbs pattern: Array[String | Symbol]
@@ -76,14 +115,21 @@ module Skyward::API::Assembly::Boot
76
115
  # @rbs providers: Hash[Symbol, Skyward::API::Routing::Router::Provider]
77
116
  # @rbs reader: Skyward::Core::Types::Reader
78
117
  # @rbs max_body_size: Integer
79
- # @rbs return: Skyward::API::Routing::Router::Endpoint | String
80
- def endpoint: (Skyward::API api, Skyward::API::Endpoints::Route route, String verb, Array[String | Symbol] pattern, String label, Hash[Symbol, Skyward::API::Routing::Router::Provider] providers, Skyward::Core::Types::Reader reader, Integer max_body_size) -> (Skyward::API::Routing::Router::Endpoint | String)
118
+ # @rbs return: Skyward::API::Routing::Router::Endpoint | Refusal
119
+ def endpoint: (Skyward::API api, Skyward::API::Endpoints::Route route, String verb, Array[String | Symbol] pattern, String label, Hash[Symbol, Skyward::API::Routing::Router::Provider] providers, Skyward::Core::Types::Reader reader, Integer max_body_size) -> (Skyward::API::Routing::Router::Endpoint | Refusal)
81
120
 
82
121
  # @rbs klass: Class
83
- # @rbs to: Symbol
122
+ # @rbs route: Skyward::API::Endpoints::Route
84
123
  # @rbs reader: Skyward::Core::Types::Reader
85
- # @rbs return: RBS::MethodType | String | nil
86
- def method_type: (Class klass, Symbol to, Skyward::Core::Types::Reader reader) -> (RBS::MethodType | String | nil)
124
+ # @rbs return: RBS::MethodType | Refusal | nil
125
+ def method_type: (Class klass, Skyward::API::Endpoints::Route route, Skyward::Core::Types::Reader reader) -> (RBS::MethodType | Refusal | nil)
126
+
127
+ # Only the class's own methods, so that a method it inherits, as from
128
+ # Skyward::API or Kernel, is never suggested.
129
+ # @rbs klass: Class
130
+ # @rbs to: Symbol
131
+ # @rbs return: String?
132
+ def unrouted: (Class klass, Symbol to) -> String?
87
133
 
88
134
  # @rbs owner: Module
89
135
  # @rbs name: Symbol
@@ -91,10 +137,10 @@ module Skyward::API::Assembly::Boot
91
137
  # @rbs return: RBS::MethodType?
92
138
  def signature: (Module owner, Symbol name, Skyward::Core::Types::Reader reader) -> RBS::MethodType?
93
139
 
94
- # @rbs parameters: Method::param_types
140
+ # @rbs method: UnboundMethod
95
141
  # @rbs type: RBS::Types::function?
96
- # @rbs return: Array[[Symbol, bool, RBS::Types::t]] | String
97
- def signed: (Method::param_types parameters, RBS::Types::function? type) -> (Array[[ Symbol, bool, RBS::Types::t ]] | String)
142
+ # @rbs return: Array[[Symbol, bool, RBS::Types::t]] | Refusal
143
+ def signed: (UnboundMethod method, RBS::Types::function? type) -> (Array[[ Symbol, bool, RBS::Types::t ]] | Refusal)
98
144
 
99
145
  # @rbs method_type: RBS::MethodType
100
146
  # @rbs return: String
@@ -106,8 +152,8 @@ module Skyward::API::Assembly::Boot
106
152
 
107
153
  # @rbs keywords: Hash[Symbol, bool]
108
154
  # @rbs function: RBS::Types::function
109
- # @rbs return: String
110
- def stale: (Hash[Symbol, bool] keywords, RBS::Types::function function) -> String
155
+ # @rbs return: Refusal
156
+ def stale: (Hash[Symbol, bool] keywords, RBS::Types::function function) -> Refusal
111
157
 
112
158
  # @rbs function: RBS::Types::function
113
159
  # @rbs return: RBS::Types::Function?
@@ -117,14 +163,38 @@ module Skyward::API::Assembly::Boot
117
163
  # @rbs return: Hash[Symbol, bool]
118
164
  def keyword_requirements: (RBS::Types::Function function) -> Hash[Symbol, bool]
119
165
 
166
+ # @rbs route: Skyward::API::Endpoints::Route
167
+ # @rbs method: UnboundMethod
168
+ # @rbs parameter: Symbol
169
+ # @rbs query: Array[Symbol]
170
+ # @rbs return: Refusal
171
+ def no_keyword: (Skyward::API::Endpoints::Route route, UnboundMethod method, Symbol parameter, Array[Symbol] query) -> Refusal
172
+
173
+ # A nested resource's renamed parameter, as `todo_id:` for `/:id`, isn't a
174
+ # misspelling DidYouMean would find, so a keyword that ends in the parameter,
175
+ # or that the parameter ends in, is meant too, when it's the only one.
176
+ # @rbs parameter: Symbol
177
+ # @rbs query: Array[Symbol]
178
+ # @rbs return: Symbol?
179
+ def meant: (Symbol parameter, Array[Symbol] query) -> Symbol?
180
+
181
+ # Core's spot of a parameter list that runs onto another line stops at the end
182
+ # of its first, so only a list written whole on the `def` line is rewritten.
183
+ # @rbs method: UnboundMethod
184
+ # @rbs parameters: Skyward::Core::Diagnostics::Spot
185
+ # @rbs keyword: Skyward::Core::Diagnostics::Spot
186
+ # @rbs parameter: Symbol
187
+ # @rbs return: String?
188
+ def rename_hint: (UnboundMethod method, Skyward::Core::Diagnostics::Spot parameters, Skyward::Core::Diagnostics::Spot keyword, Symbol parameter) -> String?
189
+
120
190
  # @rbs name: Symbol
121
191
  # @rbs required: bool
122
192
  # @rbs type: RBS::Types::t
123
193
  # @rbs pattern: Array[String | Symbol]
124
194
  # @rbs providers: Hash[Symbol, Skyward::API::Routing::Router::Provider]
125
195
  # @rbs reader: Skyward::Core::Types::Reader
126
- # @rbs return: Skyward::API::Routing::Router::Keyword | Skyward::API::Routing::Router::Provider | String
127
- def keyword: (Symbol name, bool required, RBS::Types::t type, Array[String | Symbol] pattern, Hash[Symbol, Skyward::API::Routing::Router::Provider] providers, Skyward::Core::Types::Reader reader) -> (Skyward::API::Routing::Router::Keyword | Skyward::API::Routing::Router::Provider | String)
196
+ # @rbs return: Skyward::API::Routing::Router::Keyword | Skyward::API::Routing::Router::Provider | Refusal
197
+ def keyword: (Symbol name, bool required, RBS::Types::t type, Array[String | Symbol] pattern, Hash[Symbol, Skyward::API::Routing::Router::Provider] providers, Skyward::Core::Types::Reader reader) -> (Skyward::API::Routing::Router::Keyword | Skyward::API::Routing::Router::Provider | Refusal)
128
198
 
129
199
  # @rbs name: Symbol
130
200
  # @rbs pattern: Array[String | Symbol]
@@ -133,16 +203,16 @@ module Skyward::API::Assembly::Boot
133
203
 
134
204
  # @rbs required: bool
135
205
  # @rbs type: RBS::Types::t
136
- # @rbs return: Skyward::API::Routing::Router::Keyword | String
137
- def request: (bool required, RBS::Types::t type) -> (Skyward::API::Routing::Router::Keyword | String)
206
+ # @rbs return: Skyward::API::Routing::Router::Keyword | Refusal
207
+ def request: (bool required, RBS::Types::t type) -> (Skyward::API::Routing::Router::Keyword | Refusal)
138
208
 
139
209
  # A provided keyword's type is the provider's to give, so it's compared, never
140
210
  # read, except that an untyped keyword is left unchecked, as untyped code is.
141
211
  # @rbs name: Symbol
142
212
  # @rbs type: RBS::Types::t
143
213
  # @rbs provider: Skyward::API::Routing::Router::Provider
144
- # @rbs return: Skyward::API::Routing::Router::Provider | String
145
- def provided: (Symbol name, RBS::Types::t type, Skyward::API::Routing::Router::Provider provider) -> (Skyward::API::Routing::Router::Provider | String)
214
+ # @rbs return: Skyward::API::Routing::Router::Provider | Refusal
215
+ def provided: (Symbol name, RBS::Types::t type, Skyward::API::Routing::Router::Provider provider) -> (Skyward::API::Routing::Router::Provider | Refusal)
146
216
 
147
217
  # @rbs type: RBS::Types::t
148
218
  # @rbs return: bool
@@ -157,8 +227,8 @@ module Skyward::API::Assembly::Boot
157
227
  # @rbs name: Symbol
158
228
  # @rbs source: :path | :query | :body | :request
159
229
  # @rbs type: Skyward::Core::Types::t
160
- # @rbs return: String?
161
- def carried: (Symbol name, :path | :query | :body | :request source, Skyward::Core::Types::t type) -> String?
230
+ # @rbs return: Refusal?
231
+ def carried: (Symbol name, :path | :query | :body | :request source, Skyward::Core::Types::t type) -> Refusal?
162
232
 
163
233
  # @rbs type: Skyward::Core::Types::t
164
234
  # @rbs within: :path | :query | :array
@@ -168,8 +238,8 @@ module Skyward::API::Assembly::Boot
168
238
  # Response values are found in the signature, because the reader can't read them.
169
239
  # @rbs type: RBS::Types::t
170
240
  # @rbs reader: Skyward::Core::Types::Reader
171
- # @rbs return: Array[Skyward::API::Routing::Router::returned] | String
172
- def returns: (RBS::Types::t type, Skyward::Core::Types::Reader reader) -> (Array[Skyward::API::Routing::Router::returned] | String)
241
+ # @rbs return: Array[Skyward::API::Routing::Router::returned] | Refusal
242
+ def returns: (RBS::Types::t type, Skyward::Core::Types::Reader reader) -> (Array[Skyward::API::Routing::Router::returned] | Refusal)
173
243
 
174
244
  # @rbs type: RBS::Types::t
175
245
  # @rbs return: Array[RBS::Types::t]
@@ -208,8 +278,8 @@ module Skyward::API::Assembly::Boot
208
278
 
209
279
  # @rbs subject: String
210
280
  # @rbs type: Skyward::Core::Types::Unreadable
211
- # @rbs return: String
212
- def unreadable: (String subject, Skyward::Core::Types::Unreadable type) -> String
281
+ # @rbs return: Refusal
282
+ def unreadable: (String subject, Skyward::Core::Types::Unreadable type) -> Refusal
213
283
 
214
284
  # @rbs text: String
215
285
  # @rbs return: String
@@ -5,11 +5,12 @@ module Skyward::API::CLI::AppFile
5
5
 
6
6
  ASSIGNMENT: String
7
7
 
8
- # @rbs (String directory, out: _Writer, kernel: singleton(Kernel)) { (Skyward::API::Assembly::Application) -> String }
9
- # -> void
10
- def run: (String directory, out: _Writer, kernel: singleton(Kernel)) { (Skyward::API::Assembly::Application) -> String } -> void
8
+ # @rbs (String directory, out: _Writer, kernel: singleton(Kernel), generate: ^() -> String?)
9
+ # { (Skyward::API::Assembly::Application) -> String } -> void
10
+ def run: (String directory, out: _Writer, kernel: singleton(Kernel), generate: ^() -> String?) { (Skyward::API::Assembly::Application) -> String } -> void
11
11
 
12
12
  # @rbs directory: String
13
+ # @rbs generate: ^() -> String?
13
14
  # @rbs return: Skyward::API::Assembly::Application | String
14
- def load: (String directory) -> (Skyward::API::Assembly::Application | String)
15
+ def load: (String directory, ^() -> String? generate) -> (Skyward::API::Assembly::Application | String)
15
16
  end
@@ -1,7 +1,7 @@
1
1
  # Generated from lib/skyward/api/cli/check.rb with RBS::Inline
2
2
 
3
3
  module Skyward::API::CLI::Check
4
- type capture = ^(Hash[String, String] env, Array[String] command, String chdir) -> [ String, bool ]
4
+ type capture = Skyward::Core::CLI::Executable::capture
5
5
 
6
6
  class Outcome < Data
7
7
  attr_reader passed(): bool
@@ -22,13 +22,11 @@ module Skyward::API::CLI::Check
22
22
 
23
23
  STEEPFILE: String
24
24
 
25
- # None holds the app's contract: its tests, its installed gems and scratch.
26
- UNCHECKED: Array[String]
27
-
28
25
  # The strict boot's own Ruby runs it, so the forced strict mode, the app's
29
26
  # side effects and an exit or crash stay out of skyward check. The require
30
27
  # lives here because a `-r` on the command line runs before RUBYOPT's
31
28
  # `-rbundler/setup` on newer Rubies, before the bundle's gems are loadable.
29
+ # skyward check writes nothing, so the boot doesn't regenerate sig/generated.
32
30
  BOOT: String
33
31
 
34
32
  INSTALL_RBS_INLINE: String
@@ -61,14 +59,6 @@ module Skyward::API::CLI::Check
61
59
  # @rbs return: Outcome
62
60
  def failed: (String detail) -> Outcome
63
61
 
64
- # @rbs directory: String
65
- # @rbs return: Array[String]
66
- def sources: (String directory) -> Array[String]
67
-
68
- # @rbs directory: String
69
- # @rbs return: Hash[String, String]
70
- def rbs_files: (String directory) -> Hash[String, String]
71
-
72
62
  # @rbs current: Hash[String, String]
73
63
  # @rbs expected: Hash[String, String]
74
64
  # @rbs return: Array[String]