fmrest-spyke 0.15.0 → 0.17.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/CHANGELOG.md +23 -8
- data/README.md +66 -12
- data/lib/fmrest/spyke/model.rb +2 -0
- data/lib/fmrest/spyke/model/rescuable.rb +27 -0
- data/lib/fmrest/spyke/model/serialization.rb +8 -0
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d90ab7cfdd1a358ceb0c8abcea9d456f3b97a1b9629346a208c72cdf9b627860
|
4
|
+
data.tar.gz: 65888738c1d5ceff390c10a86f012162b3659ca75319b9f0c70a326ba5d7178e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b5deb4e31f490766dbd17ef17c822fe38f1387c5b5e16ed7dea9d343983e470352c0be482758901ae9fe1c28e145ad8f49102e0b4aa8ff4d9f381e20e42130d
|
7
|
+
data.tar.gz: f5f500c34a809a34bc375cc62d9c7d7a39318a4172db72c2466a0fe906738406eca3c46493db7df0e1e8a1d0427cc64ee586e3134e6d53dbc8b69977adf07a69
|
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
## Changelog
|
2
2
|
|
3
|
+
### 0.17.0
|
4
|
+
|
5
|
+
* Added support for Claris ID token login
|
6
|
+
* Added ability to use procs in settings
|
7
|
+
* Added `Rescuable` mixin
|
8
|
+
|
9
|
+
### 0.16.0
|
10
|
+
|
11
|
+
* Added `FmRest.logger=`
|
12
|
+
* Handle serialization of `nil`, `true` and `false` values
|
13
|
+
|
14
|
+
### 0.15.2
|
15
|
+
|
16
|
+
* Fixed autoloading of `FmRest::Layout`
|
17
|
+
|
3
18
|
### 0.15.0
|
4
19
|
|
5
20
|
* Much improved querying API (see documentation on querying), adding new
|
@@ -14,13 +29,13 @@
|
|
14
29
|
|
15
30
|
### 0.13.1
|
16
31
|
|
17
|
-
*
|
32
|
+
* Fixed downloading of container field data from FMS19+
|
18
33
|
|
19
34
|
### 0.13.0
|
20
35
|
|
21
36
|
* Split `fmrest` gem into `fmrest-core` and `fmrest-spyke`. `fmrest` becomes a
|
22
37
|
wrapper for the two new gems.
|
23
|
-
*
|
38
|
+
* Fixed bug preventing connection databases with spaces in their names.
|
24
39
|
* Improved portal support with ability to delete portal records, and better
|
25
40
|
refreshing of portal records after saving the parent.
|
26
41
|
* `FmRest::Spyke::Base#__record_id` and `FmRest::Spyke::Base#__mod_id` now
|
@@ -35,7 +50,7 @@
|
|
35
50
|
|
36
51
|
### 0.11.1
|
37
52
|
|
38
|
-
*
|
53
|
+
* Fixed a couple crashes due to missing constants
|
39
54
|
|
40
55
|
### 0.11.0
|
41
56
|
|
@@ -50,7 +65,7 @@
|
|
50
65
|
|
51
66
|
### 0.10.1
|
52
67
|
|
53
|
-
*
|
68
|
+
* Fixed `URI.escape` obsolete warning messages in Ruby 2.7 by replacing it with
|
54
69
|
`URI.encode_www_form_component`
|
55
70
|
([PR#40](https://github.com/beezwax/fmrest-ruby/pull/40))
|
56
71
|
|
@@ -124,20 +139,20 @@
|
|
124
139
|
|
125
140
|
### 0.3.2
|
126
141
|
|
127
|
-
*
|
142
|
+
* Fixed support for ActiveSupport < 5.2
|
128
143
|
([#27](https://github.com/beezwax/fmrest-ruby/issues/27))
|
129
144
|
|
130
145
|
### 0.3.0
|
131
146
|
|
132
|
-
*
|
147
|
+
* Added Moneta token store
|
133
148
|
|
134
149
|
### 0.2.5
|
135
150
|
|
136
|
-
*
|
151
|
+
* Fixed crash in `fetch_container_data` when no proxy options were set
|
137
152
|
|
138
153
|
### 0.2.4
|
139
154
|
|
140
155
|
* Use `String#=~` instead of `String#match?` for Ruby <2.4 compatibility (Fixes
|
141
156
|
[#26](https://github.com/beezwax/fmrest-ruby/issues/26))
|
142
|
-
*
|
157
|
+
* Deprecated `FmRest.config` in favor of `FmRest.default_connection_settings`
|
143
158
|
* Honor Faraday SSL and proxy settings when fetching container files
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/fmrest.svg?style=flat)](https://rubygems.org/gems/fmrest)
|
4
4
|
![CI](https://github.com/beezwax/fmrest-ruby/workflows/CI/badge.svg)
|
5
|
+
[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://rubydoc.info/github/beezwax/fmrest-ruby)
|
5
6
|
|
6
7
|
A Ruby client for
|
7
8
|
[FileMaker 18 and 19's Data API](https://help.claris.com/en/data-api-guide)
|
@@ -9,7 +10,7 @@ using
|
|
9
10
|
[Faraday](https://github.com/lostisland/faraday) and with optional
|
10
11
|
ActiveRecord-ish ORM features through [Spyke](https://github.com/balvig/spyke).
|
11
12
|
|
12
|
-
fmrest-ruby only partially implements FileMaker
|
13
|
+
fmrest-ruby only partially implements FileMaker 19's Data API.
|
13
14
|
See the [implementation completeness table](#api-implementation-completeness-table)
|
14
15
|
to see if a feature you need is natively supported by the gem.
|
15
16
|
|
@@ -124,6 +125,10 @@ The minimum required connection settings are `:host`, `:database`, `:username`
|
|
124
125
|
and `:password`, but fmrest-ruby has many other options you can pass when
|
125
126
|
setting up a connection (see [full list](#full-list-of-available-options) below).
|
126
127
|
|
128
|
+
If you're using FileMaker Cloud you may need to pass `:fmid_token` instead
|
129
|
+
of the regular `:username` and `:password`. See the [main document on
|
130
|
+
connecting to FileMaker Cloud](docs/FileMakerCloud.md) for more info.
|
131
|
+
|
127
132
|
`:ssl` and `:proxy` are forwarded to the underlying
|
128
133
|
[Faraday](https://github.com/lostisland/faraday) connection. You can use this
|
129
134
|
to, for instance, disable SSL verification:
|
@@ -148,9 +153,11 @@ Option | Description | Format
|
|
148
153
|
`:username` | A Data API-ready account | String | None
|
149
154
|
`:password` | Your password | String | None
|
150
155
|
`:account_name` | Alias of `:username` | String | None
|
156
|
+
`:fmid_token` | Claris ID token (only needed for FileMaker Cloud) | String | None
|
151
157
|
`:ssl` | SSL options to be forwarded to Faraday | Faraday SSL options | None
|
152
158
|
`:proxy` | Proxy options to be forwarded to Faraday | Faraday proxy options | None
|
153
159
|
`:log` | Log JSON responses to STDOUT | Boolean | `false`
|
160
|
+
`:log_level` | Which log level to log into | Values accepted by `Logger#level=` | `:debug`
|
154
161
|
`:coerce_dates` | See section on [date fields](#date-fields-and-timezones) | Boolean \| `:hybrid` \| `:full` | `false`
|
155
162
|
`:date_format` | Date parsing format | String (FM date format) | `"MM/dd/yyyy"`
|
156
163
|
`:timestamp_format` | Timestmap parsing format | String (FM date format) | `"MM/dd/yyyy HH:mm:ss"`
|
@@ -281,10 +288,12 @@ Also, if not set, your model will try to use
|
|
281
288
|
#### Connection settings overlays
|
282
289
|
|
283
290
|
There may be cases where you want to use a different set of connection settings
|
284
|
-
depending on context
|
285
|
-
provided by the user in a web
|
286
|
-
|
287
|
-
|
291
|
+
depending on context, or simply change the connection settings over time. For
|
292
|
+
example, if you want to use username and password provided by the user in a web
|
293
|
+
application, or if you're connecting using an expiring Claris ID token. Since
|
294
|
+
`.fmrest_config` is set at the class level, changing the username/password for
|
295
|
+
the model in one context would also change it in all other contexts, leading to
|
296
|
+
security issues.
|
288
297
|
|
289
298
|
To solve this scenario, fmrest-ruby provides a way of defining thread-local and
|
290
299
|
reversible connection settings overlays through
|
@@ -321,7 +330,7 @@ Requests a Data API session token using the connection settings in
|
|
321
330
|
|
322
331
|
You normally don't need to use this method as fmrest-ruby will automatically
|
323
332
|
request and store session tokens for you (provided that `:autologin` is
|
324
|
-
`true`).
|
333
|
+
`true` in the connection settings, which it is by default).
|
325
334
|
|
326
335
|
### FmRest::Layout.logout
|
327
336
|
|
@@ -450,13 +459,48 @@ field values on the database that model is configured for.
|
|
450
459
|
See the [main document on setting global field values](docs/GlobalFields.md)
|
451
460
|
for details.
|
452
461
|
|
462
|
+
### Rescuable mixin
|
463
|
+
|
464
|
+
Sometimes you may want to handle Data API errors at the model level. For
|
465
|
+
instance, if you're logging in to a file hosted by FileMaker Cloud using a
|
466
|
+
Claris ID token, and you want to be able to renew said token when it fails to
|
467
|
+
log you in. For such cases fmrest-ruby provides an off-by-default mixin called
|
468
|
+
`Rescuable` that provides convenience macros for that. If you've used Ruby on
|
469
|
+
Rails you may be familiar with its syntax from controllers. E.g.
|
470
|
+
|
471
|
+
```ruby
|
472
|
+
class BeeBase < FmRest::Layout
|
473
|
+
include FmRest::Spyke::Model::Rescuable
|
474
|
+
|
475
|
+
rescue_from FmRest::APIError::SystemError, with: :notify_admin_of_system_error
|
476
|
+
|
477
|
+
# Shorthand for rescue_with FmRest::APIError::AccountError, ...
|
478
|
+
rescue_account_error { ClarisIDTokenManager.expire_token }
|
479
|
+
|
480
|
+
def self.notify_admin_of_system_error(e)
|
481
|
+
# Shoot an email to the FM admin...
|
482
|
+
end
|
483
|
+
end
|
484
|
+
```
|
485
|
+
|
486
|
+
Since `Rescuable` uses `ActiveSupport::Rescuable` internally, you may want to
|
487
|
+
check [Rails'
|
488
|
+
documentation](https://api.rubyonrails.org/classes/ActiveSupport/Rescuable/ClassMethods.html)
|
489
|
+
too for details on how it works.
|
490
|
+
|
491
|
+
One caveat of using `rescue_from` is that it always catches exceptions at the
|
492
|
+
class level, so if you pass a method name to `with:` that method has to be a
|
493
|
+
class method. Also note that this will only catch exceptions raised during an
|
494
|
+
API call to the Data API server (in other words, only on actions that perform
|
495
|
+
an HTTP request).
|
496
|
+
|
453
497
|
## Logging
|
454
498
|
|
455
499
|
If using `fmrest-spyke` with Rails then pretty log output will be set up for
|
456
500
|
you automatically by Spyke (see [their
|
457
501
|
README](https://github.com/balvig/spyke#log-output)).
|
458
502
|
|
459
|
-
You can also enable simple Faraday
|
503
|
+
You can also enable simple Faraday logging of raw requests (useful for
|
460
504
|
debugging) by passing `log: true` in the options hash for either
|
461
505
|
`FmRest.default_connection_settings=` or your models' `fmrest_config=`, e.g.:
|
462
506
|
|
@@ -477,7 +521,17 @@ class LoggyBee < FmRest::Layout
|
|
477
521
|
end
|
478
522
|
```
|
479
523
|
|
480
|
-
|
524
|
+
You can also pass `log_level` to connection settings to change the severity of
|
525
|
+
log output (defaults to `:debug`).
|
526
|
+
|
527
|
+
By default fmrest-ruby logs to STDOUT or to Rails' logger object if available.
|
528
|
+
You can change this by providing your own logger object to `FmRest.logger=`:
|
529
|
+
|
530
|
+
```ruby
|
531
|
+
FmRest.logger = Logger.new("fmrest.log")
|
532
|
+
```
|
533
|
+
|
534
|
+
If you need to set up more complex logging for your models you can use the
|
481
535
|
`faraday` block inside your class to inject your own logger middleware into the
|
482
536
|
Faraday connection, e.g.:
|
483
537
|
|
@@ -498,7 +552,7 @@ FM Data API reference: https://fmhelp.filemaker.com/docs/18/en/dataapi/
|
|
498
552
|
| Log in using HTTP Basic Auth | Yes | Yes |
|
499
553
|
| Log in using OAuth | No | No |
|
500
554
|
| Log in to an external data source | No | No |
|
501
|
-
| Log in using
|
555
|
+
| Log in using Claris ID account | Yes | Yes |
|
502
556
|
| Log out | Yes | Yes |
|
503
557
|
| Get product information | Manual* | No |
|
504
558
|
| Get database names | Manual* | No |
|
@@ -552,6 +606,6 @@ See [LICENSE.txt](LICENSE.txt).
|
|
552
606
|
|
553
607
|
## Disclaimer
|
554
608
|
|
555
|
-
This project is not sponsored by or otherwise affiliated with
|
556
|
-
an Apple subsidiary. FileMaker is a trademark of
|
557
|
-
the U.S. and other countries.
|
609
|
+
This project is not sponsored by or otherwise affiliated with Claris
|
610
|
+
International Inc., an Apple Inc. subsidiary. FileMaker is a trademark of
|
611
|
+
Claris International Inc., registered in the U.S. and other countries.
|
data/lib/fmrest/spyke/model.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FmRest
|
4
|
+
module Spyke
|
5
|
+
module Model
|
6
|
+
module Rescuable
|
7
|
+
extend ::ActiveSupport::Concern
|
8
|
+
|
9
|
+
include ::ActiveSupport::Rescuable
|
10
|
+
|
11
|
+
class_methods do
|
12
|
+
def request(*args)
|
13
|
+
begin
|
14
|
+
super
|
15
|
+
rescue => e
|
16
|
+
rescue_with_handler(e) || raise
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def rescue_account_error(with: nil, &block)
|
21
|
+
rescue_from APIError::AccountError, with: with, &block
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -73,6 +73,10 @@ module FmRest
|
|
73
73
|
# Modifies the given hash in-place encoding non-string values (e.g.
|
74
74
|
# dates) to their string representation when appropriate.
|
75
75
|
#
|
76
|
+
# nil gets converted to empty string as the Data API doesn't accept
|
77
|
+
# nulls in JSON. Likewise, true and false get converted to 1 and 0
|
78
|
+
# respectively.
|
79
|
+
#
|
76
80
|
def serialize_values!(params)
|
77
81
|
params.transform_values! do |value|
|
78
82
|
case value
|
@@ -80,6 +84,10 @@ module FmRest
|
|
80
84
|
FmRest::V1.convert_datetime_timezone(value.to_datetime, fmrest_config.timezone).strftime(FmRest::V1::Dates::FM_DATETIME_FORMAT)
|
81
85
|
when *FmRest::V1.date_classes
|
82
86
|
value.strftime(FmRest::V1::Dates::FM_DATE_FORMAT)
|
87
|
+
when nil
|
88
|
+
""
|
89
|
+
when true, false
|
90
|
+
value ? 1 : 0
|
83
91
|
else
|
84
92
|
value
|
85
93
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fmrest-spyke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.17.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pedro Carbajal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fmrest-core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.17.0.rc1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.17.0.rc1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: spyke
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- lib/fmrest/spyke/model/http.rb
|
65
65
|
- lib/fmrest/spyke/model/orm.rb
|
66
66
|
- lib/fmrest/spyke/model/record_id.rb
|
67
|
+
- lib/fmrest/spyke/model/rescuable.rb
|
67
68
|
- lib/fmrest/spyke/model/serialization.rb
|
68
69
|
- lib/fmrest/spyke/model/uri.rb
|
69
70
|
- lib/fmrest/spyke/portal.rb
|
@@ -85,11 +86,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
86
|
version: '0'
|
86
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
88
|
requirements:
|
88
|
-
- - "
|
89
|
+
- - ">"
|
89
90
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
91
|
+
version: 1.3.1
|
91
92
|
requirements: []
|
92
|
-
rubygems_version: 3.
|
93
|
+
rubygems_version: 3.2.3
|
93
94
|
signing_key:
|
94
95
|
specification_version: 4
|
95
96
|
summary: FileMaker Data API ORM client library
|