souls 1.18.1 → 1.18.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50c61510de150fa0ac46e4852e8d6af59668deb2fc8a7c0c2491910774c50a20
4
- data.tar.gz: a39e77bc5fef8a251082200229dee2c8352dc6f2eb4d7df2aba2fee8fad9b83d
3
+ metadata.gz: 5ba70edb311a90f1f057ff1f2b2c389b00a410ad70c71b65690fce6c99ed421b
4
+ data.tar.gz: 7b275943c3fa409bcf61afa5d9cec33d1851a41758c23ea9e05f8e3704d74e2f
5
5
  SHA512:
6
- metadata.gz: 3b41685999a25ea62021d66639b23a7bba886d1e6cb98cdbdcf93cb7f02afe763cbd0089ca0f68f734f46edf964669092972f32983157691b66aec0576bf14c8
7
- data.tar.gz: 5636763a73025f379157d0750f1a83136c1589fd58849be747ca5711da11e22b08ec3ef5ec6979ea2d785bd65541c4e02df0c6008deca2148ca5e8f59e408896
6
+ metadata.gz: ecfc23cc35de0ff0445222441a0a8650098cca66de7f688e513bf8a4a2ef2fa771e4214939962f9e0a3e7205898504dfc66a1fd41dbf59036a5cd555677d1034
7
+ data.tar.gz: 594e93876a6cab03cc3d5a4fd95c7f74f9a913cacb264413aad36e141f68be1cc8e91f9eb419649c1e742aab5f8097a9fa5815fa8754de9cea7254b7e6790d52
@@ -1,6 +1,15 @@
1
1
  module SOULs
2
2
  class SOULsMutation < GraphQL::Schema::RelayClassicMutation
3
- def souls_fb_auth(token:)
3
+ def self.souls_check_user_permissions(user, obj, method)
4
+ raise(StandardError, "Invalid or Missing Token") unless user
5
+
6
+ policy_class = obj.class.name + "Policy"
7
+ policy_clazz = policy_class.constantize.new(user, obj)
8
+ permission = policy_clazz.public_send(method)
9
+ raise(Pundit::NotAuthorizedError, "permission error!") unless permission
10
+ end
11
+
12
+ def self.souls_fb_auth(token:)
4
13
  FirebaseIdToken::Certificates.request!
5
14
  sleep(3) if ENV["RACK_ENV"] == "development"
6
15
  user = FirebaseIdToken::Signature.verify(token)
@@ -9,13 +18,13 @@ module SOULs
9
18
  user
10
19
  end
11
20
 
12
- def publish_pubsub_queue(topic_name: "send-mail-job", message: "text!")
21
+ def self.souls_publish_pubsub_queue(topic_name: "send-mail-job", message: "text!")
13
22
  pubsub = Google::Cloud::Pubsub.new(project: ENV["SOULS_GCP_PROJECT_ID"])
14
23
  topic = pubsub.topic(topic_name)
15
24
  topic.publish(message)
16
25
  end
17
26
 
18
- def make_graphql_query(query: "newCommentMailer", args: {})
27
+ def self.souls_make_graphql_query(query: "newCommentMailer", args: {})
19
28
  if args.blank?
20
29
  query_string = %(query { #{query.to_s.underscore.camelize(:lower)} { response } })
21
30
  else
@@ -33,20 +42,20 @@ module SOULs
33
42
  query_string
34
43
  end
35
44
 
36
- def post_to_dev(worker_name: "", query_string: "")
45
+ def self.souls_post_to_dev(worker_name: "", query_string: "")
37
46
  app = SOULs.configuration.app
38
- port = get_worker(worker_name: "souls-#{app}-#{worker_name}")[0][:port]
47
+ port = souls_get_worker(worker_name: "souls-#{app}-#{worker_name}")[0][:port]
39
48
  endpoint = SOULs.configuration.endpoint
40
49
  res = Net::HTTP.post_form(URI.parse("http://localhost:#{port}#{endpoint}"), { query: query_string })
41
50
  res.body
42
51
  end
43
52
 
44
- def get_worker(worker_name: "")
53
+ def self.souls_get_worker(worker_name: "")
45
54
  workers = SOULs.configuration.workers
46
55
  workers.filter { |n| n[:name] == worker_name }
47
56
  end
48
57
 
49
- def auth_check(context)
58
+ def self.souls_auth_check(context)
50
59
  raise(GraphQL::ExecutionError, "You need to sign in!!") if context[:user].nil?
51
60
  end
52
61
 
@@ -5,6 +5,15 @@ module SOULs
5
5
  attr_accessor :schedule
6
6
  end
7
7
 
8
+ def self.check_user_permissions(user, obj, method)
9
+ raise(StandardError, "Invalid or Missing Token") unless user
10
+
11
+ policy_class = obj.class.name + "Policy"
12
+ policy_clazz = policy_class.constantize.new(user, obj)
13
+ permission = policy_clazz.public_send(method)
14
+ raise(Pundit::NotAuthorizedError, "permission error!") unless permission
15
+ end
16
+
8
17
  def self.cron(schedule)
9
18
  self.schedule = schedule
10
19
  end
@@ -3,6 +3,17 @@ module SOULs
3
3
  class BaseObject < GraphQL::Schema::Object
4
4
  field_class SOULs::Types::BaseField
5
5
  connection_type_class SOULs::SOULsConnection
6
+
7
+ def self.get_tables
8
+ path = "./db/schema.rb"
9
+ tables = []
10
+ File.open(path, "r") do |f|
11
+ f.each_line.with_index do |line, _i|
12
+ tables << line.split("\"")[1] if line.include?("create_table")
13
+ end
14
+ end
15
+ tables
16
+ end
6
17
  end
7
18
  end
8
19
  end
@@ -6,6 +6,8 @@ require_relative "base_interface"
6
6
  require_relative "base_object"
7
7
  require_relative "base_scalar"
8
8
  require_relative "base_union"
9
+ require_relative "mutation_object"
10
+ require_relative "query_object"
9
11
 
10
12
  module SOULs
11
13
  end
@@ -0,0 +1,35 @@
1
+ module SOULs
2
+ module Types
3
+ class MutationObject < SOULs::Types::BaseObject
4
+ unless FileUtils.pwd.split("/").last == "souls"
5
+ get_tables.each do |t|
6
+ %w[create update delete destroy_delete].each do |a|
7
+ field "#{a}_#{t.singularize.underscore}".to_sym,
8
+ mutation: Object.const_get(
9
+ "Mutations::Base::#{t.singularize.camelize}::#{a.camelize}#{t.singularize.camelize}"
10
+ )
11
+ end
12
+ end
13
+ managers =
14
+ Dir["./app/graphql/mutations/managers/*_manager/*.rb"].map do |file|
15
+ dir_name = file.scan(%r{managers/(.+?)_manager}).flatten[0]
16
+ file_name = file.scan(%r{/([^/]+)/?$}).flatten[0].gsub(".rb", "")
17
+ {
18
+ class: dir_name,
19
+ name: file_name
20
+ }
21
+ end
22
+ managers.each do |file|
23
+ field file[:name].underscore.to_s.to_sym,
24
+ mutation: Object.const_get(
25
+ "Mutations::Managers::#{
26
+ file[:class].singularize.camelize
27
+ }Manager::#{
28
+ file[:name].singularize.camelize
29
+ }"
30
+ )
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,18 @@
1
+ module SOULs
2
+ module Types
3
+ class QueryObject < SOULs::Types::BaseObject
4
+ unless FileUtils.pwd.split("/").last == "souls"
5
+ add_field(GraphQL::Types::Relay::NodeField)
6
+ add_field(GraphQL::Types::Relay::NodesField)
7
+ get_tables.each do |t|
8
+ field t.singularize.underscore.to_s.to_sym, resolver: Object.const_get("Queries::#{t.singularize.camelize}")
9
+ field "#{t.singularize.underscore}_search".to_sym,
10
+ resolver: Object.const_get("Resolvers::#{t.singularize.camelize}Search")
11
+ field t.pluralize.underscore.to_s.to_sym,
12
+ Object.const_get("Types::#{t.singularize.camelize}Type").connection_type,
13
+ null: true
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -169,7 +169,7 @@ module SOULs
169
169
  FileUtils.rm(sig_name)
170
170
  end
171
171
 
172
- def souls_api_credit(app_name)
172
+ def souls_api_credit(_app_name)
173
173
  line = Paint["====================================", :yellow]
174
174
  puts("\n")
175
175
  puts(line)
@@ -194,8 +194,6 @@ module SOULs
194
194
  puts(line)
195
195
  endroll = <<~TEXT
196
196
  Easy to Run
197
- $ cd #{app_name}
198
- $ souls check
199
197
  $ cd apps/api
200
198
  $ souls s
201
199
  Go To : http://localhost:4000
data/lib/souls/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module SOULs
2
- VERSION = "1.18.1".freeze
2
+ VERSION = "1.18.5".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 1.18.1
1
+ 1.18.5
@@ -1 +1 @@
1
- 1.18.1
1
+ 1.18.5
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: souls
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.1
4
+ version: 1.18.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: 6.1.4
21
+ version: 7.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: 6.1.4
28
+ version: 7.0.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: foreman
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -167,6 +167,8 @@ files:
167
167
  - lib/souls/app/graphql/types/base_scalar.rb
168
168
  - lib/souls/app/graphql/types/base_union.rb
169
169
  - lib/souls/app/graphql/types/index.rb
170
+ - lib/souls/app/graphql/types/mutation_object.rb
171
+ - lib/souls/app/graphql/types/query_object.rb
170
172
  - lib/souls/app/index.rb
171
173
  - lib/souls/app/utils/firebase_id_token.rb
172
174
  - lib/souls/app/utils/painter.rb