forest_admin_agent 1.18.1 → 1.18.2

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: 2c0c7ac45f6661b38704dd42df17a804322b73f224470bdb9181b5f70b410265
4
- data.tar.gz: 66097896658cb04214a890cb321f76f2923640c82c24b8c75c47c3d234f5a5c6
3
+ metadata.gz: 34b3a41aa849d5f38a8631577e514899eaf9608230f90049596787a0f9a2042b
4
+ data.tar.gz: c999f42eefa8264753f80788e6ca05d595617d944f95e88f85378bfb0f325e4c
5
5
  SHA512:
6
- metadata.gz: 5d2fdfa4dde4796136a574aa686b5fb367e63687f56df413b1f790efb5e9d03641cadda187e504d33061982c5301e63e51ec12830abc5065e722bdb3f0656f49
7
- data.tar.gz: fc2d13e26bf318ca0b9ef821ea544abc806a624e4f1a69393e414162dfb3228078fc4fb0a3fbda22c523879fdc8f55a41f48d60380a58c03e4ac5a9204d43bdc
6
+ metadata.gz: 729ab09bc7174076c67f15a3a2018c801d902b0cc1eb2fe2ca5d7414380fa0baa6b5cca22b39940df628e001b38c607a3bbfd0fdbec7aa9ec4fd872460f103a5
7
+ data.tar.gz: 4f11327ae9911fc2398ac8af076c8321c85c114b6d51b4ab352883533789aaba03f30032f39271a1ce186be77b246bcd57d993010ada55e7afa42aa9ad9be823
@@ -83,6 +83,24 @@ module ForestAdminAgent
83
83
 
84
84
  return unless @has_env_secret
85
85
 
86
+ schema = generate_schema_file
87
+
88
+ if (append_schema_path = Facades::Container.cache(:append_schema_path))
89
+ begin
90
+ append_schema_file = JSON.parse(File.read(append_schema_path), symbolize_names: true)
91
+ schema[:collections] = schema[:collections] + append_schema_file[:collections]
92
+ rescue StandardError => e
93
+ raise "Can't load additional schema #{append_schema_path}: #{e.message}"
94
+ end
95
+ end
96
+
97
+ post_schema(schema, force)
98
+ end
99
+
100
+ # Generates or loads the schema and writes it to file (in development mode).
101
+ # This method can be overridden by subclasses that need to customize schema handling.
102
+ # @return [Hash] The schema hash with :meta and :collections keys
103
+ def generate_schema_file
86
104
  schema_path = Facades::Container.cache(:schema_path)
87
105
 
88
106
  if Facades::Container.cache(:is_production)
@@ -93,29 +111,33 @@ module ForestAdminAgent
93
111
  )
94
112
  end
95
113
 
96
- schema = JSON.parse(File.read(schema_path), symbolize_names: true)
114
+ JSON.parse(File.read(schema_path), symbolize_names: true)
97
115
  else
98
- generated = SchemaEmitter.generate(@container.resolve(:datasource))
99
- meta = SchemaEmitter.meta
100
-
101
- schema = {
102
- meta: meta,
103
- collections: generated
104
- }
105
-
106
- File.write(schema_path, format_schema_json(schema))
116
+ datasource = @container.resolve(:datasource)
117
+ schema = build_schema(datasource)
118
+ write_schema_file(schema_path, schema)
119
+ schema
107
120
  end
121
+ end
108
122
 
109
- if (append_schema_path = Facades::Container.cache(:append_schema_path))
110
- begin
111
- append_schema_file = JSON.parse(File.read(append_schema_path), symbolize_names: true)
112
- schema[:collections] = schema[:collections] + append_schema_file[:collections]
113
- rescue StandardError => e
114
- raise "Can't load additional schema #{append_schema_path}: #{e.message}"
115
- end
116
- end
123
+ # Builds the schema hash from the datasource
124
+ # @param datasource [Object] The datasource to generate schema from
125
+ # @return [Hash] The schema hash with :meta and :collections keys
126
+ def build_schema(datasource)
127
+ generated = SchemaEmitter.generate(datasource)
128
+ meta = SchemaEmitter.meta
117
129
 
118
- post_schema(schema, force)
130
+ {
131
+ meta: meta,
132
+ collections: generated
133
+ }
134
+ end
135
+
136
+ # Writes the schema to a file
137
+ # @param schema_path [String] Path to write the schema file
138
+ # @param schema [Hash] The schema to write
139
+ def write_schema_file(schema_path, schema)
140
+ File.write(schema_path, format_schema_json(schema))
119
141
  end
120
142
 
121
143
  private
@@ -29,8 +29,9 @@ module ForestAdminAgent
29
29
  action = collection.schema[:actions][name]
30
30
  action_index = collection.schema[:actions].keys.index(name)
31
31
  slug = get_action_slug(name)
32
- form_elements = extract_fields_and_layout(collection.get_form(nil, name))
32
+
33
33
  if action.static_form
34
+ form_elements = extract_fields_and_layout(collection.get_form(nil, name))
34
35
  fields = build_fields(collection, form_elements[:fields])
35
36
  layout = form_elements[:layout]
36
37
  else
@@ -6,7 +6,7 @@ module ForestAdminAgent
6
6
  module Schema
7
7
  class SchemaEmitter
8
8
  LIANA_NAME = "agent-ruby"
9
- LIANA_VERSION = "1.18.1"
9
+ LIANA_VERSION = "1.18.2"
10
10
 
11
11
  def self.generate(datasource)
12
12
  datasource.collections
@@ -1,3 +1,3 @@
1
1
  module ForestAdminAgent
2
- VERSION = "1.18.1"
2
+ VERSION = "1.18.2"
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.18.1
4
+ version: 1.18.2
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: 2025-12-11 00:00:00.000000000 Z
12
+ date: 2025-12-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport