habarico 7.3.0.pre.beta.4 → 7.3.0.pre.beta.6
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/VERSION +1 -1
- data/app/controllers/habarico/action_schema_controller.rb +2 -6
- data/app/controllers/habarico/application_controller.rb +9 -0
- data/app/controllers/habarico/global_schema_controller.rb +1 -1
- data/app/controllers/habarico/local_schema_controller.rb +2 -2
- data/lib/habarico/active_model/extensible_enum.rb +43 -0
- data/lib/habarico/controller.rb +73 -379
- data/lib/habarico/definition/actions/action.rb +1 -1
- data/lib/habarico/definition/actions/{upload_images_action.rb → upload_files_action.rb} +2 -2
- data/lib/habarico/definition/definition.rb +9 -6
- data/lib/habarico/definition/response.rb +1 -1
- data/lib/habarico/generators/action/action_schema_generator.rb +6 -6
- data/lib/habarico/generators/action/{upload_images_action_parameters_generator.rb → upload_files_action_parameters_generator.rb} +10 -10
- data/lib/habarico/generators/endpoint/field_options_generator.rb +8 -8
- data/lib/habarico/generators/endpoint/field_schema_generator.rb +1 -1
- data/lib/habarico/generators/view/field_descriptor_generator.rb +1 -1
- data/lib/habarico/helpers/order_by_helper.rb +7 -27
- data/lib/habarico/helpers/reflection_helper.rb +6 -0
- data/lib/habarico/queries/records_query.rb +79 -0
- data/lib/habarico/resolvers/field_path_resolver.rb +141 -0
- data/lib/habarico/{file_validations.rb → resolvers/file_rules_resolver.rb} +48 -54
- data/lib/habarico/resolvers/filter_params_resolver.rb +100 -0
- data/lib/habarico/resolvers/record_params_resolver.rb +45 -0
- data/lib/habarico/resolvers/sorting_resolver.rb +65 -0
- data/lib/habarico/schema/action/action_schema.rb +4 -4
- data/lib/habarico/schema/action/{upload_images_action_parameters.rb → upload_files_action_parameters.rb} +9 -8
- data/lib/habarico/schema/endpoint/field_options.rb +2 -2
- data/lib/habarico/schema/endpoint/field_schema.rb +3 -3
- data/lib/habarico/schema/endpoint/filter_schema.rb +3 -3
- data/lib/habarico/schema/types.rb +5 -14
- data/lib/habarico/schema/view/box_schema.rb +3 -3
- data/lib/habarico/search/search_matcher.rb +4 -3
- data/lib/habarico/serializers/compact_json.rb +10 -0
- data/lib/habarico/serializers/{serializer.rb → fields_serializer.rb} +9 -2
- data/lib/habarico/serializers/record_serializer.rb +62 -11
- data/lib/habarico/serializers/response_serializer.rb +24 -0
- data/lib/habarico/validators/order_by_validator.rb +111 -0
- data/lib/habarico.rb +19 -9
- metadata +18 -13
- data/lib/habarico/helpers/filter_params_helper.rb +0 -49
- data/lib/habarico/helpers/sorting_helper.rb +0 -136
- data/lib/habarico/schema/extensible_enum.rb +0 -20
- data/lib/habarico/search/field_resolver.rb +0 -138
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eda89e03950b126daf32cd28fc71e2304ad8f0ea952a40a7cbbe4f22bb214074
|
|
4
|
+
data.tar.gz: e3d1f3ba8d50cc95d9a06ac90aef33a2a79a3cc988a69c099e259d6ee00ff4bc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7543c39d73bd2e0036111fdfccb10d43527c93efea40486a5cf57f112b1566e7a032c8e6224838cd9ae3b56cdb27072eea7858a58e631c63d99e9c16e2b8fff3
|
|
7
|
+
data.tar.gz: e1791678ea0908958c68090f9545b1870c37096f65e94a37ba502f35905c5260d60d3480351b48cc5516560c101780cff72ce8618d12edeac7927542637a1664
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
7.3.0-beta.
|
|
1
|
+
7.3.0-beta.6
|
|
@@ -13,9 +13,7 @@ module Habarico
|
|
|
13
13
|
current_user: current_user,
|
|
14
14
|
target: (JSON.parse(params['_target']) rescue {}).symbolize_keys
|
|
15
15
|
)
|
|
16
|
-
|
|
17
|
-
.as_json
|
|
18
|
-
.deep_compact(compactable: [nil, {}].freeze)
|
|
16
|
+
render_schema(Habarico::SchemaService.instance.get_action_schema(resource_name, action_name, context))
|
|
19
17
|
end
|
|
20
18
|
|
|
21
19
|
def show
|
|
@@ -32,9 +30,7 @@ module Habarico
|
|
|
32
30
|
record_pk: params[:id],
|
|
33
31
|
target: (JSON.parse(params['_target']) rescue {}).symbolize_keys
|
|
34
32
|
)
|
|
35
|
-
|
|
36
|
-
.as_json
|
|
37
|
-
.deep_compact(compactable: [nil, {}].freeze)
|
|
33
|
+
render_schema(Habarico::SchemaService.instance.get_action_schema(resource_name, action_name, context))
|
|
38
34
|
end
|
|
39
35
|
|
|
40
36
|
end
|
|
@@ -11,5 +11,14 @@ module Habarico
|
|
|
11
11
|
request.format = :json if %w[text/html */*].include?(request.format.to_s)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
# Renders a generated schema; `SchemaService` answers nil for a resource it does not know.
|
|
17
|
+
def render_schema(schema)
|
|
18
|
+
raise Eluvia::Errors::NotFound.new('Resource not found.') if schema.nil?
|
|
19
|
+
|
|
20
|
+
render json: Habarico::Serializers.compact_json(schema)
|
|
21
|
+
end
|
|
22
|
+
|
|
14
23
|
end
|
|
15
24
|
end
|
|
@@ -4,7 +4,7 @@ module Habarico
|
|
|
4
4
|
def index
|
|
5
5
|
# Prepare context and generate schema
|
|
6
6
|
context = Habarico::Context.new(current_user: current_user)
|
|
7
|
-
|
|
7
|
+
render_schema(Habarico::SchemaService.instance.get_global_schema(context))
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
end
|
|
@@ -12,7 +12,7 @@ module Habarico
|
|
|
12
12
|
target: (JSON.parse(params['_target']) rescue {}).symbolize_keys,
|
|
13
13
|
source: (JSON.parse(params['_source']) rescue {}).symbolize_keys
|
|
14
14
|
)
|
|
15
|
-
|
|
15
|
+
render_schema(Habarico::SchemaService.instance.get_local_schema(resource_name, context))
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def show
|
|
@@ -28,7 +28,7 @@ module Habarico
|
|
|
28
28
|
target: (JSON.parse(params['_target']) rescue {}).symbolize_keys,
|
|
29
29
|
source: (JSON.parse(params['_source']) rescue {}).symbolize_keys
|
|
30
30
|
)
|
|
31
|
-
|
|
31
|
+
render_schema(Habarico::SchemaService.instance.get_local_schema(resource_name, context))
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module Habarico
|
|
2
|
+
module ActiveModel
|
|
3
|
+
# Declarations built from a list of choices that may grow after the class is defined.
|
|
4
|
+
#
|
|
5
|
+
# `enum_attr` and `intended_for_types` copy the choices into the class when they are called, so
|
|
6
|
+
# appending to the list alone would change nothing. This module records every declaration made
|
|
7
|
+
# from a list and repeats it when `add_values` extends the list.
|
|
8
|
+
module ExtensibleEnum
|
|
9
|
+
extend ::ActiveSupport::Concern
|
|
10
|
+
|
|
11
|
+
# Declarations made from a list, as `{ list => [declaration, ...] }`, keyed by the list itself
|
|
12
|
+
# since its contents change.
|
|
13
|
+
def self.declarations
|
|
14
|
+
@declarations ||= Hash.new { |hash, list| hash[list] = [] }.compare_by_identity
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Runs `declaration` now and again whenever `add_values` extends `list`.
|
|
18
|
+
def self.declare(list, &declaration)
|
|
19
|
+
declarations[list] << declaration
|
|
20
|
+
declaration.call
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Appends `values` to `list` and repeats every declaration made from it.
|
|
24
|
+
def self.add_values(list, values)
|
|
25
|
+
list.concat(values)
|
|
26
|
+
declarations[list].each(&:call)
|
|
27
|
+
list
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class_methods do
|
|
31
|
+
# `enum_attr attr_name, list`, kept in step with `list`.
|
|
32
|
+
def extensible_enum_attr(attr_name, list)
|
|
33
|
+
ExtensibleEnum.declare(list) { enum_attr attr_name, list }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# `intended_for_types(*list)`, kept in step with `list`.
|
|
37
|
+
def extensible_intended_for_types(list)
|
|
38
|
+
ExtensibleEnum.declare(list) { intended_for_types(*list) }
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|