souls 1.9.14 → 1.10.0

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: f38e1e3e302943fc00240b194b97a78873e3940910521abec972381e5e0c6d5c
4
- data.tar.gz: 39dd708178403c48242142fa6c726c499667dcdae0cee92976ebe0c4ebbfc64d
3
+ metadata.gz: b6c497eec55aae48fa1912a49afaf7be8bf0dcd168d470f636e59c6e66673952
4
+ data.tar.gz: 8f65a33d00b9748c03b533e534c8b11a737445c8be576050d6ed6c394c652274
5
5
  SHA512:
6
- metadata.gz: 589ae3d10cd888a8fc49e63d9fd4f3c437cbb4c07f3ea1901315ca41c743aa84484346cdfd867c7417105e41e89dfd7bb53b56cac9dfe8e1af8bfb1aaaa653e3
7
- data.tar.gz: d456976d4d3781b12873db4ff5c4abc26faa42c48a0380b8030a28b2971b2815a0c4057b704b60a3c8a5275b450f5fd9bb7fb777c50c2286718de1fa8d88db98
6
+ metadata.gz: 681dd439e9da5f57011eb049952f3ccdf78a21827f21e1e376f21103a87177569824c6edb805d1fca7f9cd0aa89390c500dc21f7f1046fe401c472f7de27ec41
7
+ data.tar.gz: 05c940c0e58cf77cc90749a432a2860c2c98afa134956a5e6d06f24a405b394a7c5bedbacfb10e6b77862b116961fae2d90726fb89c32e76d54ede485752aeec
data/README.md CHANGED
@@ -52,7 +52,7 @@ Powered by Ruby GraphQL, RBS/Steep, Active Record, RSpec, RuboCop, and Google Cl
52
52
 
53
53
  ![SOULs Architecture](https://souls.elsoul.nl/imgs/docs/SOULs-architecture.jpg)
54
54
 
55
- SOULs creates 2 types of APP.
55
+ SOULs creates 2 types of App.
56
56
 
57
57
  1. API - GraphQL (Ruby) - Simple API - Cloud Run
58
58
  2. Worker - Google Pub/Sub Messaging Worker API (Ruby) - Cloud Run
@@ -0,0 +1,61 @@
1
+ module Souls
2
+ class SoulsMutation < GraphQL::Schema::RelayClassicMutation
3
+ def souls_fb_auth(token:)
4
+ FirebaseIdToken::Certificates.request!
5
+ sleep(3) if ENV["RACK_ENV"] == "development"
6
+ user = FirebaseIdToken::Signature.verify(token)
7
+ raise(ArgumentError, "Invalid or Missing Token") if user.blank?
8
+
9
+ user
10
+ end
11
+
12
+ def publish_pubsub_queue(topic_name: "send-mail-job", message: "text!")
13
+ pubsub = Google::Cloud::Pubsub.new(project: ENV["SOULS_GCP_PROJECT_ID"])
14
+ topic = pubsub.topic(topic_name)
15
+ topic.publish(message)
16
+ end
17
+
18
+ def make_graphql_query(query: "newCommentMailer", args: {})
19
+ if args.blank?
20
+ query_string = %(query { #{query.to_s.underscore.camelize(:lower)} { response } })
21
+ else
22
+ inputs = ""
23
+ args.each do |key, value|
24
+ inputs +=
25
+ if value.instance_of?(String)
26
+ "#{key.to_s.underscore.camelize(:lower)}: \"#{value}\" "
27
+ else
28
+ "#{key.to_s.underscore.camelize(:lower)}: #{value} "
29
+ end
30
+ end
31
+ query_string = %(query { #{query.to_s.underscore.camelize(:lower)}(#{inputs}) { response } })
32
+ end
33
+ query_string
34
+ end
35
+
36
+ def post_to_dev(worker_name: "", query_string: "")
37
+ app = Souls.configuration.app
38
+ port = get_worker(worker_name: "souls-#{app}-#{worker_name}")[0][:port]
39
+ endpoint = Souls.configuration.endpoint
40
+ res = Net::HTTP.post_form(URI.parse("http://localhost:#{port}#{endpoint}"), { query: query_string })
41
+ res.body
42
+ end
43
+
44
+ def get_worker(worker_name: "")
45
+ workers = Souls.configuration.workers
46
+ workers.filter { |n| n[:name] == worker_name }
47
+ end
48
+
49
+ def auth_check(context)
50
+ raise(GraphQL::ExecutionError, "You need to sign in!!") if context[:user].nil?
51
+ end
52
+
53
+ def production?
54
+ ENV["RACK_ENV"] == "production"
55
+ end
56
+
57
+ def get_instance_id
58
+ `curl http://metadata.google.internal/computeMetadata/v1/instance/id -H Metadata-Flavor:Google`
59
+ end
60
+ end
61
+ end
@@ -1,5 +1,7 @@
1
+ require_relative "graphql/souls_mutation"
1
2
  require_relative "graphql/souls_query"
2
3
  require_relative "utils/souls_logger"
4
+ require_relative "utils/firebase_id_token"
3
5
 
4
6
  module Souls
5
7
  end
@@ -0,0 +1,3 @@
1
+ FirebaseIdToken.configure do |config|
2
+ config.project_ids = [ENV["GCP_PROJECT_ID"]]
3
+ end
@@ -4,6 +4,7 @@ module Souls
4
4
  def psql
5
5
  system(
6
6
  "docker run --rm -d \
7
+ --name souls-psql \
7
8
  -p 5433:5432 \
8
9
  -v postgres-tmp:/var/lib/postgresql/data \
9
10
  -e POSTGRES_USER=postgres \
@@ -18,6 +19,7 @@ module Souls
18
19
  def mysql
19
20
  system(
20
21
  "docker run --rm -d \
22
+ --name souls-mysql \
21
23
  -p 3306:3306 \
22
24
  -v mysql-tmp:/var/lib/mysql \
23
25
  -e MYSQL_USER=mysql \
@@ -27,5 +29,11 @@ module Souls
27
29
  )
28
30
  system("docker ps")
29
31
  end
32
+
33
+ desc "redis", "Run Redis Docker Container"
34
+ def redis
35
+ system("docker run --rm -d --name souls-redis -p 6379:6379 redis:latest")
36
+ system("docker ps")
37
+ end
30
38
  end
31
39
  end
@@ -71,7 +71,7 @@ module Souls
71
71
  { yellow_text: [github_secret_url, :yellow], yellow_text2: [souls_doc_url, :yellow] }
72
72
  ]
73
73
  )
74
- FileUtils.rm(file_path)
74
+ FileUtils.rm_f(file_path)
75
75
  end
76
76
 
77
77
  def add_service_account_role(role: "roles/firebase.admin")
@@ -18,8 +18,7 @@ module Souls
18
18
  --topic-project #{project_id} \
19
19
  --push-auth-service-account #{service_account} \
20
20
  --push-endpoint #{options[:endpoint]} \
21
- --expiration-period never
22
- "
21
+ --expiration-period never"
23
22
  )
24
23
  end
25
24
 
@@ -24,7 +24,7 @@ module Souls
24
24
  File.open(file_path, "w") do |f|
25
25
  f.write(<<~TEXT)
26
26
  module Resolvers
27
- class #{class_name.camelize}Search < Base
27
+ class #{class_name.camelize}Search < BaseResolver
28
28
  include SearchObject.module(:graphql)
29
29
  scope { ::#{class_name.camelize}.all }
30
30
  type Types::#{class_name.camelize}Type.connection_type, null: false
@@ -78,8 +78,6 @@ module Souls
78
78
  end
79
79
 
80
80
  option :filter, type: #{class_name.camelize}Filter, with: :apply_filter
81
- option :first, type: types.Int, with: :apply_first
82
- option :skip, type: types.Int, with: :apply_skip
83
81
 
84
82
  def apply_filter(scope, value)
85
83
  branches = normalize_filters(value).inject { |a, b| a.or(b) }
@@ -12,15 +12,13 @@ module Souls
12
12
 
13
13
  File.open(file_path, "w") do |f|
14
14
  f.write(<<~TEXT)
15
- class Base
15
+ class BaseResolver
16
16
  end
17
- class #{singularized_class_name.camelize}Search < Base
17
+ class #{singularized_class_name.camelize}Search < BaseResolver
18
18
  include SearchObject
19
19
  def self.scope: () ?{ () -> nil } -> [Hash[Symbol, untyped]]
20
20
  def self.type: (*untyped) -> String
21
21
  def self.option: (:filter, type: untyped, with: :apply_filter) -> String
22
- | (:first, type: untyped, with: :apply_first) -> String
23
- | (:skip, type: untyped, with: :apply_skip) -> String
24
22
  def self.description: (String) -> String
25
23
  def self.types: (*untyped) -> String
26
24
  def decode_global_key: (String value) -> Integer
@@ -139,9 +139,9 @@ module Souls
139
139
  write_txt +=
140
140
  if gem[0] == "souls"
141
141
  if local
142
- " gem \"souls\", \"#{version}\", path: \"~/.local_souls/\"\n"
142
+ "gem \"souls\", \"#{version}\", path: \"~/.local_souls/\"\n"
143
143
  else
144
- " gem \"souls\", \"#{version}\"\n"
144
+ "gem \"souls\", \"#{version}\"\n"
145
145
  end
146
146
  else
147
147
  line
data/lib/souls/index.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require_relative "./version"
2
2
  require "thor"
3
3
  require "graphql"
4
+ require "firebase_id_token"
4
5
  require_relative "./cli/index"
5
6
  require_relative "./utils/index"
6
7
  require_relative "./app/index"
data/lib/souls/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "1.9.14".freeze
2
+ VERSION = "1.10.0".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 1.9.14
1
+ 1.10.0
@@ -1 +1 @@
1
- 1.9.14
1
+ 1.10.0
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.9.14
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-11-29 00:00:00.000000000 Z
13
+ date: 2021-12-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -40,6 +40,20 @@ dependencies:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
42
  version: 0.87.2
43
+ - !ruby/object:Gem::Dependency
44
+ name: firebase_id_token
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 2.4.0
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 2.4.0
43
57
  - !ruby/object:Gem::Dependency
44
58
  name: google-cloud-pubsub
45
59
  requirement: !ruby/object:Gem::Requirement
@@ -54,6 +68,20 @@ dependencies:
54
68
  - - ">="
55
69
  - !ruby/object:Gem::Version
56
70
  version: 2.8.0
71
+ - !ruby/object:Gem::Dependency
72
+ name: graphql
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: 1.12.19
78
+ type: :runtime
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 1.12.19
57
85
  - !ruby/object:Gem::Dependency
58
86
  name: paint
59
87
  requirement: !ruby/object:Gem::Requirement
@@ -128,8 +156,10 @@ files:
128
156
  - README.md
129
157
  - exe/souls
130
158
  - lib/souls.rb
159
+ - lib/souls/app/graphql/souls_mutation.rb
131
160
  - lib/souls/app/graphql/souls_query.rb
132
161
  - lib/souls/app/index.rb
162
+ - lib/souls/app/utils/firebase_id_token.rb
133
163
  - lib/souls/app/utils/souls_logger.rb
134
164
  - lib/souls/cli.rb
135
165
  - lib/souls/cli/cli_exception.rb