wcc-contentful 1.4.0.rc1 → 1.4.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/app/jobs/wcc/contentful/webhook_enable_job.rb +0 -1
- data/lib/wcc/contentful/active_record_shim.rb +2 -2
- data/lib/wcc/contentful/middleware/store/caching_middleware.rb +10 -3
- data/lib/wcc/contentful/model_builder.rb +2 -2
- data/lib/wcc/contentful/simple_client.rb +0 -2
- data/lib/wcc/contentful/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b1a0aa21bc1bc749fdfc169eecf55d5bf829e0d4ac4272e90649c2d46abf622
|
4
|
+
data.tar.gz: 12812d6728c4992ea3763cdbe0dc8f204267a75c3f35a052a663ec8c4f380115
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9226778b6abf97db358f836ed0659e202f13266fbf946acd793cbeed23f69cb3cab475e9750ca64761ba6ceecd38cdaaad7f919ea2a2d04f00fa4d8e940d9653
|
7
|
+
data.tar.gz: c4f0bb1b6e44fa8b0a4aa647e246ff7dd6726d62e2905d026f2bb201867fb09af640b266ab95c22e04dab6b23f4c162ec6d88cf3bd45ca41c9a5853eb4842d80
|
data/README.md
CHANGED
@@ -374,7 +374,6 @@ WCC::Contentful::SimpleClient::Cdn.new(
|
|
374
374
|
space: '1234',
|
375
375
|
# optional
|
376
376
|
environment: 'staging', # omit to use master
|
377
|
-
default_locale: '*',
|
378
377
|
rate_limit_wait_timeout: 10,
|
379
378
|
instrumentation: ActiveSupport::Notifications,
|
380
379
|
connection: Faraday.new { |builder| ... },
|
@@ -51,7 +51,6 @@ module WCC::Contentful
|
|
51
51
|
management_token: config.management_token,
|
52
52
|
space: config.space,
|
53
53
|
environment: config.environment,
|
54
|
-
default_locale: config.default_locale,
|
55
54
|
connection: config.connection,
|
56
55
|
webhook_username: config.webhook_username,
|
57
56
|
webhook_password: config.webhook_password,
|
@@ -33,7 +33,7 @@ module WCC::Contentful::ActiveRecordShim
|
|
33
33
|
|
34
34
|
class_methods do
|
35
35
|
def model_name
|
36
|
-
WCC::Contentful::Helpers.constant_from_content_type(content_type)
|
36
|
+
ActiveModel::Name.new(self, nil, WCC::Contentful::Helpers.constant_from_content_type(content_type))
|
37
37
|
end
|
38
38
|
|
39
39
|
def const_get(name)
|
@@ -46,7 +46,7 @@ module WCC::Contentful::ActiveRecordShim
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def table_name
|
49
|
-
model_name.tableize
|
49
|
+
model_name.plural.tableize
|
50
50
|
end
|
51
51
|
|
52
52
|
def unscoped
|
@@ -34,7 +34,8 @@ module WCC::Contentful::Middleware::Store
|
|
34
34
|
# Now that the one locale is in the cache, when we index next time we'll index the
|
35
35
|
# all-locales version and we'll be fine.
|
36
36
|
locale = options[:locale]&.to_s || default_locale
|
37
|
-
|
37
|
+
found_locale = found.dig('sys', 'locale')&.to_s
|
38
|
+
if found_locale && (found_locale != locale)
|
38
39
|
event = 'miss'
|
39
40
|
return store.find(key, **options)
|
40
41
|
end
|
@@ -90,15 +91,21 @@ module WCC::Contentful::Middleware::Store
|
|
90
91
|
id = json.dig('sys', 'id')
|
91
92
|
type = json.dig('sys', 'type')
|
92
93
|
prev = @cache.read(id)
|
93
|
-
|
94
|
+
if prev.nil? && LAZILY_CACHEABLE_TYPES.include?(type)
|
95
|
+
_instrument('miss.index', key: id, type: type, prev: nil, next: nil)
|
96
|
+
return
|
97
|
+
end
|
94
98
|
|
95
99
|
if (prev_rev = prev&.dig('sys', 'revision')) && (next_rev = json.dig('sys', 'revision')) && (next_rev < prev_rev)
|
100
|
+
_instrument('miss.index', key: id, type: type, prev: prev_rev, next: next_rev)
|
96
101
|
return prev
|
97
102
|
end
|
98
103
|
|
99
104
|
# we also set DeletedEntry objects in the cache - no need to go hit the API when we know
|
100
105
|
# this is a nil object
|
101
|
-
|
106
|
+
_instrument('write.index', key: id, type: type, prev: prev_rev, next: next_rev) do
|
107
|
+
@cache.write(id, json, expires_in: expires_in)
|
108
|
+
end
|
102
109
|
|
103
110
|
case type
|
104
111
|
when 'DeletedEntry', 'DeletedAsset'
|
@@ -59,11 +59,11 @@ module WCC::Contentful
|
|
59
59
|
|
60
60
|
define_method(:initialize) do |raw, context = nil|
|
61
61
|
ct = content_type_from_raw(raw)
|
62
|
-
if ct != typedef.content_type
|
62
|
+
if ct.present? && ct != typedef.content_type
|
63
63
|
raise ArgumentError, 'Wrong Content Type - ' \
|
64
64
|
"'#{raw.dig('sys', 'id')}' is a #{ct}, expected #{typedef.content_type}"
|
65
65
|
end
|
66
|
-
if raw.dig('sys', 'locale').blank?
|
66
|
+
if raw.dig('sys', 'locale').blank? && %w[Entry Asset].include?(raw.dig('sys', 'type'))
|
67
67
|
raise ArgumentError, 'Model layer cannot represent "locale=*" entries. ' \
|
68
68
|
"Please use a specific locale in your query. \n" \
|
69
69
|
"(Error occurred with entry id: #{raw.dig('sys', 'id')})"
|
@@ -36,7 +36,6 @@ module WCC::Contentful
|
|
36
36
|
# @param [Hash] options The remaining optional parameters, defined below
|
37
37
|
# @option options [Symbol, Object] connection The Faraday connection to use to make requests.
|
38
38
|
# Auto-discovered based on what gems are installed if this is not provided.
|
39
|
-
# @option options [String] default_locale The locale query param to set by default.
|
40
39
|
# @option options [String] environment The contentful environment to access. Defaults to 'master'.
|
41
40
|
# @option options [Boolean] no_follow_redirects If true, do not follow 300 level redirects.
|
42
41
|
# @option options [Number] rate_limit_wait_timeout The maximum time to block the thread waiting
|
@@ -51,7 +50,6 @@ module WCC::Contentful
|
|
51
50
|
@options = options
|
52
51
|
@_instrumentation = @options[:instrumentation]
|
53
52
|
@query_defaults = {}
|
54
|
-
@query_defaults[:locale] = @options[:default_locale] if @options[:default_locale]
|
55
53
|
# default 1.5 so that we retry one time then fail if still rate limited
|
56
54
|
# https://www.contentful.com/developers/docs/references/content-preview-api/#/introduction/api-rate-limits
|
57
55
|
@rate_limit_wait_timeout = @options[:rate_limit_wait_timeout] || 1.5
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wcc-contentful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.0.
|
4
|
+
version: 1.4.0.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Watermark Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -698,8 +698,8 @@ summary: '[![Gem Version](https://badge.fury.io/rb/wcc-contentful.svg)](https://
|
|
698
698
|
credentials, or to connect without setting up all the rest of WCC::Contentful, is
|
699
699
|
easy: ```ruby WCC::Contentful::SimpleClient::Cdn.new( # required access_token:
|
700
700
|
''xxxx'', space: ''1234'', # optional environment: ''staging'', # omit to use master
|
701
|
-
|
702
|
-
|
701
|
+
rate_limit_wait_timeout: 10, instrumentation: ActiveSupport::Notifications, connection:
|
702
|
+
Faraday.new { |builder| ... }, ) ``` You can also create a {WCC::Contentful::SimpleClient::Preview}
|
703
703
|
to talk to the Preview API, or a {WCC::Contentful::SimpleClient::Management} to
|
704
704
|
talk to the Management API. ### Store Layer The Store Layer represents the data
|
705
705
|
store where Contentful entries are kept for querying. By default, `WCC::Contentful.init!`
|