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: 59bcabb74959ab090658d106c743b18c6503f75b085ad32c9282288a2ece4963
4
- data.tar.gz: 66c2283f513b2f22d603b16f30480713992879a31fb46985f14dd7cf74b94c0a
3
+ metadata.gz: a13562c23233f9b3e5083c0d0f8d4478fd09eeaf6f9581b9e7b38b3020c96507
4
+ data.tar.gz: f6055e0ab36bdddc899de5e44d792c63185c1d0f040234f94812ac73672d562a
5
5
  SHA512:
6
- metadata.gz: de2234332df46b3fbe7ddfeaf7425df1f0e789d39e9c0cba722044508f03019cabffe700edf977160beb1a087c96d07deb67f65b3e0ca1c8f4e31706be03c909
7
- data.tar.gz: 8dd2c52e79c5253e7618ef9c70a93db8f4920bb56f96b9b7c2da5d6afb220fcc704d29f10019ecee4901d8d6e5755087dbb2067da3c024c2bf6dc3e7697a1c2a
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).to_s
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
- value_with_context_variables_injected = value
41
- encountered_variables = []
42
-
43
- while (match = REGEX.match(value_with_context_variables_injected))
44
- context_variable_key = match[1]
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
- unless encountered_variables.include?(context_variable_key)
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
- value_with_context_variables_injected
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)
@@ -6,7 +6,7 @@ module ForestAdminAgent
6
6
  module Schema
7
7
  class SchemaEmitter
8
8
  LIANA_NAME = "agent-ruby"
9
- LIANA_VERSION = "1.36.0"
9
+ LIANA_VERSION = "1.36.1"
10
10
 
11
11
  def self.generate(datasource)
12
12
  datasource.collections
@@ -1,3 +1,3 @@
1
1
  module ForestAdminAgent
2
- VERSION = "1.36.0"
2
+ VERSION = "1.36.1"
3
3
  end
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.0
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-24 00:00:00.000000000 Z
12
+ date: 2026-07-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport