Module: Parse::API::Server

Included in:
Client
Defined in:
lib/parse/api/server.rb

Overview

APIs related to the open source Parse Server.

Constant Summary collapse

DEPRECATED_SERVER_VERSION_BELOW =

Minimum supported Parse Server major version. Below this floor the SDK emits a one-shot deprecation warning per client instance the first time server_info resolves. The threshold tracks "current major minus two" against Parse Server's release cadence — Parse Server 9.x is current in 2026, so anything below 7.0 is flagged. Override with PARSE_DEPRECATED_SERVER_VERSION_BELOW=6.0 or silence entirely with PARSE_SUPPRESS_SERVER_VERSION_WARNING=true.

"7.0.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#server_infoHash

Fetch and cache information about the Parse server configuration. This hash contains information specifically to the configuration of the running parse server.

Returns:

  • (Hash)

    a hash containing server configuration if available.



11
# File 'lib/parse/api/server.rb', line 11

attr_writer :server_info

Instance Method Details

#server_featuresHash

The features block advertised by GET /serverInfo. Parse Server surfaces coarse capability groups here (globalConfig, hooks, cloudCode, logs, push, schemas), each a Hash of booleans. This is authoritative where present but intentionally coarse — it does NOT carry fine-grained behavior flags like "public explain" or the LiveQuery keys rename. Those are resolved by version inference in #server_supports?.

Returns:

  • (Hash)

    the advertised features block, or {} if unavailable.



70
71
72
73
74
75
# File 'lib/parse/api/server.rb', line 70

def server_features
  info = server_info
  return {} unless info.is_a?(Hash)
  feats = info[:features]
  feats.is_a?(Hash) ? feats : {}
end

#server_healthBoolean

Fetches the status of the server based on the health check.

Returns:

  • (Boolean)

    whether the server is 'OK'.



42
43
44
45
46
# File 'lib/parse/api/server.rb', line 42

def server_health
  opts = { cache: false }
  response = request :get, SERVER_HEALTH_PATH, opts: opts
  response.success?
end

#server_info!Hash

Force fetches the server information.

Returns:

  • (Hash)

    a hash containing server configuration if available.



50
51
52
53
54
# File 'lib/parse/api/server.rb', line 50

def server_info!
  @server_info = nil
  @server_version_warned = false
  server_info
end

#server_supports?(feature) ⇒ Boolean

Capability probe against the connected Parse Server. Builds on the already-memoized #server_info (no extra round-trip beyond the one serverInfo fetch) and the coarse features block, falling back to version inference for behavior flags the features block does not carry.

Fails OPEN to the modern server line: when the server version cannot be determined (offline unit tests, a serverInfo outage, a wire surprise), a since: capability resolves true and an until: capability resolves false — i.e. "assume the current server", mirroring #warn_if_deprecated_server_version!.

Examples:

client.server_supports?(:public_explain)   # => false on PS 9.x
client.server_supports?(:aggregate_raw_values)

Parameters:

  • feature (Symbol)

    a key of CAPABILITIES.

Returns:

  • (Boolean)

    whether the connected server supports the feature.

Raises:

  • (ArgumentError)

    for an unknown capability key (typo guard).



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/parse/api/server.rb', line 129

def server_supports?(feature)
  spec = CAPABILITIES[feature]
  raise ArgumentError, "Unknown Parse Server capability #{feature.inspect}" if spec.nil?

  # Prefer the advertised features block when a capability declares a
  # `[group, flag]` path AND the server actually surfaces it.
  if (path = spec[:feature])
    group, flag = path
    advertised = server_features.dig(group.to_s, flag.to_s)
    advertised = server_features.dig(group, flag) if advertised.nil?
    return advertised == true unless advertised.nil?
  end

  version = server_version.to_s
  if (floor = spec[:since])
    # Supported on `floor` and newer. Unknown version => assume modern => true.
    return true if version.empty?
    !server_version_below?(version, floor)
  elsif (ceiling = spec[:until])
    # Supported strictly below `ceiling`. Unknown version => assume modern => false.
    return false if version.empty?
    server_version_below?(version, ceiling)
  else
    false
  end
end

#server_versionString

Returns the version of the Parse server the client is connected to.

Returns:

  • (String)

    a version string (ex. '2.2.25') if available.



58
59
60
# File 'lib/parse/api/server.rb', line 58

def server_version
  server_info.present? ? @server_info[:parseServerVersion] : nil
end