zendesk_apps_support 4.44.0.alpha.1 → 4.44.0.alpha.3

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: fe37253e337a257e36a42c6006453c38496c17ef5841602349414a56cb7a1033
4
+ data.tar.gz: 79810be6dda1ddd34c9d5f1071f9daf27d19f827291f564fc36fc340f7d86f26
5
5
  SHA512:
6
- metadata.gz: 7052e5b47f7b72d52073f25e39291ef32b0373d850b4912d1f82b05a7463188e328452823471bde20ffa537d1bb47ffb53a5ad50713343114423352d3a0861d8
7
- data.tar.gz: 8010184c5735b90149c78a3f75ba4d29a08e90f5d4ed0eebda6f94f16763ceeb08328671ef273355492f53a9b931802a253b0be0879fa4969f00c6beddc36ec6
6
+ metadata.gz: 9da2e41badbb91b7f25eb7967bf1ef34148494a1f28f36992ea7c5fd793586490db4c3d967d7f2c5d758764150c5ed5eced1e9f589838133fa58e39aca9c0d66
7
+ data.tar.gz: bbc500a4a44f9fcb4a95245719d24de6bfa25227e33c12b6fbae5dac072bc2d0217cfe55d7ceb027bd006266217bb76690dd0f19d5feb4b2424139137d5d57fe
@@ -49,6 +49,89 @@ en:
49
49
  excessive_custom_objects_requirements: The requirements.json file contains
50
50
  too many custom objects requirements. The current limit is %{max} requirements.
51
51
  This app has %{count} requirements.
52
+ excessive_custom_objects_v2_requirements: The requirements.json file contains
53
+ too many custom objects v2 requirements. The current limit is %{max}
54
+ custom objects per account. This app has %{count} custom objects per
55
+ account.
56
+ excessive_custom_objects_v2_fields: The requirements.json file contains
57
+ too many custom object fields. The current limit is %{max} fields per
58
+ custom object. This app has %{count} fields for object %{object_key}.
59
+ excessive_custom_objects_v2_triggers: The requirements.json file contains
60
+ too many custom object triggers. The current limit is %{max} triggers
61
+ per custom object. This app has %{count} triggers for object %{object_key}.
62
+ excessive_custom_objects_v2_trigger_conditions: The requirements.json
63
+ file contains too many custom object trigger conditions. The current
64
+ limit is %{max} conditions per trigger. This app has %{count} conditions
65
+ for trigger %{trigger_title}.
66
+ excessive_custom_objects_v2_trigger_actions: The requirements.json file
67
+ contains too many custom object trigger actions. The current limit is
68
+ %{max} actions per trigger. This app has %{count} actions for trigger
69
+ %{trigger_title}.
70
+ excessive_cov2_dropdown_fields_per_object: The requirements.json file
71
+ contains too many custom object fields of type dropdown. The current
72
+ limit is %{max} fields per object. This app has %{count} fields of type
73
+ dropdown for object %{object_key}.
74
+ excessive_cov2_multiselect_fields_per_object: The requirements.json file
75
+ contains too many custom object fields of type multiselect. The current
76
+ limit is %{max} fields per object. This app has %{count} fields of type
77
+ multiselect for object %{object_key}.
78
+ excessive_cov2_field_options: The requirements.json file contains too
79
+ many options for custom object field %{field_key}. The current limit
80
+ is %{max} options per field. This app has %{count} options for field
81
+ %{field_key} in object %{object_key}.
82
+ excessive_cov2_relationship_filter_conditions: The requirements.json file
83
+ contains too many conditions in relationship filter for custom object
84
+ field %{field_key}. The current limit is %{max} conditions per field.
85
+ This app has %{count} conditions for field %{field_key} in object %{object_key}.
86
+ missing_cov2_object_schema_key: 'The requirements.json file is missing
87
+ custom object schema key for object %{object_key}. The following key
88
+ is required: %{missing_key}.'
89
+ missing_cov2_field_schema_key: 'The requirements.json file is missing
90
+ custom object field schema key for field %{field_key} in object %{object_key}.
91
+ The following key is required: %{missing_key}.'
92
+ missing_cov2_trigger_schema_key: 'The requirements.json file is missing
93
+ custom object trigger schema key for trigger %{trigger_title} in object
94
+ %{object_key}. The following key is required: %{missing_key}.'
95
+ empty_cov2_trigger_conditions: The requirements.json file contains an
96
+ empty conditions array for custom object trigger %{trigger_title} in
97
+ object %{object_key}.
98
+ invalid_cov2_requirements_structure: The requirements.json file contains
99
+ an invalid custom_objects_v2 structure. \"custom_objects_v2\" requirements
100
+ must be an object.
101
+ excessive_cov2_payload_size: The requirements.json file contains a custom
102
+ objects v2 payload that is too large. The maximum allowed size is 1
103
+ MB.
104
+ invalid_cov2_trigger_conditions_structure: The requirements.json file
105
+ contains an invalid custom object trigger conditions structure. Conditions
106
+ must be a hash with "all" and "any" arrays for trigger %{trigger_title}.
107
+ invalid_cov2_trigger_actions_structure: The requirements.json file contains
108
+ an invalid custom object trigger actions structure. \"actions\" must
109
+ be an array for trigger %{trigger_title}.
110
+ empty_cov2_trigger_actions: The requirements.json file contains empty
111
+ custom object trigger actions. At least one action must be specified
112
+ for trigger %{trigger_title}.
113
+ excessive_cov2_selection_fields_per_object: The requirements.json file
114
+ contains too many custom object fields of type %{field_type}. The current
115
+ limit is %{max} fields per object. This app has %{count} fields of type
116
+ %{field_type} for object %{object_key}.
117
+ invalid_objects_structure_in_cov2_requirements: The requirements.json
118
+ file contains an invalid objects structure. \"objects\" must be an array.
119
+ invalid_object_fields_structure_in_cov2_requirements: The requirements.json
120
+ file contains an invalid object_fields structure. \"object_fields\"
121
+ must be an array.
122
+ invalid_object_triggers_structure_in_cov2_requirements: The requirements.json
123
+ file contains an invalid object_triggers structure. \"object_triggers\"
124
+ must be an array.
125
+ empty_cov2_requirements: The requirements.json file contains empty custom
126
+ objects v2 requirements. You must define valid requirements.
127
+ invalid_cov2_object_reference_in_fields: The requirements.json file contains
128
+ an invalid object reference in object_fields. Field \"%{item_identifier}\"
129
+ references object \"%{object_key}\" which does not exist in the objects
130
+ array.
131
+ invalid_cov2_object_reference_in_triggers: The requirements.json file
132
+ contains an invalid object reference in object_triggers. Trigger \"%{item_identifier}\"
133
+ references object \"%{object_key}\" which does not exist in the objects
134
+ array.
52
135
  missing_required_fields: 'Missing required fields in requirements.json:
53
136
  "%{field}" is required in "%{identifier}"'
54
137
  duplicate_requirements:
@@ -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.3'
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.3
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-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: i18n