trmnl_preview 0.22.0 → 0.23.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +10 -0
- data/lib/trmnlp/config/plugin.rb +3 -1
- data/lib/trmnlp/poller.rb +13 -11
- data/lib/trmnlp/testing/publishable_recipe.rb +2 -1
- data/lib/trmnlp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8ae35ca9666591a11737a146ccc41ce507f64e9828df8e099d4200e3d6fda809
|
|
4
|
+
data.tar.gz: fafd948b1cac498f3b24a793075782eff32dd3608ea083242cc90807227ab6a7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3877a9953a508027f9fb2ad2700a138842f7376f4f7567af2259b168a82a910d1bec70e9a192ad50623410c575f8c47ffc0ba60f1a8681c6e4f8aff68fdb47b0
|
|
7
|
+
data.tar.gz: 8da826b2291adbc73c08043c9c8239a9924103aecd42f16e1a5e072e63832ba8dbb79081591d368f526861359aa26880b2912e256d2fbc1f1928781a7499379f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
|
|
2
2
|
# Changelog
|
|
3
3
|
|
|
4
|
+
## 0.23.0
|
|
5
|
+
|
|
6
|
+
- `TRMNLP::Poller#fetch_responses` is public: each polling url as TRMNL resolves it, with its live response. A tool can keep them as the mocks `trmnlp test` answers with.
|
|
7
|
+
- `it_behaves_like 'a publishable recipe'` uses the group's `data`, so a webhook plugin's examples can draw from the merge variables it stores.
|
|
8
|
+
- A static plugin with blank `static_data` renders with no data, as on TRMNL, instead of failing with "invalid JSON in static_data". A byte order mark before the JSON is skipped, as on TRMNL.
|
|
9
|
+
|
|
10
|
+
## 0.22.1
|
|
11
|
+
|
|
12
|
+
- The Docker image runs liquid 5.14 and selenium-webdriver 4.50, as TRMNL does. It had 5.13 and 4.48, so Liquid output could differ from TRMNL. Installs of the gem already took the newer versions.
|
|
13
|
+
|
|
4
14
|
## 0.22.0
|
|
5
15
|
|
|
6
16
|
- The `bin/trmnlp` script that `trmnlp init` writes takes the steps that run the Docker image from the image, once a day, so a fix to them reaches every plugin with the image. Before, each plugin kept its own copy, which changed only when `trmnlp init` ran again. A plugin made before this release gets the new script from `trmnlp init <its folder>`, answering `y` for `bin/trmnlp` only, once.
|
data/README.md
CHANGED
|
@@ -550,6 +550,16 @@ To cut a release:
|
|
|
550
550
|
|
|
551
551
|
By convention, add a matching `CHANGELOG.md` entry in the same change.
|
|
552
552
|
|
|
553
|
+
## Related guides
|
|
554
|
+
|
|
555
|
+
- [Private Plugins](https://help.trmnl.com/en/articles/9510536-private-plugins): strategies, polling and webhooks
|
|
556
|
+
- [Liquid 101](https://help.trmnl.com/en/articles/10671186-liquid-101) and the [Framework Design Docs](https://help.trmnl.com/en/articles/12410486-framework-design-docs)
|
|
557
|
+
- [Custom plugin form builder](https://help.trmnl.com/en/articles/10513740-custom-plugin-form-builder): the form fields `src/settings.yml` declares
|
|
558
|
+
- [Syncing Plugins with GitHub](https://help.trmnl.com/en/articles/13465101-syncing-plugins-with-github) and [GitHub Sync](https://help.trmnl.com/en/articles/15977899-github-sync)
|
|
559
|
+
- [Recipe best practices](https://help.trmnl.com/en/articles/11395668-recipe-best-practices) and [Demo Data for Publishing Plugins](https://help.trmnl.com/en/articles/12772238-demo-data-for-publishing-plugins)
|
|
560
|
+
- [TRMNL CLI](https://help.trmnl.com/en/articles/17226209-trmnl-cli): the rest of your account from the terminal
|
|
561
|
+
- [MCP Server](https://help.trmnl.com/en/articles/17432548-mcp-server) and our [agent skills](https://github.com/usetrmnl/trmnl-agent-skills): build plugins with an AI agent
|
|
562
|
+
|
|
553
563
|
## Contributing
|
|
554
564
|
|
|
555
565
|
Bug reports and pull requests are welcome on GitHub at https://github.com/usetrmnl/trmnlp.
|
data/lib/trmnlp/config/plugin.rb
CHANGED
|
@@ -69,8 +69,10 @@ module TRMNLP
|
|
|
69
69
|
|
|
70
70
|
def id = @config['id']
|
|
71
71
|
|
|
72
|
+
# Like TRMNL: blank is no data, and a byte order mark is not part of the JSON.
|
|
72
73
|
def static_data
|
|
73
|
-
|
|
74
|
+
text = @config['static_data'].to_s.delete_prefix("\uFEFF")
|
|
75
|
+
text.strip.empty? ? {} : JSON.parse(text)
|
|
74
76
|
rescue JSON::ParserError
|
|
75
77
|
raise InvalidConfig, 'invalid JSON in static_data'
|
|
76
78
|
end
|
data/lib/trmnlp/poller.rb
CHANGED
|
@@ -46,6 +46,16 @@ module TRMNLP
|
|
|
46
46
|
{}
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
+
# Each polling url as TRMNL resolves it, with its response, or nil when the fetch failed.
|
|
50
|
+
def fetch_responses
|
|
51
|
+
# Resolve once per attempt (it refreshes as a side effect), then share across
|
|
52
|
+
# every URL, header, and body render.
|
|
53
|
+
variables = trmnl_variables.call.merge(oauth_session.liquid_variables)
|
|
54
|
+
headers = config.plugin.polling_headers(extra_variables: variables)
|
|
55
|
+
body = config.plugin.polling_body(extra_variables: variables)
|
|
56
|
+
config.plugin.polling_urls(extra_variables: variables).map { |url| [url, fetch_one(url, headers, body)] }
|
|
57
|
+
end
|
|
58
|
+
|
|
49
59
|
private
|
|
50
60
|
|
|
51
61
|
attr_reader :config, :paths, :oauth_session, :trmnl_variables, :reporter, :async_callback
|
|
@@ -74,24 +84,16 @@ module TRMNLP
|
|
|
74
84
|
end
|
|
75
85
|
|
|
76
86
|
def aggregate_responses
|
|
77
|
-
fetched =
|
|
87
|
+
fetched = fetch_responses
|
|
78
88
|
# Like the hosted service: a token rejected before its expiry gets one refresh and retry.
|
|
79
|
-
|
|
89
|
+
token_rejected = fetched.any? { |_url, response| response&.status == 401 }
|
|
90
|
+
fetched = fetch_responses if token_rejected && oauth_session.force_refresh!
|
|
80
91
|
responses = fetched.map { |url, response| response ? parse_response(response, url) : {} }
|
|
81
92
|
return responses.first if responses.size == 1
|
|
82
93
|
|
|
83
94
|
responses.each_with_index.with_object({}) { |(r, i), h| h["IDX_#{i}"] = r }
|
|
84
95
|
end
|
|
85
96
|
|
|
86
|
-
def fetch_all
|
|
87
|
-
# Resolve once per attempt (it refreshes as a side effect), then share across
|
|
88
|
-
# every URL, header, and body render.
|
|
89
|
-
variables = trmnl_variables.call.merge(oauth_session.liquid_variables)
|
|
90
|
-
headers = config.plugin.polling_headers(extra_variables: variables)
|
|
91
|
-
body = config.plugin.polling_body(extra_variables: variables)
|
|
92
|
-
config.plugin.polling_urls(extra_variables: variables).map { |url| [url, fetch_one(url, headers, body)] }
|
|
93
|
-
end
|
|
94
|
-
|
|
95
97
|
def fetch_one(url, headers, body)
|
|
96
98
|
verb = config.plugin.polling_verb.upcase
|
|
97
99
|
response, failure = outbound_request.call(verb, url, headers:, body:)
|
|
@@ -35,7 +35,8 @@ end
|
|
|
35
35
|
RSpec.shared_examples 'a publishable recipe' do |screens: TRMNLP::Testing::PUBLISHABLE_RECIPE_SCREENS|
|
|
36
36
|
let(:recipe_inputs) do
|
|
37
37
|
{ mocks: respond_to?(:mocks) ? mocks : {}, custom_fields: respond_to?(:custom_fields) ? custom_fields : {},
|
|
38
|
-
variables: respond_to?(:variables) ? variables : {}, now: respond_to?(:now) ? now : nil
|
|
38
|
+
variables: respond_to?(:variables) ? variables : {}, now: respond_to?(:now) ? now : nil,
|
|
39
|
+
data: respond_to?(:data) ? data : nil }
|
|
39
40
|
end
|
|
40
41
|
|
|
41
42
|
def draw_cleanly = have_no_problems.and(have_no_leaked_text)
|
data/lib/trmnlp/version.rb
CHANGED