spree_api 6.0.0.rc4 → 6.0.0.rc5

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.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/spree/api/v3/allowed_redirect_url.rb +27 -0
  3. data/app/controllers/concerns/spree/api/v3/cart_resolvable.rb +8 -2
  4. data/app/controllers/concerns/spree/api/v3/scoped_authorization.rb +6 -2
  5. data/app/controllers/spree/api/v3/admin/companies/addresses_controller.rb +7 -1
  6. data/app/controllers/spree/api/v3/admin/custom_fields_controller.rb +30 -8
  7. data/app/controllers/spree/api/v3/admin/customers/addresses_controller.rb +4 -0
  8. data/app/controllers/spree/api/v3/admin/customers_controller.rb +1 -6
  9. data/app/controllers/spree/api/v3/admin/gift_cards_controller.rb +1 -8
  10. data/app/controllers/spree/api/v3/admin/orders_controller.rb +11 -5
  11. data/app/controllers/spree/api/v3/admin/package_types_controller.rb +2 -3
  12. data/app/controllers/spree/api/v3/admin/products/variants_controller.rb +3 -4
  13. data/app/controllers/spree/api/v3/admin/products_controller.rb +5 -3
  14. data/app/controllers/spree/api/v3/admin/store_controller.rb +1 -1
  15. data/app/controllers/spree/api/v3/admin/variants_controller.rb +96 -1
  16. data/app/controllers/spree/api/v3/oauth/authorizations_controller.rb +17 -6
  17. data/app/controllers/spree/api/v3/resource_controller.rb +35 -5
  18. data/app/controllers/spree/api/v3/seller/package_types_controller.rb +2 -2
  19. data/app/controllers/spree/api/v3/seller/products_controller.rb +7 -61
  20. data/app/controllers/spree/api/v3/seller/resource_controller.rb +2 -6
  21. data/app/controllers/spree/api/v3/store/carts/addresses_controller.rb +53 -0
  22. data/app/controllers/spree/api/v3/store/carts_controller.rb +3 -3
  23. data/app/controllers/spree/api/v3/store/companies/addresses_controller.rb +4 -0
  24. data/app/controllers/spree/api/v3/store/customer/addresses_controller.rb +4 -0
  25. data/app/controllers/spree/api/v3/store/customer/data_requests_controller.rb +19 -1
  26. data/app/controllers/spree/api/v3/store/customer/password_resets_controller.rb +3 -14
  27. data/app/controllers/spree/api/v3/store/data_request_confirmations_controller.rb +23 -0
  28. data/app/controllers/spree/api/v3/store/data_requests_controller.rb +56 -0
  29. data/app/controllers/spree/api/v3/store/newsletter_subscribers_controller.rb +2 -11
  30. data/app/request_schemas/spree/api/v3/admin/variant_request_schema.rb +21 -0
  31. data/app/request_schemas/spree/api/v3/seller/price_request_schema.rb +20 -0
  32. data/app/request_schemas/spree/api/v3/seller/variant_request_schema.rb +19 -0
  33. data/app/request_schemas/spree/api/v3/variant_request_schema.rb +8 -13
  34. data/app/serializers/spree/api/v3/address_owner_serializer.rb +27 -0
  35. data/app/serializers/spree/api/v3/address_serializer.rb +5 -1
  36. data/app/serializers/spree/api/v3/admin/address_owner_serializer.rb +10 -0
  37. data/app/serializers/spree/api/v3/admin/address_serializer.rb +1 -10
  38. data/app/serializers/spree/api/v3/admin/api_key_serializer.rb +1 -1
  39. data/app/serializers/spree/api/v3/admin/catalog_assignment_serializer.rb +1 -1
  40. data/app/serializers/spree/api/v3/admin/catalog_price_serializer.rb +1 -1
  41. data/app/serializers/spree/api/v3/admin/collection_rule_serializer.rb +1 -1
  42. data/app/serializers/spree/api/v3/admin/collection_serializer.rb +1 -1
  43. data/app/serializers/spree/api/v3/admin/commission_line_serializer.rb +2 -2
  44. data/app/serializers/spree/api/v3/admin/commission_rate_serializer.rb +1 -1
  45. data/app/serializers/spree/api/v3/admin/consent_record_serializer.rb +1 -1
  46. data/app/serializers/spree/api/v3/admin/email_template_serializer.rb +1 -1
  47. data/app/serializers/spree/api/v3/admin/order_serializer.rb +1 -1
  48. data/app/serializers/spree/api/v3/admin/package_type_serializer.rb +3 -3
  49. data/app/serializers/spree/api/v3/admin/permission_serializer.rb +1 -1
  50. data/app/serializers/spree/api/v3/admin/price_list_serializer.rb +1 -1
  51. data/app/serializers/spree/api/v3/admin/purchase_order_serializer.rb +1 -1
  52. data/app/serializers/spree/api/v3/admin/seller_requirement_status_serializer.rb +1 -1
  53. data/app/serializers/spree/api/v3/admin/seller_serializer.rb +2 -2
  54. data/app/serializers/spree/api/v3/admin/seller_transfer_serializer.rb +1 -1
  55. data/app/serializers/spree/api/v3/admin/shipping_label_serializer.rb +3 -3
  56. data/app/serializers/spree/api/v3/admin/stock_location_serializer.rb +1 -1
  57. data/app/serializers/spree/api/v3/admin/stock_receipt_item_serializer.rb +2 -2
  58. data/app/serializers/spree/api/v3/admin/stock_receipt_serializer.rb +1 -1
  59. data/app/serializers/spree/api/v3/admin/stock_transfer_serializer.rb +1 -1
  60. data/app/serializers/spree/api/v3/admin/store_serializer.rb +1 -0
  61. data/app/serializers/spree/api/v3/admin/tax_identifier_serializer.rb +2 -2
  62. data/app/serializers/spree/api/v3/admin/tax_line_serializer.rb +1 -1
  63. data/app/serializers/spree/api/v3/admin/variant_serializer.rb +1 -1
  64. data/app/serializers/spree/api/v3/base_serializer.rb +27 -5
  65. data/app/serializers/spree/api/v3/claim_serializer.rb +1 -1
  66. data/app/serializers/spree/api/v3/collection_serializer.rb +1 -1
  67. data/app/serializers/spree/api/v3/company_invitation_serializer.rb +1 -1
  68. data/app/serializers/spree/api/v3/company_serializer.rb +1 -1
  69. data/app/serializers/spree/api/v3/data_request_confirmation_requested_event_serializer.rb +28 -0
  70. data/app/serializers/spree/api/v3/data_request_event_serializer.rb +1 -1
  71. data/app/serializers/spree/api/v3/data_request_serializer.rb +8 -4
  72. data/app/serializers/spree/api/v3/delivery_serializer.rb +1 -1
  73. data/app/serializers/spree/api/v3/delivery_zone_member_serializer.rb +1 -1
  74. data/app/serializers/spree/api/v3/discount_serializer.rb +1 -1
  75. data/app/serializers/spree/api/v3/file_upload_serializer.rb +1 -1
  76. data/app/serializers/spree/api/v3/fulfillment_serializer.rb +1 -1
  77. data/app/serializers/spree/api/v3/media_event_serializer.rb +1 -1
  78. data/app/serializers/spree/api/v3/media_serializer.rb +1 -1
  79. data/app/serializers/spree/api/v3/option_type_serializer.rb +1 -1
  80. data/app/serializers/spree/api/v3/order_group_serializer.rb +2 -2
  81. data/app/serializers/spree/api/v3/order_serializer.rb +4 -2
  82. data/app/serializers/spree/api/v3/payment_serializer.rb +1 -1
  83. data/app/serializers/spree/api/v3/product_filter_availability_option_serializer.rb +1 -1
  84. data/app/serializers/spree/api/v3/product_filter_option_serializer.rb +1 -1
  85. data/app/serializers/spree/api/v3/seller/address_serializer.rb +3 -2
  86. data/app/serializers/spree/api/v3/seller/order_serializer.rb +3 -3
  87. data/app/serializers/spree/api/v3/seller/package_type_serializer.rb +3 -3
  88. data/app/serializers/spree/api/v3/seller/profile_serializer.rb +2 -2
  89. data/app/serializers/spree/api/v3/seller/requirement_status_serializer.rb +1 -1
  90. data/app/serializers/spree/api/v3/seller/tax_identifier_serializer.rb +1 -1
  91. data/app/serializers/spree/api/v3/seller/variant_serializer.rb +1 -1
  92. data/app/serializers/spree/api/v3/shipping_label_event_serializer.rb +1 -1
  93. data/app/serializers/spree/api/v3/stock_movement_serializer.rb +1 -1
  94. data/app/serializers/spree/api/v3/stock_receipt_event_serializer.rb +1 -1
  95. data/app/serializers/spree/api/v3/variant_serializer.rb +2 -2
  96. data/app/services/spree/api/v3/filter_table.rb +22 -3
  97. data/app/services/spree/api/v3/request_schema.rb +64 -17
  98. data/config/locales/en.yml +1 -0
  99. data/config/routes.rb +19 -11
  100. data/lib/spree/api/agent_write_schemas.rb +15 -3
  101. data/lib/spree/api/dependencies.rb +2 -2
  102. data/lib/spree/api/enum_types.rb +118 -0
  103. data/lib/spree/api/openapi/filter_documentation.rb +8 -1
  104. data/lib/spree/api/typelizer_generation.rb +5 -0
  105. data/lib/typelizer/open_enums.rb +40 -16
  106. metadata +17 -6
@@ -8,7 +8,7 @@ module Spree
8
8
  class CollectionSerializer < V3::CollectionSerializer
9
9
  include Spree::Api::V3::Admin::Translatable
10
10
 
11
- typelize automatic: :boolean, rules_match_policy: [:string, enum: Spree::Collection::RULES_MATCH_POLICIES],
11
+ typelize automatic: :boolean, rules_match_policy: [:string, enum: Spree::Collection::RULES_MATCH_POLICIES, enum_type_name: 'MatchPolicy'],
12
12
  metadata: 'Record<string, unknown>'
13
13
 
14
14
  attributes :automatic, :rules_match_policy, :metadata,
@@ -19,8 +19,8 @@ module Spree
19
19
  line_item_id: 'string | null',
20
20
  fulfillment_id: 'string | null',
21
21
  commission_rate_id: 'string | null',
22
- kind: [:string, enum: Spree::CommissionRate::KINDS],
23
- taxability_reason: 'string | null',
22
+ kind: [:string, enum: Spree::CommissionRate::KINDS, enum_type_name: 'CommissionKind'],
23
+ taxability_reason: [:string, nullable: true, enum: Spree::TaxLine::BUILT_IN_TAXABILITY_REASONS, enum_type_name: 'TaxabilityReason'],
24
24
  country_code: [:string, nullable: true, enum: Spree::IsoData.country_codes, enum_type_name: 'CountryCode'],
25
25
  state_code: 'string | null',
26
26
  currency: [:string, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode']
@@ -15,7 +15,7 @@ module Spree
15
15
  enabled: :boolean,
16
16
  position: :number,
17
17
  global: :boolean,
18
- kind: [:string, enum: Spree::CommissionRate::KINDS],
18
+ kind: [:string, enum: Spree::CommissionRate::KINDS, enum_type_name: 'CommissionKind'],
19
19
  amounts: 'Record<string, string>',
20
20
  bounds: 'Record<string, { min_amount: string | null; max_amount: string | null }>',
21
21
  tax_inclusive: :boolean,
@@ -5,7 +5,7 @@ module Spree
5
5
  # Admin API Consent Record Serializer
6
6
  # The evidence trail behind a customer's consent state.
7
7
  class ConsentRecordSerializer < BaseSerializer
8
- typelize purpose: :string, source: [:string, enum: Spree::ConsentRecord::SOURCES], accepted: :boolean,
8
+ typelize purpose: :string, source: [:string, enum: Spree::ConsentRecord::SOURCES, enum_type_name: 'ConsentSource'], accepted: :boolean,
9
9
  email: [:string, nullable: true],
10
10
  ip_address: [:string, nullable: true],
11
11
  recorded_at: [:string, nullable: true],
@@ -7,7 +7,7 @@ module Spree
7
7
  # default, and the draft in progress.
8
8
  class EmailTemplateSerializer < V3::BaseSerializer
9
9
  typelize key: :string,
10
- kind: [:string, enum: Spree::Emails::EditableTemplates::KINDS.map(&:to_s)],
10
+ kind: [:string, enum: Spree::Emails::EditableTemplates::KINDS.map(&:to_s), enum_type_name: 'EmailTemplateKind'],
11
11
  language: :string,
12
12
  customized: :boolean,
13
13
  customized_languages: [:string, multi: true],
@@ -31,7 +31,7 @@ module Spree
31
31
  total: [:string, nullable: false],
32
32
  amount_due: [:string, nullable: false]
33
33
 
34
- typelize status: [:string, enum: Spree::Order::STATUSES],
34
+ typelize status: [:string, enum: Spree::Order::STATUSES, enum_type_name: 'OrderStatus'],
35
35
  last_ip_address: [:string, nullable: true],
36
36
  considered_risky: :boolean, confirmation_delivered: :boolean,
37
37
  store_owner_notification_delivered: [:boolean, nullable: true],
@@ -7,14 +7,14 @@ module Spree
7
7
  # only — a shopper never picks their packaging.
8
8
  class PackageTypeSerializer < V3::BaseSerializer
9
9
  typelize name: :string,
10
- kind: [:string, enum: Spree::PackageType::KINDS],
10
+ kind: [:string, enum: Spree::PackageType::KINDS, enum_type_name: 'PackageTypeKind'],
11
11
  length: [:string, nullable: true],
12
12
  width: [:string, nullable: true],
13
13
  height: [:string, nullable: true],
14
- dimensions_unit: [:string, enum: Spree::Variant::DIMENSION_UNITS],
14
+ dimensions_unit: [:string, enum: Spree::Variant::DIMENSION_UNITS, enum_type_name: 'DimensionUnit'],
15
15
  weight: [:string, nullable: true],
16
16
  max_weight: [:string, nullable: true],
17
- weight_unit: [:string, enum: Spree::Variant::WEIGHT_UNITS],
17
+ weight_unit: [:string, enum: Spree::Variant::WEIGHT_UNITS, enum_type_name: 'WeightUnit'],
18
18
  volume: [:string, nullable: true],
19
19
  default: :boolean,
20
20
  seller_id: [:string, nullable: true],
@@ -10,7 +10,7 @@ module Spree
10
10
  include Alba::Resource
11
11
  include Typelizer::DSL
12
12
 
13
- typelize key: :string, resource: :string, kind: [:string, enum: %w[read write]], group: :string,
13
+ typelize key: :string, resource: :string, kind: [:string, enum: %w[read write], enum_type_name: 'PermissionKind'], group: :string,
14
14
  group_label: :string, label: :string, description: :string
15
15
 
16
16
  attributes :key
@@ -14,7 +14,7 @@ module Spree
14
14
  starts_at: 'string | null',
15
15
  ends_at: 'string | null',
16
16
  deleted_at: 'string | null',
17
- match_policy: [:string, enum: Spree::PriceList::MATCH_POLICIES],
17
+ match_policy: [:string, enum: Spree::PriceList::MATCH_POLICIES, enum_type_name: 'MatchPolicy'],
18
18
  price_adjustment_percentage: 'string | null',
19
19
  adjust_compare_at: :boolean,
20
20
  automatic_pricing: :boolean,
@@ -6,7 +6,7 @@ module Spree
6
6
  # the merchant owes and expects, which no customer ever sees.
7
7
  class PurchaseOrderSerializer < V3::BaseSerializer
8
8
  typelize number: :string,
9
- status: :string,
9
+ status: [:string, enum: Spree::PurchaseOrder.statuses, enum_type_name: 'PurchaseOrderStatus'],
10
10
  currency: [:string, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'],
11
11
  reference: 'string | null',
12
12
  notes: 'string | null',
@@ -12,7 +12,7 @@ module Spree
12
12
 
13
13
  typelize id: :string, kind: [:string, comment: 'Requirement kind. Built-in: accept_terms, complete_profile, billing_address, returns_address, delivery_method, package_type, minimum_products, payout_account, required_custom_fields, policy, attestation, operator_review, document. Extensions may register more.'], name: :string,
14
14
  description: [:string, nullable: true],
15
- required: :boolean, position: :number, status: [:string, enum: Spree::SellerRequirementStatus::STATUSES],
15
+ required: :boolean, position: :number, status: [:string, enum: Spree::SellerRequirementStatus::STATUSES, enum_type_name: 'SellerRequirementState'],
16
16
  blocking: :boolean, action_url: [:string, nullable: true],
17
17
  blocker: ['{ state: string; message: string | null } | null'],
18
18
  required_policy_name: [:string, nullable: true]
@@ -10,8 +10,8 @@ module Spree
10
10
  legal_name: [:string, nullable: true],
11
11
  registration_number: [:string, nullable: true],
12
12
  contact_email: [:string, nullable: true], billing_email: [:string, nullable: true],
13
- tax_remittance: :string,
14
- payouts_schedule_interval: [:string, nullable: true],
13
+ tax_remittance: [:string, enum: Spree::Seller::TAX_REMITTANCES, enum_type_name: 'TaxRemittance'],
14
+ payouts_schedule_interval: [:string, nullable: true, enum: Spree::Seller::PAYOUT_INTERVALS, enum_type_name: 'PayoutScheduleInterval'],
15
15
  minimum_payout_amount: [:string, nullable: true],
16
16
  holiday_mode_until: [:string, nullable: true],
17
17
  terms_accepted_at: [:string, nullable: true],
@@ -14,7 +14,7 @@ module Spree
14
14
  refund_id: 'string | null',
15
15
  seller_name: 'string | null',
16
16
  order_number: 'string | null',
17
- kind: [:string, enum: Spree::SellerTransfer::KINDS],
17
+ kind: [:string, enum: Spree::SellerTransfer::KINDS, enum_type_name: 'SellerTransferKind'],
18
18
  status: [:string, enum: Spree::SellerTransfer.statuses, enum_type_name: 'SellerTransferStatus'],
19
19
  provider: [:string, comment: 'Payout provider. Built-in: system. Provider gems register more (e.g. stripe).'],
20
20
  amount: :string,
@@ -7,15 +7,15 @@ module Spree
7
7
  # The file is streamed through +download_url+, never linked to storage.
8
8
  class ShippingLabelSerializer < V3::BaseSerializer
9
9
  typelize owner_id: :string,
10
- owner_type: [:string, enum: Spree::ShippingLabel::OWNER_TYPES.map { |type| Spree::Base.polymorphic_api_type(type) }],
11
- source: [:string, enum: Spree::ShippingLabel::SOURCES],
10
+ owner_type: [:string, enum: Spree::ShippingLabel::OWNER_TYPES.map { |type| Spree::Base.polymorphic_api_type(type) }, enum_type_name: 'ShippingLabelOwnerType'],
11
+ source: [:string, enum: Spree::ShippingLabel::SOURCES, enum_type_name: 'ShippingLabelSource'],
12
12
  status: [:string, enum: Spree::ShippingLabel.statuses, enum_type_name: 'ShippingLabelStatus'],
13
13
  carrier: [:string, nullable: true],
14
14
  carrier_name: [:string, nullable: true],
15
15
  service: [:string, nullable: true],
16
16
  tracking_number: [:string, nullable: true],
17
17
  currency: [:string, nullable: true, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'],
18
- format: [:string, nullable: true],
18
+ format: [:string, nullable: true, enum: Spree::ShippingLabel::FORMATS, enum_type_name: 'ShippingLabelFormat'],
19
19
  external_id: [:string, nullable: true],
20
20
  integration_id: [:string, nullable: true],
21
21
  download_url: [:string, nullable: true],
@@ -15,7 +15,7 @@ module Spree
15
15
  address2: [:string, nullable: true], state_name: [:string, nullable: true],
16
16
  phone: [:string, nullable: true], company: [:string, nullable: true],
17
17
  kind: [:string, enum: Spree::StockLocation::KINDS, enum_type_name: 'StockLocationKind'],
18
- pickup_stock_policy: [:string, enum: Spree::StockLocation::PICKUP_STOCK_POLICIES],
18
+ pickup_stock_policy: [:string, enum: Spree::StockLocation::PICKUP_STOCK_POLICIES, enum_type_name: 'PickupStockPolicy'],
19
19
  pickup_ready_in_minutes: [:number, nullable: true],
20
20
  pickup_instructions: [:string, nullable: true]
21
21
 
@@ -7,9 +7,9 @@ module Spree
7
7
  class StockReceiptItemSerializer < V3::BaseSerializer
8
8
  typelize quantity_accepted: :number,
9
9
  quantity_rejected: :number,
10
- rejection_reason: [:string, enum: Spree::StockReceiptItem::REJECTION_REASONS, nullable: true],
10
+ rejection_reason: [:string, enum: Spree::StockReceiptItem::REJECTION_REASONS, nullable: true, enum_type_name: 'StockReceiptRejectionReason'],
11
11
  notes: 'string | null',
12
- line_type: [:string, enum: %w[purchase_order_item stock_transfer_item]],
12
+ line_type: [:string, enum: %w[purchase_order_item stock_transfer_item], enum_type_name: 'StockReceiptLineType'],
13
13
  line_id: 'string | null',
14
14
  product_id: 'string | null',
15
15
  variant_id: 'string | null',
@@ -9,7 +9,7 @@ module Spree
9
9
  reference: 'string | null',
10
10
  notes: 'string | null',
11
11
  received_at: :string,
12
- receivable_type: [:string, enum: %w[purchase_order stock_transfer]],
12
+ receivable_type: [:string, enum: %w[purchase_order stock_transfer], enum_type_name: 'StockReceiptReceivableType'],
13
13
  receivable_id: :string,
14
14
  received_by_id: 'string | null',
15
15
  received_by_type: [:string, nullable: true, enum: Spree::Actor::BUILT_IN_KINDS, enum_type_name: 'ActorKind'],
@@ -6,7 +6,7 @@ module Spree
6
6
  # has a middle: `shipped_at` is when the units left the source,
7
7
  # `received_at` when the destination finished counting them in.
8
8
  class StockTransferSerializer < V3::StockTransferSerializer
9
- typelize status: :string,
9
+ typelize status: [:string, enum: Spree::StockTransfer.statuses, enum_type_name: 'StockTransferStatus'],
10
10
  notes: 'string | null',
11
11
  items_count: :number,
12
12
  quantity_shipped_total: :number,
@@ -36,6 +36,7 @@ module Spree
36
36
  # and rate settings are formatted below.
37
37
  preference_attributes Spree::Store, except: %i[order_routing_strategy payout_provider
38
38
  default_minimum_payout_amount default_commission_tax_rate]
39
+ typelize weight_unit: [:string, enum: Spree::Variant::WEIGHT_UNITS, enum_type_name: 'WeightUnit']
39
40
 
40
41
  # Once the counter has issued a number the starting value no longer
41
42
  # applies, so the settings page can say that instead of accepting a
@@ -3,10 +3,10 @@ module Spree
3
3
  module V3
4
4
  module Admin
5
5
  class TaxIdentifierSerializer < V3::TaxIdentifierSerializer
6
- typelize validation_status: [:string, nullable: true, enum: Spree::TaxIdentifier::VALIDATION_STATUSES],
6
+ typelize validation_status: [:string, nullable: true, enum: Spree::TaxIdentifier::VALIDATION_STATUSES, enum_type_name: 'TaxIdentifierValidationStatus'],
7
7
  validated_at: [:string, nullable: true],
8
8
  validation_evidence: ['Record<string, unknown>', nullable: true],
9
- source: [:string, nullable: true, enum: Spree::TaxIdentifier::SOURCES],
9
+ source: [:string, nullable: true, enum: Spree::TaxIdentifier::SOURCES, enum_type_name: 'TaxIdentifierSource'],
10
10
  validatable: :boolean,
11
11
  customer_id: [:string, nullable: true],
12
12
  cart_id: [:string, nullable: true],
@@ -7,7 +7,7 @@ module Spree
7
7
 
8
8
  typelize amount: [:string, nullable: false],
9
9
  provider_id: [:string, nullable: true], metadata: ['Record<string, unknown>', nullable: true],
10
- taxability_reason: [:string, nullable: true], country_code: [:string, nullable: true, enum: Spree::IsoData.country_codes, enum_type_name: 'CountryCode'],
10
+ taxability_reason: [:string, nullable: true, enum: Spree::TaxLine::BUILT_IN_TAXABILITY_REASONS, enum_type_name: 'TaxabilityReason'], country_code: [:string, nullable: true, enum: Spree::IsoData.country_codes, enum_type_name: 'CountryCode'],
11
11
  state_code: [:string, nullable: true], data: ['Record<string, unknown>', nullable: true],
12
12
  original_tax_line_id: [:string, nullable: true]
13
13
 
@@ -24,7 +24,7 @@ module Spree
24
24
  deleted_at: [:string, nullable: true],
25
25
  delivery_profile_id: [:string, nullable: true],
26
26
  minimum_order_quantity: ['number | null'], order_multiple: ['number | null'],
27
- purchase_unit: [:string, nullable: true, enum: Spree::Variant::PURCHASE_UNITS],
27
+ purchase_unit: [:string, nullable: true, enum: Spree::Variant::PURCHASE_UNITS, enum_type_name: 'PurchaseUnit'],
28
28
  carton_package_type_id: [:string, nullable: true],
29
29
  carton_weight: [:string, nullable: true],
30
30
  cartons_per_pallet: ['number | null'],
@@ -126,7 +126,7 @@ module Spree
126
126
  names = model.exposed_preference_names.to_a - except if names.empty?
127
127
  definitions = model.preference_definitions
128
128
  names.each do |name|
129
- typelize name => preference_type_hint(Spree::PreferenceSchema::JsonSchema.property_schema(definitions.fetch(name)))
129
+ typelize name => preference_type_hint(Spree::PreferenceSchema::JsonSchema.property_schema(definitions.fetch(name)), name)
130
130
  reader = :"preferred_#{name}"
131
131
  attribute(name) do |object|
132
132
  value = object.public_send(reader)
@@ -138,12 +138,29 @@ module Spree
138
138
  TYPELIZER_TYPES = { 'string' => :string, 'integer' => :number, 'number' => :number, 'boolean' => :boolean }.freeze
139
139
  private_constant :TYPELIZER_TYPES
140
140
 
141
- def self.preference_type_hint(schema)
141
+ # The shared name of each setting's value list, so it is defined once
142
+ # in `@spree/core` rather than inline wherever the setting appears.
143
+ PREFERENCE_LIST_NAMES = {
144
+ capture_method: 'CaptureMethod',
145
+ default_payouts_schedule_interval: 'PayoutScheduleInterval',
146
+ document_number_format: 'DocumentNumberFormat',
147
+ email_font: 'EmailFont',
148
+ inventory_provider_failure_policy: 'ProviderFailurePolicy',
149
+ pricing_provider_failure_policy: 'ProviderFailurePolicy',
150
+ storefront_access: 'StorefrontAccess',
151
+ unit_system: 'UnitSystem'
152
+ }.freeze
153
+ private_constant :PREFERENCE_LIST_NAMES
154
+
155
+ def self.preference_type_hint(schema, name)
142
156
  types = Array(schema['type'])
143
157
  hint = TYPELIZER_TYPES.fetch((types - ['null']).first, :unknown)
144
158
  options = {}
145
159
  options[:nullable] = true if types.include?('null')
146
- options[:enum] = schema['enum'].compact if schema['enum']
160
+ if schema['enum']
161
+ options[:enum] = schema['enum'].compact
162
+ options[:enum_type_name] = PREFERENCE_LIST_NAMES[name.to_sym] if PREFERENCE_LIST_NAMES.key?(name.to_sym)
163
+ end
147
164
  options.empty? ? hint : [hint, options]
148
165
  end
149
166
  private_class_method :preference_type_hint
@@ -277,6 +294,10 @@ module Spree
277
294
  currency: current_currency,
278
295
  store: current_store,
279
296
  user: current_user,
297
+ company: params[:company],
298
+ market: params[:market],
299
+ channel: params[:channel],
300
+ country: params[:country],
280
301
  quantity: quantity
281
302
  )
282
303
  end
@@ -295,8 +316,9 @@ module Spree
295
316
  return Spree::QuantityRule.new if current_store.nil?
296
317
 
297
318
  Spree::Current.quantity_rules_resolver_for(
298
- company: Spree::Current.standing_company_for(current_user),
299
- user: current_user
319
+ company: params.key?(:company) ? params[:company] : Spree::Current.standing_company_for(current_user),
320
+ user: current_user,
321
+ channel: params[:channel]
300
322
  ).call(variant)
301
323
  end
302
324
 
@@ -7,7 +7,7 @@ module Spree
7
7
  class ClaimSerializer < BaseSerializer
8
8
  typelize number: :string,
9
9
  status: [:string, enum: Spree::Claim.statuses, enum_type_name: 'ClaimStatus'],
10
- resolution: [:string, nullable: true],
10
+ resolution: [:string, nullable: true, enum: Spree::Claim::RESOLUTIONS, enum_type_name: 'ClaimResolution'],
11
11
  order_id: [:string, nullable: true],
12
12
  reason_id: [:string, nullable: true],
13
13
  approved_at: [:string, nullable: true],
@@ -6,7 +6,7 @@ module Spree
6
6
  # back-office state exposed only by the Admin serializer.
7
7
  class CollectionSerializer < BaseSerializer
8
8
  typelize name: :string, permalink: :string, position: :number,
9
- sort_order: :string,
9
+ sort_order: [:string, enum: Spree::Collection::SORT_ORDERS, enum_type_name: 'CollectionSortOrder'],
10
10
  meta_title: [:string, nullable: true], meta_description: [:string, nullable: true], meta_keywords: [:string, nullable: true],
11
11
  description: :string, description_html: :string,
12
12
  image_url: [:string, nullable: true], square_image_url: [:string, nullable: true],
@@ -4,7 +4,7 @@ module Spree
4
4
  # A pending (or spent) invitation into a company node. The token is
5
5
  # deliberately absent — it travels only in the invite email.
6
6
  class CompanyInvitationSerializer < BaseSerializer
7
- typelize email: :string, company_id: :string, status: [:string, enum: %w[pending accepted revoked expired]],
7
+ typelize email: :string, company_id: :string, status: [:string, enum: %w[pending accepted revoked expired], enum_type_name: 'CompanyInvitationStatus'],
8
8
  expires_at: [:string, nullable: true]
9
9
 
10
10
  attributes :email, expires_at: :iso8601
@@ -7,7 +7,7 @@ module Spree
7
7
  # back-office fields stay in one place.
8
8
  class CompanySerializer < BaseSerializer
9
9
  typelize name: :string,
10
- kind: [:string, enum: Spree::Company::KINDS], parent_id: [:string, nullable: true],
10
+ kind: [:string, enum: Spree::Company::KINDS, enum_type_name: 'CompanyKind'], parent_id: [:string, nullable: true],
11
11
  po_number_required: :boolean,
12
12
  ancestors: 'Array<{id: string, name: string, kind: string}>'
13
13
 
@@ -0,0 +1,28 @@
1
+ module Spree
2
+ module Api
3
+ module V3
4
+ # The event shape for `data_request.confirmation_requested`: what a
5
+ # storefront that sends its own emails needs to ask the person to confirm
6
+ # a request they raised. `confirmation_token` is a live credential, so
7
+ # the event reaches only endpoints that name it.
8
+ class DataRequestConfirmationRequestedEventSerializer < DataRequestEventSerializer
9
+ typelize email: :string, confirmation_token: :string, store_id: :string,
10
+ redirect_url: [:string, optional: true]
11
+
12
+ attributes :email
13
+
14
+ attribute :confirmation_token do
15
+ params[:confirmation_token]
16
+ end
17
+
18
+ attribute :store_id do |data_request|
19
+ data_request.store.prefixed_id
20
+ end
21
+
22
+ attribute :redirect_url, if: proc { params[:redirect_url].present? } do
23
+ params[:redirect_url]
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -11,7 +11,7 @@ module Spree
11
11
  # log. Subscribers get the fact that a request finished; fetching the
12
12
  # file stays an authenticated act by the person it belongs to.
13
13
  class DataRequestEventSerializer < BaseSerializer
14
- typelize number: :string, kind: [:string, enum: Spree::DataRequest::KINDS], status: [:string, enum: Spree::DataRequest.statuses, enum_type_name: 'DataRequestStatus'],
14
+ typelize number: :string, kind: [:string, enum: Spree::DataRequest::KINDS, enum_type_name: 'DataRequestKind'], status: [:string, enum: Spree::DataRequest.statuses, enum_type_name: 'DataRequestStatus'],
15
15
  requested_at: [:string, nullable: true],
16
16
  completed_at: [:string, nullable: true]
17
17
 
@@ -4,7 +4,7 @@ module Spree
4
4
  # Store API Data Request Serializer
5
5
  # A customer's own GDPR access or erasure request.
6
6
  class DataRequestSerializer < BaseSerializer
7
- typelize number: :string, kind: [:string, enum: Spree::DataRequest::KINDS], status: [:string, enum: Spree::DataRequest.statuses, enum_type_name: 'DataRequestStatus'],
7
+ typelize number: :string, kind: [:string, enum: Spree::DataRequest::KINDS, enum_type_name: 'DataRequestKind'], status: [:string, enum: Spree::DataRequest.statuses, enum_type_name: 'DataRequestStatus'],
8
8
  requested_at: [:string, nullable: true],
9
9
  completed_at: [:string, nullable: true],
10
10
  expires_at: [:string, nullable: true],
@@ -25,11 +25,15 @@ module Spree
25
25
  end
26
26
 
27
27
  # Present only while the file is still there — a link the storefront
28
- # can render without having to reason about expiry itself.
29
- attribute :download_url do |data_request, params|
28
+ # can render without having to reason about expiry itself — and only
29
+ # to a caller holding the confirmation token, never to the signed-in
30
+ # account, because the export covers guest orders placed at the address
31
+ # the request names.
32
+ attribute :download_url do |data_request|
33
+ next nil unless params[:download_url_visible]
30
34
  next nil unless data_request.downloadable?
31
35
 
32
- host = (params&.dig(:store) || data_request.store)&.formatted_url
36
+ host = (params[:store] || data_request.store)&.formatted_url
33
37
  next nil if host.blank?
34
38
 
35
39
  Spree::Api::DataRequestUrls.download_url(data_request, host)
@@ -10,7 +10,7 @@ module Spree
10
10
  carrier: [:string, nullable: true],
11
11
  carrier_name: [:string, nullable: true],
12
12
  service: [:string, nullable: true],
13
- status: [:string, enum: Spree::Delivery::STATUSES],
13
+ status: [:string, enum: Spree::Delivery::STATUSES, enum_type_name: 'DeliveryStatus'],
14
14
  estimated_delivery_at: [:string, nullable: true],
15
15
  delivered_at: [:string, nullable: true]
16
16
 
@@ -2,7 +2,7 @@ module Spree
2
2
  module Api
3
3
  module V3
4
4
  class DeliveryZoneMemberSerializer < BaseSerializer
5
- typelize member_type: [:string, enum: Spree::DeliveryZoneMember::MEMBER_TYPES], country_code: [:string, nullable: true, enum: Spree::IsoData.country_codes, enum_type_name: 'CountryCode'],
5
+ typelize member_type: [:string, enum: Spree::DeliveryZoneMember::MEMBER_TYPES, enum_type_name: 'DeliveryZoneMemberType'], country_code: [:string, nullable: true, enum: Spree::IsoData.country_codes, enum_type_name: 'CountryCode'],
6
6
  country_name: [:string, nullable: true],
7
7
  state_code: [:string, nullable: true], state_name: [:string, nullable: true],
8
8
  postal_code_prefix: [:string, nullable: true],
@@ -5,7 +5,7 @@ module Spree
5
5
  # line item or fulfillment. The embedded `discounts` key on Cart/Order
6
6
  # stays the applied-promotion summary — see AppliedPromotionSerializer.
7
7
  class DiscountSerializer < BaseSerializer
8
- typelize label: :string, kind: [:string, enum: Spree::Discount::KINDS], code: [:string, nullable: true],
8
+ typelize label: :string, kind: [:string, enum: Spree::Discount::KINDS, enum_type_name: 'DiscountKind'], code: [:string, nullable: true],
9
9
  value: [:string, nullable: true], value_type: [:string, nullable: true],
10
10
  promotion_id: [:string, nullable: true], line_item_id: [:string, nullable: true],
11
11
  fulfillment_id: [:string, nullable: true]
@@ -15,7 +15,7 @@ module Spree
15
15
  filename: :string,
16
16
  content_type: :string,
17
17
  byte_size: :number,
18
- visibility: [:string, enum: Spree::FileUpload::VISIBILITIES],
18
+ visibility: [:string, enum: Spree::FileUpload::VISIBILITIES, enum_type_name: 'FileUploadVisibility'],
19
19
  expires_at: :string,
20
20
  upload: [:FileUploadTarget, nullable: true]
21
21
 
@@ -4,7 +4,7 @@ module Spree
4
4
  class FulfillmentSerializer < BaseSerializer
5
5
  typelize number: :string,
6
6
  status: [:string, enum: Spree::Fulfillment.statuses, enum_type_name: 'FulfillmentStatus'],
7
- fulfillment_type: [:string, enum: %w[shipping digital pickup pickup_point]],
7
+ fulfillment_type: [:string, enum: %w[shipping digital pickup pickup_point], enum_type_name: 'FulfillmentType'],
8
8
  tracking: [:string, nullable: true], tracking_url: [:string, nullable: true],
9
9
  fulfilled_at: [:string, nullable: true], delivered_at: [:string, nullable: true], unpriced: :boolean,
10
10
  items: 'Array<{ item_id: string; variant_id: string; quantity: number }>',
@@ -7,7 +7,7 @@ module Spree
7
7
  # `type` is not exposed: the old Spree::Image/Spree::Video STI collapsed
8
8
  # into one class, so the column is a legacy vestige with no subclasses
9
9
  # — `media_type` is the discriminator (see MediaSerializer).
10
- typelize media_type: [:string, enum: Spree::Media::MEDIA_TYPES], viewable_type: :string,
10
+ typelize media_type: [:string, enum: Spree::Media::MEDIA_TYPES, enum_type_name: 'MediaType'], viewable_type: :string,
11
11
  viewable_id: :string, position: [:number, nullable: true],
12
12
  alt: [:string, nullable: true]
13
13
 
@@ -5,7 +5,7 @@ module Spree
5
5
  typelize position: :number, alt: [:string, nullable: true],
6
6
  product_id: [:string, nullable: true],
7
7
  variant_ids: [:string, multi: true],
8
- media_type: [:string, enum: Spree::Media::MEDIA_TYPES],
8
+ media_type: [:string, enum: Spree::Media::MEDIA_TYPES, enum_type_name: 'MediaType'],
9
9
  focal_point_x: [:number, nullable: true],
10
10
  focal_point_y: [:number, nullable: true],
11
11
  external_video_url: [:string, nullable: true],
@@ -2,7 +2,7 @@ module Spree
2
2
  module Api
3
3
  module V3
4
4
  class OptionTypeSerializer < BaseSerializer
5
- typelize name: :string, label: :string, position: :number, kind: [:string, enum: Spree::OptionType::KINDS]
5
+ typelize name: :string, label: :string, position: :number, kind: [:string, enum: Spree::OptionType::KINDS, enum_type_name: 'OptionTypeKind']
6
6
 
7
7
  attributes :name, :label, :position, :kind
8
8
  end
@@ -9,8 +9,8 @@ module Spree
9
9
  # inside it, each carrying its own items, delivery and tracking.
10
10
  class OrderGroupSerializer < BaseSerializer
11
11
  typelize number: :string, email: [:string, nullable: true], currency: [:string, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'],
12
- fulfillment_status: [:string, nullable: true, enum: Spree::Order::FULFILLMENT_STATUSES],
13
- payment_status: [:string, nullable: true, enum: Spree::Order::PAYMENT_STATUSES],
12
+ fulfillment_status: [:string, nullable: true, enum: Spree::Order::FULFILLMENT_STATUSES, enum_type_name: 'OrderFulfillmentStatus'],
13
+ payment_status: [:string, nullable: true, enum: Spree::Order::PAYMENT_STATUSES, enum_type_name: 'OrderPaymentStatus'],
14
14
  completed_at: [:string, nullable: true],
15
15
  billing_address: { nullable: true }, shipping_address: { nullable: true }
16
16
 
@@ -11,10 +11,11 @@ module Spree
11
11
  po_document_filename: [:string, nullable: true], po_document_byte_size: ['number | null'],
12
12
  currency: [:string, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'], locale: [:string, nullable: true, enum: Spree::Locales::ALL, enum_type_name: 'LocaleCode'], total_quantity: :number,
13
13
  coupon_code: [:string, nullable: true],
14
- fulfillment_status: [:string, nullable: true, enum: Spree::Order::FULFILLMENT_STATUSES],
15
- payment_status: [:string, nullable: true, enum: Spree::Order::PAYMENT_STATUSES],
14
+ fulfillment_status: [:string, nullable: true, enum: Spree::Order::FULFILLMENT_STATUSES, enum_type_name: 'OrderFulfillmentStatus'],
15
+ payment_status: [:string, nullable: true, enum: Spree::Order::PAYMENT_STATUSES, enum_type_name: 'OrderPaymentStatus'],
16
16
  completed_at: [:string, nullable: true],
17
17
  withdrawal_period_ends_at: [:string, nullable: true], within_withdrawal_period: :boolean,
18
+ shipping_eq_billing_address: :boolean,
18
19
  billing_address: { nullable: true }, shipping_address: { nullable: true },
19
20
  gift_card: { nullable: true }, market: { nullable: true }
20
21
 
@@ -28,6 +29,7 @@ module Spree
28
29
  end
29
30
 
30
31
  attribute :within_withdrawal_period, &:within_withdrawal_period?
32
+ attribute :shipping_eq_billing_address, &:shipping_eq_billing_address?
31
33
 
32
34
  # The checkout handle this order was born from (nil for admin drafts).
33
35
  # Lets abandonment tooling match cart.* events to the conversion.
@@ -4,7 +4,7 @@ module Spree
4
4
  class PaymentSerializer < BaseSerializer
5
5
  typelize status: [:string, enum: Spree::Payment.statuses, enum_type_name: 'PaymentStatus'],
6
6
  payment_method_id: :string, response_code: [:string, nullable: true], number: :string,
7
- source_type: [:string, nullable: true, enum: %w[credit_card store_credit payment_source]],
7
+ source_type: [:string, nullable: true, enum: %w[credit_card store_credit payment_source], enum_type_name: 'PaymentSourceType'],
8
8
  source_id: [:string, nullable: true], source: 'CreditCard | StoreCredit | PaymentSource | null'
9
9
 
10
10
  prefixed_id_attributes :payment_method
@@ -2,7 +2,7 @@ module Spree
2
2
  module Api
3
3
  module V3
4
4
  class ProductFilterAvailabilityOptionSerializer < BaseSerializer
5
- typelize id: [:string, enum: %w[in_stock out_of_stock]], count: :number
5
+ typelize id: [:string, enum: %w[in_stock out_of_stock], enum_type_name: 'StockAvailability'], count: :number
6
6
 
7
7
  attributes :id, :count
8
8
  end
@@ -6,7 +6,7 @@ module Spree
6
6
  type: "'option'",
7
7
  name: :string,
8
8
  label: :string,
9
- kind: [:string, enum: Spree::OptionType::KINDS],
9
+ kind: [:string, enum: Spree::OptionType::KINDS, enum_type_name: 'OptionTypeKind'],
10
10
  options: [:ProductFilterOptionValue, multi: true]
11
11
 
12
12
  attributes :id, :type, :name, :label, :kind
@@ -3,8 +3,9 @@ module Spree
3
3
  module V3
4
4
  module Seller
5
5
  class AddressSerializer < V3::AddressSerializer
6
- # The Store API keeps these deprecated names until 6.1.
7
- %i[state_abbr country_iso].each { |key| _attributes.delete(key) }
6
+ # The Store API keeps these deprecated names until 6.1. A seller
7
+ # keeps no address book of the buyer's, so has no owner to read.
8
+ %i[state_abbr country_iso owner].each { |key| _attributes.delete(key) }
8
9
  end
9
10
  end
10
11
  end
@@ -23,9 +23,9 @@ module Spree
23
23
  class OrderSerializer < V3::BaseSerializer
24
24
  typelize number: :string, customer_note: [:string, nullable: true], currency: [:string, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'],
25
25
  total_quantity: :number,
26
- fulfillment_status: [:string, nullable: true, enum: Spree::Order::FULFILLMENT_STATUSES],
27
- payment_status: [:string, nullable: true, enum: Spree::Order::PAYMENT_STATUSES],
28
- status: [:string, enum: Spree::Order::STATUSES], canceled_at: [:string, nullable: true],
26
+ fulfillment_status: [:string, nullable: true, enum: Spree::Order::FULFILLMENT_STATUSES, enum_type_name: 'OrderFulfillmentStatus'],
27
+ payment_status: [:string, nullable: true, enum: Spree::Order::PAYMENT_STATUSES, enum_type_name: 'OrderPaymentStatus'],
28
+ status: [:string, enum: Spree::Order::STATUSES, enum_type_name: 'OrderStatus'], canceled_at: [:string, nullable: true],
29
29
  cancel_reason_name: [:string, nullable: true], cancel_note: [:string, nullable: true],
30
30
  internal_note: [:string, nullable: true], internal_note_html: [:string, nullable: true]
31
31