rhino_project_core 0.26.0.beta.4 → 0.30.0.alpha.1

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.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/app/helpers/rhino/omniauth_helper.rb +5 -1
  3. data/app/models/rhino/user.rb +5 -5
  4. data/app/overrides/devise_token_auth/confirmations_controller_override.rb +1 -1
  5. data/app/overrides/devise_token_auth/passwords_controller_override.rb +1 -1
  6. data/app/overrides/devise_token_auth/registrations_controller_override.rb +0 -8
  7. data/lib/generators/rhino/dev/setup/setup_generator.rb +32 -0
  8. data/lib/generators/rhino/dev/setup/templates/env.tt +16 -7
  9. data/lib/generators/rhino/model/model_generator.rb +0 -5
  10. data/lib/generators/rhino/module/templates/test/dummy/config/initializers/devise_token_auth.rb +2 -2
  11. data/lib/rhino/engine.rb +0 -12
  12. data/lib/rhino/resource/active_record_extension/params.rb +4 -23
  13. data/lib/rhino/resource/active_record_extension/properties_describe.rb +11 -18
  14. data/lib/rhino/resource/active_storage_extension.rb +7 -24
  15. data/lib/rhino/sieve/order.rb +1 -1
  16. data/lib/rhino/version.rb +2 -2
  17. metadata +16 -37
  18. data/app/controllers/rhino/active_record_discard_controller.rb +0 -28
  19. data/app/helpers/rhino/env_helper.rb +0 -32
  20. data/app/overrides/activeadmin/resource_dsl_override.rb +0 -36
  21. data/lib/generators/rhino/admin/admin_generator.rb +0 -13
  22. data/lib/generators/rhino/admin/templates/resource.rb.tt +0 -4
  23. data/lib/generators/rhino/ui/route/route_generator.rb +0 -54
  24. data/lib/generators/rhino/ui/route/templates/$id.edit.tsx.tt +0 -12
  25. data/lib/generators/rhino/ui/route/templates/$id.index.tsx.tt +0 -12
  26. data/lib/generators/rhino/ui/route/templates/index.tsx.tt +0 -10
  27. data/lib/generators/rhino/ui/route/templates/new.tsx.tt +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7df8643a88b18a63b4ca16ab4b2e7416fc0c74189f16c3e8c493ba6b94d046b7
4
- data.tar.gz: c5da3dd0a8d9a190c8fbf86c23636f61a3ce70af8e3058d8c95c55dfafbd69f5
3
+ metadata.gz: '09bab6f8b81658c76669317d949e44e1e0728d7be46cb80793fa2488ffcff097'
4
+ data.tar.gz: 571b132824ac728b7e8072095a106c9731350abe88ce69d74b46852fe3ada36f
5
5
  SHA512:
6
- metadata.gz: e7cec388ae4c1e390ba9b743290c22fb1fef63da8aca68785d277870d6798d76d3587ea5085d3c273663df93f9b776164ed6efb4de12ad50e3a5b212f06759dc
7
- data.tar.gz: b944a6ca7a2e91b37718c45a1ecbc34df917be113086cabff8574e26744e26f8148ff2ade3bc6bd1ce99c8c658a2b820bd4c7901aff5309212db58f803f778d2
6
+ metadata.gz: 134e615ee50fbfe6de3f37a04a633dc82b89cdcae1d7c2e881b2000f759bdabae4ff22d2e0912d9d642660ee4ff323238b2d134c4644552082dc2d05e252e896
7
+ data.tar.gz: 975781708959682419d2f40637cf1833dc316f05d353d12422de0074a1a541f63db49f06d7de18e084ecaaaad3460604df9ccaf929ba5ad1e6050b155e176e18
@@ -5,10 +5,12 @@ module Rhino
5
5
  module_function
6
6
 
7
7
  def strategies_metadata
8
+ params = { resource_class: "User" }
9
+
8
10
  strategies.each_with_object([]) do |strategy, array|
9
11
  array << {
10
12
  name: strategy,
11
- path: "#{::OmniAuth.config.path_prefix}/#{strategy}"
13
+ path: "#{::OmniAuth.config.path_prefix}/#{strategy}?#{params.to_param}"
12
14
  }
13
15
  end
14
16
  end
@@ -21,6 +23,8 @@ module Rhino
21
23
  match[1].downcase.to_sym
22
24
  end.uniq
23
25
 
26
+ strategies += [:developer] if Rails.env.development? && !Rake.try(:application)
27
+
24
28
  strategies
25
29
  end
26
30
 
@@ -19,15 +19,12 @@ module Rhino
19
19
  devise(*devise_modules_to_load)
20
20
 
21
21
  validates :email, uniqueness: { case_sensitive: false }
22
+ after_create_commit :track_sign_up
22
23
 
23
24
  def display_name
24
25
  name || email
25
26
  end
26
27
 
27
- def token_validation_response
28
- to_caching_json
29
- end
30
-
31
28
  def self.roles_for_auth(auth_owner, record = nil)
32
29
  return {} unless auth_owner
33
30
 
@@ -39,6 +36,9 @@ module Rhino
39
36
  {}
40
37
  end
41
38
 
42
- ActiveSupport.run_load_hooks(:rhino_user, self)
39
+ private
40
+ def track_sign_up
41
+ Rhino::SegmentHelper.track("Signed Up", self)
42
+ end
43
43
  end
44
44
  end
@@ -5,7 +5,7 @@ module DeviseTokenAuth::ConfirmationsController::Extensions
5
5
  def show
6
6
  super
7
7
  rescue StandardError
8
- redirect_to ENV["RHINO_APP_URL"]
8
+ redirect_to ENV["FRONT_END_URL"]
9
9
  end
10
10
  end
11
11
 
@@ -4,6 +4,6 @@ class DeviseTokenAuth::PasswordsController
4
4
  # If there is an error preparing to edit the password, redirect to frontend
5
5
  # This would normally be an expired password token
6
6
  def render_edit_error
7
- redirect_to "#{ENV['RHINO_APP_URL']}/auth/reset-password/expired"
7
+ redirect_to "#{ENV['FRONT_END_URL']}/auth/reset-password/expired"
8
8
  end
9
9
  end
@@ -13,14 +13,6 @@ module DeviseTokenAuth::RegistrationsController::Extensions
13
13
  create_organization(resource) if Rhino.resources.include?("Organization")
14
14
  end
15
15
  end
16
-
17
- # Get all the information just like the token_validation_response and sign_in
18
- def render_create_success
19
- render json: {
20
- success: true,
21
- data: resource_data(resource_json: @resource.token_validation_response)
22
- }
23
- end
24
16
  end
25
17
 
26
18
  class DeviseTokenAuth::RegistrationsController
@@ -15,6 +15,8 @@ module Rhino
15
15
  class_option :db_port, type: :numeric, default: 5432, group: :database
16
16
  class_option :db_user, type: :string, group: :database
17
17
  class_option :db_password, type: :string, group: :database
18
+ class_option :redis_port, type: :numeric, default: 6379, group: :redis
19
+ class_option :redis_database, type: :numeric, default: 0, group: :redis
18
20
 
19
21
  attr_reader :server_port,
20
22
  :db_name,
@@ -22,6 +24,9 @@ module Rhino
22
24
  :db_port,
23
25
  :db_user,
24
26
  :db_password,
27
+ :redis_host,
28
+ :redis_port,
29
+ :redis_database,
25
30
  :dockerized
26
31
 
27
32
  source_root File.expand_path("templates", __dir__)
@@ -87,6 +92,18 @@ module Rhino
87
92
  options[:db_password] || ENV["DB_PASSWORD"] || ""
88
93
  end
89
94
 
95
+ def redis_host_default
96
+ options[:redis_host] || ENV["REDIS_HOST"] || "localhost"
97
+ end
98
+
99
+ def redis_port_default
100
+ options[:redis_port] || ENV["REDIS_PORT"]
101
+ end
102
+
103
+ def redis_database_default
104
+ options[:redis_database] || ENV["REDIS_DATABASE"]
105
+ end
106
+
90
107
  def dockerized_default
91
108
  options[:defaults] == "docker" ? "Y" : "N"
92
109
  end
@@ -97,6 +114,7 @@ module Rhino
97
114
  @server_port = ask_prompt("Port?", server_port_default)
98
115
 
99
116
  collect_database_info
117
+ collect_redis_info
100
118
  end
101
119
 
102
120
  def collect_docker_info
@@ -108,6 +126,9 @@ module Rhino
108
126
  @db_user = "postgres"
109
127
  @db_password = "password"
110
128
  @db_port = 5432
129
+ @redis_host = "redis"
130
+ @redis_port = 6379
131
+ @redis_database = 0
111
132
 
112
133
  puts <<~HERE
113
134
  The following docker configuration has been automatically set for you:
@@ -115,6 +136,9 @@ module Rhino
115
136
  Database port: #{db_port}
116
137
  Database user: #{db_user}
117
138
  Database password: #{db_password}
139
+ Redis host: #{redis_host}
140
+ Redis port: #{redis_port}
141
+ Redis database: #{redis_database}
118
142
  HERE
119
143
  end
120
144
 
@@ -128,6 +152,14 @@ module Rhino
128
152
  nil
129
153
  end
130
154
 
155
+ def collect_redis_info
156
+ @redis_host ||= ask_prompt("Redis host?", redis_host_default)
157
+ @redis_port ||= ask_prompt("Redis port?", redis_port_default)
158
+ @redis_database ||= ask_prompt("Redis database?", redis_database_default)
159
+
160
+ nil
161
+ end
162
+
131
163
  def project_file(file)
132
164
  File.join(project_dir, file)
133
165
  end
@@ -1,20 +1,22 @@
1
1
  PORT=<%= server_port %>
2
2
 
3
- RHINO_APP_URL=http://localhost:$PORT
3
+ # Server
4
+ ROOT_URL=http://localhost:$PORT
5
+ FRONT_END_URL=http://localhost:$PORT
4
6
 
5
7
  DB_NAME=<%= db_name %>
6
8
  DB_HOST=<%= db_host %>
7
9
  DB_PORT=<%= db_port %>
8
10
  DB_USERNAME=<%= db_user %>
9
11
  DB_PASSWORD=<%= db_password %>
12
+ REDIS_HOST=<%= redis_host %>
13
+ REDIS_PORT=<%= redis_port %>
14
+ REDIS_DATABASE=<%= redis_database %>
10
15
 
11
- # Production
12
-
13
- #RHINO_PUBLIC_ROLLBAR_ACCESS_TOKEN=
14
-
15
- #RHINO_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_...
16
- #RHINO_STRIPE_SECRET_KEY=sk_...
16
+ # Client
17
+ VITE_API_ROOT_PATH=$ROOT_URL
17
18
 
19
+ # Production server:
18
20
  SENDGRID_API_KEY=<api-key>
19
21
 
20
22
  #AWS_ACCESS_KEY=
@@ -26,6 +28,13 @@ SENDGRID_API_KEY=<api-key>
26
28
  #AZURE_ACCOUNT_NAME="azure_acc_name"
27
29
  #AZURE_CONTAINER="container-test"
28
30
 
31
+ #STRIPE_PUBLISHABLE_KEY=pk_...
32
+ #STRIPE_SECRET_KEY=sk_...
33
+
29
34
  #AUTH_GOOGLE_OAUTH2_CLIENT_ID=
30
35
  #AUTH_GOOGLE_OAUTH2_SECRET_KEY=
31
36
 
37
+ ROLLBAR_ACCESS_TOKEN=
38
+
39
+ # Production client:
40
+ VITE_ROLLBAR_ACCESS_TOKEN=
@@ -11,7 +11,6 @@ module Rhino
11
11
  class_option :owner, type: :string, desc: "The model is owned by the reference attribute", group: :owner
12
12
  class_option :base_owner, type: :boolean, default: false, desc: "The model is owned by the base owner", group: :owner
13
13
  class_option :global_owner, type: :boolean, default: false, desc: "The model is globally owned", group: :owner
14
- class_option :skip_admin, type: :boolean, default: false, desc: "Skip generating ActiveAdmin resources", group: :admin
15
14
 
16
15
  # Parent source paths
17
16
  def source_paths
@@ -53,10 +52,6 @@ module Rhino
53
52
  end
54
53
  end
55
54
 
56
- def active_admin_resource
57
- generate "rhino:admin", class_name unless options[:skip_admin]
58
- end
59
-
60
55
  protected
61
56
  def check_ownership
62
57
  raise Thor::Error, "Exactly one owner must be defined on a reference or globally" unless base_owner? ^ global_owner? ^ reference_owner?
@@ -66,6 +66,6 @@ DeviseTokenAuth.setup do |config|
66
66
  # send email, set it to true. (This is a setting for compatibility)
67
67
  # config.send_confirmation_email = true
68
68
 
69
- config.default_confirm_success_url = "#{ENV['RHINO_APP_URL']}/auth/signin"
70
- config.default_password_reset_url = "#{ENV['RHINO_APP_URL']}/auth/reset-password"
69
+ config.default_confirm_success_url = "#{ENV['FRONT_END_URL']}/auth/signin"
70
+ config.default_password_reset_url = "#{ENV['FRONT_END_URL']}/auth/reset-password"
71
71
  end
data/lib/rhino/engine.rb CHANGED
@@ -10,7 +10,6 @@ require "arel-helpers"
10
10
  require "countries"
11
11
  require "devise"
12
12
  require "devise_token_auth"
13
- require "discard"
14
13
  require "friendly_id"
15
14
  require "geocoder"
16
15
  require "omniauth"
@@ -37,17 +36,6 @@ module Rhino
37
36
  end
38
37
  end
39
38
 
40
- initializer "rhino.user_signup_tracking" do
41
- ActiveSupport.on_load(:rhino_user) do
42
- after_create_commit :track_sign_up
43
-
44
- private
45
- def track_sign_up
46
- Rhino::SegmentHelper.track("Signed Up", self)
47
- end
48
- end
49
- end
50
-
51
39
  initializer "rhino.active_record_extension" do
52
40
  ActiveSupport.on_load(:active_record) do
53
41
  require_relative "resource/active_record_extension"
@@ -89,12 +89,7 @@ module Rhino
89
89
  # An array of references
90
90
  if desc[:type] == :array && (desc[:items].key?(:$ref) || desc[:items].key?(:anyOf))
91
91
  # FIXME: Hack for has_many_attached
92
- if desc.dig(:items, :anyOf)[0]&.dig(:$ref) == "#/components/schemas/active_storage_attachment"
93
- params << { prop => [] }
94
- params << { prop => ["signed_id"] }
95
-
96
- next
97
- end
92
+ next params << { prop => [] } if desc.dig(:items, :anyOf)[0]&.dig(:$ref) == "#/components/schemas/active_storage_attachment"
98
93
 
99
94
  # We only accept if the active record accepts it
100
95
  next unless nested_attributes_options.key?(prop_sym) || desc.dig(:items, :anyOf)[0]&.dig(:$ref)
@@ -143,8 +138,7 @@ module Rhino
143
138
 
144
139
  { prop => assoc_params.flatten.uniq }
145
140
  else
146
- # For ActiveStorage::Attachment we want to accept the signed_id
147
- { prop => klasses.map { it == ActiveStorage::Attachment ? "signed_id" : it.identifier_property }.uniq }
141
+ { prop => klasses.map(&:identifier_property).uniq }
148
142
  end
149
143
  end
150
144
 
@@ -168,25 +162,12 @@ module Rhino
168
162
  # FIXME
169
163
  # Hack to rewrite for attachment/attachments and guard against object resubmission
170
164
  if param_key.end_with?("_attachment")
171
- # If its a string, its the signed_id
172
- hash[param_key.remove("_attachment")] = if param_value.is_a?(String) || param_value.nil?
173
- param_value
174
-
175
- # Otherwise if its a hash, and we want the signed_id from it
176
- elsif param_value.is_a?(ActionController::Parameters)
177
- param_value["signed_id"]
178
- end
165
+ hash[param_key.remove("_attachment")] = param_value if param_value.is_a?(String) || param_value.nil?
179
166
 
180
167
  next
181
168
  end
182
169
  if param_key.end_with?("_attachments")
183
- hash[param_key.remove("_attachments")] = if param_value.nil?
184
- param_value
185
-
186
- # if an element is a string, its the signed_id, if its a hash, we want the signed_id from it
187
- elsif param_value.is_a?(Array)
188
- param_value.map { it.is_a?(ActionController::Parameters) ? it["signed_id"] : it }
189
- end
170
+ hash[param_key.remove("_attachments")] = param_value if param_value.is_a?(Array) || param_value.nil?
190
171
 
191
172
  next
192
173
  end
@@ -61,35 +61,27 @@ module Rhino
61
61
  }
62
62
  end
63
63
 
64
- DATE_FORMATS = %i[datetime date time].freeze
65
64
  def property_type_and_format_attr(name)
66
- type = attribute_types[name.to_s].type
67
- format = nil
65
+ atype = attribute_types[name.to_s].type
68
66
 
69
67
  # The PG array delegates type to "subtype" which is the actual type of the array elements
70
68
  if attribute_types[name.to_s].is_a? ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Array
71
69
  return {
72
70
  type: :array,
73
- items: { type: }
71
+ items: {
72
+ type: atype
73
+ }
74
74
  }
75
75
  end
76
76
 
77
- # Identifier is a special format for identification on the front end
78
- format = :identifier if name == identifier_property
79
-
80
- # Float is double precision in postgres by default
81
- if type == :float
82
- type = :number
83
- format = :double
84
- end
85
-
86
- # Dates and times are strings
87
- if DATE_FORMATS.include?(type)
88
- format = type
89
- type = :string
77
+ if %i[datetime date time].include?(atype)
78
+ return {
79
+ type: "string",
80
+ format: atype
81
+ }
90
82
  end
91
83
 
92
- { type:, format: }.compact
84
+ { type: atype }
93
85
  end
94
86
 
95
87
  def nested_array_options(name)
@@ -134,6 +126,7 @@ module Rhino
134
126
 
135
127
  def property_type_and_format(name) # rubocop:disable Metrics/AbcSize
136
128
  # Special cases
129
+ return { type: :identifier } if name == identifier_property
137
130
  return { type: :string } if defined_enums.key?(name)
138
131
 
139
132
  # FIXME: Hack for tags for now
@@ -11,8 +11,6 @@ module Rhino
11
11
  included do
12
12
  attribute :url
13
13
  attribute :url_attachment
14
- attribute :previews, :json, default: {}
15
- attribute :representations, :json, default: {}
16
14
  attribute :variants, :json, default: {}
17
15
 
18
16
  rhino_policy :active_storage_attachment
@@ -25,35 +23,20 @@ module Rhino
25
23
  url(attachment, disposition: :attachment)
26
24
  end
27
25
 
28
- def representations
29
- return unless representable?
26
+ def variants
27
+ # Not everything may be processed into a variant based on mime type
28
+ return unless variable?
30
29
 
31
30
  record.attachment_reflections[self.name]&.named_variants&.keys&.index_with do |v|
32
- representation = representation(v)
31
+ variant = variant(v)
33
32
 
34
33
  {
35
- url: url(representation),
36
- url_attachment: url_attachment(representation)
34
+ url: url(variant),
35
+ url_attachment: url_attachment(variant)
37
36
  }
38
37
  end
39
38
  end
40
39
 
41
- # FIXME: Cache for performance
42
- def previews
43
- # Not everything may be processed into a preview based on mime type
44
- return unless previewable?
45
-
46
- representations
47
- end
48
-
49
- # FIXME: Cache for performance
50
- def variants
51
- # Not everything may be processed into a variant based on mime type
52
- return unless variable?
53
-
54
- representations
55
- end
56
-
57
40
  def display_name
58
41
  filename.to_s
59
42
  end
@@ -61,7 +44,7 @@ module Rhino
61
44
 
62
45
  class_methods do
63
46
  def readable_properties
64
- super + [ "previews", "representations", "variants", "signed_id"]
47
+ super + [ "variants", "signed_id"]
65
48
  end
66
49
  end
67
50
 
@@ -13,7 +13,7 @@ module Rhino
13
13
  @param = params[:order]
14
14
 
15
15
  # Always append id to the end of the order clause to ensure a stable sort for pagination
16
- result = apply_order.order(scope.primary_key.to_sym)
16
+ result = apply_order.order(scope.primary_key)
17
17
  @app.resolve(result, params)
18
18
  end
19
19
 
data/lib/rhino/version.rb CHANGED
@@ -8,9 +8,9 @@ module Rhino
8
8
 
9
9
  module VERSION
10
10
  MAJOR = 0
11
- MINOR = 26
11
+ MINOR = 30
12
12
  TINY = 0
13
- PRE = "beta.4"
13
+ PRE = "alpha.1"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhino_project_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.0.beta.4
4
+ version: 0.30.0.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Rosevear
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2024-12-08 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: rails
@@ -15,20 +16,20 @@ dependencies:
15
16
  requirements:
16
17
  - - "~>"
17
18
  - !ruby/object:Gem::Version
18
- version: 8.0.0
19
+ version: 7.2.0
19
20
  - - ">="
20
21
  - !ruby/object:Gem::Version
21
- version: 8.0.0
22
+ version: 7.2.0
22
23
  type: :runtime
23
24
  prerelease: false
24
25
  version_requirements: !ruby/object:Gem::Requirement
25
26
  requirements:
26
27
  - - "~>"
27
28
  - !ruby/object:Gem::Version
28
- version: 8.0.0
29
+ version: 7.2.0
29
30
  - - ">="
30
31
  - !ruby/object:Gem::Version
31
- version: 8.0.0
32
+ version: 7.2.0
32
33
  - !ruby/object:Gem::Dependency
33
34
  name: activeadmin
34
35
  requirement: !ruby/object:Gem::Requirement
@@ -49,14 +50,14 @@ dependencies:
49
50
  requirements:
50
51
  - - '='
51
52
  - !ruby/object:Gem::Version
52
- version: 12.0.0
53
+ version: 11.0.0
53
54
  type: :runtime
54
55
  prerelease: false
55
56
  version_requirements: !ruby/object:Gem::Requirement
56
57
  requirements:
57
58
  - - '='
58
59
  - !ruby/object:Gem::Version
59
- version: 12.0.0
60
+ version: 11.0.0
60
61
  - !ruby/object:Gem::Dependency
61
62
  name: analytics-ruby
62
63
  requirement: !ruby/object:Gem::Requirement
@@ -91,14 +92,14 @@ dependencies:
91
92
  requirements:
92
93
  - - '='
93
94
  - !ruby/object:Gem::Version
94
- version: 2.16.0
95
+ version: 2.15.0
95
96
  type: :runtime
96
97
  prerelease: false
97
98
  version_requirements: !ruby/object:Gem::Requirement
98
99
  requirements:
99
100
  - - '='
100
101
  - !ruby/object:Gem::Version
101
- version: 2.16.0
102
+ version: 2.15.0
102
103
  - !ruby/object:Gem::Dependency
103
104
  name: countries
104
105
  requirement: !ruby/object:Gem::Requirement
@@ -133,28 +134,14 @@ dependencies:
133
134
  requirements:
134
135
  - - '='
135
136
  - !ruby/object:Gem::Version
136
- version: 1.2.5
137
+ version: 1.2.4
137
138
  type: :runtime
138
139
  prerelease: false
139
140
  version_requirements: !ruby/object:Gem::Requirement
140
141
  requirements:
141
142
  - - '='
142
143
  - !ruby/object:Gem::Version
143
- version: 1.2.5
144
- - !ruby/object:Gem::Dependency
145
- name: discard
146
- requirement: !ruby/object:Gem::Requirement
147
- requirements:
148
- - - '='
149
- - !ruby/object:Gem::Version
150
- version: 1.4.0
151
- type: :runtime
152
- prerelease: false
153
- version_requirements: !ruby/object:Gem::Requirement
154
- requirements:
155
- - - '='
156
- - !ruby/object:Gem::Version
157
- version: 1.4.0
144
+ version: 1.2.4
158
145
  - !ruby/object:Gem::Dependency
159
146
  name: friendly_id
160
147
  requirement: !ruby/object:Gem::Requirement
@@ -397,12 +384,10 @@ files:
397
384
  - app/controllers/concerns/rhino/set_current_user.rb
398
385
  - app/controllers/rhino/account_controller.rb
399
386
  - app/controllers/rhino/active_model_extension_controller.rb
400
- - app/controllers/rhino/active_record_discard_controller.rb
401
387
  - app/controllers/rhino/base_controller.rb
402
388
  - app/controllers/rhino/crud_controller.rb
403
389
  - app/controllers/rhino/simple_controller.rb
404
390
  - app/controllers/rhino/simple_stream_controller.rb
405
- - app/helpers/rhino/env_helper.rb
406
391
  - app/helpers/rhino/omniauth_helper.rb
407
392
  - app/helpers/rhino/policy_helper.rb
408
393
  - app/helpers/rhino/segment_helper.rb
@@ -410,7 +395,6 @@ files:
410
395
  - app/models/rhino/current.rb
411
396
  - app/models/rhino/user.rb
412
397
  - app/overrides/active_record/nested_error_override.rb
413
- - app/overrides/activeadmin/resource_dsl_override.rb
414
398
  - app/overrides/activestorage/direct_uploads_controller_override.rb
415
399
  - app/overrides/activestorage/redirect_controller_override.rb
416
400
  - app/overrides/activestorage/redirect_representation_controller_override.rb
@@ -442,8 +426,6 @@ files:
442
426
  - lib/commands/rhino/module/new_command.rb
443
427
  - lib/commands/rhino/module/rails_command.rb
444
428
  - lib/commands/rhino/module/test_command.rb
445
- - lib/generators/rhino/admin/admin_generator.rb
446
- - lib/generators/rhino/admin/templates/resource.rb.tt
447
429
  - lib/generators/rhino/dev/setup/setup_generator.rb
448
430
  - lib/generators/rhino/dev/setup/templates/env.tt
449
431
  - lib/generators/rhino/dev/setup/templates/prepare-commit-msg
@@ -465,11 +447,6 @@ files:
465
447
  - lib/generators/rhino/module/templates/test/test_helper.rb
466
448
  - lib/generators/rhino/policy/policy_generator.rb
467
449
  - lib/generators/rhino/policy/templates/policy.rb.tt
468
- - lib/generators/rhino/ui/route/route_generator.rb
469
- - lib/generators/rhino/ui/route/templates/$id.edit.tsx.tt
470
- - lib/generators/rhino/ui/route/templates/$id.index.tsx.tt
471
- - lib/generators/rhino/ui/route/templates/index.tsx.tt
472
- - lib/generators/rhino/ui/route/templates/new.tsx.tt
473
450
  - lib/generators/rhino/update/update_generator.rb
474
451
  - lib/generators/test_unit/rhino_policy_generator.rb
475
452
  - lib/generators/test_unit/templates/policy_test.rb.tt
@@ -531,6 +508,7 @@ homepage: ''
531
508
  licenses:
532
509
  - MIT
533
510
  metadata: {}
511
+ post_install_message:
534
512
  rdoc_options: []
535
513
  require_paths:
536
514
  - lib
@@ -545,7 +523,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
545
523
  - !ruby/object:Gem::Version
546
524
  version: '0'
547
525
  requirements: []
548
- rubygems_version: 3.6.7
526
+ rubygems_version: 3.5.22
527
+ signing_key:
549
528
  specification_version: 4
550
529
  summary: ''
551
530
  test_files: []
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Rhino
4
- class ActiveRecordDiscardController < CrudController
5
- def index
6
- authorize klass
7
-
8
- @models = klass.sieves.resolve(policy_scope(klass), params).kept
9
- render json: {
10
- results: @models.eager_load_refs.map { |m| permit_model(m) },
11
- total: @models.unscope(:limit, :offset).reselect(:id).count
12
- }
13
- end
14
-
15
- def show
16
- @model = authorize find_resource(policy_scope(klass).kept.eager_load_refs)
17
-
18
- permit_and_render
19
- end
20
-
21
- def destroy
22
- @model = authorize find_resource
23
- @model.discard!
24
-
25
- permit_and_render
26
- end
27
- end
28
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Rhino
4
- module EnvHelper
5
- module_function
6
-
7
- def rhino_env_tag
8
- # Filter environment variables to get only those starting with "RHINO_PUBLIC"
9
- rhino_public_env = ENV.select { |key, _| key.start_with?("RHINO_PUBLIC") }
10
-
11
- # Create a JavaScript object with the environment variables
12
- js_env = rhino_public_env.transform_keys { |key| key.sub("RHINO_PUBLIC_", "") }
13
-
14
- # Create a JavaScript snippet that initializes window.rhino.env
15
- js_code = <<~JS
16
- (function() {
17
- window.rhino = window.rhino || {};
18
- window.rhino.env = window.rhino.env || {};
19
- var env = #{js_env.to_json};
20
- for (var key in env) {
21
- if (Object.prototype.hasOwnProperty.call(env, key)) {
22
- window.rhino.env[key] = env[key];
23
- }
24
- }
25
- })();
26
- JS
27
-
28
- # Return as a script tag
29
- javascript_tag(js_code)
30
- end
31
- end
32
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_admin/resource_dsl"
4
-
5
- module ActiveAdmin
6
- # This is the class where all the register blocks are evaluated.
7
- class ResourceDSL
8
- # Runs in the context of the ResourceDSL
9
- def rhino_filters
10
- klass = self.config.resource_class_name.constantize
11
- klass.ransackable_filters.each do |attr|
12
- filter attr.to_sym
13
- end
14
- end
15
-
16
- # Runs in the context of the controller
17
- def rhino_permit_params(permitted: [])
18
- permit_params do
19
- klass = self.active_admin_config.resource_class_name.constantize
20
-
21
- permitted += klass.creatable_properties.map(&:to_sym) if params[:action] == "create"
22
- permitted += klass.updatable_properties.map(&:to_sym) if params[:action] == "update"
23
-
24
- # Allow owner and other references to be assigned or changed by admin
25
- # All possible relations
26
- references = klass.describe[:properties].select { |_p, d| d[:type] == :reference }.keys
27
-
28
- # Restrict to the valid create/update properties
29
- references.select! { |r| permitted.include?(r.to_sym) }
30
- permitted += references.map { |r| klass.reflections[r].foreign_key }
31
-
32
- permitted.uniq
33
- end
34
- end
35
- end
36
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails/generators"
4
-
5
- module Rhino
6
- class AdminGenerator < Rails::Generators::NamedBase
7
- source_root File.expand_path("templates", __dir__)
8
-
9
- def admin
10
- template "resource.rb", "app/admin/#{file_path.tr('/', '_').pluralize}.rb" unless options[:skip_admin]
11
- end
12
- end
13
- end
@@ -1,4 +0,0 @@
1
- ActiveAdmin.register <%= class_name %> do
2
- rhino_filters
3
- rhino_permit_params
4
- end
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Rhino
4
- module Generators
5
- module Ui
6
- class RouteGenerator < ::Rails::Generators::NamedBase
7
- class_option :routes_directory, type: :string, desc: "The directory to copy the routes to",
8
- default: "app/frontend/routes", group: :route
9
- class_option :route_path, type: :string, desc: "The path to routes relative to the routes directory", default: "_authenticated/$owner", group: :route
10
- class_option :model_path, type: :string, desc: "The base path name for the model (defaults to model plural name)", group: :route
11
- class_option :copy_index, type: :boolean, desc: "Copy the index route", default: true, group: :route
12
- class_option :copy_show, type: :boolean, desc: "Copy the show route", default: true, group: :route
13
- class_option :copy_create, type: :boolean, desc: "Copy the create route", default: true, group: :route
14
- class_option :copy_edit, type: :boolean, desc: "Copy the edit route", default: true, group: :route
15
-
16
- source_root File.expand_path("templates", __dir__)
17
-
18
- def copy_index_route
19
- return unless options.copy_index?
20
- template "index.tsx", route_file_path("index.tsx")
21
- end
22
-
23
- def copy_show_route
24
- return unless options.copy_show?
25
- template "$id.index.tsx", route_file_path("$id.index.tsx")
26
- end
27
-
28
- def copy_create_route
29
- return unless options.copy_create?
30
- template "new.tsx", route_file_path("new.tsx")
31
- end
32
-
33
- def copy_edit_route
34
- return unless options.copy_edit?
35
- template "$id.edit.tsx", route_file_path("$id.edit.tsx")
36
- end
37
-
38
- private
39
- def model_path
40
- options[:model_path] || plural_table_name
41
- end
42
-
43
- def route_path
44
- File.join("/", options[:route_path], model_path, "/")
45
- end
46
-
47
-
48
- def route_file_path(file_name)
49
- File.join(options[:routes_directory], options[:route_path], model_path, file_name)
50
- end
51
- end
52
- end
53
- end
54
- end
@@ -1,12 +0,0 @@
1
- import { ModelEditPage } from '@rhino-project/ui-heroui';
2
- import { createFileRoute } from '@tanstack/react-router';
3
-
4
- export const Route = createFileRoute('<%= route_path %>$id/edit')({
5
- component: RouteComponent
6
- });
7
-
8
- function RouteComponent() {
9
- const { id: modelId } = Route.useParams();
10
-
11
- return <ModelEditPage model="<%= singular_table_name %>" modelId={modelId} />;
12
- }
@@ -1,12 +0,0 @@
1
- import { ModelShowPage } from '@rhino-project/ui-heroui';
2
- import { createFileRoute } from '@tanstack/react-router';
3
-
4
- export const Route = createFileRoute('<%= route_path %>$id/')({
5
- component: RouteComponent
6
- });
7
-
8
- function RouteComponent() {
9
- const { id: modelId } = Route.useParams();
10
-
11
- return <ModelShowPage model="<%= singular_table_name %>" modelId={modelId} />;
12
- }
@@ -1,10 +0,0 @@
1
- import { ModelIndexPage } from '@rhino-project/ui-heroui';
2
- import { createFileRoute } from '@tanstack/react-router';
3
-
4
- export const Route = createFileRoute('<%= route_path %>')({
5
- component: RouteComponent
6
- });
7
-
8
- function RouteComponent() {
9
- return <ModelIndexPage model="<%= singular_table_name %>" syncUrl />;
10
- }
@@ -1,17 +0,0 @@
1
- import { ModelCreatePage } from '@rhino-project/ui-heroui';
2
- import { createFileRoute } from '@tanstack/react-router';
3
-
4
- export const Route = createFileRoute('<%= route_path %>new')({
5
- validateSearch: (search: Record<string, unknown>): { parentId: number } => {
6
- return {
7
- parentId: Number(search?.parentId)
8
- };
9
- },
10
- component: RouteComponent
11
- });
12
-
13
- function RouteComponent() {
14
- const { parentId } = Route.useSearch();
15
-
16
- return <ModelCreatePage model="<%= singular_table_name %>" parentId={parentId} />;
17
- }