parse-stack-next 4.5.0
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 +7 -0
- data/.bundle/config +2 -0
- data/.env.sample +112 -0
- data/.env.test +10 -0
- data/.github/workflows/ruby.yml +36 -0
- data/.gitignore +49 -0
- data/.ruby-version +1 -0
- data/.solargraph.yml +22 -0
- data/CHANGELOG.md +5816 -0
- data/Gemfile +30 -0
- data/Gemfile.lock +175 -0
- data/LICENSE.txt +23 -0
- data/Makefile +63 -0
- data/README.md +5655 -0
- data/Rakefile +573 -0
- data/bin/console +38 -0
- data/bin/parse-console +136 -0
- data/bin/server +17 -0
- data/bin/setup +7 -0
- data/config/parse-config.json +12 -0
- data/docs/TEST_SERVER.md +271 -0
- data/docs/_config.yml +1 -0
- data/docs/mcp_guide.md +3484 -0
- data/docs/mongodb_direct_guide.md +1348 -0
- data/docs/mongodb_index_optimization_guide.md +631 -0
- data/examples/transaction_example.rb +219 -0
- data/lib/parse/acl_scope.rb +728 -0
- data/lib/parse/agent/cancellation_token.rb +80 -0
- data/lib/parse/agent/constraint_translator.rb +480 -0
- data/lib/parse/agent/describe.rb +420 -0
- data/lib/parse/agent/errors.rb +133 -0
- data/lib/parse/agent/mcp_client.rb +557 -0
- data/lib/parse/agent/mcp_dispatcher.rb +1023 -0
- data/lib/parse/agent/mcp_rack_app.rb +1143 -0
- data/lib/parse/agent/mcp_server.rb +376 -0
- data/lib/parse/agent/metadata_audit.rb +259 -0
- data/lib/parse/agent/metadata_dsl.rb +733 -0
- data/lib/parse/agent/metadata_registry.rb +794 -0
- data/lib/parse/agent/pipeline_validator.rb +82 -0
- data/lib/parse/agent/prompts.rb +351 -0
- data/lib/parse/agent/rate_limiter.rb +158 -0
- data/lib/parse/agent/relation_graph.rb +162 -0
- data/lib/parse/agent/result_formatter.rb +453 -0
- data/lib/parse/agent/tools.rb +5489 -0
- data/lib/parse/agent.rb +3249 -0
- data/lib/parse/api/aggregate.rb +79 -0
- data/lib/parse/api/all.rb +26 -0
- data/lib/parse/api/analytics.rb +18 -0
- data/lib/parse/api/batch.rb +33 -0
- data/lib/parse/api/cloud_functions.rb +58 -0
- data/lib/parse/api/config.rb +125 -0
- data/lib/parse/api/files.rb +29 -0
- data/lib/parse/api/hooks.rb +117 -0
- data/lib/parse/api/objects.rb +146 -0
- data/lib/parse/api/path_segment.rb +75 -0
- data/lib/parse/api/push.rb +20 -0
- data/lib/parse/api/schema.rb +49 -0
- data/lib/parse/api/server.rb +50 -0
- data/lib/parse/api/sessions.rb +24 -0
- data/lib/parse/api/users.rb +250 -0
- data/lib/parse/atlas_search/index_manager.rb +353 -0
- data/lib/parse/atlas_search/result.rb +204 -0
- data/lib/parse/atlas_search/search_builder.rb +604 -0
- data/lib/parse/atlas_search/session.rb +253 -0
- data/lib/parse/atlas_search.rb +995 -0
- data/lib/parse/client/authentication.rb +97 -0
- data/lib/parse/client/batch.rb +234 -0
- data/lib/parse/client/body_builder.rb +240 -0
- data/lib/parse/client/caching.rb +203 -0
- data/lib/parse/client/logging.rb +293 -0
- data/lib/parse/client/profiling.rb +181 -0
- data/lib/parse/client/protocol.rb +91 -0
- data/lib/parse/client/request.rb +233 -0
- data/lib/parse/client/response.rb +208 -0
- data/lib/parse/client.rb +1104 -0
- data/lib/parse/clp_scope.rb +361 -0
- data/lib/parse/live_query/circuit_breaker.rb +256 -0
- data/lib/parse/live_query/client.rb +1001 -0
- data/lib/parse/live_query/configuration.rb +224 -0
- data/lib/parse/live_query/event.rb +115 -0
- data/lib/parse/live_query/event_queue.rb +272 -0
- data/lib/parse/live_query/health_monitor.rb +214 -0
- data/lib/parse/live_query/logging.rb +149 -0
- data/lib/parse/live_query/subscription.rb +294 -0
- data/lib/parse/live_query.rb +163 -0
- data/lib/parse/lookup_rewriter.rb +445 -0
- data/lib/parse/model/acl.rb +968 -0
- data/lib/parse/model/associations/belongs_to.rb +275 -0
- data/lib/parse/model/associations/collection_proxy.rb +435 -0
- data/lib/parse/model/associations/has_many.rb +597 -0
- data/lib/parse/model/associations/has_one.rb +158 -0
- data/lib/parse/model/associations/pointer_collection_proxy.rb +134 -0
- data/lib/parse/model/associations/relation_collection_proxy.rb +177 -0
- data/lib/parse/model/bytes.rb +62 -0
- data/lib/parse/model/classes/audience.rb +262 -0
- data/lib/parse/model/classes/installation.rb +363 -0
- data/lib/parse/model/classes/job_schedule.rb +153 -0
- data/lib/parse/model/classes/job_status.rb +264 -0
- data/lib/parse/model/classes/product.rb +75 -0
- data/lib/parse/model/classes/push_status.rb +263 -0
- data/lib/parse/model/classes/role.rb +751 -0
- data/lib/parse/model/classes/session.rb +201 -0
- data/lib/parse/model/classes/user.rb +943 -0
- data/lib/parse/model/clp.rb +544 -0
- data/lib/parse/model/core/actions.rb +1268 -0
- data/lib/parse/model/core/builder.rb +139 -0
- data/lib/parse/model/core/create_lock.rb +386 -0
- data/lib/parse/model/core/describe.rb +382 -0
- data/lib/parse/model/core/enhanced_change_tracking.rb +159 -0
- data/lib/parse/model/core/errors.rb +38 -0
- data/lib/parse/model/core/fetching.rb +566 -0
- data/lib/parse/model/core/field_guards.rb +220 -0
- data/lib/parse/model/core/indexing.rb +382 -0
- data/lib/parse/model/core/parse_reference.rb +407 -0
- data/lib/parse/model/core/properties.rb +809 -0
- data/lib/parse/model/core/querying.rb +491 -0
- data/lib/parse/model/core/schema.rb +202 -0
- data/lib/parse/model/core/search_indexing.rb +174 -0
- data/lib/parse/model/date.rb +88 -0
- data/lib/parse/model/email.rb +213 -0
- data/lib/parse/model/file.rb +527 -0
- data/lib/parse/model/geojson.rb +271 -0
- data/lib/parse/model/geopoint.rb +261 -0
- data/lib/parse/model/model.rb +260 -0
- data/lib/parse/model/object.rb +2068 -0
- data/lib/parse/model/phone.rb +520 -0
- data/lib/parse/model/pointer.rb +443 -0
- data/lib/parse/model/polygon.rb +406 -0
- data/lib/parse/model/push.rb +975 -0
- data/lib/parse/model/shortnames.rb +8 -0
- data/lib/parse/model/time_zone.rb +141 -0
- data/lib/parse/model/validations/uniqueness_validator.rb +97 -0
- data/lib/parse/model/validations.rb +96 -0
- data/lib/parse/mongodb.rb +2300 -0
- data/lib/parse/pipeline_security.rb +554 -0
- data/lib/parse/query/constraint.rb +198 -0
- data/lib/parse/query/constraints.rb +3279 -0
- data/lib/parse/query/cursor.rb +434 -0
- data/lib/parse/query/n_plus_one_detector.rb +445 -0
- data/lib/parse/query/operation.rb +104 -0
- data/lib/parse/query/ordering.rb +66 -0
- data/lib/parse/query.rb +7028 -0
- data/lib/parse/schema/index_migrator.rb +291 -0
- data/lib/parse/schema/search_index_migrator.rb +289 -0
- data/lib/parse/schema.rb +494 -0
- data/lib/parse/stack/generators/rails.rb +40 -0
- data/lib/parse/stack/generators/templates/model.erb +51 -0
- data/lib/parse/stack/generators/templates/model_installation.rb +4 -0
- data/lib/parse/stack/generators/templates/model_role.rb +4 -0
- data/lib/parse/stack/generators/templates/model_session.rb +4 -0
- data/lib/parse/stack/generators/templates/model_user.rb +11 -0
- data/lib/parse/stack/generators/templates/parse.rb +12 -0
- data/lib/parse/stack/generators/templates/webhooks.rb +10 -0
- data/lib/parse/stack/railtie.rb +18 -0
- data/lib/parse/stack/tasks.rb +563 -0
- data/lib/parse/stack/version.rb +11 -0
- data/lib/parse/stack.rb +455 -0
- data/lib/parse/two_factor_auth/user_extension.rb +449 -0
- data/lib/parse/two_factor_auth.rb +310 -0
- data/lib/parse/webhooks/payload.rb +360 -0
- data/lib/parse/webhooks/registration.rb +199 -0
- data/lib/parse/webhooks/replay_protection.rb +189 -0
- data/lib/parse/webhooks.rb +510 -0
- data/lib/parse-stack-next.rb +5 -0
- data/lib/parse-stack.rb +5 -0
- data/parse-stack-next.gemspec +82 -0
- data/parse-stack.png +0 -0
- data/scripts/debug-ips.js +35 -0
- data/scripts/docker/Dockerfile.parse +13 -0
- data/scripts/docker/atlas-init.js +284 -0
- data/scripts/docker/docker-compose.atlas.yml +76 -0
- data/scripts/docker/docker-compose.test.yml +106 -0
- data/scripts/docker/mongo-init.js +21 -0
- data/scripts/eval_mcp_with_lm_studio.rb +274 -0
- data/scripts/start-parse.sh +90 -0
- data/scripts/start_mcp_server.rb +78 -0
- data/scripts/test_server_connection.rb +82 -0
- metadata +377 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "operation"
|
|
5
|
+
require "time"
|
|
6
|
+
require "date"
|
|
7
|
+
|
|
8
|
+
module Parse
|
|
9
|
+
# Constraints are the heart of the Parse::Query system.
|
|
10
|
+
# Each constraint is made up of an Operation and a value (the right side
|
|
11
|
+
# of an operator). Constraints are responsible for making their specific
|
|
12
|
+
# Parse hash format required when sending Queries to Parse. All constraints can
|
|
13
|
+
# be combined by merging different constraints (since they are multiple hashes)
|
|
14
|
+
# and some constraints may have higher precedence than others (ex. equality is higher
|
|
15
|
+
# precedence than an "in" query).
|
|
16
|
+
#
|
|
17
|
+
# All constraints should inherit from Parse::Constraint and should
|
|
18
|
+
# register their specific Operation method (ex. :eq or :lte)
|
|
19
|
+
# For more information about the query design pattern from DataMapper
|
|
20
|
+
# that inspired this, see http://datamapper.org/docs/find.html
|
|
21
|
+
class Constraint
|
|
22
|
+
|
|
23
|
+
# @!attribute operation
|
|
24
|
+
# The operation tied to this constraint.
|
|
25
|
+
# @return [Parse::Operation]
|
|
26
|
+
|
|
27
|
+
# @!attribute value
|
|
28
|
+
# The value to be applied to this constraint.
|
|
29
|
+
# @return [Parse::Operation]
|
|
30
|
+
|
|
31
|
+
attr_accessor :operation, :value
|
|
32
|
+
|
|
33
|
+
# Create a new constraint.
|
|
34
|
+
# @param operation [Parse::Operation] the operation for this constraint.
|
|
35
|
+
# @param value [Object] the value to attach to this constraint.
|
|
36
|
+
# @yield You may also pass a block to modify the operation or value.
|
|
37
|
+
def initialize(operation, value)
|
|
38
|
+
# if the first parameter is not an Operation, but it is a symbol
|
|
39
|
+
# it most likely is just the field name, so let's assume they want
|
|
40
|
+
# the default equality operation.
|
|
41
|
+
if operation.is_a?(Operation) == false && operation.respond_to?(:to_sym)
|
|
42
|
+
operation = Operation.new(operation.to_sym, self.class.operand)
|
|
43
|
+
end
|
|
44
|
+
@operation = operation
|
|
45
|
+
@value = value
|
|
46
|
+
yield(self) if block_given?
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
class << self
|
|
50
|
+
# @!attribute key
|
|
51
|
+
# The class attributes keep track of the Parse key (special Parse
|
|
52
|
+
# text symbol representing this operation. Ex. local method could be called
|
|
53
|
+
# .ex, where the Parse Query operation that should be sent out is "$exists")
|
|
54
|
+
# in this case, key should be set to "$exists"
|
|
55
|
+
# @return [Symbol]
|
|
56
|
+
attr_accessor :key
|
|
57
|
+
|
|
58
|
+
# @!attribute precedence
|
|
59
|
+
# Precedence defines the priority of this operation when merging.
|
|
60
|
+
# The higher the more priority it will receive.
|
|
61
|
+
# @return [Integer]
|
|
62
|
+
attr_writer :precedence
|
|
63
|
+
|
|
64
|
+
# @!attribute operand
|
|
65
|
+
# @return [Symbol] the operand for this constraint.
|
|
66
|
+
attr_accessor :operand
|
|
67
|
+
|
|
68
|
+
# Creates a new constraint given an operation and value.
|
|
69
|
+
def create(operation, value)
|
|
70
|
+
#default to a generic equality constraint if not passed an operation
|
|
71
|
+
unless operation.is_a?(Parse::Operation) && operation.valid?
|
|
72
|
+
return self.new(operation, value)
|
|
73
|
+
end
|
|
74
|
+
operation.constraint(value)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Set the keyword for this Constraint. Subclasses should use this method.
|
|
78
|
+
# @param keyword [Symbol]
|
|
79
|
+
# @return (see key)
|
|
80
|
+
def constraint_keyword(keyword)
|
|
81
|
+
@key = keyword
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Set the default precedence for this constraint.
|
|
85
|
+
# @param priority [Integer] a higher priority has higher precedence
|
|
86
|
+
# @return [Integer]
|
|
87
|
+
def precedence(priority = nil)
|
|
88
|
+
@precedence = 0 if @precedence.nil?
|
|
89
|
+
@precedence = priority unless priority.nil?
|
|
90
|
+
@precedence
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Register the given operand for this Parse::Constraint subclass.
|
|
94
|
+
# @note All subclasses should register their operation and themselves.
|
|
95
|
+
# @param op [Symbol] the operand
|
|
96
|
+
# @param klass [Parse::Constraint] a subclass of Parse::Constraint
|
|
97
|
+
# @return (see Parse::Operation.register)
|
|
98
|
+
def register(op, klass = self)
|
|
99
|
+
self.operand ||= op
|
|
100
|
+
Operation.register op, klass
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# @return [Object] a formatted value based on the data type.
|
|
104
|
+
def formatted_value(value)
|
|
105
|
+
d = value
|
|
106
|
+
|
|
107
|
+
# Handle arrays by recursively processing each element
|
|
108
|
+
if d.is_a?(Array)
|
|
109
|
+
return d.map { |item| formatted_value(item) }
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
d = { __type: Parse::Model::TYPE_DATE, iso: d.utc.iso8601(3) } if d.respond_to?(:utc)
|
|
113
|
+
# if it responds to parse_date (most likely a time/date object), then call the conversion
|
|
114
|
+
d = d.parse_date if d.respond_to?(:parse_date)
|
|
115
|
+
# if it's not a Parse::Date, but still responds to iso8601, then do it manually
|
|
116
|
+
if d.is_a?(Parse::Date) == false && d.respond_to?(:iso8601)
|
|
117
|
+
d = { __type: Parse::Model::TYPE_DATE, iso: d.iso8601(3) }
|
|
118
|
+
end
|
|
119
|
+
d = d.pointer if d.respond_to?(:pointer) #simplified query object
|
|
120
|
+
d = d.to_s if d.is_a?(Regexp)
|
|
121
|
+
# d = d.pointer if d.is_a?(Parse::Object) #simplified query object
|
|
122
|
+
# d = d.compile
|
|
123
|
+
if d.is_a?(Parse::Query)
|
|
124
|
+
compiled = d.compile(encode: false, includeClassName: true)
|
|
125
|
+
# compiled["className"] = d.table
|
|
126
|
+
d = compiled
|
|
127
|
+
end
|
|
128
|
+
d
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# @return [Integer] the precedence of this constraint
|
|
133
|
+
def precedence
|
|
134
|
+
self.class.precedence
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# @return [Symbol] the Parse keyword for this constraint.
|
|
138
|
+
def key
|
|
139
|
+
self.class.key
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# @!attribute operand
|
|
143
|
+
# @return [Symbol] the operand for the operation.
|
|
144
|
+
def operand
|
|
145
|
+
@operation.operand unless @operation.nil?
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def operand=(o)
|
|
149
|
+
@operation.operand = o unless @operation.nil?
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# @!attribute operator
|
|
153
|
+
# @return [Symbol] the operator for the operation.
|
|
154
|
+
def operator
|
|
155
|
+
@operation.operator unless @operation.nil?
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def operator=(o)
|
|
159
|
+
@operation.operator = o unless @operation.nil?
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# @!visibility private
|
|
163
|
+
def inspect
|
|
164
|
+
"<#{self.class} #{operator.to_s}(#{operand.inspect}, `#{value}`)>"
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# Calls build internally
|
|
168
|
+
# @return [Hash]
|
|
169
|
+
def as_json(*args)
|
|
170
|
+
build
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# Builds the JSON hash representation of this constraint for a Parse query.
|
|
174
|
+
# This method should be overriden by subclasses. The default implementation
|
|
175
|
+
# implements buildling the equality constraint.
|
|
176
|
+
# @raise ArgumentError if the constraint could be be build due to a bad parameter.
|
|
177
|
+
# This will be different depending on the constraint subclass.
|
|
178
|
+
# @return [Hash]
|
|
179
|
+
def build
|
|
180
|
+
return { @operation.operand => formatted_value } if @operation.operator == :eq || key.nil?
|
|
181
|
+
{ @operation.operand => { key => formatted_value } }
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# @return [String] string representation of this constraint.
|
|
185
|
+
def to_s
|
|
186
|
+
inspect
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# @return [Object] formatted value based on the specific data type.
|
|
190
|
+
def formatted_value
|
|
191
|
+
self.class.formatted_value(@value)
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# Registers the default constraint of equality
|
|
195
|
+
register :eq, Constraint
|
|
196
|
+
precedence 100
|
|
197
|
+
end
|
|
198
|
+
end
|