zendesk_apps_support 4.44.0.alpha.1 → 4.44.0.alpha.2

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: b611098add00d4e6f1c03e6604521db85f49bd6beea30a43695a286c0d474122
4
- data.tar.gz: 40e1ade02e50ac1980eeda60def6501368499e48f46c6180f5e5e7f0053564e2
3
+ metadata.gz: a2d6e7a936e79ffd9af267e73b5a4013415b4b5c1db85ce326758913a20d5ef2
4
+ data.tar.gz: 2e4204dcd26518cff3ea848aaa52b5897f074366a073becfba928ee5ee5a696e
5
5
  SHA512:
6
- metadata.gz: 7052e5b47f7b72d52073f25e39291ef32b0373d850b4912d1f82b05a7463188e328452823471bde20ffa537d1bb47ffb53a5ad50713343114423352d3a0861d8
7
- data.tar.gz: 8010184c5735b90149c78a3f75ba4d29a08e90f5d4ed0eebda6f94f16763ceeb08328671ef273355492f53a9b931802a253b0be0879fa4969f00c6beddc36ec6
6
+ metadata.gz: e107a2a670cd16d81056520bdf7907962748ca232234a6fbad84e5b5e454b26b9658c867b952068271b464294bef2918d4cd4eb8c0a5b5770b146da6315dc937
7
+ data.tar.gz: 830b07edfba8c165e437e9ace71c797905cf169ebe53c2fd034b2af98aa88cde5be420e44585f21d33826c02160563bc79dd6a610b0c1e4ec333cd884d9ef066
@@ -7,6 +7,9 @@ module ZendeskAppsSupport
7
7
  CUSTOM_OBJECTS_TYPE_KEY = 'custom_object_types'
8
8
  CUSTOM_OBJECTS_RELATIONSHIP_TYPE_KEY = 'custom_object_relationship_types'
9
9
  CUSTOM_OBJECTS_V2_KEY = 'custom_objects_v2'
10
+ CUSTOM_OBJECTS_V2_OBJECTS_KEY = 'objects'
11
+ CUSTOM_OBJECTS_V2_OBJECT_FIELDS_KEY = 'object_fields'
12
+ CUSTOM_OBJECT_V2_OBJECT_TRIGGERS_KEY = 'object_triggers'
10
13
  TYPES = %w[automations channel_integrations custom_objects macros targets views ticket_fields
11
14
  triggers user_fields organization_fields webhooks custom_objects_v2].freeze
12
15
  end
@@ -31,7 +31,8 @@ module ZendeskAppsSupport
31
31
  @warnings = []
32
32
  end
33
33
 
34
- def validate(marketplace: true, skip_marketplace_translations: false, error_on_password_parameter: false)
34
+ def validate(marketplace: true, skip_marketplace_translations: false, error_on_password_parameter: false,
35
+ validate_custom_objects_v2: false)
35
36
  errors = []
36
37
  errors << Validations::Manifest.call(self, error_on_password_parameter: error_on_password_parameter)
37
38
 
@@ -39,7 +40,7 @@ module ZendeskAppsSupport
39
40
  errors << Validations::Marketplace.call(self) if marketplace
40
41
  errors << Validations::Source.call(self)
41
42
  errors << Validations::Translations.call(self, skip_marketplace_translations: skip_marketplace_translations)
42
- errors << Validations::Requirements.call(self)
43
+ errors << Validations::Requirements.call(self, validate_custom_objects_v2:)
43
44
 
44
45
  # only adds warnings
45
46
  Validations::SecureSettings.call(self)
@@ -61,9 +62,14 @@ module ZendeskAppsSupport
61
62
  errors.flatten.compact
62
63
  end
63
64
 
64
- def validate!(marketplace: true, skip_marketplace_translations: false, error_on_password_parameter: false)
65
- errors = validate(marketplace: marketplace, skip_marketplace_translations: skip_marketplace_translations, error_on_password_parameter: error_on_password_parameter)
65
+ def validate!(marketplace: true, skip_marketplace_translations: false, error_on_password_parameter: false,
66
+ validate_custom_objects_v2: false)
67
+ errors = validate(marketplace: marketplace,
68
+ skip_marketplace_translations: skip_marketplace_translations,
69
+ error_on_password_parameter: error_on_password_parameter,
70
+ validate_custom_objects_v2:)
66
71
  raise errors.first if errors.any?
72
+
67
73
  true
68
74
  end
69
75
 
@@ -47,6 +47,11 @@ module ZendeskAppsSupport
47
47
  UNDEFINED_VALUE = '(undefined)'
48
48
  CONDITION_KEYS = [ALL, ANY].freeze
49
49
  MAX_PAYLOAD_SIZE_BYTES = 1_048_576 # 1 MB in bytes
50
+
51
+ REFERENCE_VALIDATION_CONFIG = {
52
+ SCHEMA_KEYS[:object_fields] => { identifier: KEY, error: :invalid_cov2_object_reference_in_fields },
53
+ SCHEMA_KEYS[:object_triggers] => { identifier: TITLE, error: :invalid_cov2_object_reference_in_triggers }
54
+ }.freeze
50
55
  end
51
56
  end
52
57
  end
@@ -10,18 +10,23 @@ module ZendeskAppsSupport
10
10
  module CustomObjectsV2
11
11
  class << self
12
12
  include Constants
13
+ include ValidationHelpers
13
14
 
14
15
  def call(requirements)
15
- errors = validate_overall_requirements_structure(requirements)
16
- return errors if errors.any?
16
+ structural_errors = validate_overall_requirements_structure(requirements)
17
+ return structural_errors if structural_errors.any?
17
18
 
18
19
  payload_size_errors = validate_payload_size(requirements)
19
20
  return payload_size_errors if payload_size_errors.any?
20
21
 
21
- [
22
+ limits_and_schema_errors = [
22
23
  validate_limits(requirements),
23
24
  validate_schema(requirements)
24
25
  ].flatten
26
+
27
+ return limits_and_schema_errors if limits_and_schema_errors.any?
28
+
29
+ validate_object_references(requirements)
25
30
  end
26
31
 
27
32
  private
@@ -67,6 +72,27 @@ module ZendeskAppsSupport
67
72
  SchemaValidator.validate(requirements)
68
73
  end
69
74
 
75
+ def validate_object_references(requirements)
76
+ valid_object_keys = extract_valid_object_keys(requirements[SCHEMA_KEYS[:objects]])
77
+
78
+ REFERENCE_VALIDATION_CONFIG.flat_map do |collection_type, config|
79
+ collection = requirements[collection_type]
80
+ validate_collection_references(collection, valid_object_keys, config[:error], config[:identifier])
81
+ end
82
+ end
83
+
84
+ def validate_collection_references(collection, valid_object_keys, error, identifier)
85
+ valid_collection = extract_hash_entries(collection)
86
+ valid_collection.filter_map do |item|
87
+ object_key = item[OBJECT_KEY]
88
+ next if valid_object_keys.include?(object_key)
89
+
90
+ ValidationError.new(error,
91
+ item_identifier: safe_value(item[identifier]),
92
+ object_key: object_key)
93
+ end
94
+ end
95
+
70
96
  def validate_collection_is_array(collection, error_type)
71
97
  return [] if collection.nil? || collection.is_a?(Array)
72
98
 
@@ -78,6 +104,14 @@ module ZendeskAppsSupport
78
104
  collection.is_a?(Array) && collection.empty?
79
105
  end
80
106
  end
107
+
108
+ def extract_valid_object_keys(objects)
109
+ valid_objects = extract_hash_entries(objects)
110
+ valid_objects.filter_map do |obj|
111
+ key = obj[KEY]
112
+ key if key.is_a?(String) && !key.strip.empty?
113
+ end.uniq
114
+ end
81
115
  end
82
116
  end
83
117
  end
@@ -60,7 +60,7 @@ module ZendeskAppsSupport
60
60
  end
61
61
 
62
62
  def validate_trigger_schema(trigger)
63
- required_keys = %w[object_key title actions conditions]
63
+ required_keys = %w[key object_key title actions conditions]
64
64
  missing_keys = required_keys - trigger.keys
65
65
  trigger_title = safe_value(trigger[TITLE])
66
66
  object_key = safe_value(trigger[OBJECT_KEY])
@@ -103,10 +103,6 @@ module ZendeskAppsSupport
103
103
  [ValidationError.new(:empty_cov2_trigger_actions, **error_data)]
104
104
  end
105
105
 
106
- def safe_value(value)
107
- value || UNDEFINED_VALUE
108
- end
109
-
110
106
  def valid_conditions_structure?(conditions)
111
107
  return false unless conditions.is_a?(Hash) && conditions.any?
112
108
  return false if (conditions.keys - CONDITION_KEYS).any?
@@ -4,6 +4,8 @@ module ZendeskAppsSupport
4
4
  module Validations
5
5
  module CustomObjectsV2
6
6
  module ValidationHelpers
7
+ include Constants
8
+
7
9
  private
8
10
 
9
11
  def extract_hash_entries(collection)
@@ -17,6 +19,10 @@ module ZendeskAppsSupport
17
19
 
18
20
  Constants::CONDITION_KEYS.sum { |key| conditions[key]&.size || 0 }
19
21
  end
22
+
23
+ def safe_value(value)
24
+ value || UNDEFINED_VALUE
25
+ end
20
26
  end
21
27
  end
22
28
  end
@@ -7,7 +7,7 @@ module ZendeskAppsSupport
7
7
  MAX_CUSTOM_OBJECTS_REQUIREMENTS = 50
8
8
 
9
9
  class << self
10
- def call(package)
10
+ def call(package, validate_custom_objects_v2: false)
11
11
  if package.manifest.requirements_only? && !package.has_requirements?
12
12
  return [ValidationError.new(:missing_requirements)]
13
13
  elsif !supports_requirements(package) && package.has_requirements?
@@ -31,7 +31,7 @@ module ZendeskAppsSupport
31
31
  errors << invalid_custom_objects(requirements)
32
32
  errors << invalid_webhooks(requirements)
33
33
  errors << invalid_target_types(requirements)
34
- errors << validate_custom_objects_v2_requirements(requirements)
34
+ errors << validate_custom_objects_v2_requirements(requirements, validate_custom_objects_v2:)
35
35
  errors << missing_required_fields(requirements)
36
36
  errors.flatten!
37
37
  errors.compact!
@@ -80,8 +80,8 @@ module ZendeskAppsSupport
80
80
  end
81
81
  end
82
82
 
83
- def validate_custom_objects_v2_requirements(requirements)
84
- return unless requirements.key?(AppRequirement::CUSTOM_OBJECTS_V2_KEY)
83
+ def validate_custom_objects_v2_requirements(requirements, validate_custom_objects_v2: false)
84
+ return unless validate_custom_objects_v2 && requirements.key?(AppRequirement::CUSTOM_OBJECTS_V2_KEY)
85
85
 
86
86
  cov2_requirements = requirements[AppRequirement::CUSTOM_OBJECTS_V2_KEY]
87
87
  CustomObjectsV2.call(cov2_requirements)
@@ -1,3 +1,3 @@
1
1
  module ZendeskAppsSupport
2
- VERSION = "4.44.0.alpha.1"
2
+ VERSION = '4.44.0.alpha.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zendesk_apps_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.44.0.alpha.1
4
+ version: 4.44.0.alpha.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James A. Rosen
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2025-09-19 00:00:00.000000000 Z
14
+ date: 2025-10-01 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: i18n