spree_api 6.0.2 → 6.0.3
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/app/controllers/concerns/spree/api/v3/admin/embed_permissions.rb +5 -2
- data/app/controllers/spree/api/v3/admin/products_controller.rb +56 -0
- data/app/serializers/spree/api/v3/admin/admin_user_serializer.rb +2 -2
- data/app/serializers/spree/api/v3/admin/delivery_profile_serializer.rb +2 -1
- data/app/serializers/spree/api/v3/admin/fulfillment_serializer.rb +1 -1
- data/app/serializers/spree/api/v3/admin/import_serializer.rb +1 -1
- data/app/serializers/spree/api/v3/admin/invitation_serializer.rb +2 -2
- data/app/serializers/spree/api/v3/admin/price_rule_serializer.rb +3 -1
- data/app/serializers/spree/api/v3/admin/product_serializer.rb +8 -0
- data/app/serializers/spree/api/v3/admin/promotion_action_serializer.rb +2 -2
- data/app/serializers/spree/api/v3/admin/promotion_rule_serializer.rb +4 -1
- data/app/serializers/spree/api/v3/admin/promotion_serializer.rb +13 -0
- data/app/serializers/spree/api/v3/admin/return_serializer.rb +1 -1
- data/app/serializers/spree/api/v3/admin/seller_requirement_status_serializer.rb +3 -2
- data/app/serializers/spree/api/v3/admin/seller_serializer.rb +2 -2
- data/app/serializers/spree/api/v3/fulfillment_serializer.rb +1 -1
- data/app/serializers/spree/api/v3/seller/import_serializer.rb +1 -1
- data/app/serializers/spree/api/v3/seller/invitation_serializer.rb +2 -2
- data/app/serializers/spree/api/v3/seller/product_serializer.rb +8 -0
- data/app/serializers/spree/api/v3/seller/requirement_status_serializer.rb +3 -2
- data/config/initializers/typelizer.rb +8 -19
- data/config/routes.rb +5 -0
- data/lib/spree/api/admin_document.rb +284 -0
- data/lib/spree/api/agent_operations.rb +300 -0
- data/lib/spree/api/agent_resource_map.rb +32 -7
- data/lib/spree/api/agent_write_schemas.rb +15 -51
- data/lib/spree/api/engine.rb +14 -1
- data/lib/spree/api/enum_types.rb +4 -1
- data/lib/spree/api/openapi/schema_helper.rb +3 -3
- data/lib/spree/api/sdk_types.rb +190 -0
- data/lib/spree/api/sdk_types_task.rb +68 -0
- data/lib/spree/api/testing_support/agent_tools.rb +35 -0
- data/lib/spree/api/testing_support/agent_tools_contract.rb +110 -0
- data/lib/spree/api/testing_support/deterministic_openapi.rb +147 -0
- data/lib/spree/api/testing_support/filter_parameters.rb +99 -0
- data/lib/spree/api/testing_support/openapi.rb +232 -0
- data/lib/spree/api/testing_support/openapi_tasks.rb +21 -0
- data/lib/spree/api/typelizer_generation.rb +39 -11
- data/lib/tasks/openapi.rake +5 -0
- data/lib/tasks/sdk_types.rake +6 -0
- data/lib/typelizer/open_enums.rb +13 -1
- data/openapi/admin.yaml +1540 -33
- metadata +20 -9
- data/lib/spree/api/agent_workflow_endpoints.rb +0 -113
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.0.
|
|
4
|
+
version: 6.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vendo Connect Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rswag-specs
|
|
@@ -30,28 +30,28 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 0.
|
|
33
|
+
version: 0.14.0
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 0.
|
|
40
|
+
version: 0.14.0
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: spree_core
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - '='
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 6.0.
|
|
47
|
+
version: 6.0.3
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - '='
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: 6.0.
|
|
54
|
+
version: 6.0.3
|
|
55
55
|
description: Spree Commerce Store / Admin API and HTTP webhooks
|
|
56
56
|
email:
|
|
57
57
|
- hello@spreecommerce.org
|
|
@@ -806,9 +806,10 @@ files:
|
|
|
806
806
|
- config/locales/zh-TW.yml
|
|
807
807
|
- config/routes.rb
|
|
808
808
|
- lib/spree/api.rb
|
|
809
|
+
- lib/spree/api/admin_document.rb
|
|
809
810
|
- lib/spree/api/agent_membership_map.rb
|
|
811
|
+
- lib/spree/api/agent_operations.rb
|
|
810
812
|
- lib/spree/api/agent_resource_map.rb
|
|
811
|
-
- lib/spree/api/agent_workflow_endpoints.rb
|
|
812
813
|
- lib/spree/api/agent_write_schemas.rb
|
|
813
814
|
- lib/spree/api/configuration.rb
|
|
814
815
|
- lib/spree/api/dependencies.rb
|
|
@@ -823,15 +824,25 @@ files:
|
|
|
823
824
|
- lib/spree/api/openapi/schema_helper.rb
|
|
824
825
|
- lib/spree/api/preference_families.rb
|
|
825
826
|
- lib/spree/api/preference_types.rb
|
|
827
|
+
- lib/spree/api/sdk_types.rb
|
|
828
|
+
- lib/spree/api/sdk_types_task.rb
|
|
829
|
+
- lib/spree/api/testing_support/agent_tools.rb
|
|
830
|
+
- lib/spree/api/testing_support/agent_tools_contract.rb
|
|
826
831
|
- lib/spree/api/testing_support/always_register_type_hints.rb
|
|
832
|
+
- lib/spree/api/testing_support/deterministic_openapi.rb
|
|
827
833
|
- lib/spree/api/testing_support/factories.rb
|
|
834
|
+
- lib/spree/api/testing_support/filter_parameters.rb
|
|
828
835
|
- lib/spree/api/testing_support/matchers/webhooks.rb
|
|
836
|
+
- lib/spree/api/testing_support/openapi.rb
|
|
837
|
+
- lib/spree/api/testing_support/openapi_tasks.rb
|
|
829
838
|
- lib/spree/api/testing_support/spree_webhooks.rb
|
|
830
839
|
- lib/spree/api/testing_support/v3/base.rb
|
|
831
840
|
- lib/spree/api/typelizer_generation.rb
|
|
832
841
|
- lib/spree/api/webhook_event_types.rb
|
|
833
842
|
- lib/spree_api.rb
|
|
834
843
|
- lib/tasks/filters.rake
|
|
844
|
+
- lib/tasks/openapi.rake
|
|
845
|
+
- lib/tasks/sdk_types.rake
|
|
835
846
|
- lib/typelizer/open_enums.rb
|
|
836
847
|
- lib/typelizer/proc_resource_resolution.rb
|
|
837
848
|
- openapi/admin.yaml
|
|
@@ -841,9 +852,9 @@ licenses:
|
|
|
841
852
|
- BSD-3-Clause
|
|
842
853
|
metadata:
|
|
843
854
|
bug_tracker_uri: https://github.com/spree/spree/issues
|
|
844
|
-
changelog_uri: https://github.com/spree/spree/releases/tag/v6.0.
|
|
855
|
+
changelog_uri: https://github.com/spree/spree/releases/tag/v6.0.3
|
|
845
856
|
documentation_uri: https://spreecommerce.org/docs/
|
|
846
|
-
source_code_uri: https://github.com/spree/spree/tree/v6.0.
|
|
857
|
+
source_code_uri: https://github.com/spree/spree/tree/v6.0.3
|
|
847
858
|
post_install_message:
|
|
848
859
|
rdoc_options: []
|
|
849
860
|
require_paths:
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
module Spree
|
|
2
|
-
module Api
|
|
3
|
-
# Which Admin API operation runs each workflow, derived rather than listed.
|
|
4
|
-
#
|
|
5
|
-
# Walk the admin routes; for each one, read the controller source and ask
|
|
6
|
-
# whether the action behind it calls that workflow. The verb and path come
|
|
7
|
-
# from the route, and the body keys from the generated OpenAPI document —
|
|
8
|
-
# which is the only place that records a rename (a cancellation's
|
|
9
|
-
# `reason:` keyword travels as `cancel_reason_id`).
|
|
10
|
-
#
|
|
11
|
-
# Read off the controllers for the same reason {AgentResourceMap} is: a
|
|
12
|
-
# workflow that gains an endpoint is dispatched without anyone editing a
|
|
13
|
-
# file, and one whose endpoint goes away stops being dispatched.
|
|
14
|
-
module AgentWorkflowEndpoints
|
|
15
|
-
# Where a controller declares a workflow for the base class to run,
|
|
16
|
-
# rather than calling it inside an action of its own.
|
|
17
|
-
DECLARED_IN = { 'create_workflow' => 'create', 'update_workflow' => 'update' }.freeze
|
|
18
|
-
|
|
19
|
-
class << self
|
|
20
|
-
# @param map [Module]
|
|
21
|
-
# @return [Integer] how many workflows were mapped
|
|
22
|
-
def install(map: Spree::AgentTools::WorkflowEndpoints)
|
|
23
|
-
map.reset!
|
|
24
|
-
keys = Spree::AgentTools::DefaultCatalog::WORKFLOWS.keys
|
|
25
|
-
document = openapi_document
|
|
26
|
-
|
|
27
|
-
admin_routes.each do |route|
|
|
28
|
-
source = controller_source(route[:controller])
|
|
29
|
-
next if source.nil?
|
|
30
|
-
|
|
31
|
-
keys.each do |key|
|
|
32
|
-
# `find` would derive, and deriving is what this is — read the
|
|
33
|
-
# entries already registered instead.
|
|
34
|
-
next if map.registered.key?(key)
|
|
35
|
-
next unless action_calling(source, key) == route[:action]
|
|
36
|
-
|
|
37
|
-
map.register(key: key, verb: route[:verb], path: route[:path],
|
|
38
|
-
body_keys: body_keys_for(document, route))
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
map.registered.size
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
private
|
|
46
|
-
|
|
47
|
-
def admin_routes
|
|
48
|
-
Spree::Core::Engine.routes.routes.filter_map do |route|
|
|
49
|
-
controller = route.defaults[:controller].to_s
|
|
50
|
-
next unless controller.start_with?('spree/api/v3/admin')
|
|
51
|
-
|
|
52
|
-
{ controller: controller, action: route.defaults[:action].to_s,
|
|
53
|
-
verb: route.verb.to_s, path: route.path.spec.to_s.sub('(.:format)', '') }
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
# Which action calls this workflow: the `def` nearest above the call.
|
|
58
|
-
# A declaration consumed by the base class names the action it serves
|
|
59
|
-
# instead.
|
|
60
|
-
def action_calling(source, key)
|
|
61
|
-
index = source.index("Spree.#{key}")
|
|
62
|
-
return if index.nil?
|
|
63
|
-
|
|
64
|
-
enclosing = source[0...index].scan(/^\s+def ([a-z_]+)/).flatten.last
|
|
65
|
-
DECLARED_IN.fetch(enclosing, enclosing)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def controller_source(controller_path)
|
|
69
|
-
@sources ||= {}
|
|
70
|
-
return @sources[controller_path] if @sources.key?(controller_path)
|
|
71
|
-
|
|
72
|
-
@sources[controller_path] = begin
|
|
73
|
-
klass = "#{controller_path.camelize}Controller".safe_constantize
|
|
74
|
-
file = klass && Object.const_source_location(klass.name)&.first
|
|
75
|
-
file && File.exist?(file) ? File.read(file) : nil
|
|
76
|
-
rescue StandardError
|
|
77
|
-
nil
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
# What the operation's request body accepts, in the names the wire
|
|
82
|
-
# uses. A workflow keyword and its body key often differ, and the
|
|
83
|
-
# document is where that difference is recorded.
|
|
84
|
-
def body_keys_for(document, route)
|
|
85
|
-
operation = document.dig('paths', openapi_path(route[:path]), route[:verb].downcase)
|
|
86
|
-
schema = operation&.dig('requestBody', 'content', 'application/json', 'schema')
|
|
87
|
-
# Bodies are declared once and published as components, so the
|
|
88
|
-
# operation points at one rather than carrying its properties.
|
|
89
|
-
schema = Spree::Api::AgentWriteSchemas.resolve_schema(schema)
|
|
90
|
-
|
|
91
|
-
(schema&.dig('properties') || {}).keys
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def openapi_path(path)
|
|
95
|
-
path.gsub(/:([a-z_]+)/) { "{#{Regexp.last_match(1)}}" }
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
# A body the document does not describe is simply passed through
|
|
99
|
-
# unchecked.
|
|
100
|
-
#
|
|
101
|
-
# `AgentWriteSchemas` already holds this file parsed, so it is read
|
|
102
|
-
# through there rather than a second time: the document is nearly a
|
|
103
|
-
# megabyte, and parsing it twice at boot is a second of nothing.
|
|
104
|
-
def openapi_document
|
|
105
|
-
Spree::Api::AgentWriteSchemas.document
|
|
106
|
-
rescue StandardError => e
|
|
107
|
-
Rails.logger.warn("[Spree] could not read the admin API document: #{e.class}: #{e.message}")
|
|
108
|
-
{}
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|