fmrest-core 0.17.0 → 0.18.0.rc3

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: 6ba93e217eb5159973fc3e82d06c9cfd395f9f2d1bd4cee1bc0f193f661303f1
4
- data.tar.gz: 151da1d88185b7a12b23bd7e8067a52ca7209fb729367682789c9c26d29808f2
3
+ metadata.gz: 9070ffa50e9886a1c1a46c91575c3252469ea22423bbc0658d0b4c86f325c1ac
4
+ data.tar.gz: 29b2bfef12c6352492aa3fbb5f19031aaf263e39dacc3e334bf6470df07de7e7
5
5
  SHA512:
6
- metadata.gz: 06ded09ca8619ae8428ec534355d61f6aaca6076aa2ff7d341e6f8ce0464c50d0568b8006512eec25d3afad9591cec06adc39a9da1f2813323a116fcee7e6a0d
7
- data.tar.gz: 96dc882fc26b359a7a91ce547de4f6e25b050f9e1a201c69b447e9a3677709ee49c1f113739f431d86cb1701a7603dd490756ac467332648a0562fc33b79f822
6
+ metadata.gz: 65ea5b666e2debed130714df05a9275e991e8127d17d44dbee94a4651a05394472ab1381e1bbf35551648234a6d3c6c174fcc4fe8025ec45148bcc27a5aef495
7
+ data.tar.gz: bfdc063f4701eb03ed3f8e2edc7c9b2131cb6cc82175c88462debdd67891050fd53dfa160f47f35323809d6860d4a89ec341d8116791cae6d4e69b900b7715af
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  ## Changelog
2
2
 
3
+ ### 0.18.0
4
+
5
+ * Better support for portals with mismatching field qualifiers
6
+ * Better ergonomics for script execution, improved documentation
7
+ * Defining an attribute on a model that would collide with an existing method
8
+ now raises an error
9
+ * Cleared Faraday deprecation messages on authentication methods
10
+ * Added fmrest-ruby/VERSION to User-Agent headers
11
+
12
+ ### 0.17.1
13
+
14
+ * Fixed crash when `fmid_token` is set but `username` isn't
15
+
3
16
  ### 0.17.0
4
17
 
5
18
  * Added support for Claris ID token login
data/README.md CHANGED
@@ -543,6 +543,10 @@ class LoggyBee < FmRest::Layout
543
543
  end
544
544
  ```
545
545
 
546
+ ## Gotchas
547
+
548
+ Read about unexpected scenarios in the [gotchas doc](docs/Gotchas.md).
549
+
546
550
  ## API implementation completeness table
547
551
 
548
552
  FM Data API reference: https://fmhelp.filemaker.com/docs/18/en/dataapi/
@@ -8,7 +8,8 @@ module FmRest
8
8
  BASE_PATH = "/fmi/data/v1"
9
9
  DATABASES_PATH = "#{BASE_PATH}/databases"
10
10
 
11
- AUTH_HEADERS = { "Content-Type" => "application/json" }.freeze
11
+ DEFAULT_HEADERS = { "User-Agent" => "fmrest-ruby/#{::FmRest::VERSION} Faraday/#{::Faraday::VERSION}" }.freeze
12
+ AUTH_CONNECTION_HEADERS = DEFAULT_HEADERS.merge("Content-Type" => "application/json").freeze
12
13
  CLARIS_ID_HTTP_AUTH_TYPE = "FMID"
13
14
 
14
15
  # Builds a complete DAPI Faraday connection with middleware already
@@ -21,7 +22,7 @@ module FmRest
21
22
  def build_connection(settings = FmRest.default_connection_settings, &block)
22
23
  settings = ConnectionSettings.wrap(settings)
23
24
 
24
- base_connection(settings) do |conn|
25
+ base_connection(settings, headers: DEFAULT_HEADERS) do |conn|
25
26
  conn.use RaiseErrors
26
27
  conn.use TokenSession, settings
27
28
 
@@ -56,13 +57,13 @@ module FmRest
56
57
  def auth_connection(settings = FmRest.default_connection_settings)
57
58
  settings = ConnectionSettings.wrap(settings)
58
59
 
59
- base_connection(settings, { headers: AUTH_HEADERS }) do |conn|
60
+ base_connection(settings, headers: AUTH_CONNECTION_HEADERS) do |conn|
60
61
  conn.use RaiseErrors
61
62
 
62
63
  if settings.fmid_token?
63
- conn.authorization CLARIS_ID_HTTP_AUTH_TYPE, settings.fmid_token
64
+ conn.request :authorization, CLARIS_ID_HTTP_AUTH_TYPE, settings.fmid_token
64
65
  else
65
- conn.basic_auth settings.username!, settings.password!
66
+ conn.request :basic_auth, settings.username!, settings.password!
66
67
  end
67
68
 
68
69
  if settings.log
@@ -5,10 +5,9 @@ module FmRest
5
5
  # FM Data API response middleware for raising exceptions on API response
6
6
  # errors
7
7
  #
8
- # https://fmhelp.filemaker.com/help/17/fmp/en/index.html#page/FMP_Help/error-codes.html
9
- #
10
8
  class RaiseErrors < Faraday::Response::Middleware
11
- # https://fmhelp.filemaker.com/help/17/fmp/en/index.html#page/FMP_Help/error-codes.html
9
+ # Error codes reference:
10
+ # https://help.claris.com/en/pro-help/content/error-codes.html
12
11
  ERROR_RANGES = {
13
12
  -1 => APIError::UnknownError,
14
13
  100 => APIError::ResourceMissingError,
@@ -100,7 +100,13 @@ module FmRest
100
100
  # Strip the host part to just the hostname (i.e. no scheme or port)
101
101
  host = @settings.host!
102
102
  host = URI(host).hostname if host =~ /\Ahttps?:\/\//
103
- "#{host}:#{@settings.database!}:#{@settings.username!}"
103
+ identity_segment = if fmid_token = @settings.fmid_token
104
+ require "digest"
105
+ Digest::SHA256.hexdigest(fmid_token)
106
+ else
107
+ @settings.username!
108
+ end
109
+ "#{host}:#{@settings.database!}:#{identity_segment}"
104
110
  end
105
111
  end
106
112
 
@@ -8,6 +8,8 @@ module FmRest
8
8
  # See https://help.claris.com/en/pro-help/content/finding-text.html
9
9
  FM_FIND_OPERATORS_RE = /([@\*#\?!=<>"])/
10
10
 
11
+ FULLY_QUALIFIED_FIELD_NAME_MATCHER = /\A[^:]+::[^:]+\Z/.freeze
12
+
11
13
  # Converts custom script options to a hash with the Data API's expected
12
14
  # JSON script format.
13
15
  #
@@ -104,6 +106,18 @@ module FmRest
104
106
  s.gsub(FM_FIND_OPERATORS_RE, "\\\\\\1")
105
107
  end
106
108
 
109
+ # Returns whether the given FileMaker field name is a fully-qualified
110
+ # name. In other words, whether it contains the string "::".
111
+ #
112
+ # Note that this is a simple naive check which doesn't account for
113
+ # invalid field names.
114
+ #
115
+ # @param field_name [String] The field name to test
116
+ # @return [Boolean] Whether the field is a FQN
117
+ def is_fully_qualified?(field_name)
118
+ FULLY_QUALIFIED_FIELD_NAME_MATCHER === field_name.to_s
119
+ end
120
+
107
121
  private
108
122
 
109
123
  def convert_script_arguments(script_arguments, suffix = nil)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FmRest
4
- VERSION = "0.17.0"
4
+ VERSION = "0.18.0.rc3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fmrest-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.18.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Carbajal
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-05 00:00:00.000000000 Z
11
+ date: 2021-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -104,9 +104,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
104
104
  version: '0'
105
105
  required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - ">="
107
+ - - ">"
108
108
  - !ruby/object:Gem::Version
109
- version: '0'
109
+ version: 1.3.1
110
110
  requirements: []
111
111
  rubygems_version: 3.2.3
112
112
  signing_key: