easol-canvas 4.17.0 → 4.20.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2396c564e638650f1f50b0f81e6b79bc9cc3020304f559f1b050034721056d58
4
- data.tar.gz: ebfb662861d72d0e7c9777343ee8aee6330f348dc132575d4ca4081c0f7249d4
3
+ metadata.gz: fa515bf37be7d80d67de3a67e92d6097e17d7298fc436a916acf0ca04687d78c
4
+ data.tar.gz: bbc64745d8df45188a081795995e0c92fc86b99f53beef20a69b72741657dd91
5
5
  SHA512:
6
- metadata.gz: a64ab47a1802570ed45ff6a524cd1648a9025b7082a290814049aaec927c363a952299d4e15a311b826735301d95c79cfcb036ff5a1c1cf635f5a989d99e878e
7
- data.tar.gz: 365bb2ee7c14ff920f6a15558a01c25cc492814616299ab8159f88a9effd36f645a92566e4a5ad0f10ddf0ff3a4880c56c198e251906f47775bced5a13614b9f
6
+ metadata.gz: c91c9b333de32d036428dd9bd0c88840e57ea37c3509bb266440ffa6df89fd50d7161edf155ea40f4e22898a0ff1e0a55e0c9900f03fc67a33e0eebf3dbaed19
7
+ data.tar.gz: 2a8d559a57048b770104a5a3faf5536539c081571f37f44717b2850bd4f9ab7e2975f897f87da1b34014e42d5de7ed11712a9ba90b062a8cb6b3cd6676dafd98
@@ -6,9 +6,11 @@ module Canvas
6
6
  # custom types that are defined in the /types directory.
7
7
  class ValidCustomTypesCheck < Check
8
8
  def run
9
+ custom_types = Canvas::FetchCustomTypes.call
10
+
9
11
  custom_type_files.each do |filename|
10
12
  schema = extract_json(filename)
11
- validator = Validator::CustomType.new(schema: schema)
13
+ validator = Validator::CustomType.new(schema: schema, custom_types: custom_types)
12
14
 
13
15
  next if validator.validate
14
16
 
@@ -30,27 +30,30 @@ module Canvas
30
30
  ::Liquid::Template.register_tag(name, klass)
31
31
  end
32
32
 
33
- # These are the tags that we define in the Rails app. If we add a new custom tag
34
- # in the Rails app, we'll need to register it here.
33
+ # These are the tags that we define in the Rails app. If we add a
34
+ # new custom tag in the Rails app, we'll need to register it here.
35
35
  def register_tags!
36
- register_tag("form", ::Liquid::Block)
37
- register_tag("product_search", ::Liquid::Block)
38
- register_tag("easol_badge", ::Liquid::Tag)
39
- register_tag("accommodation_availability", ::Liquid::Block)
40
- register_tag("cache", ::Liquid::Block)
41
- register_tag("currency_switcher", ::Liquid::Tag)
42
- register_tag("json", ::Liquid::Block)
43
- register_tag("variant_pricing", ::Liquid::Tag)
44
- register_tag("dynamic_package_booking_price", ::Liquid::Tag)
36
+ # Single statement non-block tags, no closing tag required.
45
37
  register_tag("cart_timer", ::Liquid::Tag)
46
38
  register_tag("cart_timer_add_time", ::Liquid::Tag)
47
- register_tag("experience_slot_search", ::Liquid::Block)
48
- register_tag("experience_slot_calendar", ::Liquid::Block)
49
- register_tag("package_availability", Liquid::Block)
50
- register_tag("package_price", Liquid::Block)
39
+ register_tag("currency_switcher", ::Liquid::Tag)
40
+ register_tag("dynamic_package_booking_price", ::Liquid::Tag)
41
+ register_tag("easol_badge", ::Liquid::Tag)
51
42
  register_tag("input", ::Liquid::Tag)
52
43
  register_tag("label", ::Liquid::Tag)
44
+ register_tag("variant_pricing", ::Liquid::Tag)
45
+ # Tags wrapping nested content with a closing tag.
46
+ register_tag("accommodation_availability", ::Liquid::Block)
47
+ register_tag("cache", ::Liquid::Block)
48
+ register_tag("experience_slot_calendar", ::Liquid::Block)
49
+ register_tag("experience_slot_search", ::Liquid::Block)
50
+ register_tag("form", ::Liquid::Block)
51
+ register_tag("json", ::Liquid::Block)
52
+ register_tag("package_availability", ::Liquid::Block)
53
+ register_tag("package_price", ::Liquid::Block)
53
54
  register_tag("package_step_product_search", ::Liquid::Block)
55
+ register_tag("packages_search_and_calendar", ::Liquid::Block)
56
+ register_tag("product_search", ::Liquid::Block)
54
57
  end
55
58
  end
56
59
  end
@@ -16,6 +16,7 @@ module Canvas
16
16
  color
17
17
  image
18
18
  link
19
+ modifier
19
20
  number
20
21
  page
21
22
  post
@@ -26,10 +26,11 @@ module Canvas
26
26
  class CustomType
27
27
  REQUIRED_KEYS = %w[key name attributes].freeze
28
28
 
29
- attr_reader :schema, :errors
29
+ attr_reader :schema, :errors, :custom_types
30
30
 
31
- def initialize(schema:)
31
+ def initialize(schema:, custom_types: [])
32
32
  @schema = schema
33
+ @custom_types = custom_types
33
34
  @errors = []
34
35
  end
35
36
 
@@ -127,7 +128,7 @@ module Canvas
127
128
  schema["attributes"].each do |attribute_schema|
128
129
  attr_validator = Validator::SchemaAttribute.new(
129
130
  attribute: attribute_schema,
130
- custom_types: []
131
+ custom_types: custom_types
131
132
  )
132
133
  next if attr_validator.validate
133
134
 
@@ -20,6 +20,7 @@ module Canvas
20
20
  class SchemaAttribute
21
21
  VALIDATORS = {
22
22
  "image" => SchemaAttribute::Image,
23
+ "modifier" => SchemaAttribute::Modifier,
23
24
  "product" => SchemaAttribute::Product,
24
25
  "post" => SchemaAttribute::Post,
25
26
  "page" => SchemaAttribute::Page,
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Canvas
4
+ module Validator
5
+ class SchemaAttribute
6
+ # :documented:
7
+ # Attribute validations specific to modifier-type variables.
8
+ # Modifier drops expose name and id properties for use in site builder schemas.
9
+ class Modifier < Base
10
+ ALLOWED_DEFAULT_VALUES = %w[random].freeze
11
+
12
+ def validate
13
+ super &&
14
+ ensure_default_values_are_valid
15
+ end
16
+
17
+ private
18
+
19
+ def permitted_values_for_default_key
20
+ if attribute["array"]
21
+ Array
22
+ else
23
+ String
24
+ end
25
+ end
26
+
27
+ def ensure_default_values_are_valid
28
+ return true unless attribute.key?("default")
29
+
30
+ if attribute["array"]
31
+ attribute["default"].all? { |value| default_value_is_valid?(value) }
32
+ else
33
+ default_value_is_valid?(attribute["default"])
34
+ end
35
+ end
36
+
37
+ def default_value_is_valid?(value)
38
+ value = value.downcase
39
+ if !ALLOWED_DEFAULT_VALUES.include?(value)
40
+ @errors << %["default" for modifier-type variables must be one of: #{ALLOWED_DEFAULT_VALUES.join(', ')}]
41
+ false
42
+ else
43
+ true
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Canvas
4
- VERSION = "4.17.0"
4
+ VERSION = "4.20.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easol-canvas
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.17.0
4
+ version: 4.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Byrne
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2025-04-25 00:00:00.000000000 Z
12
+ date: 2026-01-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -145,6 +145,7 @@ files:
145
145
  - lib/canvas/validators/schema_attributes/experience_slot.rb
146
146
  - lib/canvas/validators/schema_attributes/image.rb
147
147
  - lib/canvas/validators/schema_attributes/link.rb
148
+ - lib/canvas/validators/schema_attributes/modifier.rb
148
149
  - lib/canvas/validators/schema_attributes/number.rb
149
150
  - lib/canvas/validators/schema_attributes/package.rb
150
151
  - lib/canvas/validators/schema_attributes/page.rb