forest_admin_agent 1.0.0.pre.beta.98 → 1.0.0.pre.beta.100
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/lib/forest_admin_agent/auth/oauth2/forest_provider.rb +3 -0
- data/lib/forest_admin_agent/http/Exceptions/authentication_open_id_client.rb +4 -7
- data/lib/forest_admin_agent/routes/abstract_authenticated_route.rb +2 -2
- data/lib/forest_admin_agent/routes/resources/related/list_related.rb +2 -1
- data/lib/forest_admin_agent/routes/resources/show.rb +1 -2
- data/lib/forest_admin_agent/routes/resources/store.rb +3 -4
- data/lib/forest_admin_agent/routes/security/authentication.rb +3 -2
- data/lib/forest_admin_agent/utils/condition_tree_parser.rb +1 -2
- data/lib/forest_admin_agent/utils/schema/schema_emitter.rb +1 -1
- data/lib/forest_admin_agent/version.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 571b2ad1ae88257dca7e1818d91782c6f2e2e6289406814170bff6df5f1e298d
         | 
| 4 | 
            +
              data.tar.gz: 80b3fc61ce8df873bc697ff898594cc0d90cd3a66312de5f7d205b4d9940ae74
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 8aabb66ff52ccabc7ac79c3e8f0d848e78d786a4d9205965107c39d5bcffd5a08511915b60525bfa90010486075a2214e1bf551c0db3be5f05f5ed1a428ae483
         | 
| 7 | 
            +
              data.tar.gz: f06148e05b27bc68c11aa1193f6ba737c8cc17458a9bf57925f96759f512202488c6e7d271cc573c3587bb963044d321b67637d1ddccd59fa682af6d44f5d9ab
         | 
| @@ -47,6 +47,9 @@ module ForestAdminAgent | |
| 47 47 | 
             
                        raise OpenIDConnect::BadRequest.new('API Access Failed', response)
         | 
| 48 48 | 
             
                      when 401
         | 
| 49 49 | 
             
                        raise OpenIDConnect::Unauthorized.new(Utils::ErrorMessages::AUTHORIZATION_FAILED, response)
         | 
| 50 | 
            +
                      when 403
         | 
| 51 | 
            +
                        error = response.body['errors'].first
         | 
| 52 | 
            +
                        raise OpenIDConnect::Forbidden.new(error['name'], error['detail'])
         | 
| 50 53 | 
             
                      when 404
         | 
| 51 54 | 
             
                        raise OpenIDConnect::HttpError.new(response.status, Utils::ErrorMessages::SECRET_NOT_FOUND, response)
         | 
| 52 55 | 
             
                      when 422
         | 
| @@ -2,13 +2,10 @@ module ForestAdminAgent | |
| 2 2 | 
             
              module Http
         | 
| 3 3 | 
             
                module Exceptions
         | 
| 4 4 | 
             
                  class AuthenticationOpenIdClient < HttpException
         | 
| 5 | 
            -
                     | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
                      super | 
| 9 | 
            -
                      @error = error
         | 
| 10 | 
            -
                      @message = error_description
         | 
| 11 | 
            -
                      @state = state
         | 
| 5 | 
            +
                    def initialize(status = 401,
         | 
| 6 | 
            +
                                   message = 'Authentication failed with OpenID Client',
         | 
| 7 | 
            +
                                   name = 'AuthenticationOpenIdClient')
         | 
| 8 | 
            +
                      super
         | 
| 12 9 | 
             
                    end
         | 
| 13 10 | 
             
                  end
         | 
| 14 11 | 
             
                end
         | 
| @@ -11,12 +11,12 @@ module ForestAdminAgent | |
| 11 11 | 
             
                  end
         | 
| 12 12 |  | 
| 13 13 | 
             
                  def format_attributes(args)
         | 
| 14 | 
            -
                    record = args[:params][:data][:attributes]
         | 
| 14 | 
            +
                    record = args[:params][:data][:attributes] || {}
         | 
| 15 15 |  | 
| 16 16 | 
             
                    args[:params][:data][:relationships]&.map do |field, value|
         | 
| 17 17 | 
             
                      schema = @collection.schema[:fields][field]
         | 
| 18 18 |  | 
| 19 | 
            -
                      record[schema.foreign_key] = value['data'][ | 
| 19 | 
            +
                      record[schema.foreign_key] = value['data']['id'] if schema.type == 'ManyToOne'
         | 
| 20 20 | 
             
                    end
         | 
| 21 21 |  | 
| 22 22 | 
             
                    record || {}
         | 
| @@ -31,7 +31,8 @@ module ForestAdminAgent | |
| 31 31 | 
             
                              ForestAdminAgent::Utils::QueryStringParser.parse_condition_tree(@child_collection, args)
         | 
| 32 32 | 
             
                            ]
         | 
| 33 33 | 
             
                          ),
         | 
| 34 | 
            -
                          page: ForestAdminAgent::Utils::QueryStringParser.parse_pagination(args)
         | 
| 34 | 
            +
                          page: ForestAdminAgent::Utils::QueryStringParser.parse_pagination(args),
         | 
| 35 | 
            +
                          sort: ForestAdminAgent::Utils::QueryStringParser.parse_sort(@child_collection, args)
         | 
| 35 36 | 
             
                        )
         | 
| 36 37 | 
             
                        projection = ForestAdminAgent::Utils::QueryStringParser.parse_projection_with_pks(@child_collection, args)
         | 
| 37 38 | 
             
                        id = Utils::Id.unpack_id(@collection, args[:params]['id'], with_key: true)
         | 
| @@ -20,8 +20,7 @@ module ForestAdminAgent | |
| 20 20 | 
             
                      id = Utils::Id.unpack_id(@collection, args[:params]['id'], with_key: true)
         | 
| 21 21 | 
             
                      condition_tree = ConditionTree::ConditionTreeFactory.match_records(@collection, [id])
         | 
| 22 22 | 
             
                      filter = ForestAdminDatasourceToolkit::Components::Query::Filter.new(
         | 
| 23 | 
            -
                        condition_tree: ConditionTree::ConditionTreeFactory.intersect([condition_tree, scope]) | 
| 24 | 
            -
                        page: ForestAdminAgent::Utils::QueryStringParser.parse_pagination(args)
         | 
| 23 | 
            +
                        condition_tree: ConditionTree::ConditionTreeFactory.intersect([condition_tree, scope])
         | 
| 25 24 | 
             
                      )
         | 
| 26 25 |  | 
| 27 26 | 
             
                      projection = ProjectionFactory.all(@collection)
         | 
| @@ -19,10 +19,9 @@ module ForestAdminAgent | |
| 19 19 | 
             
                      data = format_attributes(args)
         | 
| 20 20 | 
             
                      record = @collection.create(@caller, data)
         | 
| 21 21 | 
             
                      link_one_to_one_relations(args, record)
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                      id = Utils::Id.unpack_id(@collection, record['id'], with_key: true)
         | 
| 22 | 
            +
                      id = ForestAdminDatasourceToolkit::Utils::Record.primary_keys(@collection, record)
         | 
| 24 23 | 
             
                      filter = ForestAdminDatasourceToolkit::Components::Query::Filter.new(
         | 
| 25 | 
            -
                        condition_tree: ConditionTree::ConditionTreeFactory. | 
| 24 | 
            +
                        condition_tree: ConditionTree::ConditionTreeFactory.match_ids(@collection, [id])
         | 
| 26 25 | 
             
                      )
         | 
| 27 26 | 
             
                      records = @collection.list(@caller, filter, ProjectionFactory.all(@collection))
         | 
| 28 27 |  | 
| @@ -40,7 +39,7 @@ module ForestAdminAgent | |
| 40 39 | 
             
                    def link_one_to_one_relations(args, record)
         | 
| 41 40 | 
             
                      args[:params][:data][:relationships]&.map do |field, value|
         | 
| 42 41 | 
             
                        schema = @collection.schema[:fields][field]
         | 
| 43 | 
            -
                        next unless [ | 
| 42 | 
            +
                        next unless %w[OneToOne PolymorphicOneToOne].include?(schema.type)
         | 
| 44 43 |  | 
| 45 44 | 
             
                        id = Utils::Id.unpack_id(@collection, value['data']['id'], with_key: true)
         | 
| 46 45 | 
             
                        foreign_collection = @datasource.get_collection(schema.foreign_collection)
         | 
| @@ -42,8 +42,9 @@ module ForestAdminAgent | |
| 42 42 |  | 
| 43 43 | 
             
                    def handle_authentication_callback(args = {})
         | 
| 44 44 | 
             
                      if args[:params].key?(:error)
         | 
| 45 | 
            -
                        raise AuthenticationOpenIdClient.new(args[:params][: | 
| 46 | 
            -
                                                             args[:params][: | 
| 45 | 
            +
                        raise AuthenticationOpenIdClient.new(args[:params][:state],
         | 
| 46 | 
            +
                                                             args[:params][:error],
         | 
| 47 | 
            +
                                                             args[:params][:error_description])
         | 
| 47 48 | 
             
                      end
         | 
| 48 49 |  | 
| 49 50 | 
             
                      if args.dig(:headers, 'action_dispatch.remote_ip')
         | 
| @@ -31,9 +31,8 @@ module ForestAdminAgent | |
| 31 31 |  | 
| 32 32 | 
             
                  def self.parse_value(collection, leaf)
         | 
| 33 33 | 
             
                    schema = Collection.get_field_schema(collection, leaf[:field])
         | 
| 34 | 
            -
                    operator = leaf[:operator].titleize.tr(' ', '_')
         | 
| 35 34 |  | 
| 36 | 
            -
                    if operator == Operators::IN && leaf[:field].is_a?(String)
         | 
| 35 | 
            +
                    if leaf[:operator] == Operators::IN && leaf[:field].is_a?(String)
         | 
| 37 36 | 
             
                      values = leaf[:value].split(',').map(&:strip)
         | 
| 38 37 |  | 
| 39 38 | 
             
                      return values.map { |item| !%w[false 0 no].include?(item) } if schema.column_type == 'Boolean'
         | 
    
        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.0.0.pre.beta. | 
| 4 | 
            +
              version: 1.0.0.pre.beta.100
         | 
| 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 | 
            +
            date: 2025-03-10 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: activesupport
         |