spree_core 6.0.3 → 6.0.4
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/jobs/spree/payments/handle_webhook_job.rb +12 -1
- data/app/models/concerns/spree/has_custom_fields.rb +4 -1
- data/app/models/concerns/spree/personal_data_matching.rb +5 -1
- data/app/models/concerns/spree/product_scopes.rb +2 -2
- data/app/models/concerns/spree/publishable.rb +26 -3
- data/app/models/spree/authentication/strategies/base_strategy.rb +10 -1
- data/app/models/spree/cart.rb +7 -2
- data/app/models/spree/invitation.rb +6 -2
- data/app/models/spree/media.rb +25 -1
- data/app/models/spree/order.rb +5 -1
- data/app/models/spree/price.rb +3 -0
- data/app/models/spree/product.rb +6 -9
- data/app/models/spree/product_category.rb +7 -1
- data/app/models/spree/product_collection.rb +8 -1
- data/app/models/spree/seller.rb +93 -10
- data/app/models/spree/seller_requirements/complete_profile.rb +26 -7
- data/app/models/spree/stock_level.rb +30 -1
- data/app/models/spree/stock_movement.rb +1 -0
- data/app/services/spree/carts/destroy.rb +22 -6
- data/app/services/spree/collections/regenerate_products.rb +37 -15
- data/app/services/spree/companies/add_member.rb +9 -4
- data/app/services/spree/diagnostics/error_log.rb +139 -0
- data/app/services/spree/diagnostics/section.rb +72 -0
- data/app/services/spree/diagnostics/sections.rb +121 -0
- data/app/services/spree/diagnostics/stack.rb +73 -0
- data/app/services/spree/diagnostics.rb +132 -0
- data/app/services/spree/newsletter/subscribe.rb +7 -3
- data/app/services/spree/orders/remove_line_item.rb +16 -5
- data/app/services/spree/product_memberships.rb +21 -1
- data/app/services/spree/product_types/apply_to_products.rb +12 -2
- data/app/services/spree/products/auto_match_collections.rb +20 -4
- data/app/services/spree/stock_reservations/reserve.rb +9 -6
- data/app/services/spree/store_credits/apply.rb +9 -1
- data/app/services/spree/update_check.rb +7 -31
- data/app/tools/spree/agent_tools/describe_resource.rb +3 -0
- data/app/tools/spree/agent_tools/get_resource.rb +1 -1
- data/app/tools/spree/agent_tools/resource_write.rb +1 -1
- data/app/tools/spree/agent_tools/search_resources.rb +42 -10
- data/app/workflows/spree/carts/add_item.rb +51 -0
- data/app/workflows/spree/carts/complete.rb +14 -2
- data/app/workflows/spree/payments/handle_webhook.rb +7 -3
- data/app/workflows/spree/sellers/approve.rb +6 -0
- data/app/workflows/spree/sellers/create.rb +5 -2
- data/app/workflows/spree/stock_levels/bulk_upsert.rb +19 -7
- data/config/locales/be.yml +1 -1
- data/config/locales/en.yml +8 -0
- data/config/locales/fr.yml +1 -1
- data/config/locales/lt.yml +1 -1
- data/config/locales/ru.yml +1 -1
- data/config/locales/uk.yml +1 -1
- data/db/migrate/20240303174340_fix_spree_stock_item_unique_index.rb +14 -10
- data/db/migrate/20260814000001_rename_stock_items_to_stock_levels.rb +13 -7
- data/lib/spree/agent_tool.rb +3 -3
- data/lib/spree/agent_tools/operation_tool.rb +1 -1
- data/lib/spree/agent_tools/record_summary.rb +8 -2
- data/lib/spree/agent_tools/resource_map.rb +82 -7
- data/lib/spree/core/engine.rb +10 -0
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +11 -0
- data/lib/spree/reporting/default_vocabulary.rb +25 -5
- data/lib/tasks/diagnostics.rake +11 -0
- metadata +10 -4
data/config/locales/be.yml
CHANGED
|
@@ -446,7 +446,7 @@ be:
|
|
|
446
446
|
not_locked: не быў заблакаваны
|
|
447
447
|
not_saved:
|
|
448
448
|
many: "%{count} памылак перашкаджаюць захаванню %{resource}:"
|
|
449
|
-
one:
|
|
449
|
+
one: "%{count} памылка перашкаджае захаванню %{resource}:"
|
|
450
450
|
other: "%{count} памылкі перашкаджаюць захаванню %{resource}:"
|
|
451
451
|
number:
|
|
452
452
|
percentage:
|
data/config/locales/en.yml
CHANGED
|
@@ -1021,6 +1021,7 @@ en:
|
|
|
1021
1021
|
subject: Invitation to join %{resource_name}
|
|
1022
1022
|
invitation_not_acceptable: Invitation not found, expired, or already accepted.
|
|
1023
1023
|
invitation_role_resource_mismatch: must belong to the same store or seller as the invitation
|
|
1024
|
+
invitation_seller_rejected: This seller was rejected, so nobody can join its team.
|
|
1024
1025
|
iso: ISO Alpha-2
|
|
1025
1026
|
item: Item
|
|
1026
1027
|
items_cannot_be_shipped: We are unable to calculate shipping rates for the selected items.
|
|
@@ -1654,6 +1655,13 @@ en:
|
|
|
1654
1655
|
name: Billing address
|
|
1655
1656
|
complete_profile:
|
|
1656
1657
|
description: Fill in the public profile shoppers see
|
|
1658
|
+
fields:
|
|
1659
|
+
about: a description
|
|
1660
|
+
contact_email: a contact email
|
|
1661
|
+
cover_photo: a cover photo
|
|
1662
|
+
logo: a logo
|
|
1663
|
+
name: a name
|
|
1664
|
+
missing: 'Still missing: %{fields}.'
|
|
1657
1665
|
name: Complete profile
|
|
1658
1666
|
delivery_method:
|
|
1659
1667
|
description: Offer at least one way to ship your orders
|
data/config/locales/fr.yml
CHANGED
|
@@ -418,7 +418,7 @@ fr:
|
|
|
418
418
|
not_found: Non trouvé(e)
|
|
419
419
|
not_locked: n'est pas bloqué
|
|
420
420
|
not_saved:
|
|
421
|
-
one: "%{resource} n'a pu etre sauvegardé à cause
|
|
421
|
+
one: "%{resource} n'a pu etre sauvegardé à cause de %{count} erreur:"
|
|
422
422
|
other: "%{resource} n'a pu etre sauvegardé à cause de %{count} erreurs:"
|
|
423
423
|
number:
|
|
424
424
|
percentage:
|
data/config/locales/lt.yml
CHANGED
|
@@ -418,7 +418,7 @@ lt:
|
|
|
418
418
|
not_found: nerastas
|
|
419
419
|
not_locked: nebuvo užrakinta
|
|
420
420
|
not_saved:
|
|
421
|
-
one:
|
|
421
|
+
one: "%{count} klaida neleido išsaugoti %{resource}:"
|
|
422
422
|
other: "%{count} klaidos neleido išsaugoti %{resource}:"
|
|
423
423
|
number:
|
|
424
424
|
percentage:
|
data/config/locales/ru.yml
CHANGED
|
@@ -426,7 +426,7 @@ ru:
|
|
|
426
426
|
not_locked: не был заблокирован
|
|
427
427
|
not_saved:
|
|
428
428
|
many: "%{count} ошибок препятствуют сохранению %{resource}:"
|
|
429
|
-
one:
|
|
429
|
+
one: "%{count} ошибка препятствует сохранению %{resource}:"
|
|
430
430
|
other: "%{count} ошибки препятствуют сохранению %{resource}:"
|
|
431
431
|
number:
|
|
432
432
|
percentage:
|
data/config/locales/uk.yml
CHANGED
|
@@ -419,7 +419,7 @@ uk:
|
|
|
419
419
|
not_saved:
|
|
420
420
|
few: "%{count} помилки завадили збереженню цього %{resource}:"
|
|
421
421
|
many: "%{count} помилок завадили збереженню цього %{resource}:"
|
|
422
|
-
one:
|
|
422
|
+
one: "%{count} помилка завадила збереженню цього %{resource}:"
|
|
423
423
|
other: "%{count} помилки завадили збереженню цього %{resource}:"
|
|
424
424
|
number:
|
|
425
425
|
percentage:
|
|
@@ -3,22 +3,26 @@ class FixSpreeStockItemUniqueIndex < ActiveRecord::Migration[6.1]
|
|
|
3
3
|
remove_index :spree_stock_items, name: 'stock_item_by_loc_var_id_deleted_at' if index_exists?(:spree_stock_items, [:stock_location_id, :variant_id], name: 'stock_item_by_loc_var_id_deleted_at')
|
|
4
4
|
|
|
5
5
|
unless index_exists?(:spree_stock_items, ['variant_id', 'stock_location_id'], name: 'index_spree_stock_items_unique_without_deleted_at')
|
|
6
|
-
# MySQL
|
|
7
|
-
|
|
6
|
+
# MySQL and MariaDB don't support partial indexes, and MariaDB rejects
|
|
7
|
+
# functional key parts too. Index a stored generated column instead,
|
|
8
|
+
# which both accept.
|
|
9
|
+
if Spree.mysql?
|
|
8
10
|
reversible do |dir|
|
|
9
11
|
dir.up do
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
unless column_exists?(:spree_stock_items, :live_key)
|
|
13
|
+
execute <<-SQL.squish
|
|
14
|
+
ALTER TABLE spree_stock_items
|
|
15
|
+
ADD COLUMN live_key TINYINT
|
|
16
|
+
AS (IF(deleted_at IS NULL, 1, NULL)) STORED
|
|
17
|
+
SQL
|
|
18
|
+
end
|
|
19
|
+
add_index :spree_stock_items, %w[stock_location_id variant_id live_key],
|
|
20
|
+
name: 'index_spree_stock_items_unique_without_deleted_at', unique: true
|
|
18
21
|
end
|
|
19
22
|
|
|
20
23
|
dir.down do
|
|
21
24
|
remove_index :spree_stock_items, name: :index_spree_stock_items_unique_without_deleted_at
|
|
25
|
+
remove_column :spree_stock_items, :live_key if column_exists?(:spree_stock_items, :live_key)
|
|
22
26
|
end
|
|
23
27
|
end
|
|
24
28
|
else
|
|
@@ -54,19 +54,25 @@ class RenameStockItemsToStockLevels < ActiveRecord::Migration[8.1]
|
|
|
54
54
|
# cannot honour is dropped without complaint, leaving a unique index over the
|
|
55
55
|
# wrong set of rows.
|
|
56
56
|
def rename_partial_uniqueness_index(from:, to:)
|
|
57
|
+
# Hosts that got the index through the generated column keep it as it is.
|
|
58
|
+
# Only the index changes name, as MariaDB cannot rebuild the expression form.
|
|
59
|
+
if column_exists?(:spree_stock_levels, :live_key)
|
|
60
|
+
rename_index :spree_stock_levels, from, to
|
|
61
|
+
return
|
|
62
|
+
end
|
|
63
|
+
|
|
57
64
|
remove_index :spree_stock_levels, name: from
|
|
58
65
|
|
|
59
66
|
if connection.supports_partial_index?
|
|
60
67
|
add_index :spree_stock_levels, %w[variant_id stock_location_id], name: to, unique: true, where: 'deleted_at IS NULL'
|
|
61
68
|
else
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
(COALESCE(deleted_at, CAST('1970-01-01' AS DATETIME)))
|
|
68
|
-
);
|
|
69
|
+
# MariaDB rejects an expression in the key, so index a stored generated column.
|
|
70
|
+
execute <<~SQL.squish
|
|
71
|
+
ALTER TABLE spree_stock_levels
|
|
72
|
+
ADD COLUMN live_key TINYINT
|
|
73
|
+
AS (IF(deleted_at IS NULL, 1, NULL)) STORED
|
|
69
74
|
SQL
|
|
75
|
+
add_index :spree_stock_levels, %w[stock_location_id variant_id live_key], name: to, unique: true
|
|
70
76
|
end
|
|
71
77
|
end
|
|
72
78
|
end
|
data/lib/spree/agent_tool.rb
CHANGED
|
@@ -24,8 +24,8 @@ class AgentTool
|
|
|
24
24
|
# The parameter every generic resource tool takes for a resource that
|
|
25
25
|
# lives under another record, such as an order's items.
|
|
26
26
|
PARENT_ID_DESCRIPTION = 'For a resource reached through another record (describe_resource names ' \
|
|
27
|
-
'it as parent, e.g. an order for its items
|
|
28
|
-
'record\'s id as shown in search results'.freeze
|
|
27
|
+
'it as parent or listed_under, e.g. an order for its items and claims, a ' \
|
|
28
|
+
'category for its products): that record\'s id as shown in search results'.freeze
|
|
29
29
|
|
|
30
30
|
# Declarations live in class attributes rather than plain class-level
|
|
31
31
|
# instance variables so a subclass inherits them. Subclassing a tool to
|
|
@@ -257,7 +257,7 @@ class AgentTool
|
|
|
257
257
|
sentences << "Pass the #{owner}'s id as parent_id to reach them under it." if reachable
|
|
258
258
|
# Each suggested call is one this caller may actually make; a hint
|
|
259
259
|
# that leads straight to a permission refusal is worse than none.
|
|
260
|
-
readable = parent_entry
|
|
260
|
+
readable = parent_entry&.readable_by?(context)
|
|
261
261
|
writable = parent_entry&.write_permission.present? && context.permitted?(parent_entry.write_permission)
|
|
262
262
|
if attribute && writable
|
|
263
263
|
sentences << "Write them in the #{attribute} attribute of #{parent} — describe_resource #{parent} shows the shape and the accepted types."
|
|
@@ -141,7 +141,7 @@ module Spree
|
|
|
141
141
|
def record_for(segment, id)
|
|
142
142
|
key = segment == 'id' ? operation.resource_key : operation.segment_keys[segment]
|
|
143
143
|
entry = key && ResourceMap.find(key)
|
|
144
|
-
return if entry.nil? || !
|
|
144
|
+
return if entry.nil? || !entry.readable_by?(context)
|
|
145
145
|
|
|
146
146
|
entry.scope_for(context).find_by_prefix_id(id)
|
|
147
147
|
rescue StandardError
|
|
@@ -9,7 +9,12 @@ module Spree
|
|
|
9
9
|
# Fields worth showing beneath the title, in the order they are preferred.
|
|
10
10
|
# Status is deliberately absent — it has its own badge on the row, and
|
|
11
11
|
# repeating it would push out the field that actually adds something.
|
|
12
|
-
SUBTITLE_FIELDS = %w[display_total display_price price email number sku].freeze
|
|
12
|
+
SUBTITLE_FIELDS = %w[display_total display_price price email number sku variant_sku].freeze
|
|
13
|
+
|
|
14
|
+
# Quantities and places a list row must carry for the model to answer
|
|
15
|
+
# from the search alone. Without them a stock level row was an id and
|
|
16
|
+
# nothing else, and "how much do I have" took one lookup per row.
|
|
17
|
+
DETAIL_FIELDS = %w[count_on_hand available_count stock_location_name options_text].freeze
|
|
13
18
|
|
|
14
19
|
# Anything that looks like a credential is dropped before a record can
|
|
15
20
|
# reach the model. The serializers are supposed to mask these already —
|
|
@@ -151,6 +156,7 @@ module Spree
|
|
|
151
156
|
title: title,
|
|
152
157
|
subtitle: subtitle_for(attributes, title),
|
|
153
158
|
status: attributes['status'],
|
|
159
|
+
details: attributes.slice(*DETAIL_FIELDS).compact.presence,
|
|
154
160
|
image_url: attributes['thumbnail_url'],
|
|
155
161
|
path: dashboard_path_from(entry, attributes['id'])
|
|
156
162
|
}.compact
|
|
@@ -160,7 +166,7 @@ module Spree
|
|
|
160
166
|
|
|
161
167
|
# The same preference order as a record's title, read from the payload.
|
|
162
168
|
def title_from(attributes)
|
|
163
|
-
%w[name number label title email sku].each do |field|
|
|
169
|
+
%w[name number label title email sku variant_name].each do |field|
|
|
164
170
|
value = attributes[field]
|
|
165
171
|
return value.to_s if value.is_a?(String) && value.present?
|
|
166
172
|
end
|
|
@@ -23,7 +23,29 @@ module Spree
|
|
|
23
23
|
Entry = Struct.new(:key, :model_name, :permission, :serializer_name,
|
|
24
24
|
:dashboard_path, :scope_name, :write_permission,
|
|
25
25
|
:writable_attributes, :create_workflow_key, :update_workflow_key,
|
|
26
|
-
:distinct, :api_paths, keyword_init: true) do
|
|
26
|
+
:distinct, :api_paths, :index_paths, :access_permissions, keyword_init: true) do
|
|
27
|
+
# Whether this caller may read the resource.
|
|
28
|
+
#
|
|
29
|
+
# Imports and exports have no key of their own: each record is gated
|
|
30
|
+
# by the scope of the resource it carries. They list those keys in
|
|
31
|
+
# `access_permissions`, and holding any one of them is enough to
|
|
32
|
+
# reach the endpoint, which filters to the records that key covers.
|
|
33
|
+
#
|
|
34
|
+
# @param context [Spree::AgentTools::Context]
|
|
35
|
+
# @return [Boolean]
|
|
36
|
+
def readable_by?(context)
|
|
37
|
+
return context.permitted?(permission) if access_permissions.nil?
|
|
38
|
+
|
|
39
|
+
access_permissions.any? { |key| context.holds?(key) }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Every key that can open this resource.
|
|
43
|
+
#
|
|
44
|
+
# @return [Array<String>]
|
|
45
|
+
def permission_keys
|
|
46
|
+
access_permissions || [permission]
|
|
47
|
+
end
|
|
48
|
+
|
|
27
49
|
# The Admin API path for one of this resource's operations, which is
|
|
28
50
|
# how a tool reaches it.
|
|
29
51
|
#
|
|
@@ -106,12 +128,32 @@ module Spree
|
|
|
106
128
|
# @param action [Symbol]
|
|
107
129
|
# @return [String, nil]
|
|
108
130
|
def parent_param(action)
|
|
109
|
-
|
|
131
|
+
param_in(api_path(action))
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# The records this resource can be listed under, each with the
|
|
135
|
+
# collection path that lists it there — claims under an order,
|
|
136
|
+
# products under a category or collection, variants under a product.
|
|
137
|
+
# A path nested twice is left out: one parent id cannot fill it.
|
|
138
|
+
#
|
|
139
|
+
# @return [Hash{String => String}] parent resource key => path
|
|
140
|
+
def index_parents
|
|
141
|
+
Array(index_paths.presence || api_path(:index)).each_with_object({}) do |path, parents|
|
|
142
|
+
next unless path.scan(/:[a-z_]+_id\b/).one?
|
|
143
|
+
|
|
144
|
+
parent = path.scan(PARENT_SEGMENT).flatten.first
|
|
145
|
+
parents[parent] ||= path if parent
|
|
146
|
+
end
|
|
110
147
|
end
|
|
111
148
|
|
|
112
149
|
# The operation's path with its segments filled, or nil when a nested
|
|
113
150
|
# resource was not given the record it lives under.
|
|
114
151
|
#
|
|
152
|
+
# A search given a parent runs on the collection under that parent,
|
|
153
|
+
# chosen by the parent id's prefix, and is nil when the resource is
|
|
154
|
+
# not listed under that kind of record. Listing the whole store
|
|
155
|
+
# instead answered "the claims on order B" with every claim.
|
|
156
|
+
#
|
|
115
157
|
# Each value is percent-encoded so it stays one segment: a `?` or `/`
|
|
116
158
|
# in an id would otherwise send the call to a different route than
|
|
117
159
|
# the one the tool checked and the approver was shown. A path with a
|
|
@@ -123,11 +165,11 @@ module Spree
|
|
|
123
165
|
# @param parent_id [String, nil]
|
|
124
166
|
# @return [String, nil]
|
|
125
167
|
def path_for(action, id: nil, parent_id: nil)
|
|
126
|
-
path = api_path(action)
|
|
168
|
+
path = action.to_sym == :index && parent_id.present? ? index_path_under(parent_id) : api_path(action)
|
|
127
169
|
return if path.blank?
|
|
128
170
|
|
|
129
171
|
path = path.sub(':id', ERB::Util.url_encode(id.to_s)) if id.present?
|
|
130
|
-
parent =
|
|
172
|
+
parent = param_in(path)
|
|
131
173
|
if parent
|
|
132
174
|
return if parent_id.blank?
|
|
133
175
|
|
|
@@ -275,6 +317,15 @@ module Spree
|
|
|
275
317
|
model_name.constantize
|
|
276
318
|
end
|
|
277
319
|
|
|
320
|
+
# The prefix of this resource's ids (`or` for orders), or nil.
|
|
321
|
+
#
|
|
322
|
+
# @return [String, nil]
|
|
323
|
+
def id_prefix
|
|
324
|
+
model_class.try(:_prefix_id_prefix).presence
|
|
325
|
+
rescue NameError
|
|
326
|
+
nil
|
|
327
|
+
end
|
|
328
|
+
|
|
278
329
|
# Records of this kind the asking admin may see.
|
|
279
330
|
#
|
|
280
331
|
# Takes the context rather than the store so the ability filter cannot
|
|
@@ -342,6 +393,23 @@ module Spree
|
|
|
342
393
|
def filterable_scopes
|
|
343
394
|
model_class.ransackable_scopes.map(&:to_s).sort
|
|
344
395
|
end
|
|
396
|
+
|
|
397
|
+
private
|
|
398
|
+
|
|
399
|
+
def param_in(path)
|
|
400
|
+
Array(path&.scan(/:([a-z_]+)/)).flatten.reject { |name| name == 'id' }.first
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
# One parent needs no matching; the endpoint answers for an id of the
|
|
404
|
+
# wrong kind. Several are told apart by the id's prefix (`ctg_` is a
|
|
405
|
+
# category, `coll_` a collection).
|
|
406
|
+
def index_path_under(parent_id)
|
|
407
|
+
parents = index_parents
|
|
408
|
+
return parents.values.first if parents.one?
|
|
409
|
+
|
|
410
|
+
prefix = parent_id.to_s[/\A([a-z]+)_/, 1]
|
|
411
|
+
parents.find { |key, _path| prefix && ResourceMap.find(key)&.id_prefix == prefix }&.last
|
|
412
|
+
end
|
|
345
413
|
end
|
|
346
414
|
|
|
347
415
|
|
|
@@ -381,10 +449,15 @@ module Spree
|
|
|
381
449
|
# @param distinct [Boolean, nil] false where the controller disables
|
|
382
450
|
# DISTINCT on its own collection, which Postgres requires when the
|
|
383
451
|
# sort column is not in the select list
|
|
452
|
+
# @param index_paths [Array<String>, nil] every collection path the
|
|
453
|
+
# resource is listed at, the nested ones under a parent included
|
|
454
|
+
# @param access_permissions [Array<String>, nil] keys any one of which
|
|
455
|
+
# opens the resource, in place of `permission`
|
|
384
456
|
# @return [Entry]
|
|
385
457
|
def register(key:, model_name:, permission:, serializer_name:, dashboard_path: nil, scope_name: nil,
|
|
386
458
|
write_permission: nil, writable_attributes: [], create_workflow_key: nil,
|
|
387
|
-
update_workflow_key: nil, distinct: nil, api_paths: nil
|
|
459
|
+
update_workflow_key: nil, distinct: nil, api_paths: nil, index_paths: nil,
|
|
460
|
+
access_permissions: nil)
|
|
388
461
|
entry = Entry.new(key: key.to_s, model_name: model_name, permission: permission,
|
|
389
462
|
serializer_name: serializer_name, dashboard_path: dashboard_path,
|
|
390
463
|
scope_name: scope_name, write_permission: write_permission,
|
|
@@ -392,7 +465,9 @@ module Spree
|
|
|
392
465
|
create_workflow_key: create_workflow_key,
|
|
393
466
|
update_workflow_key: update_workflow_key,
|
|
394
467
|
distinct: distinct,
|
|
395
|
-
api_paths: api_paths&.to_a
|
|
468
|
+
api_paths: api_paths&.to_a,
|
|
469
|
+
index_paths: index_paths,
|
|
470
|
+
access_permissions: access_permissions)
|
|
396
471
|
entries[entry.key] = entry
|
|
397
472
|
end
|
|
398
473
|
|
|
@@ -457,7 +532,7 @@ module Spree
|
|
|
457
532
|
# @param context [Spree::AgentTools::Context]
|
|
458
533
|
# @return [Array<Entry>]
|
|
459
534
|
def available_for(context)
|
|
460
|
-
all.select { |entry|
|
|
535
|
+
all.select { |entry| entry.readable_by?(context) }
|
|
461
536
|
end
|
|
462
537
|
|
|
463
538
|
private
|
data/lib/spree/core/engine.rb
CHANGED
|
@@ -606,6 +606,16 @@ module Spree
|
|
|
606
606
|
Rails.autoloaders.main.do_not_eager_load(*DEPRECATED_ALIAS_FILES.map { |path| root.join(path) })
|
|
607
607
|
end
|
|
608
608
|
|
|
609
|
+
# Hands reported errors to the diagnostics error log, resolving the
|
|
610
|
+
# class per call so a development reload picks up the new one.
|
|
611
|
+
module DiagnosticsErrorSubscriber
|
|
612
|
+
def self.report(...) = Spree::Diagnostics::ErrorLog.new.report(...)
|
|
613
|
+
end
|
|
614
|
+
|
|
615
|
+
initializer 'spree.diagnostics.error_log' do
|
|
616
|
+
Rails.error.subscribe(DiagnosticsErrorSubscriber)
|
|
617
|
+
end
|
|
618
|
+
|
|
609
619
|
# filter sensitive information during logging
|
|
610
620
|
initializer 'spree.params.filter' do |app|
|
|
611
621
|
app.config.filter_parameters += [
|
data/lib/spree/core/version.rb
CHANGED
data/lib/spree/core.rb
CHANGED
|
@@ -170,6 +170,17 @@ module Spree
|
|
|
170
170
|
@@search_provider = value.to_s
|
|
171
171
|
end
|
|
172
172
|
|
|
173
|
+
# Sections of the diagnostics report (see Spree::Diagnostics), as class
|
|
174
|
+
# names so an initializer can add one before its class is autoloaded.
|
|
175
|
+
#
|
|
176
|
+
# Spree.diagnostics_sections << 'MyGem::DiagnosticsSection'
|
|
177
|
+
#
|
|
178
|
+
# @return [Array<String>]
|
|
179
|
+
def self.diagnostics_sections
|
|
180
|
+
@@diagnostics_sections ||= %w[Platform Runtime Infrastructure Preferences].
|
|
181
|
+
map { |name| "Spree::Diagnostics::Sections::#{name}" }
|
|
182
|
+
end
|
|
183
|
+
|
|
173
184
|
# Tax ID validators, keyed by registration kind.
|
|
174
185
|
#
|
|
175
186
|
# Core ships one, for +eu_vat+, and it checks format only — the shape of an EU
|
|
@@ -429,7 +429,15 @@ module Spree
|
|
|
429
429
|
metric :orders_lifetime, sql: LIFETIME_ORDERS_SUBQUERY, base: :orders, format: :integer,
|
|
430
430
|
requires_grouping: :customer,
|
|
431
431
|
subject: -> { Spree.customer_class }, key_scope: 'read_customers'
|
|
432
|
+
end
|
|
433
|
+
install_dimensions(registry)
|
|
434
|
+
install_axes(registry)
|
|
435
|
+
install_counters(registry)
|
|
436
|
+
end
|
|
432
437
|
|
|
438
|
+
# Dimensions of the orders and line items bases.
|
|
439
|
+
def self.install_dimensions(registry)
|
|
440
|
+
registry.instance_eval do
|
|
433
441
|
dimension :completed_at, base: :orders, column: :completed_at, type: :time,
|
|
434
442
|
grains: %i[hour day week month]
|
|
435
443
|
dimension :payment_status, base: :orders, column: :payment_status,
|
|
@@ -555,7 +563,12 @@ module Spree
|
|
|
555
563
|
}]
|
|
556
564
|
end
|
|
557
565
|
}
|
|
566
|
+
end
|
|
567
|
+
end
|
|
558
568
|
|
|
569
|
+
# Dimensions of the carts, promotions, payments and stock bases.
|
|
570
|
+
def self.install_axes(registry)
|
|
571
|
+
registry.instance_eval do
|
|
559
572
|
# ---- cart axes ----
|
|
560
573
|
|
|
561
574
|
dimension :started_at, base: :carts, column: :created_at, type: :time,
|
|
@@ -650,7 +663,11 @@ module Spree
|
|
|
650
663
|
[location.id, { id: location.prefixed_id, label: location.name, meta: {} }]
|
|
651
664
|
end
|
|
652
665
|
}
|
|
666
|
+
end
|
|
667
|
+
end
|
|
653
668
|
|
|
669
|
+
def self.install_counters(registry)
|
|
670
|
+
registry.instance_eval do
|
|
654
671
|
# ---- counters ----
|
|
655
672
|
#
|
|
656
673
|
# What needs attention right now. Order counters honour the channel
|
|
@@ -697,19 +714,22 @@ module Spree
|
|
|
697
714
|
link: { resource: 'claims',
|
|
698
715
|
filters: [{ field: 'status', operator: 'in', value: OPEN_CLAIM_STATUSES.join(',') }] }
|
|
699
716
|
|
|
717
|
+
# Variants, not stock levels: a SKU stocked in one warehouse and
|
|
718
|
+
# absent from another is not out of stock, and counting one row per
|
|
719
|
+
# location would report every such pair as a problem.
|
|
700
720
|
counter :low_stock_items,
|
|
701
721
|
subject: -> { Spree::StockLevel }, key_scope: 'read_stock',
|
|
702
|
-
count: lambda { |store,
|
|
703
|
-
STORE_STOCK.call(store).
|
|
722
|
+
count: lambda { |store, **|
|
|
723
|
+
STORE_STOCK.call(store).low_stock_overall(store.preferred_low_stock_threshold).distinct.count(:variant_id)
|
|
704
724
|
},
|
|
705
725
|
link: { resource: 'inventory',
|
|
706
|
-
filters: [{ field: 'stock_status', operator: 'in', value: '
|
|
726
|
+
filters: [{ field: 'stock_status', operator: 'in', value: 'low_stock_overall' }] }
|
|
707
727
|
|
|
708
728
|
counter :out_of_stock_items,
|
|
709
729
|
subject: -> { Spree::StockLevel }, key_scope: 'read_stock',
|
|
710
|
-
count: ->(store,
|
|
730
|
+
count: ->(store, **) { STORE_STOCK.call(store).out_of_stock_overall.distinct.count(:variant_id) },
|
|
711
731
|
link: { resource: 'inventory',
|
|
712
|
-
filters: [{ field: 'stock_status', operator: 'in', value: '
|
|
732
|
+
filters: [{ field: 'stock_status', operator: 'in', value: 'out_of_stock_overall' }] }
|
|
713
733
|
end
|
|
714
734
|
end
|
|
715
735
|
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
namespace :spree do
|
|
2
|
+
# Plumbing for `spree info` in the CLI, which is how users get the report
|
|
3
|
+
# from the command line, so it has no description and stays out of
|
|
4
|
+
# `bin/rails -T`. The CLI passes what only it can see (Node, Docker,
|
|
5
|
+
# @spree packages) as `{ "title": ..., "rows": { label => value } }`.
|
|
6
|
+
task info: :environment do
|
|
7
|
+
extra_sections = ENV['SPREE_INFO_CLIENT'].present? ? [JSON.parse(ENV['SPREE_INFO_CLIENT']).symbolize_keys] : []
|
|
8
|
+
report = Spree::Diagnostics.report(extra_sections: extra_sections, errors: false)
|
|
9
|
+
puts ENV['FORMAT'] == 'json' ? report.to_h.to_json : report.to_markdown
|
|
10
|
+
end
|
|
11
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.0.
|
|
4
|
+
version: 6.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sean Schofield
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2026-11-
|
|
13
|
+
date: 2026-11-12 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: i18n-tasks
|
|
@@ -1325,6 +1325,11 @@ files:
|
|
|
1325
1325
|
- app/services/spree/deliveries/create.rb
|
|
1326
1326
|
- app/services/spree/deliveries/destroy.rb
|
|
1327
1327
|
- app/services/spree/deliveries/upsert_primary.rb
|
|
1328
|
+
- app/services/spree/diagnostics.rb
|
|
1329
|
+
- app/services/spree/diagnostics/error_log.rb
|
|
1330
|
+
- app/services/spree/diagnostics/section.rb
|
|
1331
|
+
- app/services/spree/diagnostics/sections.rb
|
|
1332
|
+
- app/services/spree/diagnostics/stack.rb
|
|
1328
1333
|
- app/services/spree/email_templates/check.rb
|
|
1329
1334
|
- app/services/spree/email_templates/no_sample_record.rb
|
|
1330
1335
|
- app/services/spree/email_templates/preview.rb
|
|
@@ -2291,6 +2296,7 @@ files:
|
|
|
2291
2296
|
- lib/tasks/delivery_migration.rake
|
|
2292
2297
|
- lib/tasks/delivery_profiles_migration.rake
|
|
2293
2298
|
- lib/tasks/dependencies.rake
|
|
2299
|
+
- lib/tasks/diagnostics.rake
|
|
2294
2300
|
- lib/tasks/fold_store_credit_categories.rake
|
|
2295
2301
|
- lib/tasks/fulfillment_statuses_migration.rake
|
|
2296
2302
|
- lib/tasks/inventory_operations_migration.rake
|
|
@@ -2350,9 +2356,9 @@ licenses:
|
|
|
2350
2356
|
- BSD-3-Clause
|
|
2351
2357
|
metadata:
|
|
2352
2358
|
bug_tracker_uri: https://github.com/spree/spree/issues
|
|
2353
|
-
changelog_uri: https://github.com/spree/spree/releases/tag/v6.0.
|
|
2359
|
+
changelog_uri: https://github.com/spree/spree/releases/tag/v6.0.4
|
|
2354
2360
|
documentation_uri: https://spreecommerce.org/docs/
|
|
2355
|
-
source_code_uri: https://github.com/spree/spree/tree/v6.0.
|
|
2361
|
+
source_code_uri: https://github.com/spree/spree/tree/v6.0.4
|
|
2356
2362
|
post_install_message:
|
|
2357
2363
|
rdoc_options: []
|
|
2358
2364
|
require_paths:
|