forest_admin_datasource_zendesk 1.30.2 → 1.30.4

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: ef8a3dea2e99838d420324d8e77fbf49e7deacf8ce2baa405e64bdfc589d06da
4
- data.tar.gz: 3a2e6250ee561c2a8340c30e773e7687b8e6485be425a1258d8b2a64dd271314
3
+ metadata.gz: 56d7779570984b30a375c7bedc606ec039d0d31276ef69b52beb010f37a0a365
4
+ data.tar.gz: f9de2c9d176da92da99d0235538cf3b07a980fd59a94d4a980f08e58a6e3a6ed
5
5
  SHA512:
6
- metadata.gz: 2b2a076b8ffedccbb6ca1933250211d88dd2eef1a0b6cc98608e4e3df9151e876344acaf2fbbe386fdc152472410a12e520707eb5b5f164b4c7677ce7a9cabac
7
- data.tar.gz: f26981c9b370ff053015f42e6e656b1110091cb18eb8af0975fe310faa4fbf56ee544e16cc26f28494671947546652a92d921e29f6f0da8c3c7a4dfab19a0b11
6
+ metadata.gz: 163575ce33bbcd0581e4d2cb8ffc0c8c2fba342a8695ada0256e20fc7a0d110627e0b35d9ef9089a7920524ca5bb115cc343a2a72a6248b6f1199d9b88b649a7
7
+ data.tar.gz: '094dc242cd1781c40b7d6a9fbed7274c39651930047b69fc4749754f11c9d7ffbe23b81f2520463939767036a16f077a04b7377d2fe0a2bd8d7b41cc5040138e'
@@ -95,6 +95,26 @@ module ForestAdminDatasourceZendesk
95
95
  [translated, filter.search].compact.reject(&:empty?).join(' ')
96
96
  end
97
97
 
98
+ # Adds custom fields, skipping any whose column name collides with a
99
+ # field already declared on the collection (native column or relation).
100
+ # Returns the list of fields actually added so callers can keep their
101
+ # serializer in sync with the schema.
102
+ def add_custom_fields(custom_fields)
103
+ custom_fields.reject do |cf|
104
+ column_name = cf[:column_name]
105
+ if schema[:fields].key?(column_name)
106
+ ForestAdminDatasourceZendesk.logger.warn(
107
+ "[forest_admin_datasource_zendesk] Custom field '#{column_name}' on collection " \
108
+ "'#{name}' conflicts with an existing field; skipping."
109
+ )
110
+ true
111
+ else
112
+ add_field(column_name, cf[:schema])
113
+ false
114
+ end
115
+ end
116
+ end
117
+
98
118
  private
99
119
 
100
120
  def sort_field_and_direction(entry)
@@ -3,6 +3,8 @@ module ForestAdminDatasourceZendesk
3
3
  class Organization < BaseCollection
4
4
  include Searchable
5
5
 
6
+ attr_reader :custom_fields
7
+
6
8
  OneToManySchema = ForestAdminDatasourceToolkit::Schema::Relations::OneToManySchema
7
9
 
8
10
  ZENDESK_SORTABLE = {
@@ -13,9 +15,9 @@ module ForestAdminDatasourceZendesk
13
15
 
14
16
  def initialize(datasource, custom_fields: [])
15
17
  super(datasource, 'ZendeskOrganization')
16
- @custom_fields = custom_fields
17
18
  define_schema
18
19
  define_relations
20
+ @custom_fields = add_custom_fields(custom_fields)
19
21
  enable_search
20
22
  enable_count
21
23
  end
@@ -79,8 +81,6 @@ module ForestAdminDatasourceZendesk
79
81
  is_read_only: true, is_sortable: true))
80
82
  add_field('updated_at', ColumnSchema.new(column_type: 'Date', filter_operators: DATE_OPS,
81
83
  is_read_only: true, is_sortable: true))
82
-
83
- @custom_fields.each { |cf| add_field(cf[:column_name], cf[:schema]) }
84
84
  end
85
85
 
86
86
  def define_relations
@@ -46,8 +46,6 @@ module ForestAdminDatasourceZendesk
46
46
  is_read_only: true, is_sortable: true))
47
47
  add_field('updated_at', ColumnSchema.new(column_type: 'Date', filter_operators: DATE_OPS,
48
48
  is_read_only: true, is_sortable: true))
49
-
50
- @custom_fields.each { |cf| add_field(cf[:column_name], cf[:schema]) }
51
49
  end
52
50
 
53
51
  def define_relations
@@ -6,6 +6,8 @@ module ForestAdminDatasourceZendesk
6
6
  include CommentsEmbedder
7
7
  include Serializer
8
8
 
9
+ attr_reader :custom_fields
10
+
9
11
  ManyToOneSchema = ForestAdminDatasourceToolkit::Schema::Relations::ManyToOneSchema
10
12
 
11
13
  ZENDESK_SORTABLE = {
@@ -28,9 +30,9 @@ module ForestAdminDatasourceZendesk
28
30
 
29
31
  def initialize(datasource, custom_fields: [])
30
32
  super(datasource, 'ZendeskTicket')
31
- @custom_fields = custom_fields
32
33
  define_schema
33
34
  define_relations
35
+ @custom_fields = add_custom_fields(custom_fields)
34
36
  enable_search
35
37
  enable_count
36
38
  end
@@ -3,6 +3,8 @@ module ForestAdminDatasourceZendesk
3
3
  class User < BaseCollection
4
4
  include Searchable
5
5
 
6
+ attr_reader :custom_fields
7
+
6
8
  ManyToOneSchema = ForestAdminDatasourceToolkit::Schema::Relations::ManyToOneSchema
7
9
  OneToManySchema = ForestAdminDatasourceToolkit::Schema::Relations::OneToManySchema
8
10
  ENUM_ROLE = %w[end-user agent admin].freeze
@@ -17,9 +19,9 @@ module ForestAdminDatasourceZendesk
17
19
 
18
20
  def initialize(datasource, custom_fields: [])
19
21
  super(datasource, 'ZendeskUser')
20
- @custom_fields = custom_fields
21
22
  define_schema
22
23
  define_relations
24
+ @custom_fields = add_custom_fields(custom_fields)
23
25
  enable_search
24
26
  enable_count
25
27
  end
@@ -89,8 +91,6 @@ module ForestAdminDatasourceZendesk
89
91
  is_read_only: true, is_sortable: true))
90
92
  add_field('updated_at', ColumnSchema.new(column_type: 'Date', filter_operators: DATE_OPS,
91
93
  is_read_only: true, is_sortable: true))
92
-
93
- @custom_fields.each { |cf| add_field(cf[:column_name], cf[:schema]) }
94
94
  end
95
95
 
96
96
  def define_relations
@@ -16,15 +16,16 @@ module ForestAdminDatasourceZendesk
16
16
  def register_collections
17
17
  introspector = Schema::CustomFieldsIntrospector.new(@client)
18
18
 
19
- ticket_cf = introspector.ticket_custom_fields
20
- user_cf = introspector.user_custom_fields
21
- org_cf = introspector.organization_custom_fields
19
+ ticket = Collections::Ticket.new(self, custom_fields: introspector.ticket_custom_fields)
20
+ user = Collections::User.new(self, custom_fields: introspector.user_custom_fields)
21
+ org = Collections::Organization.new(self, custom_fields: introspector.organization_custom_fields)
22
22
 
23
- add_collection(Collections::Ticket.new(self, custom_fields: ticket_cf))
24
- add_collection(Collections::User.new(self, custom_fields: user_cf))
25
- add_collection(Collections::Organization.new(self, custom_fields: org_cf))
23
+ add_collection(ticket)
24
+ add_collection(user)
25
+ add_collection(org)
26
26
 
27
- @custom_field_mapping = build_custom_field_mapping(ticket_cf, user_cf, org_cf)
27
+ @custom_field_mapping = build_custom_field_mapping(ticket.custom_fields,
28
+ user.custom_fields, org.custom_fields)
28
29
  end
29
30
 
30
31
  # Forest column name -> Zendesk Search field name. Lives on the instance
@@ -1,3 +1,3 @@
1
1
  module ForestAdminDatasourceZendesk
2
- VERSION = "1.30.2"
2
+ VERSION = "1.30.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_admin_datasource_zendesk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.30.2
4
+ version: 1.30.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Forest Admin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-05-21 00:00:00.000000000 Z
11
+ date: 2026-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport