souls 1.18.1 → 1.18.2
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 +4 -4
- data/lib/souls/app/graphql/souls_mutation.rb +16 -7
- data/lib/souls/app/graphql/souls_query.rb +9 -0
- data/lib/souls/app/graphql/types/base_object.rb +11 -0
- data/lib/souls/app/graphql/types/mutation_object.rb +29 -0
- data/lib/souls/app/graphql/types/query_object.rb +16 -0
- data/lib/souls/version.rb +1 -1
- data/lib/souls/versions/.souls_api_version +1 -1
- data/lib/souls/versions/.souls_worker_version +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 76cf8f87a732809e9d391db6d649b6f432811c43e27c8958e35588be10345d82
|
|
4
|
+
data.tar.gz: f5d261beee788956c05c8a1f18b92ba00e54e676ff8d80407e5b778f56808e81
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 680a29548c55d7862cd76b1bb68c47386e7416d71084f3559a7a6fbb2847d287e6df099d4612e4fb5c9bf15e2a0bc25335b16f852561ea051e7d79ff6ce84341
|
|
7
|
+
data.tar.gz: d2e6906c5eacb6745cedbdef3428f37d8f13eee75a21e199f2f5e7e7762e0ae233033bd7c2030783d4e18dc47fd68243901f8fe1f766ebcf2c9c038e6cfecedb
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
module SOULs
|
|
2
2
|
class SOULsMutation < GraphQL::Schema::RelayClassicMutation
|
|
3
|
-
def
|
|
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
|
|
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
|
|
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
|
|
45
|
+
def self.souls_post_to_dev(worker_name: "", query_string: "")
|
|
37
46
|
app = SOULs.configuration.app
|
|
38
|
-
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
|
|
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
|
|
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
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module SOULs
|
|
2
|
+
module Types
|
|
3
|
+
class MutationObject < SOULs::Types::BaseObject
|
|
4
|
+
get_tables.each do |t|
|
|
5
|
+
%w[create update delete destroy_delete].each do |a|
|
|
6
|
+
field "#{a}_#{t.singularize.underscore}".to_sym,
|
|
7
|
+
mutation: Object.const_get(
|
|
8
|
+
"Mutations::Base::#{t.singularize.camelize}::#{a.camelize}#{t.singularize.camelize}"
|
|
9
|
+
)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
managers =
|
|
13
|
+
Dir["./app/graphql/mutations/managers/*_manager/*.rb"].map do |file|
|
|
14
|
+
dir_name = file.scan(%r{managers/(.+?)_manager}).flatten[0]
|
|
15
|
+
file_name = file.scan(%r{/([^/]+)/?$}).flatten[0].gsub(".rb", "")
|
|
16
|
+
{
|
|
17
|
+
class: dir_name,
|
|
18
|
+
name: file_name
|
|
19
|
+
}
|
|
20
|
+
end
|
|
21
|
+
managers.each do |file|
|
|
22
|
+
field file[:name].underscore.to_s.to_sym,
|
|
23
|
+
mutation: Object.const_get(
|
|
24
|
+
"Mutations::Managers::#{file[:class].singularize.camelize}Manager::#{file[:name].singularize.camelize}"
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module SOULs
|
|
2
|
+
module Types
|
|
3
|
+
class QueryObject < SOULs::Types::BaseObject
|
|
4
|
+
add_field(GraphQL::Types::Relay::NodeField)
|
|
5
|
+
add_field(GraphQL::Types::Relay::NodesField)
|
|
6
|
+
get_tables.each do |t|
|
|
7
|
+
field t.singularize.underscore.to_s.to_sym, resolver: Object.const_get("Queries::#{t.singularize.camelize}")
|
|
8
|
+
field "#{t.singularize.underscore}_search".to_sym,
|
|
9
|
+
resolver: Object.const_get("Resolvers::#{t.singularize.camelize}Search")
|
|
10
|
+
field t.pluralize.underscore.to_s.to_sym,
|
|
11
|
+
Object.const_get("Types::#{t.singularize.camelize}Type").connection_type,
|
|
12
|
+
null: true
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/souls/version.rb
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.18.
|
|
1
|
+
1.18.2
|
|
@@ -1 +1 @@
|
|
|
1
|
-
1.18.
|
|
1
|
+
1.18.2
|
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.
|
|
4
|
+
version: 1.18.2
|
|
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
|