souls 1.9.16 → 1.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5a37d4f87d7cc48d2ac150e9e2054535d92f18c973f111dbdbb1b4b0a12e495
4
- data.tar.gz: eb4731be85e6811c8cad06a608b84be0b9ec72245a78107b8379a1835683a0f7
3
+ metadata.gz: 2703fee83384f5326adf112016ffb812338d8f3081e2e19d50b5eadbaf0646d7
4
+ data.tar.gz: a44a5766473a61dcae61b16116b173c348a982aef965bc81c349424d0a27f57c
5
5
  SHA512:
6
- metadata.gz: 408873a10f3f415b3ccf4ffacd0bc5840cd7c1e42a9cbec6498790f0a56a15c5cde2ae816f0fd63c1608ab47bba678325224d872f3fc53de0f55dc1c0966fc1c
7
- data.tar.gz: 9d38726efbf8c1c9c13cdc141000c30e5b06324ded980b005ffe5ca68464c113b1012ee647e638053713548456b85dabb259573e22a953dfcd3193738498a823
6
+ metadata.gz: '019b27d42faf1793a622c0b807ac85bb9ddcfb133d2a027bdf342a40f0499081aae211d4898f99869ba6ae067623acf8388282326a1b0e3e7c39d748ea303dd7'
7
+ data.tar.gz: 2333639457301b3413bd916afb92a9ad71d24710a3964911ce043e73afb92f48be4499489e921e9e137139d4e593abd496e7324010dbf38ce5da8351d3d7b045
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
@@ -150,4 +150,4 @@ The gem is available as open source under the terms of the [Apache-2.0 License](
150
150
 
151
151
  ## Code of Conduct
152
152
 
153
- Everyone interacting in the HotelPrice project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/elsoul/souls/blob/master/CODE_OF_CONDUCT.md).
153
+ Everyone interacting in the Souls project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/elsoul/souls/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,18 @@
1
+ module Souls
2
+ class SoulsConnection < GraphQL::Types::Relay::BaseConnection
3
+ field :total_count, Integer, null: false do
4
+ description "Total number of items"
5
+ end
6
+ field :total_pages, Integer, null: false do
7
+ description "Total number of pages"
8
+ end
9
+
10
+ def total_count
11
+ object.items.size
12
+ end
13
+
14
+ def total_pages
15
+ (total_count / object.max_page_size) + 1
16
+ end
17
+ end
18
+ end
@@ -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
@@ -0,0 +1,6 @@
1
+ module Souls
2
+ module Types
3
+ class BaseArgument < GraphQL::Schema::Argument
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Souls
2
+ module Types
3
+ class BaseEnum < GraphQL::Schema::Enum
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ module Souls
2
+ module Types
3
+ class BaseField < GraphQL::Schema::Field
4
+ argument_class Souls::Types::BaseArgument
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Souls
2
+ module Types
3
+ class BaseInputObject < GraphQL::Schema::InputObject
4
+ argument_class Souls::Types::BaseArgument
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module Souls
2
+ module Types
3
+ module BaseInterface
4
+ include GraphQL::Schema::Interface
5
+
6
+ field_class Souls::Types::BaseField
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ module Souls
2
+ module Types
3
+ class BaseObject < GraphQL::Schema::Object
4
+ field_class Souls::Types::BaseField
5
+ connection_type_class Souls::SoulsConnection
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ module Souls
2
+ module Types
3
+ class BaseScalar < GraphQL::Schema::Scalar
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Souls
2
+ module Types
3
+ class BaseUnion < GraphQL::Schema::Union
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,11 @@
1
+ require_relative "base_argument"
2
+ require_relative "base_enum"
3
+ require_relative "base_field"
4
+ require_relative "base_input_object"
5
+ require_relative "base_interface"
6
+ require_relative "base_object"
7
+ require_relative "base_scalar"
8
+ require_relative "base_union"
9
+
10
+ module Souls
11
+ end
@@ -1,5 +1,9 @@
1
+ require_relative "graphql/souls_mutation"
1
2
  require_relative "graphql/souls_query"
3
+ require_relative "graphql/souls_connection"
2
4
  require_relative "utils/souls_logger"
5
+ require_relative "utils/firebase_id_token"
6
+ require_relative "graphql/types/index"
3
7
 
4
8
  module Souls
5
9
  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
@@ -48,7 +48,8 @@ module Souls
48
48
 
49
49
  def current_schedules
50
50
  current_schedules = {}
51
- `gcloud scheduler jobs list`.split("\n")[1..].each do |line|
51
+ jobs = `gcloud scheduler jobs list`
52
+ jobs.split("\n")[1..].each do |line|
52
53
  columns = line.split(/\t| {2,}/)
53
54
  job_name = columns[0].to_sym
54
55
  crontab = columns[2].split(" (")[0]
@@ -24,13 +24,13 @@ 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
31
31
  description "Search #{class_name.camelize}"
32
32
 
33
- class #{class_name.camelize}Filter < ::Types::BaseInputObject
33
+ class #{class_name.camelize}Filter < Souls::Types::BaseInputObject
34
34
  argument :OR, [self], required: false
35
35
  TEXT
36
36
  end
@@ -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
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.16".freeze
2
+ VERSION = "1.10.2".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 1.9.16
1
+ 1.10.2
@@ -1 +1 @@
1
- 1.9.16
1
+ 1.10.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.9.16
4
+ version: 1.10.2
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-30 00:00:00.000000000 Z
13
+ date: 2021-12-07 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
@@ -142,8 +156,20 @@ files:
142
156
  - README.md
143
157
  - exe/souls
144
158
  - lib/souls.rb
159
+ - lib/souls/app/graphql/souls_connection.rb
160
+ - lib/souls/app/graphql/souls_mutation.rb
145
161
  - lib/souls/app/graphql/souls_query.rb
162
+ - lib/souls/app/graphql/types/base_argument.rb
163
+ - lib/souls/app/graphql/types/base_enum.rb
164
+ - lib/souls/app/graphql/types/base_field.rb
165
+ - lib/souls/app/graphql/types/base_input_object.rb
166
+ - lib/souls/app/graphql/types/base_interface.rb
167
+ - lib/souls/app/graphql/types/base_object.rb
168
+ - lib/souls/app/graphql/types/base_scalar.rb
169
+ - lib/souls/app/graphql/types/base_union.rb
170
+ - lib/souls/app/graphql/types/index.rb
146
171
  - lib/souls/app/index.rb
172
+ - lib/souls/app/utils/firebase_id_token.rb
147
173
  - lib/souls/app/utils/souls_logger.rb
148
174
  - lib/souls/cli.rb
149
175
  - lib/souls/cli/cli_exception.rb