souls 1.18.0 → 1.18.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a9005c1b66ccc08bbc1997cbb81addf3489b5410717e88146e345db9fee8ca3
4
- data.tar.gz: 2e727f7b8adb1f7b7fa9fac25d1e93e355da3bdcb4240611f2e74c367888b70c
3
+ metadata.gz: 50b41a0d4b108ad9c396be84645e3ce9e1186440013ad9857ed9bb81577aee92
4
+ data.tar.gz: 71c20a1e9e73fdeb2193dd4212f9144b4a7337558c90d3fae14b1d1a8ea89c10
5
5
  SHA512:
6
- metadata.gz: 23bd0953ff05075cd6424540d7eaf71d91a62e253f03d0a54a248d78df7d4b0c41f004ee1821c3ed61e7075cd6e7788fdc804c8345aa53d50aa28cf8003a3ad5
7
- data.tar.gz: 4105a106fc7fac76f6786490ea8115429a416957831458f1f5c0b85f5deb82686974a7e8bb7dd1fbb9caa830e1a3ca92fbf79a5d0a48ec7559e56349398b1373
6
+ metadata.gz: ddde227e02b8750902cd723e2e19af03a6b13fb0ee6c167452c3ea66f8badd8d963fdba805b86c96a7b37164e9f572f00ce322d5e2e2c22358740c051e37244b
7
+ data.tar.gz: 0dac0da1e3390bea33551334408cb05afc9e9f07a71d784cb103932ec68fd227203eb3bf20b7ebe26a121d22e9f97e051f5b2e6c3ee664c64d3f021be0f79588
@@ -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.0".freeze
2
+ VERSION = "1.18.4".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 1.18.0
1
+ 1.18.4
@@ -1 +1 @@
1
- 1.18.0
1
+ 1.18.4
data/lib/souls.rb CHANGED
@@ -1,3 +1,6 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+ Bundler.require(:default)
1
4
  require_relative "souls/index"
2
5
  require_relative "souls/cli"
3
6
  require "active_support/core_ext/string/inflections"
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.0
4
+ version: 1.18.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI
@@ -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