mobile_workflow 0.6.16 → 0.6.21

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ebe0ad698dcd7a206d14a7437719ffbbf1775f57d45968b2a454bb6ebab00289
4
- data.tar.gz: bcc3c28476104eb9037b7621ad102e9cea81097ded5fbbdabf42686149b36cd3
3
+ metadata.gz: 974cb70825d3d8b73af77e17adaedf222d6e67e0b0940c0d7158dac1d3c12c3e
4
+ data.tar.gz: 35588fbd42ae9dacf7e0e0162df48d7442126c7e874efc14fa1fd440b7989dfb
5
5
  SHA512:
6
- metadata.gz: 0dcf01b7dd9c6914b3b3240cd43a04ecfad8b582653c08cb4c5f600c4002496f16c65f4347300dd60ff0c082d5c648f23cdcfe3982d0ec0e5586f507ac2b742f
7
- data.tar.gz: b5ee432e6d049dac79cb1d22f6e59b87204c853a7dcf589309b0d34fae9f2d7c5679454f976861ec40965c026d6bf29b3df8b9559c0c4c41404de0658a22a1fd
6
+ metadata.gz: b54532ff2c16360d7ec9b9bdd8e5b0fe22b793a41cad4c090a447c35c11f961949ab948c78afb89063eccc9c6f5622abc8db42812ee096734b9235916f45c537
7
+ data.tar.gz: 67d3a4b2889644571377b9bd1ef69a56ce5e0bc577e053cdd2f5915c877163632fd4b27354c8182af26e26e729d3de73d9bc47c1b165aee9381ae3d7d097b019
@@ -10,17 +10,27 @@ module MobileWorkflow
10
10
  when 'SubscriptionConfirmation'
11
11
  confirm_subscription ? (head :ok) : (head :bad_request)
12
12
  else
13
+ add_attachment
14
+ end
15
+ end
16
+
17
+ private
18
+ def add_attachment
19
+ begin
13
20
  @object = find_object
14
21
  @object.send("#{attribute_name}=",active_record_blob)
15
22
  if @object.save
16
23
  head :ok
17
24
  else
18
25
  Rails.logger.warn "Error saving object: #{@object} #{object.errors.full_messages}"
26
+ head :unprocessable_entity
19
27
  end
28
+ rescue NameError => e
29
+ Rails.logger.warn "Error attaching object: #{e.message}"
30
+ head :unprocessable_entity
20
31
  end
21
32
  end
22
-
23
- private
33
+
24
34
  def verify_request_authenticity
25
35
  head :unauthorized if raw_post.blank?
26
36
 
@@ -37,7 +37,7 @@ module MobileWorkflow
37
37
  image_url = "https://source.unsplash.com/#{unsplash_id}/800x600"
38
38
  end
39
39
 
40
- {type: :image, previewURL: image_url, url: image_url}
40
+ {type: :image, previewURL: image_url, url: image_url}.compact
41
41
  end
42
42
 
43
43
  def mw_display_video(attachment, preview_options: { resize_to_fill: [600, 1200] })
@@ -48,36 +48,39 @@ module MobileWorkflow
48
48
  validate_on_success!(on_success)
49
49
  validate_button_style!(style)
50
50
 
51
- {type: :button, label: label, style: style, onSuccess: on_success}
51
+ {type: :button, label: label, style: style, onSuccess: on_success}.compact
52
52
  end
53
53
 
54
54
  def mw_display_delete_button(url:, label: "Delete", method: :delete, style: :danger, on_success: :backward)
55
55
  validate_on_success!(on_success)
56
56
  validate_button_style!(style)
57
57
 
58
- {type: :button, label: label, url: url, method: method, style: style, onSuccess: on_success}
58
+ {type: :button, label: label, url: url, method: method, style: style, onSuccess: on_success}.compact
59
59
  end
60
-
61
- def mw_display_button_for_url(label:, url:, method: :put, style: :primary, on_success: :reload)
60
+
61
+ def mw_display_url_button(label:, url:, method: :put, style: :primary, confirm_title: nil, confirm_text: nil, on_success: :reload)
62
62
  validate_on_success!(on_success)
63
63
  validate_button_style!(style)
64
64
 
65
- {type: :button, label: label, url: url, method: method, style: style, onSuccess: on_success}
65
+ {type: :button, label: label, url: url, method: method, style: style, confirmTitle: confirm_title, confirmText: confirm_text, onSuccess: on_success}.compact
66
66
  end
67
+ alias_method :mw_display_button_for_url, :mw_display_url_button
67
68
 
68
- def mw_display_button_for_system_url(label:, apple_system_url:, method: :put, style: :primary, on_success: :none)
69
- validate_on_success!(on_success)
69
+ def mw_display_system_url_button(label:, apple_system_url: nil, android_deep_link: nil, style: :primary)
70
70
  validate_button_style!(style)
71
+ raise 'Invalid android_deep_link' unless android_deep_link.start_with?('http')
71
72
 
72
- {type: :button, label: label, appleSystemURL: apple_system_url, method: method, style: style, onSuccess: on_success}
73
+ {type: :button, label: label, appleSystemURL: apple_system_url, androidDeepLink: android_deep_link, style: style}.compact
73
74
  end
75
+ alias_method :mw_display_button_for_system_url, :mw_display_system_url_button
74
76
 
75
- def mw_display_button_for_modal_workflow(label:, modal_workflow_name:, style: :primary, on_success: :none)
77
+ def mw_display_modal_workflow_button(label:, modal_workflow_name:, style: :primary, on_success: :none)
76
78
  validate_on_success!(on_success)
77
79
  validate_button_style!(style)
78
80
 
79
- {type: :button, label: label, modalWorkflow: modal_workflow_name, style: style, onSuccess: on_success}
81
+ {type: :button, label: label, modalWorkflow: modal_workflow_name, style: style, onSuccess: on_success}.compact
80
82
  end
83
+ alias_method :mw_display_button_for_modal_workflow, :mw_display_modal_workflow_button
81
84
 
82
85
  private
83
86
  def validate_on_success!(on_success)
@@ -0,0 +1,5 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ include MobileWorkflow::Displayable
3
+
4
+ self.abstract_class = true
5
+ end
@@ -0,0 +1,9 @@
1
+ desc "Add S3 storage to your environment"
2
+ task add_heroku_s3_storage: :environment do
3
+ require 'mobile_workflow/cli'
4
+ app_name = ENV['APP_NAME']
5
+ aws = MobileWorkflow::Cli::AwsBackend.new(app_name: app_name)
6
+ heroku = MobileWorkflow::Cli::HerokuBackend(app_name: app_name)
7
+ aws.create
8
+ aws.create_topic_subscription(heroku.notifications_endpoint)
9
+ end
@@ -1,7 +1,5 @@
1
1
  <% module_namespacing do -%>
2
2
  class <%= class_name %> < <%= parent_class_name.classify %>
3
- include MobileWorkflow::Displayable
4
-
5
3
  <% attributes.select(&:reference?).each do |attribute| -%>
6
4
  belongs_to :<%= attribute.name %><%= ', polymorphic: true' if attribute.polymorphic? %>
7
5
  <% end -%>
@@ -1,5 +1,5 @@
1
1
  require "mobile_workflow/engine"
2
2
 
3
3
  module MobileWorkflow
4
- # Your code goes here...
4
+ require 'mobile_workflow/railtie' if defined?(Rails)
5
5
  end
@@ -58,7 +58,7 @@ module MobileWorkflow
58
58
 
59
59
  def model_property_type(property)
60
60
  return property["type"] unless property["type"].blank?
61
- return 'attachment' if property['$ref'] == "#/components/schemas/attachment"
61
+ return 'attachment' if property['$ref'] == "#/components/schemas/MWAttachment"
62
62
 
63
63
  raise "Unknown property type: #{property}"
64
64
  end
@@ -0,0 +1,13 @@
1
+ require 'mobile_workflow'
2
+ require 'rails'
3
+
4
+ module MobileWorkflow
5
+ class Railtie < Rails::Railtie
6
+ railtie_name :mobile_workflow
7
+
8
+ rake_tasks do
9
+ path = File.expand_path(__dir__)
10
+ Dir.glob("#{path}/tasks/**/*.rake").each { |f| load f }
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,58 @@
1
+ require 'json'
2
+
3
+ def each_step(json, type)
4
+ json['workflows'].map{|w| w["steps"].select {|s| s["type"] == type.to_s}}.flatten.each do |step|
5
+ yield(step)
6
+ end
7
+ end
8
+
9
+ def replace_oauth(app_json)
10
+ client_id = ENV["CLIENT_ID"]
11
+ client_secret = ENV["CLIENT_SECRET"]
12
+ redirect_scheme = ENV["SCHEME"]
13
+
14
+ each_step(app_json, :networkOAuth2) do |step|
15
+ step["items"].each do |item|
16
+ if item["oAuth2ClientId"]
17
+ item["oAuth2ClientId"] = client_id
18
+ item["oAuth2ClientSecret"] = client_secret
19
+ item["oAuth2RedirectScheme"] = redirect_scheme
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ def replace_servers(app_json)
26
+ server_url = ENV["SERVER_URL"]
27
+ base_url = ENV["PREVIOUS_SERVER_URL"]
28
+
29
+ app_json["servers"].each do |server|
30
+ server["url"] = server_url
31
+ end
32
+
33
+ each_step(app_json, :display) do |step|
34
+ step["items"].each do |item|
35
+ ["appleSystemURL", "androidDeepLink"].each{|key| item[key] = item[key].gsub(base_url, server_url) }
36
+ end
37
+ end
38
+ end
39
+
40
+ def env_set(path)
41
+ app_json = JSON.parse(File.read(app_json_path))
42
+ replace_oauth(app_json)
43
+ replace_servers(app_json)
44
+ File.write(app_json_path, app_json.to_json)
45
+ end
46
+
47
+ namespace :env_set do
48
+ desc 'Update Android app.json to use new env'
49
+ task :android do
50
+ env_set(File.join('app', 'src', 'main', 'res', 'raw', 'app.json'))
51
+ end
52
+
53
+ desc 'Update iOS app.json to use new env'
54
+ task :ios do
55
+ project_name = ENV["PROJECT_NAME"]
56
+ env_set(File.join(project_name, project_name, "Resources", "app.json"))
57
+ end
58
+ end
@@ -1,5 +1,5 @@
1
1
  module MobileWorkflow
2
- VERSION = '0.6.16'
2
+ VERSION = '0.6.21'
3
3
  RUBY_VERSION = '2.7.2'
4
4
  RAILS_VERSION = '6.1.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobile_workflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.16
4
+ version: 0.6.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brooke-Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-09 00:00:00.000000000 Z
11
+ date: 2021-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -112,10 +112,12 @@ files:
112
112
  - lib/generators/mobile_workflow/install/templates/ability.rb
113
113
  - lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
114
114
  - lib/generators/mobile_workflow/install/templates/app/helpers/application_helper.rb
115
+ - lib/generators/mobile_workflow/install/templates/app/models/application_record.rb
115
116
  - lib/generators/mobile_workflow/install/templates/app/views/layouts/application.html.erb
116
117
  - lib/generators/mobile_workflow/install/templates/app/views/sessions/new.html.erb
117
118
  - lib/generators/mobile_workflow/install/templates/create_users.rb
118
119
  - lib/generators/mobile_workflow/install/templates/lib/tasks/mobile_workflow_doorkeeper.rake
120
+ - lib/generators/mobile_workflow/install/templates/lib/tasks/mobile_workflow_s3.rake
119
121
  - lib/generators/mobile_workflow/install/templates/seeds.rb.erb
120
122
  - lib/generators/mobile_workflow/install/templates/sessions_controller.rb.erb
121
123
  - lib/generators/mobile_workflow/install/templates/spec/factories/users.rb
@@ -135,6 +137,8 @@ files:
135
137
  - lib/mobile_workflow/cli/heroku_backend.rb
136
138
  - lib/mobile_workflow/engine.rb
137
139
  - lib/mobile_workflow/open_api_spec/parser.rb
140
+ - lib/mobile_workflow/railtie.rb
141
+ - lib/mobile_workflow/tasks/env_set.rake
138
142
  - lib/mobile_workflow/version.rb
139
143
  homepage: https://github.com/futureworkshops/mobile_workflow
140
144
  licenses: