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.
Files changed (178) hide show
  1. checksums.yaml +7 -0
  2. data/.bundle/config +2 -0
  3. data/.env.sample +112 -0
  4. data/.env.test +10 -0
  5. data/.github/workflows/ruby.yml +36 -0
  6. data/.gitignore +49 -0
  7. data/.ruby-version +1 -0
  8. data/.solargraph.yml +22 -0
  9. data/CHANGELOG.md +5816 -0
  10. data/Gemfile +30 -0
  11. data/Gemfile.lock +175 -0
  12. data/LICENSE.txt +23 -0
  13. data/Makefile +63 -0
  14. data/README.md +5655 -0
  15. data/Rakefile +573 -0
  16. data/bin/console +38 -0
  17. data/bin/parse-console +136 -0
  18. data/bin/server +17 -0
  19. data/bin/setup +7 -0
  20. data/config/parse-config.json +12 -0
  21. data/docs/TEST_SERVER.md +271 -0
  22. data/docs/_config.yml +1 -0
  23. data/docs/mcp_guide.md +3484 -0
  24. data/docs/mongodb_direct_guide.md +1348 -0
  25. data/docs/mongodb_index_optimization_guide.md +631 -0
  26. data/examples/transaction_example.rb +219 -0
  27. data/lib/parse/acl_scope.rb +728 -0
  28. data/lib/parse/agent/cancellation_token.rb +80 -0
  29. data/lib/parse/agent/constraint_translator.rb +480 -0
  30. data/lib/parse/agent/describe.rb +420 -0
  31. data/lib/parse/agent/errors.rb +133 -0
  32. data/lib/parse/agent/mcp_client.rb +557 -0
  33. data/lib/parse/agent/mcp_dispatcher.rb +1023 -0
  34. data/lib/parse/agent/mcp_rack_app.rb +1143 -0
  35. data/lib/parse/agent/mcp_server.rb +376 -0
  36. data/lib/parse/agent/metadata_audit.rb +259 -0
  37. data/lib/parse/agent/metadata_dsl.rb +733 -0
  38. data/lib/parse/agent/metadata_registry.rb +794 -0
  39. data/lib/parse/agent/pipeline_validator.rb +82 -0
  40. data/lib/parse/agent/prompts.rb +351 -0
  41. data/lib/parse/agent/rate_limiter.rb +158 -0
  42. data/lib/parse/agent/relation_graph.rb +162 -0
  43. data/lib/parse/agent/result_formatter.rb +453 -0
  44. data/lib/parse/agent/tools.rb +5489 -0
  45. data/lib/parse/agent.rb +3249 -0
  46. data/lib/parse/api/aggregate.rb +79 -0
  47. data/lib/parse/api/all.rb +26 -0
  48. data/lib/parse/api/analytics.rb +18 -0
  49. data/lib/parse/api/batch.rb +33 -0
  50. data/lib/parse/api/cloud_functions.rb +58 -0
  51. data/lib/parse/api/config.rb +125 -0
  52. data/lib/parse/api/files.rb +29 -0
  53. data/lib/parse/api/hooks.rb +117 -0
  54. data/lib/parse/api/objects.rb +146 -0
  55. data/lib/parse/api/path_segment.rb +75 -0
  56. data/lib/parse/api/push.rb +20 -0
  57. data/lib/parse/api/schema.rb +49 -0
  58. data/lib/parse/api/server.rb +50 -0
  59. data/lib/parse/api/sessions.rb +24 -0
  60. data/lib/parse/api/users.rb +250 -0
  61. data/lib/parse/atlas_search/index_manager.rb +353 -0
  62. data/lib/parse/atlas_search/result.rb +204 -0
  63. data/lib/parse/atlas_search/search_builder.rb +604 -0
  64. data/lib/parse/atlas_search/session.rb +253 -0
  65. data/lib/parse/atlas_search.rb +995 -0
  66. data/lib/parse/client/authentication.rb +97 -0
  67. data/lib/parse/client/batch.rb +234 -0
  68. data/lib/parse/client/body_builder.rb +240 -0
  69. data/lib/parse/client/caching.rb +203 -0
  70. data/lib/parse/client/logging.rb +293 -0
  71. data/lib/parse/client/profiling.rb +181 -0
  72. data/lib/parse/client/protocol.rb +91 -0
  73. data/lib/parse/client/request.rb +233 -0
  74. data/lib/parse/client/response.rb +208 -0
  75. data/lib/parse/client.rb +1104 -0
  76. data/lib/parse/clp_scope.rb +361 -0
  77. data/lib/parse/live_query/circuit_breaker.rb +256 -0
  78. data/lib/parse/live_query/client.rb +1001 -0
  79. data/lib/parse/live_query/configuration.rb +224 -0
  80. data/lib/parse/live_query/event.rb +115 -0
  81. data/lib/parse/live_query/event_queue.rb +272 -0
  82. data/lib/parse/live_query/health_monitor.rb +214 -0
  83. data/lib/parse/live_query/logging.rb +149 -0
  84. data/lib/parse/live_query/subscription.rb +294 -0
  85. data/lib/parse/live_query.rb +163 -0
  86. data/lib/parse/lookup_rewriter.rb +445 -0
  87. data/lib/parse/model/acl.rb +968 -0
  88. data/lib/parse/model/associations/belongs_to.rb +275 -0
  89. data/lib/parse/model/associations/collection_proxy.rb +435 -0
  90. data/lib/parse/model/associations/has_many.rb +597 -0
  91. data/lib/parse/model/associations/has_one.rb +158 -0
  92. data/lib/parse/model/associations/pointer_collection_proxy.rb +134 -0
  93. data/lib/parse/model/associations/relation_collection_proxy.rb +177 -0
  94. data/lib/parse/model/bytes.rb +62 -0
  95. data/lib/parse/model/classes/audience.rb +262 -0
  96. data/lib/parse/model/classes/installation.rb +363 -0
  97. data/lib/parse/model/classes/job_schedule.rb +153 -0
  98. data/lib/parse/model/classes/job_status.rb +264 -0
  99. data/lib/parse/model/classes/product.rb +75 -0
  100. data/lib/parse/model/classes/push_status.rb +263 -0
  101. data/lib/parse/model/classes/role.rb +751 -0
  102. data/lib/parse/model/classes/session.rb +201 -0
  103. data/lib/parse/model/classes/user.rb +943 -0
  104. data/lib/parse/model/clp.rb +544 -0
  105. data/lib/parse/model/core/actions.rb +1268 -0
  106. data/lib/parse/model/core/builder.rb +139 -0
  107. data/lib/parse/model/core/create_lock.rb +386 -0
  108. data/lib/parse/model/core/describe.rb +382 -0
  109. data/lib/parse/model/core/enhanced_change_tracking.rb +159 -0
  110. data/lib/parse/model/core/errors.rb +38 -0
  111. data/lib/parse/model/core/fetching.rb +566 -0
  112. data/lib/parse/model/core/field_guards.rb +220 -0
  113. data/lib/parse/model/core/indexing.rb +382 -0
  114. data/lib/parse/model/core/parse_reference.rb +407 -0
  115. data/lib/parse/model/core/properties.rb +809 -0
  116. data/lib/parse/model/core/querying.rb +491 -0
  117. data/lib/parse/model/core/schema.rb +202 -0
  118. data/lib/parse/model/core/search_indexing.rb +174 -0
  119. data/lib/parse/model/date.rb +88 -0
  120. data/lib/parse/model/email.rb +213 -0
  121. data/lib/parse/model/file.rb +527 -0
  122. data/lib/parse/model/geojson.rb +271 -0
  123. data/lib/parse/model/geopoint.rb +261 -0
  124. data/lib/parse/model/model.rb +260 -0
  125. data/lib/parse/model/object.rb +2068 -0
  126. data/lib/parse/model/phone.rb +520 -0
  127. data/lib/parse/model/pointer.rb +443 -0
  128. data/lib/parse/model/polygon.rb +406 -0
  129. data/lib/parse/model/push.rb +975 -0
  130. data/lib/parse/model/shortnames.rb +8 -0
  131. data/lib/parse/model/time_zone.rb +141 -0
  132. data/lib/parse/model/validations/uniqueness_validator.rb +97 -0
  133. data/lib/parse/model/validations.rb +96 -0
  134. data/lib/parse/mongodb.rb +2300 -0
  135. data/lib/parse/pipeline_security.rb +554 -0
  136. data/lib/parse/query/constraint.rb +198 -0
  137. data/lib/parse/query/constraints.rb +3279 -0
  138. data/lib/parse/query/cursor.rb +434 -0
  139. data/lib/parse/query/n_plus_one_detector.rb +445 -0
  140. data/lib/parse/query/operation.rb +104 -0
  141. data/lib/parse/query/ordering.rb +66 -0
  142. data/lib/parse/query.rb +7028 -0
  143. data/lib/parse/schema/index_migrator.rb +291 -0
  144. data/lib/parse/schema/search_index_migrator.rb +289 -0
  145. data/lib/parse/schema.rb +494 -0
  146. data/lib/parse/stack/generators/rails.rb +40 -0
  147. data/lib/parse/stack/generators/templates/model.erb +51 -0
  148. data/lib/parse/stack/generators/templates/model_installation.rb +4 -0
  149. data/lib/parse/stack/generators/templates/model_role.rb +4 -0
  150. data/lib/parse/stack/generators/templates/model_session.rb +4 -0
  151. data/lib/parse/stack/generators/templates/model_user.rb +11 -0
  152. data/lib/parse/stack/generators/templates/parse.rb +12 -0
  153. data/lib/parse/stack/generators/templates/webhooks.rb +10 -0
  154. data/lib/parse/stack/railtie.rb +18 -0
  155. data/lib/parse/stack/tasks.rb +563 -0
  156. data/lib/parse/stack/version.rb +11 -0
  157. data/lib/parse/stack.rb +455 -0
  158. data/lib/parse/two_factor_auth/user_extension.rb +449 -0
  159. data/lib/parse/two_factor_auth.rb +310 -0
  160. data/lib/parse/webhooks/payload.rb +360 -0
  161. data/lib/parse/webhooks/registration.rb +199 -0
  162. data/lib/parse/webhooks/replay_protection.rb +189 -0
  163. data/lib/parse/webhooks.rb +510 -0
  164. data/lib/parse-stack-next.rb +5 -0
  165. data/lib/parse-stack.rb +5 -0
  166. data/parse-stack-next.gemspec +82 -0
  167. data/parse-stack.png +0 -0
  168. data/scripts/debug-ips.js +35 -0
  169. data/scripts/docker/Dockerfile.parse +13 -0
  170. data/scripts/docker/atlas-init.js +284 -0
  171. data/scripts/docker/docker-compose.atlas.yml +76 -0
  172. data/scripts/docker/docker-compose.test.yml +106 -0
  173. data/scripts/docker/mongo-init.js +21 -0
  174. data/scripts/eval_mcp_with_lm_studio.rb +274 -0
  175. data/scripts/start-parse.sh +90 -0
  176. data/scripts/start_mcp_server.rb +78 -0
  177. data/scripts/test_server_connection.rb +82 -0
  178. metadata +377 -0
@@ -0,0 +1,263 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ # Note: Do not require "../object" here - this file is loaded from object.rb
5
+ # and adding that require would create a circular dependency.
6
+
7
+ module Parse
8
+ # This class represents the data and columns contained in the standard Parse
9
+ # `_PushStatus` collection. Push status records track the delivery status
10
+ # and metrics of push notifications sent through Parse Server.
11
+ #
12
+ # Push status records are created automatically when a push is sent and
13
+ # are updated as the push progresses through the delivery pipeline.
14
+ #
15
+ # Status lifecycle: pending → scheduled → running → succeeded/failed
16
+ #
17
+ # The default schema for the {PushStatus} class is as follows:
18
+ # class Parse::PushStatus < Parse::Object
19
+ # # See Parse::Object for inherited properties...
20
+ #
21
+ # property :push_hash # Unique hash identifying the push
22
+ # property :query, :object # The query used to target installations
23
+ # property :payload, :object # The push payload that was sent
24
+ # property :source # "rest" or "webUI"
25
+ # property :status # "pending", "scheduled", "running", "succeeded", "failed"
26
+ # property :num_sent, :integer
27
+ # property :num_failed, :integer
28
+ # property :sent_per_type, :object
29
+ # property :failed_per_type, :object
30
+ # property :sent_per_utc_offset, :object
31
+ # property :failed_per_utc_offset, :object
32
+ # property :count, :integer # Total installations targeted
33
+ # property :push_time, :date # When the push was/will be sent
34
+ # property :expiry, :date # When the push expires
35
+ # end
36
+ #
37
+ # @example Checking push status
38
+ # status = Parse::PushStatus.find(push_id)
39
+ # puts "Sent: #{status.num_sent}, Failed: #{status.num_failed}"
40
+ # puts "Status: #{status.status}"
41
+ #
42
+ # @example Querying recent pushes
43
+ # recent = Parse::PushStatus.recent.limit(10).all
44
+ # recent.each { |s| puts "#{s.status}: #{s.num_sent} sent" }
45
+ #
46
+ # @note This collection requires master key access
47
+ # @see Parse::Push
48
+ # @see Parse::Object
49
+ class PushStatus < Parse::Object
50
+ parse_class Parse::Model::CLASS_PUSH_STATUS
51
+
52
+ # @!attribute push_hash
53
+ # A unique hash identifying this push notification.
54
+ # @return [String] The push hash.
55
+ property :push_hash
56
+
57
+ # @!attribute query
58
+ # The query constraints used to target installations.
59
+ # @return [Hash] The query constraint hash.
60
+ property :query, :object
61
+
62
+ # @!attribute payload
63
+ # The push payload that was sent.
64
+ # @return [Hash] The payload data.
65
+ property :payload, :object
66
+
67
+ # @!attribute source
68
+ # The source of the push ("rest" for API, "webUI" for dashboard).
69
+ # @return [String] The push source.
70
+ property :source
71
+
72
+ # @!attribute status
73
+ # The current status of the push.
74
+ # One of: "pending", "scheduled", "running", "succeeded", "failed"
75
+ # @return [String] The push status.
76
+ property :status
77
+
78
+ # @!attribute num_sent
79
+ # The number of notifications successfully sent.
80
+ # @return [Integer] The success count.
81
+ property :num_sent, :integer
82
+
83
+ # @!attribute num_failed
84
+ # The number of notifications that failed to send.
85
+ # @return [Integer] The failure count.
86
+ property :num_failed, :integer
87
+
88
+ # @!attribute sent_per_type
89
+ # Breakdown of successful sends by device type (ios, android, etc.).
90
+ # @return [Hash] Device type to count mapping.
91
+ # @example
92
+ # status.sent_per_type # => {"ios" => 800, "android" => 450}
93
+ property :sent_per_type, :object
94
+
95
+ # @!attribute failed_per_type
96
+ # Breakdown of failed sends by device type.
97
+ # @return [Hash] Device type to count mapping.
98
+ property :failed_per_type, :object
99
+
100
+ # @!attribute sent_per_utc_offset
101
+ # Breakdown of successful sends by UTC timezone offset.
102
+ # @return [Hash] UTC offset to count mapping.
103
+ # @example
104
+ # status.sent_per_utc_offset # => {"-8" => 500, "0" => 300, "5" => 200}
105
+ property :sent_per_utc_offset, :object
106
+
107
+ # @!attribute failed_per_utc_offset
108
+ # Breakdown of failed sends by UTC timezone offset.
109
+ # @return [Hash] UTC offset to count mapping.
110
+ property :failed_per_utc_offset, :object
111
+
112
+ # @!attribute count
113
+ # Total number of installations targeted by this push.
114
+ # @return [Integer] The target count.
115
+ property :count, :integer
116
+
117
+ # @!attribute push_time
118
+ # When the push was/will be sent. For scheduled pushes, this is the future time.
119
+ # @return [Parse::Date] The push time.
120
+ property :push_time, :date
121
+
122
+ # @!attribute expiry
123
+ # When the push expires and will no longer be delivered.
124
+ # @return [Parse::Date] The expiration time.
125
+ property :expiry, :date
126
+
127
+ # @!attribute error_message
128
+ # Error message if the push failed.
129
+ # @return [String, nil] The error message or nil.
130
+ property :error_message
131
+
132
+ # =========================================================================
133
+ # Status Query Scopes
134
+ # =========================================================================
135
+
136
+ class << self
137
+ # Query for pending pushes (not yet started).
138
+ # @return [Parse::Query] a query for pending pushes
139
+ def pending
140
+ query(status: "pending")
141
+ end
142
+
143
+ # Query for scheduled pushes (waiting for push_time).
144
+ # @return [Parse::Query] a query for scheduled pushes
145
+ def scheduled
146
+ query(status: "scheduled")
147
+ end
148
+
149
+ # Query for running pushes (currently being sent).
150
+ # @return [Parse::Query] a query for running pushes
151
+ def running
152
+ query(status: "running")
153
+ end
154
+
155
+ # Query for succeeded pushes.
156
+ # @return [Parse::Query] a query for succeeded pushes
157
+ def succeeded
158
+ query(status: "succeeded")
159
+ end
160
+
161
+ # Query for failed pushes.
162
+ # @return [Parse::Query] a query for failed pushes
163
+ def failed
164
+ query(status: "failed")
165
+ end
166
+
167
+ # Query for recent pushes, ordered by creation time descending.
168
+ # @return [Parse::Query] a query for recent pushes
169
+ def recent
170
+ query.order(:created_at.desc)
171
+ end
172
+ end
173
+
174
+ # =========================================================================
175
+ # Status Predicates
176
+ # =========================================================================
177
+
178
+ # Check if the push is pending (not yet started).
179
+ # @return [Boolean] true if status is "pending"
180
+ def pending?
181
+ status == "pending"
182
+ end
183
+
184
+ # Check if the push is scheduled (waiting for push_time).
185
+ # @return [Boolean] true if status is "scheduled"
186
+ def scheduled?
187
+ status == "scheduled"
188
+ end
189
+
190
+ # Check if the push is currently running.
191
+ # @return [Boolean] true if status is "running"
192
+ def running?
193
+ status == "running"
194
+ end
195
+
196
+ # Check if the push succeeded.
197
+ # @return [Boolean] true if status is "succeeded"
198
+ def succeeded?
199
+ status == "succeeded"
200
+ end
201
+
202
+ # Check if the push failed.
203
+ # @return [Boolean] true if status is "failed"
204
+ def failed?
205
+ status == "failed"
206
+ end
207
+
208
+ # Check if the push is complete (either succeeded or failed).
209
+ # @return [Boolean] true if the push has finished
210
+ def complete?
211
+ succeeded? || failed?
212
+ end
213
+
214
+ # Check if the push is still in progress.
215
+ # @return [Boolean] true if pending, scheduled, or running
216
+ def in_progress?
217
+ !complete?
218
+ end
219
+
220
+ # =========================================================================
221
+ # Metrics Methods
222
+ # =========================================================================
223
+
224
+ # Get the total number of notifications attempted (sent + failed).
225
+ # @return [Integer] the total count
226
+ def total_attempted
227
+ (num_sent || 0) + (num_failed || 0)
228
+ end
229
+
230
+ # Get the success rate as a percentage.
231
+ # @return [Float] the success rate (0.0 to 100.0)
232
+ # @example
233
+ # status.success_rate # => 98.5
234
+ def success_rate
235
+ total = total_attempted
236
+ return 0.0 if total == 0
237
+ ((num_sent || 0).to_f / total * 100).round(2)
238
+ end
239
+
240
+ # Get the failure rate as a percentage.
241
+ # @return [Float] the failure rate (0.0 to 100.0)
242
+ def failure_rate
243
+ 100.0 - success_rate
244
+ end
245
+
246
+ # Get a summary of the push metrics.
247
+ # @return [Hash] summary hash with key metrics
248
+ # @example
249
+ # status.summary
250
+ # # => { status: "succeeded", sent: 1250, failed: 12, success_rate: 99.05 }
251
+ def summary
252
+ {
253
+ status: status,
254
+ sent: num_sent || 0,
255
+ failed: num_failed || 0,
256
+ total_targeted: count || 0,
257
+ success_rate: success_rate,
258
+ sent_per_type: sent_per_type || {},
259
+ failed_per_type: failed_per_type || {},
260
+ }
261
+ end
262
+ end
263
+ end