forest_admin_agent 1.36.0 → 1.36.1
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a13562c23233f9b3e5083c0d0f8d4478fd09eeaf6f9581b9e7b38b3020c96507
|
|
4
|
+
data.tar.gz: f6055e0ab36bdddc899de5e44d792c63185c1d0f040234f94812ac73672d562a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 75c550acaf51c3cd42c001d6629fdb777d730428d1dedbb1369dea0545e792b9a58e96b62825e8b428fa37458482a631bdfd78f6380f9faff0346c02b4b82d42
|
|
7
|
+
data.tar.gz: 0e78923aee30934275076f58ad3e526a34a5c7c744e864a178b83c7a34146f5e5a2c121f7f4b5c2dd33051bea050b14080afb4d1ca5f2ee196876054286ca718
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
1
3
|
module ForestAdminAgent
|
|
2
4
|
module Utils
|
|
3
5
|
class ContextVariablesInjector
|
|
@@ -5,13 +7,28 @@ module ForestAdminAgent
|
|
|
5
7
|
include ForestAdminAgent::Builder
|
|
6
8
|
|
|
7
9
|
REGEX = /{{([^}]+)}}/
|
|
10
|
+
FULL_REFERENCE_REGEX = /\A{{([^}]+)}}\z/
|
|
8
11
|
|
|
9
12
|
def self.inject_context_in_value(value, context_variables)
|
|
13
|
+
return value unless value.is_a?(String)
|
|
14
|
+
|
|
15
|
+
# A value that is exactly one {{variable}} reference (no surrounding text) keeps the
|
|
16
|
+
# resolved object as-is, so a jsonb/array field gets typed-cast correctly by the
|
|
17
|
+
# datasource instead of being compared against a serialized string that can never match.
|
|
18
|
+
full_reference = FULL_REFERENCE_REGEX.match(value)
|
|
19
|
+
return context_variables.get_value(full_reference[1]) if full_reference
|
|
20
|
+
|
|
10
21
|
inject_context_in_value_custom(value) do |context_variable_key|
|
|
11
|
-
context_variables.get_value(context_variable_key)
|
|
22
|
+
serialize_for_injection(context_variables.get_value(context_variable_key))
|
|
12
23
|
end
|
|
13
24
|
end
|
|
14
25
|
|
|
26
|
+
def self.serialize_for_injection(resolved_value)
|
|
27
|
+
return JSON.generate(resolved_value) if resolved_value.is_a?(Array) || resolved_value.is_a?(Hash)
|
|
28
|
+
|
|
29
|
+
resolved_value.to_s
|
|
30
|
+
end
|
|
31
|
+
|
|
15
32
|
def self.inject_context_in_native_query(datasource, connection_name, query, context_variables)
|
|
16
33
|
return query unless query.is_a?(String)
|
|
17
34
|
|
|
@@ -37,23 +54,17 @@ module ForestAdminAgent
|
|
|
37
54
|
def self.inject_context_in_value_custom(value)
|
|
38
55
|
return value unless value.is_a?(String)
|
|
39
56
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
57
|
+
# Resolve every distinct {{key}} found in the ORIGINAL string upfront, then substitute
|
|
58
|
+
# in a single gsub pass. A resolved value can itself contain "{{...}}"-looking text (e.g.
|
|
59
|
+
# a tag whose data happens to include it); re-scanning a mutated string for placeholders
|
|
60
|
+
# (the previous while+gsub! approach) would misinterpret that text as a new reference, or
|
|
61
|
+
# loop forever if it matched an already-resolved key without ever changing the string.
|
|
62
|
+
keys = value.scan(REGEX).map(&:first).uniq
|
|
63
|
+
return value if keys.empty?
|
|
45
64
|
|
|
46
|
-
|
|
47
|
-
value_with_context_variables_injected.gsub!(
|
|
48
|
-
/{{#{context_variable_key}}}/,
|
|
49
|
-
yield(context_variable_key)
|
|
50
|
-
)
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
encountered_variables.push(context_variable_key)
|
|
54
|
-
end
|
|
65
|
+
replacements = keys.to_h { |key| [key, yield(key)] }
|
|
55
66
|
|
|
56
|
-
|
|
67
|
+
value.gsub(REGEX) { replacements[::Regexp.last_match(1)] }
|
|
57
68
|
end
|
|
58
69
|
|
|
59
70
|
def self.inject_context_in_filter(filter, context_variables)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: forest_admin_agent
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.36.
|
|
4
|
+
version: 1.36.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matthieu
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2026-07-
|
|
12
|
+
date: 2026-07-31 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activesupport
|