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.
@@ -3,25 +3,32 @@
3
3
  class Skyward::API::CLI::Serve::Reloader
4
4
  INTERVAL: Float
5
5
 
6
- @watch: ^() -> Hash[String, Time]
6
+ @app: Skyward::API::_RackApp
7
7
 
8
- @load: ^() -> Skyward::API::_RackApp
8
+ @failure: String?
9
9
 
10
- @clock: ^() -> Float
10
+ @sources: Hash[String, Time]
11
11
 
12
- @mutex: Thread::Mutex
12
+ @files: Hash[String, Time]
13
13
 
14
14
  @checked_at: Float
15
15
 
16
- @files: Hash[String, Time]
16
+ @mutex: Thread::Mutex
17
17
 
18
- @app: Skyward::API::_RackApp
18
+ @clock: ^() -> Float
19
+
20
+ @generate: ^() -> String?
21
+
22
+ @load: ^() -> Skyward::API::_RackApp
23
+
24
+ @watch: ^() -> Hash[String, Time]
19
25
 
20
26
  # @rbs watch: ^() -> Hash[String, Time]
21
27
  # @rbs load: ^() -> Skyward::API::_RackApp
28
+ # @rbs generate: ^() -> String?
22
29
  # @rbs clock: ^() -> Float
23
30
  # @rbs return: void
24
- def initialize: (watch: ^() -> Hash[String, Time], load: ^() -> Skyward::API::_RackApp, clock: ^() -> Float) -> void
31
+ def initialize: (watch: ^() -> Hash[String, Time], load: ^() -> Skyward::API::_RackApp, generate: ^() -> String?, clock: ^() -> Float) -> void
25
32
 
26
33
  # The app is taken under the lock but called outside it, so a request in
27
34
  # flight finishes on the app it started with.
@@ -29,6 +36,10 @@ class Skyward::API::CLI::Serve::Reloader
29
36
  # @rbs return: Skyward::API::rack_response
30
37
  def call: (Hash[String, untyped] env) -> Skyward::API::rack_response
31
38
 
39
+ # Leaves the reload to the next request, which still sees the change.
40
+ # @rbs return: void
41
+ def regenerate: () -> void
42
+
32
43
  private
33
44
 
34
45
  # @rbs return: Skyward::API::_RackApp
@@ -37,6 +48,16 @@ class Skyward::API::CLI::Serve::Reloader
37
48
  # @rbs return: Skyward::API::_RackApp
38
49
  def attempt: () -> Skyward::API::_RackApp
39
50
 
51
+ # Runs rbs-inline once for the .rb files as they are, whether regenerate or
52
+ # a reload sees them first.
53
+ # @rbs files: Hash[String, Time]
54
+ # @rbs return: String?
55
+ def generate: (Hash[String, Time] files) -> String?
56
+
57
+ # @rbs error: Exception
58
+ # @rbs return: Skyward::API::_RackApp
59
+ def failed: (Exception error) -> Skyward::API::_RackApp
60
+
40
61
  # The development 500 that Skyward::API::Middleware::Rescue answers, without a request
41
62
  # ID: the app that assigns them is the one that failed to load.
42
63
  # @rbs error: Exception
@@ -18,14 +18,17 @@ module Skyward::API::CLI::Serve
18
18
  # @rbs return: void
19
19
  def run: (String directory, env: Hash[String, String], falcon: String?, kernel: singleton(Kernel)) -> void
20
20
 
21
+ # Without rbs-inline, generate is nil, and sig/generated is used as it is.
21
22
  # @rbs directory: String
22
23
  # @rbs build: ^(String config) -> Skyward::API::_RackApp
23
24
  # @rbs clock: ^() -> Float
24
25
  # @rbs apis: ^() -> Array[singleton(Skyward::API)]
25
26
  # @rbs features: Array[String]
26
27
  # @rbs loaders: ^() -> Array[Zeitwerk::Loader]
28
+ # @rbs generate: (^() -> String?)?
29
+ # @rbs every: ^(Float interval) { () -> void } -> void
27
30
  # @rbs return: Reloader
28
- def reloader: (String directory, build: ^(String config) -> Skyward::API::_RackApp, clock: ^() -> Float, apis: ^() -> Array[singleton(Skyward::API)], features: Array[String], loaders: ^() -> Array[Zeitwerk::Loader]) -> Reloader
31
+ def reloader: (String directory, build: ^(String config) -> Skyward::API::_RackApp, clock: ^() -> Float, apis: ^() -> Array[singleton(Skyward::API)], features: Array[String], loaders: ^() -> Array[Zeitwerk::Loader], generate: (^() -> String?)?, every: ^(Float interval) { () -> void } -> void) -> Reloader
29
32
 
30
33
  # @rbs directory: String
31
34
  # @rbs return: Hash[String, Time]
@@ -14,11 +14,15 @@ module Skyward::API::Endpoints
14
14
 
15
15
  attr_reader description(): String?
16
16
 
17
- def self.new: (Symbol verb, String path, Symbol to, String? summary, String? description) -> instance
18
- | (verb: Symbol, path: String, to: Symbol, summary: String?, description: String?) -> instance
17
+ attr_reader file(): String?
19
18
 
20
- def self.members: () -> [ :verb, :path, :to, :summary, :description ]
19
+ attr_reader line(): Integer?
21
20
 
22
- def members: () -> [ :verb, :path, :to, :summary, :description ]
21
+ def self.new: (Symbol verb, String path, Symbol to, String? summary, String? description, String? file, Integer? line) -> instance
22
+ | (verb: Symbol, path: String, to: Symbol, summary: String?, description: String?, file: String?, line: Integer?) -> instance
23
+
24
+ def self.members: () -> [ :verb, :path, :to, :summary, :description, :file, :line ]
25
+
26
+ def members: () -> [ :verb, :path, :to, :summary, :description, :file, :line ]
23
27
  end
24
28
  end
@@ -57,10 +57,15 @@ module Skyward::API::Inputs::Coercer
57
57
  # none of them.
58
58
  MISFIT: Invalid
59
59
 
60
- # INTEGER, DATE and TIME match a String's bytes, because a path parameter
61
- # can be any bytes, and Regexp#match raises on a String that isn't UTF-8.
60
+ # INTEGER, DECIMAL, DATE and TIME match a String's bytes, because a path
61
+ # parameter can be any bytes, and Regexp#match raises on a String that isn't
62
+ # UTF-8.
62
63
  INTEGER: Regexp
63
64
 
65
+ # No exponent, NaN or Infinity: "1e1000000000" is short, but written without
66
+ # an exponent it's a billion digits long.
67
+ DECIMAL: Regexp
68
+
64
69
  BOOLEANS: Hash[String, bool]
65
70
 
66
71
  DATE: Regexp
@@ -72,6 +77,10 @@ module Skyward::API::Inputs::Coercer
72
77
 
73
78
  FORMATS: Hash[Skyward::Core::Types::scalar, String]
74
79
 
80
+ # A Hash[String, T] says its keys are Strings, so an untyped value it holds
81
+ # keeps the JSON's String keys at every level.
82
+ AS_PARSED: Array[Skyward::Core::Types::t]
83
+
75
84
  # Path and query values are Strings, so with strings: true a coercer parses them.
76
85
  # @rbs type: Skyward::Core::Types::t
77
86
  # @rbs strings: bool
@@ -122,6 +131,9 @@ module Skyward::API::Inputs::Coercer
122
131
  # @rbs return: String?
123
132
  def last: (String | Array[String] raw) -> String?
124
133
 
134
+ # @rbs return: coercer
135
+ def as_parsed: () -> coercer
136
+
125
137
  # @rbs raw: untyped
126
138
  # @rbs return: untyped
127
139
  def symbolized: (untyped raw) -> untyped
@@ -149,6 +161,12 @@ module Skyward::API::Inputs::Coercer
149
161
  # @rbs return: Ok?
150
162
  def time: (untyped raw) -> Ok?
151
163
 
164
+ # A JSON number isn't one, because JSON.parse has already made it a Float,
165
+ # which may have lost digits.
166
+ # @rbs raw: untyped
167
+ # @rbs return: Ok?
168
+ def decimal: (untyped raw) -> Ok?
169
+
152
170
  # @rbs value: Skyward::Core::Types::literal
153
171
  # @rbs strings: bool
154
172
  # @rbs expected: String?
@@ -104,6 +104,12 @@ module Skyward::API::Serializer::Writers
104
104
  # @rbs return: String
105
105
  def time: (Time value) -> String
106
106
 
107
+ # A String, so a client that reads JSON numbers as doubles keeps every digit,
108
+ # and "F" so it never has an exponent.
109
+ # @rbs value: BigDecimal
110
+ # @rbs return: String
111
+ def decimal: (BigDecimal value) -> String
112
+
107
113
  # @rbs value: untyped
108
114
  # @rbs at: String
109
115
  # @rbs return: untyped
@@ -43,7 +43,7 @@ class Skyward::API::Serializer
43
43
  # @rbs return: Writers::Writer
44
44
  def compile: (Skyward::API::Routing::Router::returned member) -> Writers::Writer
45
45
 
46
- # Untyped code can return any response value.
46
+ # Untyped code can return any response value, or a Rack triple.
47
47
  # @rbs return: Writers::Writer
48
48
  def untyped: () -> Writers::Writer
49
49
 
@@ -62,6 +62,18 @@ class Skyward::API::Serializer
62
62
  # @rbs return: Writers::Writer
63
63
  def rack: () -> Writers::Writer
64
64
 
65
+ # Nothing typed says an untyped value is a triple, so it must have a status HTTP has and a body Rack can send.
66
+ # @rbs return: Writers::Writer
67
+ def untyped_rack: () -> Writers::Writer
68
+
69
+ # @rbs fits: ^(untyped) -> bool
70
+ # @rbs return: Writers::Writer
71
+ def rack_writer: (^(untyped) -> bool fits) -> Writers::Writer
72
+
73
+ # @rbs given: untyped
74
+ # @rbs return: bool
75
+ def triple?: (untyped given) -> bool
76
+
65
77
  # @rbs problem: Problem
66
78
  # @rbs given: untyped
67
79
  # @rbs return: Skyward::API::Assembly::Dispatcher::response
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skyward-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Bottrall
@@ -15,14 +15,28 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.2.0
18
+ version: 0.4.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.2.0
25
+ version: 0.4.0
26
+ - !ruby/object:Gem::Dependency
27
+ name: bigdecimal
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '3.1'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '3.1'
26
40
  - !ruby/object:Gem::Dependency
27
41
  name: zeitwerk
28
42
  requirement: !ruby/object:Gem::Requirement
@@ -54,7 +68,6 @@ files:
54
68
  - lib/skyward/api/cli.rb
55
69
  - lib/skyward/api/cli/app_file.rb
56
70
  - lib/skyward/api/cli/check.rb
57
- - lib/skyward/api/cli/executable.rb
58
71
  - lib/skyward/api/cli/routes.rb
59
72
  - lib/skyward/api/cli/serve.rb
60
73
  - lib/skyward/api/cli/serve.ru
@@ -103,7 +116,6 @@ files:
103
116
  - sig/generated/skyward/api/cli.rbs
104
117
  - sig/generated/skyward/api/cli/app_file.rbs
105
118
  - sig/generated/skyward/api/cli/check.rbs
106
- - sig/generated/skyward/api/cli/executable.rbs
107
119
  - sig/generated/skyward/api/cli/routes.rbs
108
120
  - sig/generated/skyward/api/cli/serve.rbs
109
121
  - sig/generated/skyward/api/cli/serve/reloader.rbs
@@ -145,7 +157,6 @@ files:
145
157
  - sig/manual/skyward/api/assembly/boot.rbs
146
158
  - sig/manual/skyward/api/cli/app_file.rbs
147
159
  - sig/manual/skyward/api/cli/check.rbs
148
- - sig/manual/skyward/api/cli/executable.rbs
149
160
  - sig/manual/skyward/api/cli/routes.rbs
150
161
  - sig/manual/skyward/api/cli/serve.rbs
151
162
  - sig/manual/skyward/api/inputs/coercer.rbs
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Skyward::API::CLI::Executable
4
- extend self
5
-
6
- # Under Bundler, Gem.find_files and Gem.bin_path see only the bundle's gems,
7
- # so a gem installed outside the app's bundle isn't found. Checking first
8
- # spares rescuing the error bin_path raises for a missing gem.
9
- # @rbs name: String
10
- # @rbs feature: String
11
- # @rbs return: String?
12
- def find(name, feature: name)
13
- Gem.bin_path(name, name) unless Gem.find_files("#{feature}.rb").empty?
14
- end
15
- end
@@ -1,11 +0,0 @@
1
- # Generated from lib/skyward/api/cli/executable.rb with RBS::Inline
2
-
3
- module Skyward::API::CLI::Executable
4
- # Under Bundler, Gem.find_files and Gem.bin_path see only the bundle's gems,
5
- # so a gem installed outside the app's bundle isn't found. Checking first
6
- # spares rescuing the error bin_path raises for a missing gem.
7
- # @rbs name: String
8
- # @rbs feature: String
9
- # @rbs return: String?
10
- def find: (String name, ?feature: String) -> String?
11
- end
@@ -1,3 +0,0 @@
1
- module Skyward::API::CLI::Executable
2
- extend ::Skyward::API::CLI::Executable
3
- end