zendesk_apps_support 1.13.2 → 1.13.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58ceec0aaae39626d6beea11fec546292b8bc189
|
4
|
+
data.tar.gz: ab381ae71f046c859a30f4d69ab4a7461dfbdb9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c17c0fc787ef6e3031f6b5328b1604ce5e1fd564ad175add7289e099560bde444516d3283bb87e58be3fe67cbb3795873d3de2998b565b5facc17e931e98ecf1
|
7
|
+
data.tar.gz: 493cd4ff0ed9a17cfd625d905e77fff4a86baa98772fc70f0baaabc9a5930d539f1ecd2911d69b3648f26937038af94aeb8a274533653b146e2017330772a289
|
data/config/locales/en.yml
CHANGED
@@ -18,6 +18,12 @@ en:
|
|
18
18
|
one: 'Missing required field in manifest: %{missing_keys}'
|
19
19
|
other: 'Missing required fields in manifest: %{missing_keys}'
|
20
20
|
requirements_not_json: requirements.json is not proper JSON. %{errors}
|
21
|
+
duplicate_requirements:
|
22
|
+
one: 'requirements.json contains a duplicate key: %{duplicate_keys}'
|
23
|
+
other: 'requirements.json contains duplicate keys: %{duplicate_keys}'
|
24
|
+
invalid_requirements_types:
|
25
|
+
one: 'requirements.json contains an invalid type: %{invalid_types}'
|
26
|
+
other: 'requirements.json contains invalid types: %{invalid_types}'
|
21
27
|
oauth_keys:
|
22
28
|
missing:
|
23
29
|
one: 'Missing required oauth field in manifest: %{missing_keys}'
|
@@ -44,6 +44,22 @@ parts:
|
|
44
44
|
key: "txt.apps.admin.error.app_build.requirements_not_json"
|
45
45
|
title: "App builder job: requirements file is invalid JSON error"
|
46
46
|
value: "requirements.json is not proper JSON. %{errors}"
|
47
|
+
- translation:
|
48
|
+
key: "txt.apps.admin.error.app_build.duplicate_requirements.one"
|
49
|
+
title: "App builder job: requirements file contains duplicate key error"
|
50
|
+
value: "requirements.json contains a duplicate key: %{duplicate_keys}"
|
51
|
+
- translation:
|
52
|
+
key: "txt.apps.admin.error.app_build.duplicate_requirements.other"
|
53
|
+
title: "App builder job: requirements file contains duplicate keys error"
|
54
|
+
value: "requirements.json contains duplicate keys: %{duplicate_keys}"
|
55
|
+
- translation:
|
56
|
+
key: "txt.apps.admin.error.app_build.invalid_requirements_types.one"
|
57
|
+
title: "App builder job: requirements file contains invalid type error"
|
58
|
+
value: "requirements.json contains an invalid type: %{invalid_types}"
|
59
|
+
- translation:
|
60
|
+
key: "txt.apps.admin.error.app_build.invalid_requirements_types.other"
|
61
|
+
title: "App builder job: requirements file contains invalid types error"
|
62
|
+
value: "requirements.json contains invalid types: %{invalid_types}"
|
47
63
|
- translation:
|
48
64
|
key: "txt.apps.admin.error.app_build.oauth_keys.missing.one"
|
49
65
|
title: "App builder job: missing oauth fields error"
|
@@ -1,29 +1,55 @@
|
|
1
1
|
require 'multi_json'
|
2
|
+
require 'json/stream'
|
3
|
+
require 'pp'
|
2
4
|
|
3
5
|
module ZendeskAppsSupport
|
4
6
|
module Validations
|
5
7
|
module Requirements
|
6
8
|
|
9
|
+
REQUIREMENTS_TYPES = %w(automations macros targets ticket_fields triggers user_fields).freeze
|
10
|
+
|
7
11
|
class <<self
|
8
12
|
def call(package)
|
9
|
-
|
13
|
+
requirements_file = package.files.find { |f| f.relative_path == 'requirements.json' }
|
10
14
|
|
11
|
-
|
15
|
+
return [ValidationError.new(:missing_requirements)] unless requirements_file
|
12
16
|
|
13
|
-
|
14
|
-
|
17
|
+
requirements_stream = requirements_file.read
|
18
|
+
duplicates = non_unique_type_keys(requirements_stream)
|
19
|
+
unless duplicates.empty?
|
20
|
+
return [ValidationError.new(:duplicate_requirements, :duplicate_keys => duplicates.join(', '), :count => duplicates.length)]
|
15
21
|
end
|
16
22
|
|
17
|
-
|
23
|
+
requirements = MultiJson.load(requirements_stream)
|
24
|
+
[].tap do |errors|
|
25
|
+
errors << invalid_requirements_types(requirements)
|
26
|
+
errors.compact!
|
27
|
+
end
|
28
|
+
rescue MultiJson::DecodeError => e
|
29
|
+
return [ValidationError.new(:requirements_not_json, :errors => e)]
|
18
30
|
end
|
19
31
|
|
20
32
|
private
|
21
33
|
|
22
|
-
def
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
34
|
+
def invalid_requirements_types(requirements)
|
35
|
+
invalid_types = requirements.keys - REQUIREMENTS_TYPES
|
36
|
+
|
37
|
+
unless invalid_types.empty?
|
38
|
+
ValidationError.new(:invalid_requirements_types, :invalid_types => invalid_types.join(', '), :count => invalid_types.length)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def non_unique_type_keys(requirements)
|
43
|
+
keys = []
|
44
|
+
duplicates = []
|
45
|
+
parser = JSON::Stream::Parser.new do
|
46
|
+
start_object { keys.push({}) }
|
47
|
+
end_object { keys.pop }
|
48
|
+
key { |k| duplicates.push(k) if keys.last.include? k; keys.last[k] = nil }
|
49
|
+
end
|
50
|
+
parser << requirements
|
51
|
+
|
52
|
+
duplicates
|
27
53
|
end
|
28
54
|
|
29
55
|
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: 1.13.
|
4
|
+
version: 1.13.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: 2014-02-
|
14
|
+
date: 2014-02-17 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: i18n
|
@@ -69,6 +69,20 @@ dependencies:
|
|
69
69
|
- - '>='
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: '0'
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: json-stream
|
74
|
+
requirement: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
type: :runtime
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
72
86
|
- !ruby/object:Gem::Dependency
|
73
87
|
name: erubis
|
74
88
|
requirement: !ruby/object:Gem::Requirement
|