tapioca 0.17.3 → 0.17.5
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 +4 -4
- data/lib/ruby_lsp/tapioca/addon.rb +1 -1
- data/lib/ruby_lsp/tapioca/server_addon.rb +9 -7
- data/lib/tapioca/bundler_ext/auto_require_hook.rb +1 -4
- data/lib/tapioca/cli.rb +2 -2
- data/lib/tapioca/commands/abstract_dsl.rb +1 -2
- data/lib/tapioca/commands/abstract_gem.rb +1 -2
- data/lib/tapioca/commands/annotations.rb +1 -1
- data/lib/tapioca/commands/command.rb +4 -6
- data/lib/tapioca/commands/command_without_tracker.rb +1 -4
- data/lib/tapioca/dsl/compiler.rb +8 -10
- data/lib/tapioca/dsl/compilers/aasm.rb +1 -2
- data/lib/tapioca/dsl/compilers/action_controller_helpers.rb +1 -2
- data/lib/tapioca/dsl/compilers/action_mailer.rb +1 -2
- data/lib/tapioca/dsl/compilers/action_text.rb +1 -2
- data/lib/tapioca/dsl/compilers/active_job.rb +1 -2
- data/lib/tapioca/dsl/compilers/active_model_attributes.rb +1 -4
- data/lib/tapioca/dsl/compilers/active_model_secure_password.rb +1 -4
- data/lib/tapioca/dsl/compilers/active_model_validations_confirmation.rb +1 -10
- data/lib/tapioca/dsl/compilers/active_record_associations.rb +1 -2
- data/lib/tapioca/dsl/compilers/active_record_columns.rb +1 -2
- data/lib/tapioca/dsl/compilers/active_record_delegated_types.rb +1 -2
- data/lib/tapioca/dsl/compilers/active_record_enum.rb +1 -2
- data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_relations.rb +54 -90
- data/lib/tapioca/dsl/compilers/active_record_scope.rb +1 -2
- data/lib/tapioca/dsl/compilers/active_record_secure_token.rb +1 -2
- data/lib/tapioca/dsl/compilers/active_record_store.rb +1 -2
- data/lib/tapioca/dsl/compilers/active_record_typed_store.rb +1 -2
- data/lib/tapioca/dsl/compilers/active_resource.rb +1 -2
- data/lib/tapioca/dsl/compilers/active_storage.rb +1 -9
- data/lib/tapioca/dsl/compilers/active_support_concern.rb +1 -2
- data/lib/tapioca/dsl/compilers/active_support_current_attributes.rb +1 -2
- data/lib/tapioca/dsl/compilers/active_support_time_ext.rb +1 -2
- data/lib/tapioca/dsl/compilers/config.rb +1 -2
- data/lib/tapioca/dsl/compilers/frozen_record.rb +1 -2
- data/lib/tapioca/dsl/compilers/graphql_input_object.rb +1 -2
- data/lib/tapioca/dsl/compilers/graphql_mutation.rb +1 -2
- data/lib/tapioca/dsl/compilers/identity_cache.rb +1 -2
- data/lib/tapioca/dsl/compilers/json_api_client_resource.rb +1 -2
- data/lib/tapioca/dsl/compilers/kredis.rb +1 -4
- data/lib/tapioca/dsl/compilers/mixed_in_class_attributes.rb +1 -2
- data/lib/tapioca/dsl/compilers/protobuf.rb +1 -2
- data/lib/tapioca/dsl/compilers/rails_generators.rb +1 -2
- data/lib/tapioca/dsl/compilers/sidekiq_worker.rb +1 -2
- data/lib/tapioca/dsl/compilers/smart_properties.rb +21 -18
- data/lib/tapioca/dsl/compilers/state_machines.rb +1 -2
- data/lib/tapioca/dsl/compilers/url_helpers.rb +1 -2
- data/lib/tapioca/gem/events.rb +2 -6
- data/lib/tapioca/gem/listeners/base.rb +1 -4
- data/lib/tapioca/helpers/cli_helper.rb +1 -4
- data/lib/tapioca/helpers/config_helper.rb +1 -4
- data/lib/tapioca/helpers/env_helper.rb +1 -4
- data/lib/tapioca/helpers/rbi_files_helper.rb +2 -5
- data/lib/tapioca/helpers/test/content.rb +1 -4
- data/lib/tapioca/helpers/test/dsl_compiler.rb +1 -4
- data/lib/tapioca/helpers/test/isolation.rb +2 -7
- data/lib/tapioca/helpers/test/template.rb +1 -4
- data/lib/tapioca/loaders/loader.rb +4 -6
- data/lib/tapioca/repo_index.rb +0 -2
- data/lib/tapioca/runtime/attached_class_of_legacy.rb +1 -4
- data/lib/tapioca/runtime/trackers/tracker.rb +1 -4
- data/lib/tapioca/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 302108d7d02504d88d18e3b0ae4832e2fd6c891e83f6428d69d5c4f6773a3a73
|
4
|
+
data.tar.gz: 646642051b0b9d8736ad30e45d0b1bcfbe82f92b980f0909c45dc7f2337e0ce1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6a75f400e82b9f311f0f53713a843a94a3e444a6a52b09d83abd818226a058ec78f02e43b193e864fc90f895ecad0425e7b9d160aaa7c4681b354392a7ad594
|
7
|
+
data.tar.gz: 831256628c364563d69fe8d742f9fe0a973e12275bdbb5498a6af83c664036aa199ec0a94bf9ba527d3165723bf17aa5852e9eb2b993ccc0ed7439ef0f663a68
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
RubyLsp::Addon.depend_on_ruby_lsp!(">= 0.23.10", "< 0.
|
4
|
+
RubyLsp::Addon.depend_on_ruby_lsp!(">= 0.23.10", "< 0.26")
|
5
5
|
|
6
6
|
begin
|
7
7
|
# The Tapioca add-on depends on the Rails add-on to add a runtime component to the runtime server. We can allow the
|
@@ -19,13 +19,15 @@ module RubyLsp
|
|
19
19
|
when "load_compilers_and_extensions"
|
20
20
|
# Load DSL extensions and compilers ahead of time, so that we don't have to pay the price of invoking
|
21
21
|
# `Gem.find_files` on every execution, which is quite expensive
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
with_notification_wrapper("load_compilers_and_extensions", "Loading DSL compilers") do
|
23
|
+
@loader = ::Tapioca::Loaders::Dsl.new(
|
24
|
+
tapioca_path: ::Tapioca::TAPIOCA_DIR,
|
25
|
+
eager_load: false,
|
26
|
+
app_root: params[:workspace_path],
|
27
|
+
halt_upon_load_error: false,
|
28
|
+
)
|
29
|
+
@loader.load_dsl_extensions_and_compilers
|
30
|
+
end
|
29
31
|
when "dsl"
|
30
32
|
fork do
|
31
33
|
with_notification_wrapper("dsl", "Generating DSL RBIs") do
|
@@ -6,12 +6,9 @@ module Tapioca
|
|
6
6
|
# This is a module that gets prepended to `Bundler::Dependency` and
|
7
7
|
# makes sure even gems marked as `require: false` are required during
|
8
8
|
# `Bundler.require`.
|
9
|
+
# @requires_ancestor: ::Bundler::Dependency
|
9
10
|
module AutoRequireHook
|
10
11
|
extend T::Sig
|
11
|
-
extend T::Helpers
|
12
|
-
|
13
|
-
requires_ancestor { ::Bundler::Dependency }
|
14
|
-
|
15
12
|
@exclude = [] #: Array[String]
|
16
13
|
@enabled = false #: bool
|
17
14
|
|
data/lib/tapioca/cli.rb
CHANGED
@@ -382,12 +382,12 @@ module Tapioca
|
|
382
382
|
# Indicates that we are running from the LSP, set using the `addon_mode!` method
|
383
383
|
attr_reader :addon_mode
|
384
384
|
|
385
|
-
|
385
|
+
#: -> void
|
386
386
|
def addon_mode!
|
387
387
|
@addon_mode = true
|
388
388
|
end
|
389
389
|
|
390
|
-
|
390
|
+
#: -> bool
|
391
391
|
def exit_on_failure?
|
392
392
|
!@addon_mode
|
393
393
|
end
|
@@ -3,12 +3,11 @@
|
|
3
3
|
|
4
4
|
module Tapioca
|
5
5
|
module Commands
|
6
|
+
# @abstract
|
6
7
|
class AbstractDsl < CommandWithoutTracker
|
7
8
|
include SorbetHelper
|
8
9
|
include RBIFilesHelper
|
9
10
|
|
10
|
-
abstract!
|
11
|
-
|
12
11
|
#: (requested_constants: Array[String], requested_paths: Array[Pathname], outpath: Pathname, only: Array[String], exclude: Array[String], file_header: bool, tapioca_path: String, ?skip_constant: Array[String], ?quiet: bool, ?verbose: bool, ?number_of_workers: Integer?, ?auto_strictness: bool, ?gem_dir: String, ?rbi_formatter: RBIFormatter, ?app_root: String, ?halt_upon_load_error: bool, ?compiler_options: Hash[String, untyped], ?lsp_addon: bool) -> void
|
13
12
|
def initialize(
|
14
13
|
requested_constants:,
|
@@ -3,12 +3,11 @@
|
|
3
3
|
|
4
4
|
module Tapioca
|
5
5
|
module Commands
|
6
|
+
# @abstract
|
6
7
|
class AbstractGem < Command
|
7
8
|
include SorbetHelper
|
8
9
|
include RBIFilesHelper
|
9
10
|
|
10
|
-
abstract!
|
11
|
-
|
12
11
|
#: (gem_names: Array[String], exclude: Array[String], include_dependencies: bool, prerequire: String?, postrequire: String, typed_overrides: Hash[String, String], outpath: Pathname, file_header: bool, include_doc: bool, include_loc: bool, include_exported_rbis: bool, ?number_of_workers: Integer?, ?auto_strictness: bool, ?dsl_dir: String, ?rbi_formatter: RBIFormatter, ?halt_upon_load_error: bool, ?lsp_addon: bool?) -> void
|
13
12
|
def initialize(
|
14
13
|
gem_names:,
|
@@ -125,7 +125,7 @@ module Tapioca
|
|
125
125
|
fetched_gems.keys.map(&:name).sort
|
126
126
|
end
|
127
127
|
|
128
|
-
|
128
|
+
#: (Array[String] repo_uris, GemInfo gem_info) -> bool
|
129
129
|
def fetch_annotation(repo_uris, gem_info)
|
130
130
|
gem_name = gem_info.name
|
131
131
|
gem_version = gem_info.version
|
@@ -3,10 +3,9 @@
|
|
3
3
|
|
4
4
|
module Tapioca
|
5
5
|
module Commands
|
6
|
+
# @abstract
|
6
7
|
class Command
|
7
8
|
extend T::Sig
|
8
|
-
extend T::Helpers
|
9
|
-
|
10
9
|
class FileWriter < Thor
|
11
10
|
include Thor::Actions
|
12
11
|
end
|
@@ -14,8 +13,6 @@ module Tapioca
|
|
14
13
|
include Thor::Base
|
15
14
|
include CliHelper
|
16
15
|
|
17
|
-
abstract!
|
18
|
-
|
19
16
|
#: -> void
|
20
17
|
def initialize
|
21
18
|
@file_writer = FileWriter.new #: Thor::Actions
|
@@ -31,8 +28,9 @@ module Tapioca
|
|
31
28
|
|
32
29
|
private
|
33
30
|
|
34
|
-
|
35
|
-
|
31
|
+
# @abstract
|
32
|
+
#: -> void
|
33
|
+
def execute = raise NotImplementedError, "Abstract method called"
|
36
34
|
|
37
35
|
#: (Symbol command, *String args) -> String
|
38
36
|
def default_command(command, *args)
|
data/lib/tapioca/dsl/compiler.rb
CHANGED
@@ -3,19 +3,15 @@
|
|
3
3
|
|
4
4
|
module Tapioca
|
5
5
|
module Dsl
|
6
|
+
# @abstract
|
7
|
+
#: [ConstantType < Module]
|
6
8
|
class Compiler
|
7
9
|
extend T::Sig
|
8
|
-
extend T::Helpers
|
9
|
-
extend T::Generic
|
10
10
|
|
11
11
|
include RBIHelper
|
12
12
|
include Runtime::Reflection
|
13
13
|
extend Runtime::Reflection
|
14
14
|
|
15
|
-
ConstantType = type_member { { upper: Module } }
|
16
|
-
|
17
|
-
abstract!
|
18
|
-
|
19
15
|
#: ConstantType
|
20
16
|
attr_reader :constant
|
21
17
|
|
@@ -35,8 +31,9 @@ module Tapioca
|
|
35
31
|
processable_constants.include?(constant)
|
36
32
|
end
|
37
33
|
|
38
|
-
|
39
|
-
|
34
|
+
# @abstract
|
35
|
+
#: -> T::Enumerable[Module]
|
36
|
+
def gather_constants = raise NotImplementedError, "Abstract method called"
|
40
37
|
|
41
38
|
#: -> Set[Module]
|
42
39
|
def processable_constants
|
@@ -100,8 +97,9 @@ module Tapioca
|
|
100
97
|
@pipeline.compiler_enabled?(compiler_name)
|
101
98
|
end
|
102
99
|
|
103
|
-
|
104
|
-
|
100
|
+
# @abstract
|
101
|
+
#: -> void
|
102
|
+
def decorate = raise NotImplementedError, "Abstract method called"
|
105
103
|
|
106
104
|
# NOTE: This should eventually accept an `Error` object or `Exception` rather than simply a `String`.
|
107
105
|
#: (String error) -> void
|
@@ -32,6 +32,7 @@ module Tapioca
|
|
32
32
|
# sleeping?, running?, cleaning?
|
33
33
|
# run, run!, run_without_validation!, may_run?
|
34
34
|
#
|
35
|
+
#: [ConstantType = (Class[::AASM] & ::AASM::ClassMethods)]
|
35
36
|
class AASM < Compiler
|
36
37
|
extend T::Sig
|
37
38
|
|
@@ -68,8 +69,6 @@ module Tapioca
|
|
68
69
|
"success",
|
69
70
|
].freeze #: Array[String]
|
70
71
|
|
71
|
-
ConstantType = type_member { { fixed: T.all(T::Class[::AASM], ::AASM::ClassMethods) } }
|
72
|
-
|
73
72
|
# @override
|
74
73
|
#: -> void
|
75
74
|
def decorate
|
@@ -61,11 +61,10 @@ module Tapioca
|
|
61
61
|
# def helpers; end
|
62
62
|
# end
|
63
63
|
# ~~~
|
64
|
+
#: [ConstantType = singleton(::ActionController::Base)]
|
64
65
|
class ActionControllerHelpers < Compiler
|
65
66
|
extend T::Sig
|
66
67
|
|
67
|
-
ConstantType = type_member { { fixed: T.class_of(::ActionController::Base) } }
|
68
|
-
|
69
68
|
# @override
|
70
69
|
#: -> void
|
71
70
|
def decorate
|
@@ -29,11 +29,10 @@ module Tapioca
|
|
29
29
|
# def self.notify_customer(customer_id); end
|
30
30
|
# end
|
31
31
|
# ~~~
|
32
|
+
#: [ConstantType = singleton(::ActionMailer::Base)]
|
32
33
|
class ActionMailer < Compiler
|
33
34
|
extend T::Sig
|
34
35
|
|
35
|
-
ConstantType = type_member { { fixed: T.class_of(::ActionMailer::Base) } }
|
36
|
-
|
37
36
|
# @override
|
38
37
|
#: -> void
|
39
38
|
def decorate
|
@@ -43,11 +43,10 @@ module Tapioca
|
|
43
43
|
# def title?; end
|
44
44
|
# end
|
45
45
|
# ~~~
|
46
|
+
#: [ConstantType = singleton(::ActiveRecord::Base)]
|
46
47
|
class ActionText < Compiler
|
47
48
|
extend T::Sig
|
48
49
|
|
49
|
-
ConstantType = type_member { { fixed: T.class_of(::ActiveRecord::Base) } }
|
50
|
-
|
51
50
|
# @override
|
52
51
|
#: -> void
|
53
52
|
def decorate
|
@@ -38,11 +38,10 @@ module Tapioca
|
|
38
38
|
# def self.perform_now(user); end
|
39
39
|
# end
|
40
40
|
# ~~~
|
41
|
+
#: [ConstantType = singleton(::ActiveJob::Base)]
|
41
42
|
class ActiveJob < Compiler
|
42
43
|
extend T::Sig
|
43
44
|
|
44
|
-
ConstantType = type_member { { fixed: T.class_of(::ActiveJob::Base) } }
|
45
|
-
|
46
45
|
# @override
|
47
46
|
#: -> void
|
48
47
|
def decorate
|
@@ -34,13 +34,10 @@ module Tapioca
|
|
34
34
|
# def name=(name); end
|
35
35
|
# end
|
36
36
|
# ~~~
|
37
|
+
#: [ConstantType = (Class[::ActiveModel::Attributes] & ::ActiveModel::Attributes::ClassMethods)]
|
37
38
|
class ActiveModelAttributes < Compiler
|
38
39
|
extend T::Sig
|
39
40
|
|
40
|
-
ConstantType = type_member do
|
41
|
-
{ fixed: T.all(T::Class[::ActiveModel::Attributes], ::ActiveModel::Attributes::ClassMethods) }
|
42
|
-
end
|
43
|
-
|
44
41
|
# @override
|
45
42
|
#: -> void
|
46
43
|
def decorate
|
@@ -53,13 +53,10 @@ module Tapioca
|
|
53
53
|
# def token_confirmation=(unencrypted_password); end
|
54
54
|
# end
|
55
55
|
# ~~~
|
56
|
+
#: [ConstantType = (Class[::ActiveModel::SecurePassword] & ::ActiveModel::SecurePassword::ClassMethods)]
|
56
57
|
class ActiveModelSecurePassword < Compiler
|
57
58
|
extend T::Sig
|
58
59
|
|
59
|
-
ConstantType = type_member do
|
60
|
-
{ fixed: T.all(T::Class[::ActiveModel::SecurePassword], ::ActiveModel::SecurePassword::ClassMethods) }
|
61
|
-
end
|
62
|
-
|
63
60
|
# @override
|
64
61
|
#: -> void
|
65
62
|
def decorate
|
@@ -40,19 +40,10 @@ module Tapioca
|
|
40
40
|
# def password_confirmation=(password_confirmation); end
|
41
41
|
# end
|
42
42
|
# ~~~
|
43
|
+
#: [ConstantType = (Class[ActiveModel::Validations] & ActiveModel::Validations::HelperMethods & ActiveModel::Validations::ClassMethods)]
|
43
44
|
class ActiveModelValidationsConfirmation < Compiler
|
44
45
|
extend T::Sig
|
45
46
|
|
46
|
-
ConstantType = type_member do
|
47
|
-
{
|
48
|
-
fixed: T.all(
|
49
|
-
T::Class[ActiveModel::Validations],
|
50
|
-
ActiveModel::Validations::HelperMethods,
|
51
|
-
ActiveModel::Validations::ClassMethods,
|
52
|
-
),
|
53
|
-
}
|
54
|
-
end
|
55
|
-
|
56
47
|
class << self
|
57
48
|
# @override
|
58
49
|
#: -> T::Enumerable[Module]
|
@@ -101,6 +101,7 @@ module Tapioca
|
|
101
101
|
# end
|
102
102
|
# end
|
103
103
|
# ~~~
|
104
|
+
#: [ConstantType = singleton(ActiveRecord::Base)]
|
104
105
|
class ActiveRecordAssociations < Compiler
|
105
106
|
extend T::Sig
|
106
107
|
include Helpers::ActiveRecordConstantsHelper
|
@@ -121,8 +122,6 @@ module Tapioca
|
|
121
122
|
end
|
122
123
|
end
|
123
124
|
|
124
|
-
ConstantType = type_member { { fixed: T.class_of(ActiveRecord::Base) } }
|
125
|
-
|
126
125
|
# @override
|
127
126
|
#: -> void
|
128
127
|
def decorate
|
@@ -120,12 +120,11 @@ module Tapioca
|
|
120
120
|
# sig { returns(T.untyped) }
|
121
121
|
# def title; end
|
122
122
|
# ~~~
|
123
|
+
#: [ConstantType = singleton(ActiveRecord::Base)]
|
123
124
|
class ActiveRecordColumns < Compiler
|
124
125
|
extend T::Sig
|
125
126
|
include Helpers::ActiveRecordConstantsHelper
|
126
127
|
|
127
|
-
ConstantType = type_member { { fixed: T.class_of(ActiveRecord::Base) } }
|
128
|
-
|
129
128
|
# @override
|
130
129
|
#: -> void
|
131
130
|
def decorate
|
@@ -63,12 +63,11 @@ module Tapioca
|
|
63
63
|
# end
|
64
64
|
#
|
65
65
|
# ~~~
|
66
|
+
#: [ConstantType = (singleton(ActiveRecord::Base) & Extensions::ActiveRecord)]
|
66
67
|
class ActiveRecordDelegatedTypes < Compiler
|
67
68
|
extend T::Sig
|
68
69
|
include Helpers::ActiveRecordConstantsHelper
|
69
70
|
|
70
|
-
ConstantType = type_member { { fixed: T.all(T.class_of(ActiveRecord::Base), Extensions::ActiveRecord) } }
|
71
|
-
|
72
71
|
# @override
|
73
72
|
#: -> void
|
74
73
|
def decorate
|
@@ -49,11 +49,10 @@ module Tapioca
|
|
49
49
|
# end
|
50
50
|
# end
|
51
51
|
# ~~~
|
52
|
+
#: [ConstantType = singleton(::ActiveRecord::Base)]
|
52
53
|
class ActiveRecordEnum < Compiler
|
53
54
|
extend T::Sig
|
54
55
|
|
55
|
-
ConstantType = type_member { { fixed: T.class_of(::ActiveRecord::Base) } }
|
56
|
-
|
57
56
|
# @override
|
58
57
|
#: -> void
|
59
58
|
def decorate
|
@@ -33,10 +33,10 @@ module Tapioca
|
|
33
33
|
# def posts(fixture_name = nil, *other_fixtures); end
|
34
34
|
# end
|
35
35
|
# ~~~
|
36
|
+
#: [ConstantType = singleton(ActiveSupport::TestCase)]
|
36
37
|
class ActiveRecordFixtures < Compiler
|
37
38
|
extend T::Sig
|
38
39
|
|
39
|
-
ConstantType = type_member { { fixed: T.class_of(ActiveSupport::TestCase) } }
|
40
40
|
MISSING = Object.new
|
41
41
|
|
42
42
|
# @override
|
@@ -148,13 +148,12 @@ module Tapioca
|
|
148
148
|
# end
|
149
149
|
# end
|
150
150
|
# ~~~
|
151
|
+
#: [ConstantType = singleton(::ActiveRecord::Base)]
|
151
152
|
class ActiveRecordRelations < Compiler
|
152
153
|
extend T::Sig
|
153
154
|
include Helpers::ActiveRecordConstantsHelper
|
154
155
|
include SorbetHelper
|
155
156
|
|
156
|
-
ConstantType = type_member { { fixed: T.class_of(::ActiveRecord::Base) } }
|
157
|
-
|
158
157
|
# From ActiveRecord::ConnectionAdapter::Quoting#quote, minus nil
|
159
158
|
ID_TYPES = [
|
160
159
|
"String",
|
@@ -217,6 +216,17 @@ module Tapioca
|
|
217
216
|
[]
|
218
217
|
end #: Array[Symbol]
|
219
218
|
BATCHES_METHODS = ActiveRecord::Batches.instance_methods(false) #: Array[Symbol]
|
219
|
+
BATCHES_METHODS_PARAMETERS = {
|
220
|
+
start: ["T.untyped", "nil"],
|
221
|
+
finish: ["T.untyped", "nil"],
|
222
|
+
load: ["T.untyped", "false"],
|
223
|
+
batch_size: ["Integer", "1000"],
|
224
|
+
of: ["Integer", "1000"],
|
225
|
+
error_on_ignore: ["T.untyped", "nil"],
|
226
|
+
order: ["Symbol", ":asc"],
|
227
|
+
cursor: ["T.untyped", "primary_key"],
|
228
|
+
use_ranges: ["T.untyped", "nil"],
|
229
|
+
} #: Hash[Symbol, [String, String]]
|
220
230
|
CALCULATION_METHODS = ActiveRecord::Calculations.instance_methods(false) #: Array[Symbol]
|
221
231
|
ENUMERABLE_QUERY_METHODS = [:any?, :many?, :none?, :one?] #: Array[Symbol]
|
222
232
|
FIND_OR_CREATE_METHODS = [
|
@@ -855,102 +865,31 @@ module Tapioca
|
|
855
865
|
end
|
856
866
|
|
857
867
|
BATCHES_METHODS.each do |method_name|
|
858
|
-
|
859
|
-
|
860
|
-
order = ActiveRecord::Batches.instance_method(:find_each).parameters.include?([:key, :order])
|
861
|
-
|
862
|
-
common_relation_methods_module.create_method("find_each") do |method|
|
863
|
-
method.add_kw_opt_param("start", "nil")
|
864
|
-
method.add_kw_opt_param("finish", "nil")
|
865
|
-
method.add_kw_opt_param("batch_size", "1000")
|
866
|
-
method.add_kw_opt_param("error_on_ignore", "nil")
|
867
|
-
method.add_kw_opt_param("order", ":asc") if order
|
868
|
-
method.add_block_param("block")
|
868
|
+
block_param, return_type, parameters = batch_method_configs(method_name)
|
869
|
+
next if block_param.nil? || return_type.nil? || parameters.nil?
|
869
870
|
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
sig.add_param("error_on_ignore", "T.untyped")
|
875
|
-
sig.add_param("order", "Symbol") if order
|
876
|
-
sig.add_param("block", "T.proc.params(object: #{constant_name}).void")
|
877
|
-
sig.return_type = "void"
|
878
|
-
end
|
871
|
+
common_relation_methods_module.create_method(method_name.to_s) do |method|
|
872
|
+
parameters.each do |name, (style, _type, default)|
|
873
|
+
# The style is always "key", but this is a safeguard to prevent confusing errors in the future.
|
874
|
+
raise "Unexpected style #{style} for #{name}" unless style == :key
|
879
875
|
|
880
|
-
method.
|
881
|
-
sig.add_param("start", "T.untyped")
|
882
|
-
sig.add_param("finish", "T.untyped")
|
883
|
-
sig.add_param("batch_size", "Integer")
|
884
|
-
sig.add_param("error_on_ignore", "T.untyped")
|
885
|
-
sig.add_param("order", "Symbol") if order
|
886
|
-
sig.return_type = "T::Enumerator[#{constant_name}]"
|
887
|
-
end
|
876
|
+
method.add_kw_opt_param(name, T.must(default))
|
888
877
|
end
|
889
|
-
|
890
|
-
order = ActiveRecord::Batches.instance_method(:find_in_batches).parameters.include?([:key, :order])
|
891
|
-
common_relation_methods_module.create_method("find_in_batches") do |method|
|
892
|
-
method.add_kw_opt_param("start", "nil")
|
893
|
-
method.add_kw_opt_param("finish", "nil")
|
894
|
-
method.add_kw_opt_param("batch_size", "1000")
|
895
|
-
method.add_kw_opt_param("error_on_ignore", "nil")
|
896
|
-
method.add_kw_opt_param("order", ":asc") if order
|
897
|
-
method.add_block_param("block")
|
898
|
-
|
899
|
-
method.add_sig do |sig|
|
900
|
-
sig.add_param("start", "T.untyped")
|
901
|
-
sig.add_param("finish", "T.untyped")
|
902
|
-
sig.add_param("batch_size", "Integer")
|
903
|
-
sig.add_param("error_on_ignore", "T.untyped")
|
904
|
-
sig.add_param("order", "Symbol") if order
|
905
|
-
sig.add_param("block", "T.proc.params(object: T::Array[#{constant_name}]).void")
|
906
|
-
sig.return_type = "void"
|
907
|
-
end
|
878
|
+
method.add_block_param("block")
|
908
879
|
|
909
|
-
|
910
|
-
|
911
|
-
sig.add_param(
|
912
|
-
sig.add_param("batch_size", "Integer")
|
913
|
-
sig.add_param("error_on_ignore", "T.untyped")
|
914
|
-
sig.add_param("order", "Symbol") if order
|
915
|
-
sig.return_type = "T::Enumerator[T::Enumerator[#{constant_name}]]"
|
880
|
+
method.add_sig do |sig|
|
881
|
+
parameters.each do |name, (_style, type, _default)|
|
882
|
+
sig.add_param(name, type)
|
916
883
|
end
|
884
|
+
sig.add_param("block", "T.proc.params(object: #{block_param}).void")
|
885
|
+
sig.return_type = "void"
|
917
886
|
end
|
918
|
-
when :in_batches
|
919
|
-
order = ActiveRecord::Batches.instance_method(:in_batches).parameters.include?([:key, :order])
|
920
|
-
use_ranges = ActiveRecord::Batches.instance_method(:in_batches).parameters.include?([:key, :use_ranges])
|
921
|
-
|
922
|
-
common_relation_methods_module.create_method("in_batches") do |method|
|
923
|
-
method.add_kw_opt_param("of", "1000")
|
924
|
-
method.add_kw_opt_param("start", "nil")
|
925
|
-
method.add_kw_opt_param("finish", "nil")
|
926
|
-
method.add_kw_opt_param("load", "false")
|
927
|
-
method.add_kw_opt_param("error_on_ignore", "nil")
|
928
|
-
method.add_kw_opt_param("order", ":asc") if order
|
929
|
-
method.add_kw_opt_param("use_ranges", "nil") if use_ranges
|
930
|
-
method.add_block_param("block")
|
931
|
-
|
932
|
-
method.add_sig do |sig|
|
933
|
-
sig.add_param("of", "Integer")
|
934
|
-
sig.add_param("start", "T.untyped")
|
935
|
-
sig.add_param("finish", "T.untyped")
|
936
|
-
sig.add_param("load", "T.untyped")
|
937
|
-
sig.add_param("error_on_ignore", "T.untyped")
|
938
|
-
sig.add_param("order", "Symbol") if order
|
939
|
-
sig.add_param("use_ranges", "T.untyped") if use_ranges
|
940
|
-
sig.add_param("block", "T.proc.params(object: #{RelationClassName}).void")
|
941
|
-
sig.return_type = "void"
|
942
|
-
end
|
943
887
|
|
944
|
-
|
945
|
-
|
946
|
-
sig.add_param(
|
947
|
-
sig.add_param("finish", "T.untyped")
|
948
|
-
sig.add_param("load", "T.untyped")
|
949
|
-
sig.add_param("error_on_ignore", "T.untyped")
|
950
|
-
sig.add_param("order", "Symbol") if order
|
951
|
-
sig.add_param("use_ranges", "T.untyped") if use_ranges
|
952
|
-
sig.return_type = "::ActiveRecord::Batches::BatchEnumerator"
|
888
|
+
method.add_sig do |sig|
|
889
|
+
parameters.each do |name, (_style, type, _default)|
|
890
|
+
sig.add_param(name, type)
|
953
891
|
end
|
892
|
+
sig.return_type = return_type
|
954
893
|
end
|
955
894
|
end
|
956
895
|
end
|
@@ -1029,6 +968,31 @@ module Tapioca
|
|
1029
968
|
end
|
1030
969
|
end
|
1031
970
|
|
971
|
+
#: (Symbol) -> [String, String, Hash[String, [Symbol, String, String?]]]?
|
972
|
+
def batch_method_configs(method_name)
|
973
|
+
block_param, return_type = case method_name
|
974
|
+
when :find_each
|
975
|
+
[constant_name, "T::Enumerator[#{constant_name}]"]
|
976
|
+
when :find_in_batches
|
977
|
+
["T::Array[#{constant_name}]", "T::Enumerator[T::Enumerator[#{constant_name}]]"]
|
978
|
+
when :in_batches
|
979
|
+
[RelationClassName, "::ActiveRecord::Batches::BatchEnumerator"]
|
980
|
+
else
|
981
|
+
return
|
982
|
+
end
|
983
|
+
|
984
|
+
parameters = {}
|
985
|
+
|
986
|
+
ActiveRecord::Batches.instance_method(method_name).parameters.each do |style, name|
|
987
|
+
type, default = BATCHES_METHODS_PARAMETERS[name]
|
988
|
+
next if type.nil?
|
989
|
+
|
990
|
+
parameters[name.to_s] = [style, type, default]
|
991
|
+
end
|
992
|
+
|
993
|
+
[block_param, return_type, parameters]
|
994
|
+
end
|
995
|
+
|
1032
996
|
#: ((Symbol | String) name, ?parameters: Array[RBI::TypedParam], ?return_type: String?) -> void
|
1033
997
|
def create_common_method(name, parameters: [], return_type: nil)
|
1034
998
|
common_relation_methods_module.create_method(
|
@@ -38,12 +38,11 @@ module Tapioca
|
|
38
38
|
# end
|
39
39
|
# end
|
40
40
|
# ~~~
|
41
|
+
#: [ConstantType = singleton(::ActiveRecord::Base)]
|
41
42
|
class ActiveRecordScope < Compiler
|
42
43
|
extend T::Sig
|
43
44
|
include Helpers::ActiveRecordConstantsHelper
|
44
45
|
|
45
|
-
ConstantType = type_member { { fixed: T.class_of(::ActiveRecord::Base) } }
|
46
|
-
|
47
46
|
# @override
|
48
47
|
#: -> void
|
49
48
|
def decorate
|
@@ -32,12 +32,11 @@ module Tapioca
|
|
32
32
|
# def regenerate_auth_token; end
|
33
33
|
# end
|
34
34
|
# ~~~
|
35
|
+
#: [ConstantType = (singleton(ActiveRecord::Base) & Extensions::ActiveRecord)]
|
35
36
|
class ActiveRecordSecureToken < Compiler
|
36
37
|
extend T::Sig
|
37
38
|
include Helpers::ActiveRecordConstantsHelper
|
38
39
|
|
39
|
-
ConstantType = type_member { { fixed: T.all(T.class_of(ActiveRecord::Base), Extensions::ActiveRecord) } }
|
40
|
-
|
41
40
|
# @override
|
42
41
|
#: -> void
|
43
42
|
def decorate
|
@@ -78,12 +78,11 @@ module Tapioca
|
|
78
78
|
# end
|
79
79
|
# end
|
80
80
|
# ~~~
|
81
|
+
#: [ConstantType = (singleton(ActiveRecord::Base) & Extensions::ActiveRecord)]
|
81
82
|
class ActiveRecordStore < Compiler
|
82
83
|
extend T::Sig
|
83
84
|
include Helpers::ActiveRecordConstantsHelper
|
84
85
|
|
85
|
-
ConstantType = type_member { { fixed: T.all(T.class_of(ActiveRecord::Base), Extensions::ActiveRecord) } }
|
86
|
-
|
87
86
|
# @override
|
88
87
|
#: -> void
|
89
88
|
def decorate
|
@@ -81,11 +81,10 @@ module Tapioca
|
|
81
81
|
# end
|
82
82
|
# end
|
83
83
|
# ~~~
|
84
|
+
#: [ConstantType = singleton(::ActiveRecord::Base)]
|
84
85
|
class ActiveRecordTypedStore < Compiler
|
85
86
|
extend T::Sig
|
86
87
|
|
87
|
-
ConstantType = type_member { { fixed: T.class_of(::ActiveRecord::Base) } }
|
88
|
-
|
89
88
|
# @override
|
90
89
|
#: -> void
|
91
90
|
def decorate
|