spree_api 6.0.4 → 6.0.5
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/Rakefile +3 -5
- data/app/controllers/concerns/spree/api/v3/storefront_gating.rb +4 -2
- data/app/controllers/spree/api/v3/admin/categories_controller.rb +1 -1
- data/app/controllers/spree/api/v3/admin/store_controller.rb +9 -1
- data/app/controllers/spree/api/v3/seller/option_types_controller.rb +41 -0
- data/app/controllers/spree/api/v3/seller/products_controller.rb +35 -0
- data/app/controllers/spree/api/v3/store/carts/store_credits_controller.rb +7 -3
- data/app/controllers/spree/api/v3/store/carts_controller.rb +1 -1
- data/app/controllers/spree/api/v3/store/categories_controller.rb +1 -1
- data/app/controllers/spree/api/v3/store/companies/addresses_controller.rb +1 -1
- data/app/controllers/spree/api/v3/store/store_controller.rb +3 -2
- data/app/request_schemas/spree/api/v3/seller/variant_request_schema.rb +4 -0
- data/app/request_schemas/spree/api/v3/store/address_request_schema.rb +2 -2
- data/app/serializers/spree/api/v3/address_serializer.rb +3 -3
- data/app/serializers/spree/api/v3/admin/address_serializer.rb +1 -1
- data/app/serializers/spree/api/v3/admin/market_serializer.rb +1 -1
- data/app/serializers/spree/api/v3/admin/refund_serializer.rb +1 -1
- data/app/serializers/spree/api/v3/admin/stock_location_serializer.rb +1 -1
- data/app/serializers/spree/api/v3/admin/store_serializer.rb +0 -7
- data/app/serializers/spree/api/v3/base_serializer.rb +1 -1
- data/app/serializers/spree/api/v3/cart_serializer.rb +4 -3
- data/app/serializers/spree/api/v3/country_serializer.rb +1 -1
- data/app/serializers/spree/api/v3/currency_serializer.rb +3 -2
- data/app/serializers/spree/api/v3/locale_serializer.rb +1 -1
- data/app/serializers/spree/api/v3/market_serializer.rb +2 -2
- data/app/serializers/spree/api/v3/price_history_serializer.rb +1 -1
- data/app/serializers/spree/api/v3/price_serializer.rb +2 -2
- data/app/serializers/spree/api/v3/refund_serializer.rb +2 -2
- data/app/serializers/spree/api/v3/seller/address_serializer.rb +1 -1
- data/app/serializers/spree/api/v3/seller/option_type_serializer.rb +18 -0
- data/app/serializers/spree/api/v3/seller/product_serializer.rb +1 -1
- data/app/serializers/spree/api/v3/seller/product_type_serializer.rb +8 -7
- data/app/serializers/spree/api/v3/seller/stock_location_serializer.rb +1 -1
- data/app/serializers/spree/api/v3/stock_location_serializer.rb +3 -3
- data/app/serializers/spree/api/v3/store_serializer.rb +17 -5
- data/app/services/spree/api/v3/request_schema.rb +1 -1
- data/config/routes.rb +6 -1
- data/lib/spree/api/dependencies.rb +5 -5
- data/lib/spree/api/oauth.rb +8 -19
- data/lib/spree/api/openapi/path_sorter.rb +91 -74
- data/lib/spree/api/typelizer_generation.rb +1 -1
- data/openapi/admin.yaml +34718 -34643
- data/openapi/store.yaml +6646 -6604
- metadata +8 -6
|
@@ -1,15 +1,27 @@
|
|
|
1
1
|
module Spree
|
|
2
2
|
module Api
|
|
3
3
|
module V3
|
|
4
|
-
# The current store's public identity and default SEO metadata,
|
|
5
|
-
# request's locale. Missing translations fall back to the store's
|
|
6
|
-
# locale.
|
|
4
|
+
# The current store's public identity, branding and default SEO metadata,
|
|
5
|
+
# in the request's locale. Missing translations fall back to the store's
|
|
6
|
+
# default locale.
|
|
7
7
|
class StoreSerializer < BaseSerializer
|
|
8
8
|
typelize name: :string,
|
|
9
9
|
seo_title: [:string, nullable: true],
|
|
10
|
-
meta_description: [:string, nullable: true]
|
|
10
|
+
meta_description: [:string, nullable: true],
|
|
11
|
+
meta_keywords: [:string, nullable: true],
|
|
12
|
+
logo_url: [:string, nullable: true],
|
|
13
|
+
facebook: [:string, nullable: true, comment: 'Facebook page, as entered by the merchant: a handle or a full URL.'],
|
|
14
|
+
twitter: [:string, nullable: true, comment: 'X (Twitter) account, as entered by the merchant: a handle or a full URL.'],
|
|
15
|
+
instagram: [:string, nullable: true, comment: 'Instagram account, as entered by the merchant: a handle or a full URL.'],
|
|
16
|
+
customer_support_email: [:string, nullable: true]
|
|
11
17
|
|
|
12
|
-
attributes :name, :seo_title, :meta_description
|
|
18
|
+
attributes :name, :seo_title, :meta_description, :meta_keywords,
|
|
19
|
+
:facebook, :twitter, :instagram,
|
|
20
|
+
:customer_support_email
|
|
21
|
+
|
|
22
|
+
attribute :logo_url do |store|
|
|
23
|
+
image_url_for(store.logo)
|
|
24
|
+
end
|
|
13
25
|
end
|
|
14
26
|
end
|
|
15
27
|
end
|
|
@@ -23,7 +23,7 @@ module Spree
|
|
|
23
23
|
# creating only. `only: :create` (or `:update`) accepts the field on one
|
|
24
24
|
# action alone. `permit: false` documents a field the controller reads
|
|
25
25
|
# from the raw params itself. `format:` documents a string's format
|
|
26
|
-
# (`email`, `uri`). `deprecated: 'Use country_code. Removed in 6.
|
|
26
|
+
# (`email`, `uri`). `deprecated: 'Use country_code. Removed in 6.5.'`
|
|
27
27
|
# keeps a field working while the API reference and the SDK types flag it.
|
|
28
28
|
class RequestSchema
|
|
29
29
|
KINDS = {
|
data/config/routes.rb
CHANGED
|
@@ -162,7 +162,7 @@ Spree::Core::Engine.add_routes do
|
|
|
162
162
|
# customer's own request names, for the same reason.
|
|
163
163
|
get 'data_requests/:token', to: 'data_requests#show', as: :data_request
|
|
164
164
|
post 'data_requests/:token/confirmation', to: 'data_request_confirmations#create', as: :data_request_confirmation
|
|
165
|
-
# Legacy path — emailed and bookmarked URLs outlive the rename. Removed in 6.
|
|
165
|
+
# Legacy path — emailed and bookmarked URLs outlive the rename. Removed in 6.5.
|
|
166
166
|
get 'digitals/:token', to: 'digital_links#show', as: :digital_download
|
|
167
167
|
|
|
168
168
|
# Data Feeds (public, no auth required)
|
|
@@ -1045,6 +1045,11 @@ Spree::Core::Engine.add_routes do
|
|
|
1045
1045
|
# the operator's (docs/plans/6.0-seller-product-submission.md).
|
|
1046
1046
|
resources :product_types, only: [:index, :show]
|
|
1047
1047
|
|
|
1048
|
+
# The option types and values a seller builds variants from. Read
|
|
1049
|
+
# only: the vocabulary is the operator's, the variants are the seller's
|
|
1050
|
+
# (docs/plans/6.0-multi-vendor-marketplace.md).
|
|
1051
|
+
resources :option_types, only: [:index, :show]
|
|
1052
|
+
|
|
1048
1053
|
# The marketplace's delivery vocabulary, for the product form's picker.
|
|
1049
1054
|
# Read only: a seller assigns a profile, never creates one
|
|
1050
1055
|
# (docs/plans/6.0-multi-vendor-marketplace.md, Decision 13).
|
|
@@ -48,7 +48,7 @@ module Spree
|
|
|
48
48
|
|
|
49
49
|
SELLER_SERIALIZERS =
|
|
50
50
|
%i[address country state profile policy team_member account invitation invitation_acceptance_link product product_type
|
|
51
|
-
delivery_profile delivery_method delivery_method_rule delivery_zone variant media stock_level order
|
|
51
|
+
option_type delivery_profile delivery_method delivery_method_rule delivery_zone variant media stock_level order
|
|
52
52
|
order_line_item fulfillment fulfillment_item delivery delivery_rate shipping_label return
|
|
53
53
|
return_line_item exchange exchange_line_item claim claim_line_item reason package_type stock_location
|
|
54
54
|
requirement_custom_field tax_identifier requirement_status import import_row import_mapping
|
|
@@ -75,7 +75,7 @@ module Spree
|
|
|
75
75
|
# legacy workflow keys in core, these forward instead of stashing: a
|
|
76
76
|
# serializer renders the same model under a new class name, so an
|
|
77
77
|
# override written against the old key is still the class the host app
|
|
78
|
-
# wants used. Removed in 6.
|
|
78
|
+
# wants used. Removed in 6.3.
|
|
79
79
|
LEGACY_SERIALIZER_KEYS = {
|
|
80
80
|
stock_item_serializer: :stock_level_serializer,
|
|
81
81
|
admin_stock_item_serializer: :admin_stock_level_serializer,
|
|
@@ -85,17 +85,17 @@ module Spree
|
|
|
85
85
|
|
|
86
86
|
LEGACY_SERIALIZER_KEYS.each do |legacy, current|
|
|
87
87
|
define_method("#{legacy}=") do |value|
|
|
88
|
-
Spree::Deprecation.warn("Spree.api.#{legacy}= is deprecated and will be removed in Spree 6.
|
|
88
|
+
Spree::Deprecation.warn("Spree.api.#{legacy}= is deprecated and will be removed in Spree 6.3. Use #{current}= instead.")
|
|
89
89
|
send("#{current}=", value)
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
define_method(legacy) do
|
|
93
|
-
Spree::Deprecation.warn("Spree.api.#{legacy} is deprecated and will be removed in Spree 6.
|
|
93
|
+
Spree::Deprecation.warn("Spree.api.#{legacy} is deprecated and will be removed in Spree 6.3. Use #{current} instead.")
|
|
94
94
|
send(current)
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
define_method("#{legacy}_class") do
|
|
98
|
-
Spree::Deprecation.warn("Spree.api.#{legacy}_class is deprecated and will be removed in Spree 6.
|
|
98
|
+
Spree::Deprecation.warn("Spree.api.#{legacy}_class is deprecated and will be removed in Spree 6.3. Use #{current}_class instead.")
|
|
99
99
|
send("#{current}_class")
|
|
100
100
|
end
|
|
101
101
|
end
|
data/lib/spree/api/oauth.rb
CHANGED
|
@@ -15,41 +15,30 @@ module Spree
|
|
|
15
15
|
# which is why this lives in `spree_api` rather than in any one gem that
|
|
16
16
|
# happens to need it.
|
|
17
17
|
module Oauth
|
|
18
|
-
# Whether a redirect URI points at the machine the client runs on
|
|
19
|
-
# literal (`127.0.0.1`, `[::1]`)
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
# does when it ignores the port of a loopback redirect.
|
|
18
|
+
# Whether a redirect URI points at the machine the client runs on: an IP
|
|
19
|
+
# literal (`127.0.0.1`, `[::1]`) or `localhost`. Doorkeeper ignores the
|
|
20
|
+
# port of exactly these (RFC 8252 §7.3), and matches `localhost` only in
|
|
21
|
+
# lowercase.
|
|
23
22
|
#
|
|
24
23
|
# @param uri [URI, String]
|
|
25
24
|
# @return [Boolean]
|
|
26
25
|
def self.loopback_uri?(uri)
|
|
27
26
|
host = uri.respond_to?(:host) ? uri.host : URI.parse(uri.to_s).host
|
|
28
27
|
return false if host.blank?
|
|
28
|
+
return true if host == 'localhost'
|
|
29
29
|
|
|
30
30
|
IPAddr.new(host).loopback?
|
|
31
31
|
rescue StandardError
|
|
32
32
|
false
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
# Whether a redirect URI may use plain http:
|
|
36
|
-
#
|
|
37
|
-
#
|
|
38
|
-
# Claude Code only ever calls back on `http://localhost:<port>`. Doorkeeper
|
|
39
|
-
# compares a `localhost` callback exactly, so the host must be lowercase
|
|
40
|
-
# and the port explicit: anything else could never match an
|
|
41
|
-
# authorization.
|
|
35
|
+
# Whether a redirect URI may use plain http: only a loopback one, which
|
|
36
|
+
# never leaves the machine.
|
|
42
37
|
#
|
|
43
38
|
# @param uri [URI, String]
|
|
44
39
|
# @return [Boolean]
|
|
45
40
|
def self.local_redirect_uri?(uri)
|
|
46
|
-
|
|
47
|
-
return true if loopback_uri?(uri)
|
|
48
|
-
|
|
49
|
-
uri.host == 'localhost' &&
|
|
50
|
-
(1..65_535).cover?(uri.port) && uri.port != uri.default_port
|
|
51
|
-
rescue StandardError
|
|
52
|
-
false
|
|
41
|
+
loopback_uri?(uri)
|
|
53
42
|
end
|
|
54
43
|
|
|
55
44
|
# Protected resources, each registered by the surface that owns it as a
|
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'yaml'
|
|
4
|
+
|
|
3
5
|
module Spree
|
|
4
6
|
module Api
|
|
5
7
|
module OpenAPI
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
+
# Orders a generated OpenAPI YAML for the Mintlify sidebar: Authentication
|
|
9
|
+
# first, every other tag alphabetical.
|
|
8
10
|
#
|
|
9
|
-
# rswag emits paths in the order specs are loaded
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
# `
|
|
11
|
+
# rswag emits paths in the order specs are loaded, and Mintlify renders one
|
|
12
|
+
# sidebar group per tag in the order tags first appear in `paths:`. So this
|
|
13
|
+
# reorders the `paths:` block by each path's primary tag, and rewrites the
|
|
14
|
+
# top-level `tags:` block in the same order, adding any tag an operation
|
|
15
|
+
# uses but swagger_helper.rb doesn't declare.
|
|
13
16
|
#
|
|
14
17
|
# The reorder is line-based to preserve the exact text formatting that
|
|
15
18
|
# rswag/Psych produced (indentation, multi-line string wrapping, etc.).
|
|
16
19
|
module PathSorter
|
|
20
|
+
FIRST_TAG = 'Authentication'
|
|
21
|
+
|
|
17
22
|
module_function
|
|
18
23
|
|
|
19
|
-
# Sort the `paths:` block in `path` so each path's first-operation primary
|
|
20
|
-
# tag follows the order defined in the document's top-level `tags:` array.
|
|
21
24
|
# Returns true if the file was rewritten, false if already sorted.
|
|
22
25
|
def sort_file!(path)
|
|
23
|
-
original = File.read(path)
|
|
26
|
+
original = File.read(path, encoding: Encoding::UTF_8)
|
|
24
27
|
sorted = sort_text(original)
|
|
25
28
|
return false if sorted == original
|
|
26
29
|
|
|
@@ -28,97 +31,111 @@ module Spree
|
|
|
28
31
|
true
|
|
29
32
|
end
|
|
30
33
|
|
|
31
|
-
# Pure-string variant: sort a YAML document's `paths:` block by tag order.
|
|
32
34
|
def sort_text(yaml)
|
|
33
35
|
lines = yaml.lines
|
|
34
|
-
tag_rank = extract_tag_rank(lines)
|
|
35
|
-
return yaml if tag_rank.empty?
|
|
36
|
-
|
|
37
|
-
paths_start = lines.index { |l| l.start_with?('paths:') }
|
|
38
|
-
return yaml unless paths_start
|
|
39
36
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
line.match?(/\A[A-Za-z]/) || line.start_with?('x-')
|
|
43
|
-
end || lines.size
|
|
37
|
+
paths_range = block_range(lines, 'paths:')
|
|
38
|
+
return yaml unless paths_range
|
|
44
39
|
|
|
45
|
-
blocks = collect_path_blocks(lines,
|
|
40
|
+
blocks = collect_path_blocks(lines, paths_range)
|
|
46
41
|
return yaml if blocks.empty?
|
|
47
42
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
tags_range = block_range(lines, 'tags:')
|
|
44
|
+
tag_entries = tags_range ? collect_tag_entries(lines, tags_range) : {}
|
|
45
|
+
blocks.flat_map { |block| block[:tags] }.uniq.each do |name|
|
|
46
|
+
tag_entries[name] ||= YAML.dump([{ 'name' => name }]).delete_prefix("---\n")
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
order = tag_entries.keys.sort_by { |name| tag_sort_key(name) }
|
|
50
|
+
rank = order.each_with_index.to_h
|
|
51
|
+
|
|
52
|
+
sorted_blocks = blocks.each_with_index.sort_by do |block, index|
|
|
53
|
+
[rank.fetch(block[:tags].first, rank.size), index]
|
|
51
54
|
end.map(&:first)
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
replacements = { paths_range => sorted_blocks.sum('') { |block| block[:text] } }
|
|
57
|
+
replacements[tags_range] = order.map { |name| tag_entries[name] }.join if tags_range
|
|
58
|
+
|
|
59
|
+
replace_ranges(lines, replacements)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def tag_sort_key(name)
|
|
63
|
+
[name == FIRST_TAG ? 0 : 1, name.downcase]
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# The body lines of a top-level key, as a range excluding the key itself.
|
|
67
|
+
def block_range(lines, key)
|
|
68
|
+
start = lines.index { |l| l.start_with?(key) }
|
|
69
|
+
return unless start
|
|
70
|
+
|
|
71
|
+
finish = ((start + 1)...lines.size).find { |i| top_level?(lines[i]) } || lines.size
|
|
72
|
+
(start + 1)...finish
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def top_level?(line)
|
|
76
|
+
line.match?(/\A[A-Za-z]/) || line.start_with?('x-')
|
|
56
77
|
end
|
|
57
78
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
79
|
+
def replace_ranges(lines, replacements)
|
|
80
|
+
out = +''
|
|
81
|
+
cursor = 0
|
|
82
|
+
replacements.sort_by { |range, _| range.begin }.each do |range, text|
|
|
83
|
+
out << lines[cursor...range.begin].join << text
|
|
84
|
+
cursor = range.end
|
|
85
|
+
end
|
|
86
|
+
out << lines[cursor..].to_a.join
|
|
87
|
+
end
|
|
63
88
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
89
|
+
# { tag_name => entry_text } in declared order.
|
|
90
|
+
def collect_tag_entries(lines, range)
|
|
91
|
+
entries = {}
|
|
92
|
+
current = nil
|
|
93
|
+
range.each do |i|
|
|
67
94
|
line = lines[i]
|
|
68
95
|
if line.start_with?('- name: ')
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
break
|
|
96
|
+
current = scalar(line.sub('- name: ', ''))
|
|
97
|
+
entries[current] = +''
|
|
72
98
|
end
|
|
73
|
-
|
|
99
|
+
entries[current] << line if current
|
|
74
100
|
end
|
|
75
|
-
|
|
101
|
+
entries
|
|
76
102
|
end
|
|
77
103
|
|
|
78
|
-
#
|
|
79
|
-
# A
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
current_start = i
|
|
88
|
-
end
|
|
104
|
+
# Each path block as { tags:, text: }, its first tag deciding its place.
|
|
105
|
+
# A block starts on a line beginning with two spaces and a slash,
|
|
106
|
+
# optionally quoted.
|
|
107
|
+
def collect_path_blocks(lines, range)
|
|
108
|
+
starts = range.select { |i| path_header?(lines[i]) }
|
|
109
|
+
starts.each_with_index.map do |from, idx|
|
|
110
|
+
to = starts[idx + 1] || range.end
|
|
111
|
+
slice = lines[from...to]
|
|
112
|
+
{ tags: extract_tags(slice), text: slice.join }
|
|
89
113
|
end
|
|
90
|
-
blocks << build_block(lines, current_start, end_idx_exclusive) if current_start
|
|
91
|
-
|
|
92
|
-
blocks
|
|
93
114
|
end
|
|
94
115
|
|
|
95
116
|
def path_header?(line)
|
|
96
117
|
line.start_with?(' "/') || line.start_with?(' /')
|
|
97
118
|
end
|
|
98
119
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
slice.each_with_index do |line, idx|
|
|
111
|
-
next unless line.match?(/\A {6}tags:\s*$/)
|
|
112
|
-
|
|
113
|
-
slice[(idx + 1)..].each do |next_line|
|
|
114
|
-
if next_line.start_with?(' - ')
|
|
115
|
-
value = next_line[8..].strip
|
|
116
|
-
return value unless value.empty?
|
|
117
|
-
end
|
|
118
|
-
break if next_line.match?(/\A {0,4}\S/)
|
|
120
|
+
# Every operation's tags in a path block, in order.
|
|
121
|
+
def extract_tags(slice)
|
|
122
|
+
tags = []
|
|
123
|
+
in_tags = false
|
|
124
|
+
slice.each do |line|
|
|
125
|
+
if line.match?(/\A {6}tags:\s*$/)
|
|
126
|
+
in_tags = true
|
|
127
|
+
elsif in_tags && line.start_with?(' - ')
|
|
128
|
+
tags << scalar(line[8..])
|
|
129
|
+
else
|
|
130
|
+
in_tags = false
|
|
119
131
|
end
|
|
120
132
|
end
|
|
121
|
-
|
|
133
|
+
tags.uniq
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# A YAML scalar as written by Psych, quotes and escapes included.
|
|
137
|
+
def scalar(text)
|
|
138
|
+
YAML.safe_load(text).to_s
|
|
122
139
|
end
|
|
123
140
|
end
|
|
124
141
|
end
|
|
@@ -12,7 +12,7 @@ module Spree
|
|
|
12
12
|
|
|
13
13
|
# The store-level types the Seller SDK carries because a seller
|
|
14
14
|
# serializer nests them (see the seller writer in the initializer).
|
|
15
|
-
SELLER_STORE_TYPES = %w[Category CustomField
|
|
15
|
+
SELLER_STORE_TYPES = %w[Category CustomField OptionValue Seller].to_set.freeze
|
|
16
16
|
|
|
17
17
|
# Typelizer's Alba plugin, taught the custom Alba types (see alba.rb);
|
|
18
18
|
# unmapped typed attributes crash generation.
|