tessa 2.0 → 6.0.0.rc2

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 (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -18
  3. data/app/assets/javascripts/tessa.esm.js +212 -173
  4. data/app/assets/javascripts/tessa.js +206 -167
  5. data/app/javascript/activestorage/file_checksum.ts +76 -0
  6. data/app/javascript/tessa/index.ts +264 -0
  7. data/app/javascript/tessa/types.ts +34 -0
  8. data/config/routes.rb +0 -1
  9. data/lib/tessa/simple_form/asset_input.rb +24 -25
  10. data/lib/tessa/version.rb +1 -1
  11. data/lib/tessa.rb +0 -80
  12. data/package.json +7 -2
  13. data/rollup.config.js +5 -5
  14. data/spec/dummy/app/models/single_asset_model.rb +1 -1
  15. data/spec/dummy/app/models/single_asset_model_form.rb +3 -5
  16. data/spec/dummy/bin/rails +2 -2
  17. data/spec/dummy/bin/rake +2 -2
  18. data/spec/dummy/bin/setup +14 -6
  19. data/spec/dummy/bin/yarn +9 -3
  20. data/spec/dummy/config/application.rb +11 -9
  21. data/spec/dummy/config/boot.rb +1 -1
  22. data/spec/dummy/config/environment.rb +1 -1
  23. data/spec/dummy/config/environments/development.rb +34 -5
  24. data/spec/dummy/config/environments/production.rb +49 -10
  25. data/spec/dummy/config/environments/test.rb +28 -12
  26. data/spec/dummy/config/initializers/backtrace_silencers.rb +4 -3
  27. data/spec/dummy/config/initializers/content_security_policy.rb +5 -0
  28. data/spec/dummy/config/initializers/filter_parameter_logging.rb +3 -1
  29. data/spec/dummy/config/initializers/new_framework_defaults_6_1.rb +67 -0
  30. data/spec/dummy/config/initializers/permissions_policy.rb +11 -0
  31. data/spec/dummy/config/initializers/wrap_parameters.rb +5 -0
  32. data/spec/dummy/config/locales/en.yml +1 -1
  33. data/spec/dummy/config/routes.rb +1 -1
  34. data/spec/dummy/config/storage.yml +31 -0
  35. data/spec/dummy/config.ru +2 -1
  36. data/spec/dummy/db/migrate/20230406194400_add_service_name_to_active_storage_blobs.active_storage.rb +22 -0
  37. data/spec/dummy/db/migrate/20230406194401_create_active_storage_variant_records.active_storage.rb +27 -0
  38. data/spec/dummy/db/schema.rb +15 -7
  39. data/tessa.gemspec +4 -5
  40. data/tsconfig.json +10 -0
  41. data/yarn.lock +74 -7
  42. metadata +36 -74
  43. data/app/javascript/activestorage/file_checksum.js +0 -53
  44. data/app/javascript/tessa/index.js.coffee +0 -183
  45. data/lib/tasks/tessa.rake +0 -18
  46. data/lib/tessa/active_storage/asset_wrapper.rb +0 -32
  47. data/lib/tessa/asset/failure.rb +0 -37
  48. data/lib/tessa/asset.rb +0 -47
  49. data/lib/tessa/asset_change.rb +0 -49
  50. data/lib/tessa/asset_change_set.rb +0 -49
  51. data/lib/tessa/config.rb +0 -16
  52. data/lib/tessa/controller_helpers.rb +0 -16
  53. data/lib/tessa/fake_connection.rb +0 -29
  54. data/lib/tessa/jobs/migrate_assets_job.rb +0 -222
  55. data/lib/tessa/model/dynamic_extensions.rb +0 -145
  56. data/lib/tessa/model/field.rb +0 -77
  57. data/lib/tessa/model.rb +0 -94
  58. data/lib/tessa/rack_upload_proxy.rb +0 -41
  59. data/lib/tessa/response_factory.rb +0 -15
  60. data/lib/tessa/upload/uploads_file.rb +0 -18
  61. data/lib/tessa/upload.rb +0 -31
  62. data/lib/tessa/view_helpers.rb +0 -23
  63. data/spec/dummy/app/models/multiple_asset_model.rb +0 -8
  64. data/spec/support/remote_call_macro.rb +0 -40
  65. data/spec/tessa/asset/failure_spec.rb +0 -48
  66. data/spec/tessa/asset_change_set_spec.rb +0 -198
  67. data/spec/tessa/asset_change_spec.rb +0 -86
  68. data/spec/tessa/asset_spec.rb +0 -196
  69. data/spec/tessa/config_spec.rb +0 -70
  70. data/spec/tessa/controller_helpers_spec.rb +0 -55
  71. data/spec/tessa/jobs/migrate_assets_job_spec.rb +0 -247
  72. data/spec/tessa/model_field_spec.rb +0 -72
  73. data/spec/tessa/model_spec.rb +0 -325
  74. data/spec/tessa/rack_upload_proxy_spec.rb +0 -83
  75. data/spec/tessa/upload/uploads_file_spec.rb +0 -72
  76. data/spec/tessa/upload_spec.rb +0 -125
  77. data/spec/tessa_spec.rb +0 -23
@@ -1,3 +1,3 @@
1
1
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
2
2
 
3
- require 'bundler/setup' # Set up gems listed in the Gemfile.
3
+ require "bundler/setup" # Set up gems listed in the Gemfile.
@@ -1,5 +1,5 @@
1
1
  # Load the Rails application.
2
- require_relative 'application'
2
+ require_relative "application"
3
3
 
4
4
  # Initialize the Rails application.
5
5
  Rails.application.initialize!
@@ -1,8 +1,10 @@
1
+ require "active_support/core_ext/integer/time"
2
+
1
3
  Rails.application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
4
- # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
6
+ # In the development environment your application's code is reloaded any time
7
+ # it changes. This slows down response time but is perfect for development
6
8
  # since you don't have to restart the web server when you make code changes.
7
9
  config.cache_classes = false
8
10
 
@@ -16,6 +18,7 @@ Rails.application.configure do
16
18
  # Run rails dev:cache to toggle caching.
17
19
  if Rails.root.join('tmp', 'caching-dev.txt').exist?
18
20
  config.action_controller.perform_caching = true
21
+ config.action_controller.enable_fragment_cache_logging = true
19
22
 
20
23
  config.cache_store = :memory_store
21
24
  config.public_file_server.headers = {
@@ -27,9 +30,29 @@ Rails.application.configure do
27
30
  config.cache_store = :null_store
28
31
  end
29
32
 
33
+ # Store uploaded files on the local file system (see config/storage.yml for options).
34
+ config.active_storage.service = :local
35
+
36
+ # Don't care if the mailer can't send.
37
+ config.action_mailer.raise_delivery_errors = false
38
+
39
+ config.action_mailer.perform_caching = false
40
+
30
41
  # Print deprecation notices to the Rails logger.
31
42
  config.active_support.deprecation = :log
32
43
 
44
+ # Raise exceptions for disallowed deprecations.
45
+ config.active_support.disallowed_deprecation = :raise
46
+
47
+ # Tell Active Support which deprecation messages to disallow.
48
+ config.active_support.disallowed_deprecation_warnings = []
49
+
50
+ # Raise an error on page load if there are pending migrations.
51
+ config.active_record.migration_error = :page_load
52
+
53
+ # Highlight code that triggered database queries in logs.
54
+ config.active_record.verbose_query_logs = true
55
+
33
56
  # Debug mode disables concatenation and preprocessing of assets.
34
57
  # This option may cause significant delays in view rendering with a large
35
58
  # number of complex assets.
@@ -38,10 +61,16 @@ Rails.application.configure do
38
61
  # Suppress logger output for asset requests.
39
62
  config.assets.quiet = true
40
63
 
41
- # Raises error for missing translations
42
- # config.action_view.raise_on_missing_translations = true
64
+ # Raises error for missing translations.
65
+ # config.i18n.raise_on_missing_translations = true
66
+
67
+ # Annotate rendered view with file names.
68
+ # config.action_view.annotate_rendered_view_with_filenames = true
43
69
 
44
70
  # Use an evented file watcher to asynchronously detect changes in source code,
45
71
  # routes, locales, etc. This feature depends on the listen gem.
46
- # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
72
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
73
+
74
+ # Uncomment if you wish to allow Action Cable access from any origin.
75
+ # config.action_cable.disable_request_forgery_protection = true
47
76
  end
@@ -1,3 +1,5 @@
1
+ require "active_support/core_ext/integer/time"
2
+
1
3
  Rails.application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
@@ -22,27 +24,28 @@ Rails.application.configure do
22
24
  # Apache or NGINX already handles this.
23
25
  config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
24
26
 
25
- # Compress CSS.
27
+ # Compress CSS using a preprocessor.
26
28
  # config.assets.css_compressor = :sass
27
29
 
28
30
  # Do not fallback to assets pipeline if a precompiled asset is missed.
29
31
  config.assets.compile = false
30
32
 
31
- # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
32
-
33
33
  # Enable serving of images, stylesheets, and JavaScripts from an asset server.
34
- # config.action_controller.asset_host = 'http://assets.example.com'
34
+ # config.asset_host = 'http://assets.example.com'
35
35
 
36
36
  # Specifies the header that your server uses for sending files.
37
37
  # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
38
38
  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
39
39
 
40
+ # Store uploaded files on the local file system (see config/storage.yml for options).
41
+ config.active_storage.service = :local
42
+
40
43
  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
41
44
  # config.force_ssl = true
42
45
 
43
- # Use the lowest log level to ensure availability of diagnostic information
44
- # when problems arise.
45
- config.log_level = :debug
46
+ # Include generic and useful information about system operation, but avoid logging too much
47
+ # information to avoid inadvertent exposure of personally identifiable information (PII).
48
+ config.log_level = :info
46
49
 
47
50
  # Prepend all log lines with the following tags.
48
51
  config.log_tags = [ :request_id ]
@@ -50,9 +53,15 @@ Rails.application.configure do
50
53
  # Use a different cache store in production.
51
54
  # config.cache_store = :mem_cache_store
52
55
 
53
- # Use a real queuing backend for Active Job (and separate queues per environment)
56
+ # Use a real queuing backend for Active Job (and separate queues per environment).
54
57
  # config.active_job.queue_adapter = :resque
55
- # config.active_job.queue_name_prefix = "dummy_#{Rails.env}"
58
+ # config.active_job.queue_name_prefix = "dummy_production"
59
+
60
+ config.action_mailer.perform_caching = false
61
+
62
+ # Ignore bad email addresses and do not raise email delivery errors.
63
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
64
+ # config.action_mailer.raise_delivery_errors = false
56
65
 
57
66
  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
58
67
  # the I18n.default_locale when a translation cannot be found).
@@ -61,11 +70,17 @@ Rails.application.configure do
61
70
  # Send deprecation notices to registered listeners.
62
71
  config.active_support.deprecation = :notify
63
72
 
73
+ # Log disallowed deprecations.
74
+ config.active_support.disallowed_deprecation = :log
75
+
76
+ # Tell Active Support which deprecation messages to disallow.
77
+ config.active_support.disallowed_deprecation_warnings = []
78
+
64
79
  # Use default logging formatter so that PID and timestamp are not suppressed.
65
80
  config.log_formatter = ::Logger::Formatter.new
66
81
 
67
82
  # Use a different logger for distributed setups.
68
- # require 'syslog/logger'
83
+ # require "syslog/logger"
69
84
  # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
70
85
 
71
86
  if ENV["RAILS_LOG_TO_STDOUT"].present?
@@ -73,4 +88,28 @@ Rails.application.configure do
73
88
  logger.formatter = config.log_formatter
74
89
  config.logger = ActiveSupport::TaggedLogging.new(logger)
75
90
  end
91
+
92
+ # Do not dump schema after migrations.
93
+ config.active_record.dump_schema_after_migration = false
94
+
95
+ # Inserts middleware to perform automatic connection switching.
96
+ # The `database_selector` hash is used to pass options to the DatabaseSelector
97
+ # middleware. The `delay` is used to determine how long to wait after a write
98
+ # to send a subsequent read to the primary.
99
+ #
100
+ # The `database_resolver` class is used by the middleware to determine which
101
+ # database is appropriate to use based on the time delay.
102
+ #
103
+ # The `database_resolver_context` class is used by the middleware to set
104
+ # timestamps for the last write to the primary. The resolver uses the context
105
+ # class timestamps to determine how long to wait before reading from the
106
+ # replica.
107
+ #
108
+ # By default Rails will store a last write timestamp in the session. The
109
+ # DatabaseSelector middleware is designed as such you can define your own
110
+ # strategy for connection switching and pass that into the middleware through
111
+ # these configuration options.
112
+ # config.active_record.database_selector = { delay: 2.seconds }
113
+ # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
114
+ # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
76
115
  end
@@ -1,11 +1,14 @@
1
+ require "active_support/core_ext/integer/time"
2
+
3
+ # The test environment is used exclusively to run your application's
4
+ # test suite. You never need to work with it otherwise. Remember that
5
+ # your test database is "scratch space" for the test suite and is wiped
6
+ # and recreated between test runs. Don't rely on the data there!
7
+
1
8
  Rails.application.configure do
2
9
  # Settings specified here will take precedence over those in config/application.rb.
3
10
 
4
- # The test environment is used exclusively to run your application's
5
- # test suite. You never need to work with it otherwise. Remember that
6
- # your test database is "scratch space" for the test suite and is wiped
7
- # and recreated between test runs. Don't rely on the data there!
8
- config.cache_classes = false
11
+ config.cache_classes = true
9
12
 
10
13
  # Do not eager load code on boot. This avoids loading your whole application
11
14
  # just for the purpose of running a single test. If you are using a tool that
@@ -21,6 +24,7 @@ Rails.application.configure do
21
24
  # Show full error reports and disable caching.
22
25
  config.consider_all_requests_local = true
23
26
  config.action_controller.perform_caching = false
27
+ config.cache_store = :null_store
24
28
 
25
29
  # Raise exceptions instead of rendering exception templates.
26
30
  config.action_dispatch.show_exceptions = false
@@ -28,16 +32,28 @@ Rails.application.configure do
28
32
  # Disable request forgery protection in test environment.
29
33
  config.action_controller.allow_forgery_protection = false
30
34
 
35
+ # Store uploaded files on the local file system in a temporary directory.
36
+ config.active_storage.service = :test
37
+
38
+ config.action_mailer.perform_caching = false
39
+
40
+ # Tell Action Mailer not to deliver emails to the real world.
41
+ # The :test delivery method accumulates sent emails in the
42
+ # ActionMailer::Base.deliveries array.
43
+ config.action_mailer.delivery_method = :test
44
+
31
45
  # Print deprecation notices to the stderr.
32
46
  config.active_support.deprecation = :stderr
33
47
 
34
- config.active_storage.service = :local
48
+ # Raise exceptions for disallowed deprecations.
49
+ config.active_support.disallowed_deprecation = :raise
35
50
 
36
- # Raises error for missing translations
37
- # config.action_view.raise_on_missing_translations = true
51
+ # Tell Active Support which deprecation messages to disallow.
52
+ config.active_support.disallowed_deprecation_warnings = []
38
53
 
39
- config.action_controller.default_url_options = {
40
- protocol: 'https',
41
- host: "www.example.com"
42
- }
54
+ # Raises error for missing translations.
55
+ # config.i18n.raise_on_missing_translations = true
56
+
57
+ # Annotate rendered view with file names.
58
+ # config.action_view.annotate_rendered_view_with_filenames = true
43
59
  end
@@ -1,7 +1,8 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
3
  # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
- # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
4
+ # Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) }
5
5
 
6
- # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
- # Rails.backtrace_cleaner.remove_silencers!
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code
7
+ # by setting BACKTRACE=1 before calling your invocation, like "BACKTRACE=1 ./bin/rails runner 'MyClass.perform'".
8
+ Rails.backtrace_cleaner.remove_silencers! if ENV["BACKTRACE"]
@@ -11,6 +11,8 @@
11
11
  # policy.object_src :none
12
12
  # policy.script_src :self, :https
13
13
  # policy.style_src :self, :https
14
+ # # If you are using webpack-dev-server then specify webpack-dev-server host
15
+ # policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
14
16
 
15
17
  # # Specify URI for violation reports
16
18
  # # policy.report_uri "/csp-violation-report-endpoint"
@@ -19,6 +21,9 @@
19
21
  # If you are using UJS then enable automatic nonce generation
20
22
  # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
21
23
 
24
+ # Set the nonce only to specific directives
25
+ # Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
26
+
22
27
  # Report CSP violations to a specified URI
23
28
  # For further information see the following documentation:
24
29
  # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
@@ -1,4 +1,6 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
3
  # Configure sensitive parameters which will be filtered from the log file.
4
- Rails.application.config.filter_parameters += [:password]
4
+ Rails.application.config.filter_parameters += [
5
+ :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
6
+ ]
@@ -0,0 +1,67 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains migration options to ease your Rails 6.1 upgrade.
4
+ #
5
+ # Once upgraded flip defaults one by one to migrate to the new default.
6
+ #
7
+ # Read the Guide for Upgrading Ruby on Rails for more info on each option.
8
+
9
+ # Support for inversing belongs_to -> has_many Active Record associations.
10
+ # Rails.application.config.active_record.has_many_inversing = true
11
+
12
+ # Track Active Storage variants in the database.
13
+ # Rails.application.config.active_storage.track_variants = true
14
+
15
+ # Apply random variation to the delay when retrying failed jobs.
16
+ # Rails.application.config.active_job.retry_jitter = 0.15
17
+
18
+ # Stop executing `after_enqueue`/`after_perform` callbacks if
19
+ # `before_enqueue`/`before_perform` respectively halts with `throw :abort`.
20
+ # Rails.application.config.active_job.skip_after_callbacks_if_terminated = true
21
+
22
+ # Specify cookies SameSite protection level: either :none, :lax, or :strict.
23
+ #
24
+ # This change is not backwards compatible with earlier Rails versions.
25
+ # It's best enabled when your entire app is migrated and stable on 6.1.
26
+ # Rails.application.config.action_dispatch.cookies_same_site_protection = :lax
27
+
28
+ # Generate CSRF tokens that are encoded in URL-safe Base64.
29
+ #
30
+ # This change is not backwards compatible with earlier Rails versions.
31
+ # It's best enabled when your entire app is migrated and stable on 6.1.
32
+ # Rails.application.config.action_controller.urlsafe_csrf_tokens = true
33
+
34
+ # Specify whether `ActiveSupport::TimeZone.utc_to_local` returns a time with an
35
+ # UTC offset or a UTC time.
36
+ # ActiveSupport.utc_to_local_returns_utc_offset_times = true
37
+
38
+ # Change the default HTTP status code to `308` when redirecting non-GET/HEAD
39
+ # requests to HTTPS in `ActionDispatch::SSL` middleware.
40
+ # Rails.application.config.action_dispatch.ssl_default_redirect_status = 308
41
+
42
+ # Use new connection handling API. For most applications this won't have any
43
+ # effect. For applications using multiple databases, this new API provides
44
+ # support for granular connection swapping.
45
+ # Rails.application.config.active_record.legacy_connection_handling = false
46
+
47
+ # Make `form_with` generate non-remote forms by default.
48
+ # Rails.application.config.action_view.form_with_generates_remote_forms = false
49
+
50
+ # Set the default queue name for the analysis job to the queue adapter default.
51
+ # Rails.application.config.active_storage.queues.analysis = nil
52
+
53
+ # Set the default queue name for the purge job to the queue adapter default.
54
+ # Rails.application.config.active_storage.queues.purge = nil
55
+
56
+ # Set the default queue name for the incineration job to the queue adapter default.
57
+ # Rails.application.config.action_mailbox.queues.incineration = nil
58
+
59
+ # Set the default queue name for the routing job to the queue adapter default.
60
+ # Rails.application.config.action_mailbox.queues.routing = nil
61
+
62
+ # Set the default queue name for the mail deliver job to the queue adapter default.
63
+ # Rails.application.config.action_mailer.deliver_later_queue_name = nil
64
+
65
+ # Generate a `Link` header that gives a hint to modern browsers about
66
+ # preloading assets when using `javascript_include_tag` and `stylesheet_link_tag`.
67
+ # Rails.application.config.action_view.preload_links_header = true
@@ -0,0 +1,11 @@
1
+ # Define an application-wide HTTP permissions policy. For further
2
+ # information see https://developers.google.com/web/updates/2018/06/feature-policy
3
+ #
4
+ # Rails.application.config.permissions_policy do |f|
5
+ # f.camera :none
6
+ # f.gyroscope :none
7
+ # f.microphone :none
8
+ # f.usb :none
9
+ # f.fullscreen :self
10
+ # f.payment :self, "https://secure.example.com"
11
+ # end
@@ -7,3 +7,8 @@
7
7
  ActiveSupport.on_load(:action_controller) do
8
8
  wrap_parameters format: [:json]
9
9
  end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -27,7 +27,7 @@
27
27
  # 'true': 'foo'
28
28
  #
29
29
  # To learn more, please read the Rails Internationalization guide
30
- # available at http://guides.rubyonrails.org/i18n.html.
30
+ # available at https://guides.rubyonrails.org/i18n.html.
31
31
 
32
32
  en:
33
33
  hello: "Hello world"
@@ -1,3 +1,3 @@
1
1
  Rails.application.routes.draw do
2
- # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
2
+ # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
3
3
  end
@@ -1,3 +1,34 @@
1
+ test:
2
+ service: Disk
3
+ root: <%= Rails.root.join("tmp/storage") %>
4
+
1
5
  local:
2
6
  service: Disk
3
7
  root: <%= Rails.root.join("storage") %>
8
+
9
+ # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
10
+ # amazon:
11
+ # service: S3
12
+ # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
13
+ # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
14
+ # region: us-east-1
15
+ # bucket: your_own_bucket
16
+
17
+ # Remember not to checkin your GCS keyfile to a repository
18
+ # google:
19
+ # service: GCS
20
+ # project: your_project
21
+ # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
22
+ # bucket: your_own_bucket
23
+
24
+ # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
25
+ # microsoft:
26
+ # service: AzureStorage
27
+ # storage_account_name: your_account_name
28
+ # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
29
+ # container: your_container_name
30
+
31
+ # mirror:
32
+ # service: Mirror
33
+ # primary: local
34
+ # mirrors: [ amazon, google, microsoft ]
data/spec/dummy/config.ru CHANGED
@@ -1,5 +1,6 @@
1
1
  # This file is used by Rack-based servers to start the application.
2
2
 
3
- require_relative 'config/environment'
3
+ require_relative "config/environment"
4
4
 
5
5
  run Rails.application
6
+ Rails.application.load_server
@@ -0,0 +1,22 @@
1
+ # This migration comes from active_storage (originally 20190112182829)
2
+ class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0]
3
+ def up
4
+ return unless table_exists?(:active_storage_blobs)
5
+
6
+ unless column_exists?(:active_storage_blobs, :service_name)
7
+ add_column :active_storage_blobs, :service_name, :string
8
+
9
+ if configured_service = ActiveStorage::Blob.service.name
10
+ ActiveStorage::Blob.unscoped.update_all(service_name: configured_service)
11
+ end
12
+
13
+ change_column :active_storage_blobs, :service_name, :string, null: false
14
+ end
15
+ end
16
+
17
+ def down
18
+ return unless table_exists?(:active_storage_blobs)
19
+
20
+ remove_column :active_storage_blobs, :service_name
21
+ end
22
+ end
@@ -0,0 +1,27 @@
1
+ # This migration comes from active_storage (originally 20191206030411)
2
+ class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0]
3
+ def change
4
+ return unless table_exists?(:active_storage_blobs)
5
+
6
+ # Use Active Record's configured type for primary key
7
+ create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t|
8
+ t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type
9
+ t.string :variation_digest, null: false
10
+
11
+ t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true
12
+ t.foreign_key :active_storage_blobs, column: :blob_id
13
+ end
14
+ end
15
+
16
+ private
17
+ def primary_key_type
18
+ config = Rails.configuration.generators
19
+ config.options[config.orm][:primary_key_type] || :primary_key
20
+ end
21
+
22
+ def blobs_primary_key_type
23
+ pkey_name = connection.primary_key(:active_storage_blobs)
24
+ pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name }
25
+ pkey_column.bigint? ? :bigint : pkey_column.type
26
+ end
27
+ end
@@ -2,15 +2,15 @@
2
2
  # of editing this file, please use the migrations feature of Active Record to
3
3
  # incrementally modify your database, and then regenerate this schema definition.
4
4
  #
5
- # Note that this schema.rb definition is the authoritative source for your
6
- # database schema. If you need to create the application database on another
7
- # system, you should be using db:schema:load, not running all the migrations
8
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
- # you'll amass, the slower it'll run and the greater likelihood for issues).
5
+ # This file is the source Rails uses to define your schema when running `bin/rails
6
+ # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7
+ # be faster and is potentially less error prone than running all of your
8
+ # migrations from scratch. Old migrations may fail to apply correctly if those
9
+ # migrations use external dependencies or application code.
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 2022_06_07_191519) do
13
+ ActiveRecord::Schema.define(version: 2023_04_06_194401) do
14
14
 
15
15
  create_table "active_storage_attachments", force: :cascade do |t|
16
16
  t.string "name", null: false
@@ -27,12 +27,19 @@ ActiveRecord::Schema.define(version: 2022_06_07_191519) do
27
27
  t.string "filename", null: false
28
28
  t.string "content_type"
29
29
  t.text "metadata"
30
- t.bigint "byte_size", null: false
30
+ t.integer "byte_size", null: false
31
31
  t.string "checksum", null: false
32
32
  t.datetime "created_at", null: false
33
+ t.string "service_name", null: false
33
34
  t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
34
35
  end
35
36
 
37
+ create_table "active_storage_variant_records", force: :cascade do |t|
38
+ t.integer "blob_id", null: false
39
+ t.string "variation_digest", null: false
40
+ t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
41
+ end
42
+
36
43
  create_table "multiple_asset_models", force: :cascade do |t|
37
44
  t.string "title"
38
45
  t.string "another_place", default: "[]"
@@ -47,4 +54,5 @@ ActiveRecord::Schema.define(version: 2022_06_07_191519) do
47
54
  t.datetime "updated_at", null: false
48
55
  end
49
56
 
57
+ add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
50
58
  end
data/tessa.gemspec CHANGED
@@ -23,12 +23,11 @@ Gem::Specification.new do |spec|
23
23
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
24
24
  spec.require_paths = ["lib"]
25
25
 
26
- spec.add_dependency "virtus", "~>1.0.4"
27
-
28
- spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rake", "~> 13"
29
27
  spec.add_development_dependency "rspec", "~> 3.1"
30
28
  spec.add_development_dependency "rspec_junit_formatter", "~> 0.4"
31
29
  spec.add_development_dependency "simplecov", "~> 0.15.1"
32
- spec.add_development_dependency "rails", "~> 5"
33
- spec.add_development_dependency 'sqlite3', '~> 1.3.6'
30
+ spec.add_development_dependency "rails", "~> 6"
31
+ spec.add_development_dependency 'sqlite3', '~> 1.4'
32
+ spec.add_development_dependency 'listen'
34
33
  end
data/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "compilerOptions": {
3
+ "strict": true,
4
+ "esModuleInterop": true,
5
+ "lib": [
6
+ "es2017",
7
+ "dom"
8
+ ]
9
+ }
10
+ }