parse-stack 1.8.0 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.solargraph.yml +23 -0
- data/.travis.yml +0 -1
- data/Gemfile +13 -12
- data/Gemfile.lock +88 -51
- data/README.md +2 -4
- data/Rakefile +14 -14
- data/lib/parse/api/aggregate.rb +4 -7
- data/lib/parse/api/all.rb +1 -1
- data/lib/parse/api/analytics.rb +0 -3
- data/lib/parse/api/batch.rb +3 -5
- data/lib/parse/api/cloud_functions.rb +0 -3
- data/lib/parse/api/config.rb +0 -4
- data/lib/parse/api/files.rb +3 -7
- data/lib/parse/api/hooks.rb +4 -8
- data/lib/parse/api/objects.rb +7 -12
- data/lib/parse/api/push.rb +0 -4
- data/lib/parse/api/schema.rb +2 -6
- data/lib/parse/api/server.rb +4 -7
- data/lib/parse/api/sessions.rb +2 -5
- data/lib/parse/api/users.rb +9 -14
- data/lib/parse/client.rb +54 -50
- data/lib/parse/client/authentication.rb +29 -33
- data/lib/parse/client/batch.rb +8 -11
- data/lib/parse/client/body_builder.rb +19 -20
- data/lib/parse/client/caching.rb +23 -28
- data/lib/parse/client/protocol.rb +11 -12
- data/lib/parse/client/request.rb +4 -6
- data/lib/parse/client/response.rb +5 -7
- data/lib/parse/model/acl.rb +14 -12
- data/lib/parse/model/associations/belongs_to.rb +14 -21
- data/lib/parse/model/associations/collection_proxy.rb +328 -329
- data/lib/parse/model/associations/has_many.rb +18 -25
- data/lib/parse/model/associations/has_one.rb +6 -11
- data/lib/parse/model/associations/pointer_collection_proxy.rb +5 -8
- data/lib/parse/model/associations/relation_collection_proxy.rb +5 -9
- data/lib/parse/model/bytes.rb +8 -10
- data/lib/parse/model/classes/installation.rb +2 -4
- data/lib/parse/model/classes/product.rb +2 -5
- data/lib/parse/model/classes/role.rb +3 -5
- data/lib/parse/model/classes/session.rb +2 -5
- data/lib/parse/model/classes/user.rb +20 -16
- data/lib/parse/model/core/actions.rb +31 -46
- data/lib/parse/model/core/builder.rb +6 -6
- data/lib/parse/model/core/errors.rb +0 -1
- data/lib/parse/model/core/fetching.rb +45 -50
- data/lib/parse/model/core/properties.rb +51 -66
- data/lib/parse/model/core/querying.rb +291 -294
- data/lib/parse/model/core/schema.rb +89 -92
- data/lib/parse/model/date.rb +16 -17
- data/lib/parse/model/file.rb +171 -174
- data/lib/parse/model/geopoint.rb +12 -16
- data/lib/parse/model/model.rb +31 -37
- data/lib/parse/model/object.rb +47 -53
- data/lib/parse/model/pointer.rb +177 -176
- data/lib/parse/model/push.rb +8 -10
- data/lib/parse/model/shortnames.rb +1 -2
- data/lib/parse/model/time_zone.rb +3 -5
- data/lib/parse/query.rb +34 -35
- data/lib/parse/query/constraint.rb +4 -6
- data/lib/parse/query/constraints.rb +21 -29
- data/lib/parse/query/operation.rb +8 -11
- data/lib/parse/query/ordering.rb +45 -49
- data/lib/parse/stack.rb +11 -12
- data/lib/parse/stack/generators/rails.rb +28 -30
- data/lib/parse/stack/generators/templates/model.erb +5 -6
- data/lib/parse/stack/generators/templates/model_installation.rb +0 -1
- data/lib/parse/stack/generators/templates/model_role.rb +0 -1
- data/lib/parse/stack/generators/templates/model_session.rb +0 -1
- data/lib/parse/stack/generators/templates/model_user.rb +0 -1
- data/lib/parse/stack/generators/templates/parse.rb +9 -9
- data/lib/parse/stack/generators/templates/webhooks.rb +1 -2
- data/lib/parse/stack/railtie.rb +2 -4
- data/lib/parse/stack/tasks.rb +70 -86
- data/lib/parse/stack/version.rb +1 -1
- data/lib/parse/webhooks.rb +19 -26
- data/lib/parse/webhooks/payload.rb +26 -28
- data/lib/parse/webhooks/registration.rb +23 -31
- data/parse-stack.gemspec +25 -25
- data/parse-stack.png +0 -0
- metadata +13 -7
- data/.github/parse-ruby-sdk.png +0 -0
@@ -1,9 +1,8 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
|
4
|
+
require "active_support"
|
5
|
+
require "active_support/inflector"
|
7
6
|
|
8
7
|
module Parse
|
9
8
|
|
@@ -36,7 +35,7 @@ module Parse
|
|
36
35
|
|
37
36
|
# Whether this operation is defined properly.
|
38
37
|
def valid?
|
39
|
-
!
|
38
|
+
!(@operand.nil? || @operator.nil? || handler.nil?)
|
40
39
|
end
|
41
40
|
|
42
41
|
# @return [Parse::Constraint] the constraint class designed to handle
|
@@ -69,13 +68,11 @@ module Parse
|
|
69
68
|
|
70
69
|
# Register a new symbol operator method mapped to a specific {Parse::Constraint}.
|
71
70
|
def self.register(op, klass)
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
71
|
+
Operation.operators[op.to_sym] = klass
|
72
|
+
Symbol.send :define_method, op do |value = nil|
|
73
|
+
operation = Operation.new self, op
|
74
|
+
value.nil? ? operation : operation.constraint(value)
|
75
|
+
end
|
77
76
|
end
|
78
|
-
|
79
77
|
end
|
80
|
-
|
81
78
|
end
|
data/lib/parse/query/ordering.rb
CHANGED
@@ -1,62 +1,59 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
4
|
module Parse
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
# @!attribute [rw] field
|
25
|
-
# @return [Symbol] the name of the field
|
26
|
-
attr_accessor :field
|
5
|
+
# This class adds support for describing ordering for Parse queries. You can
|
6
|
+
# either order by ascending (asc) or descending (desc) order.
|
7
|
+
#
|
8
|
+
# Ordering is implemented similarly to constraints in which we add
|
9
|
+
# special methods to the Symbol class. The developer can then pass one
|
10
|
+
# or an array of fields (as symbols) and call the particular ordering
|
11
|
+
# polarity (ex. _:name.asc_ would create a Parse::Order where we want
|
12
|
+
# things to be sortd by the name field in ascending order)
|
13
|
+
# For more information about the query design pattern from DataMapper
|
14
|
+
# that inspired this, see http://datamapper.org/docs/find.html'
|
15
|
+
# @example
|
16
|
+
# :name.asc # => Parse::Order by ascending :name
|
17
|
+
# :like_count.desc # => Parse::Order by descending :like_count
|
18
|
+
#
|
19
|
+
class Order
|
20
|
+
# The Parse operators to indicate ordering direction.
|
21
|
+
ORDERING = { asc: "", desc: "-" }.freeze
|
27
22
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
attr_accessor :direction
|
23
|
+
# @!attribute [rw] field
|
24
|
+
# @return [Symbol] the name of the field
|
25
|
+
attr_accessor :field
|
32
26
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
27
|
+
# @!attribute [rw] direction
|
28
|
+
# The direction of the sorting. This is either `:asc` or `:desc`.
|
29
|
+
# @return [Symbol]
|
30
|
+
attr_accessor :direction
|
37
31
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
# @return [String] the sort direction
|
43
|
-
def polarity
|
44
|
-
ORDERING[@direction] || ORDERING[:asc]
|
45
|
-
end # polarity
|
32
|
+
def initialize(field, order = :asc)
|
33
|
+
@field = field.to_sym || :objectId
|
34
|
+
@direction = order
|
35
|
+
end
|
46
36
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
polarity + @field.to_s
|
51
|
-
end
|
37
|
+
def field=(f)
|
38
|
+
@field = f.to_sym
|
39
|
+
end
|
52
40
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
41
|
+
# @return [String] the sort direction
|
42
|
+
def polarity
|
43
|
+
ORDERING[@direction] || ORDERING[:asc]
|
44
|
+
end # polarity
|
57
45
|
|
58
|
-
|
46
|
+
# @return [String] the ordering as a string
|
47
|
+
def to_s
|
48
|
+
"" if @field.nil?
|
49
|
+
polarity + @field.to_s
|
50
|
+
end
|
59
51
|
|
52
|
+
# @!visibility private
|
53
|
+
def inspect
|
54
|
+
"#{@direction.to_s}(#{@field.inspect})"
|
55
|
+
end
|
56
|
+
end # Order
|
60
57
|
end
|
61
58
|
|
62
59
|
# Extension to add all the operator instance methods to the Symbol classe
|
@@ -66,5 +63,4 @@ class Symbol
|
|
66
63
|
Parse::Order.new self, sym
|
67
64
|
end
|
68
65
|
end # each
|
69
|
-
|
70
66
|
end
|
data/lib/parse/stack.rb
CHANGED
@@ -2,18 +2,17 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require_relative "stack/version"
|
5
|
-
require_relative
|
6
|
-
require_relative
|
7
|
-
require_relative
|
8
|
-
require_relative
|
9
|
-
|
5
|
+
require_relative "client"
|
6
|
+
require_relative "query"
|
7
|
+
require_relative "model/object"
|
8
|
+
require_relative "webhooks"
|
10
9
|
|
11
10
|
module Parse
|
12
|
-
class Error < StandardError; end
|
13
|
-
module Stack
|
11
|
+
class Error < StandardError; end
|
14
12
|
|
13
|
+
module Stack
|
15
14
|
end
|
16
|
-
|
15
|
+
|
17
16
|
# Special class to support Modernistik Hyperdrive server.
|
18
17
|
class Hyperdrive
|
19
18
|
# Applies a remote JSON hash containing the ENV keys and values from a remote
|
@@ -23,11 +22,11 @@ module Parse
|
|
23
22
|
# @param url [String] the remote url that responds with the JSON body.
|
24
23
|
# @return [Boolean] true if the JSON hash was found and applied successfully.
|
25
24
|
def self.config!(url = nil)
|
26
|
-
url ||= ENV["HYPERDRIVE_URL"] || ENV[
|
25
|
+
url ||= ENV["HYPERDRIVE_URL"] || ENV["CONFIG_URL"]
|
27
26
|
if url.present?
|
28
27
|
begin
|
29
|
-
remote_config = JSON.load open(
|
30
|
-
remote_config.each do |key,value|
|
28
|
+
remote_config = JSON.load open(url)
|
29
|
+
remote_config.each do |key, value|
|
31
30
|
k = key.upcase
|
32
31
|
next unless ENV[k].nil?
|
33
32
|
ENV[k] ||= value.to_s
|
@@ -42,4 +41,4 @@ module Parse
|
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
45
|
-
require_relative
|
44
|
+
require_relative "stack/railtie" if defined?(::Rails)
|
@@ -1,42 +1,40 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
4
|
+
require "parse/stack"
|
5
|
+
require "parse/stack/tasks"
|
6
|
+
require "rails/generators"
|
7
|
+
require "rails/generators/named_base"
|
8
8
|
|
9
9
|
# Module namespace to show up in the generators list for Rails.
|
10
10
|
module ParseStack
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
desc "This generator creates an initializer file at config/initializers"
|
16
|
-
# @!visibility private
|
17
|
-
def generate_initializer
|
18
|
-
copy_file "parse.rb", "config/initializers/parse.rb"
|
19
|
-
copy_file "model_user.rb", File.join("app/models", "user.rb")
|
20
|
-
copy_file "model_role.rb", File.join("app/models", "role.rb")
|
21
|
-
copy_file "model_session.rb", File.join("app/models", "session.rb")
|
22
|
-
copy_file "model_installation.rb", File.join("app/models", "installation.rb")
|
23
|
-
copy_file "webhooks.rb", File.join("app/models", "webhooks.rb")
|
24
|
-
end
|
25
|
-
end
|
11
|
+
# Adds support for rails when installing Parse::Stack to a Rails project.
|
12
|
+
class InstallGenerator < Rails::Generators::Base
|
13
|
+
source_root File.expand_path("../templates", __FILE__)
|
26
14
|
|
15
|
+
desc "This generator creates an initializer file at config/initializers"
|
27
16
|
# @!visibility private
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
17
|
+
def generate_initializer
|
18
|
+
copy_file "parse.rb", "config/initializers/parse.rb"
|
19
|
+
copy_file "model_user.rb", File.join("app/models", "user.rb")
|
20
|
+
copy_file "model_role.rb", File.join("app/models", "role.rb")
|
21
|
+
copy_file "model_session.rb", File.join("app/models", "session.rb")
|
22
|
+
copy_file "model_installation.rb", File.join("app/models", "installation.rb")
|
23
|
+
copy_file "webhooks.rb", File.join("app/models", "webhooks.rb")
|
24
|
+
end
|
25
|
+
end
|
33
26
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
27
|
+
# @!visibility private
|
28
|
+
class ModelGenerator < Rails::Generators::NamedBase
|
29
|
+
source_root File.expand_path(__dir__ + "/templates")
|
30
|
+
desc "Creates a Parse::Object model subclass."
|
31
|
+
argument :attributes, type: :array, default: [], banner: "field:type field:type"
|
32
|
+
check_class_collision
|
39
33
|
|
34
|
+
# @!visibility private
|
35
|
+
def create_model_file
|
36
|
+
@allowed_types = Parse::Properties::TYPES - [:acl, :id, :relation]
|
37
|
+
template "model.erb", File.join("app/models", class_path, "#{file_name}.rb")
|
40
38
|
end
|
41
|
-
|
39
|
+
end
|
42
40
|
end
|
@@ -5,12 +5,11 @@ class <%= class_name %> < Parse::Object
|
|
5
5
|
# You can change the inferred Parse table/collection name below
|
6
6
|
# parse_class "<%= class_name.to_s.to_parse_class %>"
|
7
7
|
<% attributes.each do |attr|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
%>
|
8
|
+
parse_type = attr.type.to_s.downcase.to_sym
|
9
|
+
unless @allowed_types.include?(parse_type)
|
10
|
+
puts "\n[Warning] Skipping property `#{attr.name}` with type `#{parse_type}`. Type should be one of #{@allowed_types}."
|
11
|
+
next
|
12
|
+
end %>
|
14
13
|
property :<%= attr.name %>, :<%= parse_type -%>
|
15
14
|
<% end %>
|
16
15
|
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
1
|
+
require "parse/stack"
|
2
2
|
|
3
3
|
# Set your specific Parse keys in your ENV. For all connection options, see
|
4
4
|
# https://github.com/modernistik/parse-stack#connection-setup
|
5
|
-
Parse.setup app_id: ENV[
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
Parse.setup app_id: ENV["PARSE_SERVER_APPLICATION_ID"],
|
6
|
+
api_key: ENV["PARSE_SERVER_REST_API_KEY"],
|
7
|
+
master_key: ENV["PARSE_SERVER_MASTER_KEY"], # optional
|
8
|
+
server_url: "https://localhost:1337/parse"
|
9
|
+
# optional
|
10
|
+
# logging: false,
|
11
|
+
# cache: Moneta.new(:File, dir: 'tmp/cache'),
|
12
|
+
# expires: 1 # cache ttl 1 second
|
@@ -1,8 +1,7 @@
|
|
1
|
-
|
2
1
|
# See: https://github.com/modernistik/parse-stack#cloud-code-webhooks
|
3
2
|
Parse::Webhooks.route(:function, :helloWorld) do
|
4
3
|
# use the Parse::Payload instance methods in this block
|
5
|
-
name = params[
|
4
|
+
name = params["name"].to_s #function params
|
6
5
|
|
7
6
|
# will return proper error response
|
8
7
|
# error!("Missing argument 'name'.") unless name.present?
|
data/lib/parse/stack/railtie.rb
CHANGED
@@ -5,16 +5,14 @@ module Parse
|
|
5
5
|
module Stack
|
6
6
|
# Support for adding rake tasks to a Rails project.
|
7
7
|
class Railtie < ::Rails::Railtie
|
8
|
-
|
9
8
|
rake_tasks do
|
10
|
-
require_relative
|
9
|
+
require_relative "tasks"
|
11
10
|
Parse::Stack.load_tasks
|
12
11
|
end
|
13
12
|
|
14
13
|
generators do
|
15
|
-
require_relative
|
14
|
+
require_relative "generators/rails"
|
16
15
|
end
|
17
|
-
|
18
16
|
end
|
19
17
|
end
|
20
18
|
end
|
data/lib/parse/stack/tasks.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require_relative
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
4
|
+
require_relative "../stack.rb"
|
5
|
+
require "active_support"
|
6
|
+
require "active_support/inflector"
|
7
|
+
require "active_support/core_ext"
|
8
|
+
require "rake"
|
9
|
+
require "rake/dsl_definition"
|
10
10
|
|
11
11
|
module Parse
|
12
|
-
|
13
12
|
module Stack
|
14
13
|
# Loads and installs all Parse::Stack related tasks in a rake file.
|
15
14
|
def self.load_tasks
|
@@ -22,42 +21,36 @@ module Parse
|
|
22
21
|
|
23
22
|
# Installs the rake tasks.
|
24
23
|
def install_tasks
|
25
|
-
|
26
24
|
if defined?(::Rails)
|
27
|
-
unless Rake::Task.task_defined?(
|
25
|
+
unless Rake::Task.task_defined?("db:seed") || Rails.root.blank?
|
28
26
|
namespace :db do
|
29
27
|
desc "Seeds your database with by loading db/seeds.rb"
|
30
|
-
task :seed =>
|
31
|
-
load Rails.root.join("db","seeds.rb")
|
28
|
+
task :seed => "parse:env" do
|
29
|
+
load Rails.root.join("db", "seeds.rb")
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
35
33
|
end
|
36
34
|
|
37
35
|
namespace :parse do
|
38
|
-
|
39
36
|
task :env do
|
40
|
-
|
41
|
-
|
42
|
-
Rake::Task['environment'].invoke
|
37
|
+
if Rake::Task.task_defined?("environment")
|
38
|
+
Rake::Task["environment"].invoke
|
43
39
|
if defined?(::Rails)
|
44
40
|
Rails.application.eager_load! if Rails.application.present?
|
45
41
|
end
|
46
|
-
|
47
42
|
end
|
48
43
|
end
|
49
44
|
|
50
45
|
task :verify_env => :env do
|
51
|
-
|
52
46
|
unless Parse::Client.client?
|
53
47
|
raise "Please make sure you have setup the Parse.setup configuration before invoking task. Usually done in the :environment task."
|
54
48
|
end
|
55
49
|
|
56
|
-
endpoint = ENV[
|
57
|
-
unless endpoint.starts_with?(
|
50
|
+
endpoint = ENV["HOOKS_URL"] || ""
|
51
|
+
unless endpoint.starts_with?("http://") || endpoint.starts_with?("https://")
|
58
52
|
raise "The ENV variable HOOKS_URL must be a <http/s> url : '#{endpoint}'. Ex. https://12345678.ngrok.io/webhooks"
|
59
53
|
end
|
60
|
-
|
61
54
|
end
|
62
55
|
|
63
56
|
desc "Run auto_upgrade on all of your Parse models."
|
@@ -69,92 +62,83 @@ module Parse
|
|
69
62
|
end
|
70
63
|
|
71
64
|
namespace :webhooks do
|
65
|
+
desc "Register local webhooks with Parse server"
|
66
|
+
task :register => :verify_env do
|
67
|
+
endpoint = ENV["HOOKS_URL"]
|
68
|
+
puts "Registering Parse Webhooks @ #{endpoint}"
|
69
|
+
Rake::Task["parse:webhooks:register:functions"].invoke
|
70
|
+
Rake::Task["parse:webhooks:register:triggers"].invoke
|
71
|
+
end
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
Rake::Task['parse:webhooks:register:triggers'].invoke
|
79
|
-
end
|
80
|
-
|
81
|
-
desc "List all webhooks and triggers registered with the Parse Server"
|
82
|
-
task :list => :verify_env do
|
83
|
-
Rake::Task['parse:webhooks:list:functions'].invoke
|
84
|
-
Rake::Task['parse:webhooks:list:triggers'].invoke
|
85
|
-
end
|
73
|
+
desc "List all webhooks and triggers registered with the Parse Server"
|
74
|
+
task :list => :verify_env do
|
75
|
+
Rake::Task["parse:webhooks:list:functions"].invoke
|
76
|
+
Rake::Task["parse:webhooks:list:triggers"].invoke
|
77
|
+
end
|
86
78
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
79
|
+
desc "Remove all locally registered webhooks from the Parse Application."
|
80
|
+
task :remove => :verify_env do
|
81
|
+
Rake::Task["parse:webhooks:remove:functions"].invoke
|
82
|
+
Rake::Task["parse:webhooks:remove:triggers"].invoke
|
83
|
+
end
|
92
84
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
85
|
+
namespace :list do
|
86
|
+
task :functions => :verify_env do
|
87
|
+
endpoint = ENV["HOOKS_URL"] || "-"
|
88
|
+
Parse.client.functions.each do |r|
|
89
|
+
name = r["functionName"]
|
90
|
+
url = r["url"]
|
91
|
+
star = url.starts_with?(endpoint) ? "*" : " "
|
92
|
+
puts "[#{star}] #{name} -> #{url}"
|
93
|
+
end
|
101
94
|
end
|
102
|
-
end
|
103
95
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
96
|
+
task :triggers => :verify_env do
|
97
|
+
endpoint = ENV["HOOKS_URL"] || "-"
|
98
|
+
triggers = Parse.client.triggers.results
|
99
|
+
triggers.sort! { |x, y| [x["className"], x["triggerName"]] <=> [y["className"], y["triggerName"]] }
|
100
|
+
triggers.each do |r|
|
101
|
+
name = r["className"]
|
102
|
+
trigger = r["triggerName"]
|
103
|
+
url = r["url"]
|
104
|
+
star = url.starts_with?(endpoint) ? "*" : " "
|
105
|
+
puts "[#{star}] #{name}.#{trigger} -> #{url}"
|
106
|
+
end
|
114
107
|
end
|
115
108
|
end
|
116
109
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
Parse::Webhooks.register_functions!(endpoint) do |name|
|
124
|
-
puts "[+] function - #{name}"
|
110
|
+
namespace :register do
|
111
|
+
task :functions => :verify_env do
|
112
|
+
endpoint = ENV["HOOKS_URL"]
|
113
|
+
Parse::Webhooks.register_functions!(endpoint) do |name|
|
114
|
+
puts "[+] function - #{name}"
|
115
|
+
end
|
125
116
|
end
|
126
|
-
end
|
127
117
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
118
|
+
task :triggers => :verify_env do
|
119
|
+
endpoint = ENV["HOOKS_URL"]
|
120
|
+
Parse::Webhooks.register_triggers!(endpoint, { include_wildcard: true }) do |trigger, name|
|
121
|
+
puts "[+] #{trigger.to_s.ljust(12, " ")} - #{name}"
|
122
|
+
end
|
132
123
|
end
|
133
124
|
end
|
134
125
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
Parse::Webhooks.remove_all_functions! do |name|
|
141
|
-
puts "[-] function - #{name}"
|
126
|
+
namespace :remove do
|
127
|
+
task :functions => :verify_env do
|
128
|
+
Parse::Webhooks.remove_all_functions! do |name|
|
129
|
+
puts "[-] function - #{name}"
|
130
|
+
end
|
142
131
|
end
|
143
|
-
end
|
144
132
|
|
145
|
-
|
146
|
-
|
147
|
-
|
133
|
+
task :triggers => :verify_env do
|
134
|
+
Parse::Webhooks.remove_all_triggers! do |trigger, name|
|
135
|
+
puts "[-] #{trigger.to_s.ljust(12, " ")} - #{name}"
|
136
|
+
end
|
148
137
|
end
|
149
138
|
end
|
150
|
-
|
151
|
-
end
|
152
|
-
|
153
139
|
end # webhooks
|
154
|
-
|
155
140
|
end # webhooks namespace
|
156
141
|
end
|
157
142
|
end # Tasks
|
158
143
|
end # Webhooks
|
159
|
-
|
160
144
|
end # Parse
|