multiwoven-integrations 0.1.47 → 0.1.48

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,26 +6,27 @@
6
6
  "title": "Salesforce Consumer Goods Cloud",
7
7
  "type": "object",
8
8
  "required": [
9
- "access_token",
10
- "refresh_token",
11
- "instance_url",
9
+ "username",
10
+ "password",
11
+ "host",
12
+ "security_token",
12
13
  "client_id",
13
14
  "client_secret"
14
15
  ],
15
16
  "properties": {
16
- "access_token": {
17
+ "username": {
17
18
  "type": "string",
18
- "title": "Access Token",
19
+ "title": "Username",
19
20
  "order": 0
20
21
  },
21
- "refresh_token": {
22
+ "password": {
22
23
  "type": "string",
23
- "title": "Refresh Token",
24
+ "title": "Password",
24
25
  "order": 1
25
26
  },
26
- "instance_url": {
27
+ "host": {
27
28
  "type": "string",
28
- "title": "Instance URL",
29
+ "title": "Host",
29
30
  "order": 2
30
31
  },
31
32
  "client_id": {
@@ -37,6 +38,11 @@
37
38
  "type": "string",
38
39
  "title": "Client Secret",
39
40
  "order": 4
41
+ },
42
+ "security_token": {
43
+ "type": "string",
44
+ "title": "Security Token",
45
+ "order": 5
40
46
  }
41
47
  }
42
48
  }
@@ -0,0 +1,130 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Multiwoven
4
+ module Integrations
5
+ module Source
6
+ module SalesforceConsumerGoodsCloud
7
+ module SchemaHelper
8
+ include Core::Constants
9
+
10
+ module_function
11
+
12
+ def salesforce_field_to_json_schema_type(sf_field) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
13
+ case sf_field["type"]
14
+ when "string", "Email", "Phone", "Text", "TextArea", "TextEncrypted", "URL", "Picklist (Single)"
15
+ if sf_field["nillable"]
16
+ { "type": %w[string null] }
17
+ else
18
+ { "type": "string" }
19
+ end
20
+ when "double", "Currency", "Percent"
21
+ if sf_field["nillable"]
22
+ { "type": %w[number null] }
23
+ else
24
+ { "type": "number" }
25
+ end
26
+ when "boolean", "Checkbox"
27
+ if sf_field["nillable"]
28
+ { "type": %w[boolean null] }
29
+ else
30
+ { "type": "boolean" }
31
+ end
32
+ when "int", "AutoNumber"
33
+ if sf_field["nillable"]
34
+ { "type": %w[integer null] }
35
+ else
36
+ { "type": "integer" }
37
+ end
38
+ when "date"
39
+ if sf_field["nillable"]
40
+ { "type": %w[string null], "format": "date" }
41
+ else
42
+ { "type": "string", "format": "date" }
43
+ end
44
+ when "datetime", "DateTime"
45
+ if sf_field["nillable"]
46
+ { "type": %w[string null], "format": "date-time" }
47
+ else
48
+ { "type": "string", "format": "date-time" }
49
+ end
50
+ when "time"
51
+ if sf_field["nillable"]
52
+ { "type": %w[string null], "format": "time" }
53
+ else
54
+ { "type": "string", "format": "time" }
55
+ end
56
+ when "textarea", "Text Area (Long)", "Text Area (Rich)"
57
+ if sf_field["nillable"]
58
+ { "type": %w[string null] }
59
+ else
60
+ { "type": "string" }
61
+ end
62
+ when "picklist", "multipicklist", "Picklist (Multi-select)"
63
+ if sf_field[:picklistValues] && sf_field["nillable"]
64
+ enum_values = sf_field[:picklistValues].map { |val| val["value"] }
65
+ { "type": %w[array null], "items": { "type": "string" }, "enum": enum_values }
66
+ elsif sf_field[:picklistValues]
67
+ enum_values = sf_field[:picklistValues].map { |val| val["value"] }
68
+ { "type": "array", "items": { "type": "string" }, "enum": enum_values }
69
+ else
70
+ { "type": "array", "items": { "type": "string" } }
71
+ end
72
+ when "reference", "Reference (Lookup & Master-Detail)"
73
+ if sf_field["nillable"]
74
+ { "type": %w[string null] }
75
+ else
76
+ { "type": "string" }
77
+ end
78
+ when "location", "Geolocation"
79
+ if sf_field["nillable"]
80
+ { "type": %w[object null], "properties": { "latitude": { "type": "number" }, "longitude": { "type": "number" } } }
81
+ else
82
+ { "type": "object", "properties": { "latitude": { "type": "number" }, "longitude": { "type": "number" } } }
83
+ end
84
+ else
85
+ if sf_field["nillable"]
86
+ { "type": %w[string null] }
87
+ else
88
+ { "type": "string" }
89
+ end
90
+ end
91
+ end
92
+
93
+ def create_json_schema_for_object(metadata)
94
+ fields_schema = metadata["fields"].map do |field|
95
+ {
96
+ "#{field[:name]}": salesforce_field_to_json_schema_type(field)
97
+ }
98
+ end.reduce(:merge)
99
+
100
+ json_schema = {
101
+ "$schema": "http://json-schema.org/draft-07/schema#",
102
+ "title": metadata["name"],
103
+ "type": "object",
104
+ "additionalProperties": true,
105
+ "properties": fields_schema
106
+ }
107
+
108
+ required = metadata["fields"].map do |field|
109
+ field["name"] if field["nillable"] == false
110
+ end.compact
111
+ primary_key = metadata["fields"].map do |field|
112
+ field["name"] if field["nillable"] == false && field["unique"] == true
113
+ end.compact
114
+
115
+ {
116
+ "name": metadata["name"],
117
+ "action": "create",
118
+ "json_schema": json_schema,
119
+ "required": required,
120
+ "supported_sync_modes": %w[full_refresh incremental],
121
+ "source_defined_cursor": true,
122
+ "default_cursor_field": ["updated"],
123
+ "source_defined_primary_key": [primary_key]
124
+ }
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end
130
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Multiwoven
4
4
  module Integrations
5
- VERSION = "0.1.47"
5
+ VERSION = "0.1.48"
6
6
 
7
7
  ENABLED_SOURCES = %w[
8
8
  Snowflake
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "stringio"
4
+ require_relative "schema_helper"
4
5
 
5
6
  module Multiwoven
6
7
  module Integrations
@@ -9,9 +10,9 @@ module Multiwoven
9
10
  include Multiwoven::Integrations::Core
10
11
 
11
12
  API_VERSION = "59.0"
12
- SALESFORCE_OBJECTS = %w[Account User Visit RetailStore].freeze
13
+ SALESFORCE_OBJECTS = %w[Account User Visit RetailStore RecordType].freeze
13
14
 
14
- class Client < SourceConnector # rubocop:disable Metrics/ClassLength
15
+ class Client < SourceConnector
15
16
  prepend Multiwoven::Integrations::Core::RateLimiter
16
17
  def check_connection(connection_config)
17
18
  connection_config = connection_config.with_indifferent_access
@@ -29,11 +30,11 @@ module Multiwoven
29
30
  streams = catalog[:streams]
30
31
  SALESFORCE_OBJECTS.each do |object|
31
32
  object_description = @client.describe(object)
32
- streams << JSON.parse(create_json_schema_for_object(object_description).to_json)
33
+ streams << JSON.parse(SchemaHelper.create_json_schema_for_object(object_description).to_json)
33
34
  end
34
35
  catalog.to_multiwoven_message
35
36
  rescue StandardError => e
36
- handle_exception("SALESFORCE:CRM:DISCOVER:EXCEPTION", "error", e)
37
+ handle_exception("SALESFORCE:CONSUMER:GOODS:ClOUD:DISCOVER:EXCEPTION", "error", e)
37
38
  end
38
39
 
39
40
  def read(sync_config)
@@ -55,7 +56,7 @@ module Multiwoven
55
56
  RecordMessage.new(data: row, emitted_at: Time.now.to_i).to_multiwoven_message
56
57
  end
57
58
  rescue StandardError => e
58
- handle_exception("SALESFORCE:CRM:WRITE:EXCEPTION", "error", e)
59
+ handle_exception("SALESFORCE:CONSUMER:GOODS:ClOUD:WRITE:EXCEPTION", "error", e)
59
60
  end
60
61
 
61
62
  private
@@ -85,121 +86,6 @@ module Multiwoven
85
86
  api_version: API_VERSION)
86
87
  end
87
88
 
88
- def salesforce_field_to_json_schema_type(sf_field) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
89
- case sf_field["type"]
90
- when "string", "Email", "Phone", "Text", "TextArea", "TextEncrypted", "URL", "Picklist (Single)"
91
- if sf_field["nillable"]
92
- { "type": %w[string null] }
93
- else
94
- { "type": "string" }
95
- end
96
- when "double", "Currency", "Percent"
97
- if sf_field["nillable"]
98
- { "type": %w[number null] }
99
- else
100
- { "type": "number" }
101
- end
102
- when "boolean", "Checkbox"
103
- if sf_field["nillable"]
104
- { "type": %w[boolean null] }
105
- else
106
- { "type": "boolean" }
107
- end
108
- when "int", "AutoNumber"
109
- if sf_field["nillable"]
110
- { "type": %w[integer null] }
111
- else
112
- { "type": "integer" }
113
- end
114
- when "date"
115
- if sf_field["nillable"]
116
- { "type": %w[string null], "format": "date" }
117
- else
118
- { "type": "string", "format": "date" }
119
- end
120
- when "datetime", "DateTime"
121
- if sf_field["nillable"]
122
- { "type": %w[string null], "format": "date-time" }
123
- else
124
- { "type": "string", "format": "date-time" }
125
- end
126
- when "time"
127
- if sf_field["nillable"]
128
- { "type": %w[string null], "format": "time" }
129
- else
130
- { "type": "string", "format": "time" }
131
- end
132
- when "textarea", "Text Area (Long)", "Text Area (Rich)"
133
- if sf_field["nillable"]
134
- { "type": %w[string null] }
135
- else
136
- { "type": "string" }
137
- end
138
- when "picklist", "multipicklist", "Picklist (Multi-select)"
139
- if sf_field[:picklistValues] && sf_field["nillable"]
140
- enum_values = sf_field[:picklistValues].map { |val| val["value"] }
141
- { "type": %w[array null], "items": { "type": "string" }, "enum": enum_values }
142
- elsif sf_field[:picklistValues]
143
- enum_values = sf_field[:picklistValues].map { |val| val["value"] }
144
- { "type": "array", "items": { "type": "string" }, "enum": enum_values }
145
- else
146
- { "type": "array", "items": { "type": "string" } }
147
- end
148
- when "reference", "Reference (Lookup & Master-Detail)"
149
- if sf_field["nillable"]
150
- { "type": %w[string null] }
151
- else
152
- { "type": "string" }
153
- end
154
- when "location", "Geolocation"
155
- if sf_field["nillable"]
156
- { "type": %w[object null], "properties": { "latitude": { "type": "number" }, "longitude": { "type": "number" } } }
157
- else
158
- { "type": "object", "properties": { "latitude": { "type": "number" }, "longitude": { "type": "number" } } }
159
- end
160
- else
161
- if sf_field["nillable"]
162
- { "type": %w[string null] }
163
- else
164
- { "type": "string" }
165
- end
166
- end
167
- end
168
-
169
- def create_json_schema_for_object(metadata)
170
- fields_schema = metadata["fields"].map do |field|
171
- {
172
- "#{field[:name]}": salesforce_field_to_json_schema_type(field)
173
- }
174
- end.reduce(:merge)
175
-
176
- json_schema = {
177
- "$schema": "http://json-schema.org/draft-07/schema#",
178
- "title": metadata["name"],
179
- "type": "object",
180
- "additionalProperties": true,
181
- "properties": fields_schema
182
- }
183
-
184
- required = metadata["fields"].map do |field|
185
- field["name"] if field["nillable"] == false
186
- end.compact
187
- primary_key = metadata["fields"].map do |field|
188
- field["name"] if field["nillable"] == false && field["unique"] == true
189
- end.compact
190
-
191
- {
192
- "name": metadata["name"],
193
- "action": "create",
194
- "json_schema": json_schema,
195
- "required": required,
196
- "supported_sync_modes": %w[full_refresh incremental],
197
- "source_defined_cursor": true,
198
- "default_cursor_field": ["updated"],
199
- "source_defined_primary_key": [primary_key]
200
- }
201
- end
202
-
203
89
  def authenticate_client
204
90
  @client.authenticate!
205
91
  end
@@ -0,0 +1,130 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Multiwoven
4
+ module Integrations
5
+ module Destination
6
+ module SalesforceConsumerGoodsCloud
7
+ module SchemaHelper
8
+ include Core::Constants
9
+
10
+ module_function
11
+
12
+ def salesforce_field_to_json_schema_type(sf_field) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
13
+ case sf_field["type"]
14
+ when "string", "Email", "Phone", "Text", "TextArea", "TextEncrypted", "URL", "Picklist (Single)"
15
+ if sf_field["nillable"]
16
+ { "type": %w[string null] }
17
+ else
18
+ { "type": "string" }
19
+ end
20
+ when "double", "Currency", "Percent"
21
+ if sf_field["nillable"]
22
+ { "type": %w[number null] }
23
+ else
24
+ { "type": "number" }
25
+ end
26
+ when "boolean", "Checkbox"
27
+ if sf_field["nillable"]
28
+ { "type": %w[boolean null] }
29
+ else
30
+ { "type": "boolean" }
31
+ end
32
+ when "int", "AutoNumber"
33
+ if sf_field["nillable"]
34
+ { "type": %w[integer null] }
35
+ else
36
+ { "type": "integer" }
37
+ end
38
+ when "date"
39
+ if sf_field["nillable"]
40
+ { "type": %w[string null], "format": "date" }
41
+ else
42
+ { "type": "string", "format": "date" }
43
+ end
44
+ when "datetime", "DateTime"
45
+ if sf_field["nillable"]
46
+ { "type": %w[string null], "format": "date-time" }
47
+ else
48
+ { "type": "string", "format": "date-time" }
49
+ end
50
+ when "time"
51
+ if sf_field["nillable"]
52
+ { "type": %w[string null], "format": "time" }
53
+ else
54
+ { "type": "string", "format": "time" }
55
+ end
56
+ when "textarea", "Text Area (Long)", "Text Area (Rich)"
57
+ if sf_field["nillable"]
58
+ { "type": %w[string null] }
59
+ else
60
+ { "type": "string" }
61
+ end
62
+ when "picklist", "multipicklist", "Picklist (Multi-select)"
63
+ if sf_field[:picklistValues] && sf_field["nillable"]
64
+ enum_values = sf_field[:picklistValues].map { |val| val["value"] }
65
+ { "type": %w[array null], "items": { "type": "string" }, "enum": enum_values }
66
+ elsif sf_field[:picklistValues]
67
+ enum_values = sf_field[:picklistValues].map { |val| val["value"] }
68
+ { "type": "array", "items": { "type": "string" }, "enum": enum_values }
69
+ else
70
+ { "type": "array", "items": { "type": "string" } }
71
+ end
72
+ when "reference", "Reference (Lookup & Master-Detail)"
73
+ if sf_field["nillable"]
74
+ { "type": %w[string null] }
75
+ else
76
+ { "type": "string" }
77
+ end
78
+ when "location", "Geolocation"
79
+ if sf_field["nillable"]
80
+ { "type": %w[object null], "properties": { "latitude": { "type": "number" }, "longitude": { "type": "number" } } }
81
+ else
82
+ { "type": "object", "properties": { "latitude": { "type": "number" }, "longitude": { "type": "number" } } }
83
+ end
84
+ else
85
+ if sf_field["nillable"]
86
+ { "type": %w[string null] }
87
+ else
88
+ { "type": "string" }
89
+ end
90
+ end
91
+ end
92
+
93
+ def create_json_schema_for_object(metadata)
94
+ fields_schema = metadata["fields"].map do |field|
95
+ {
96
+ "#{field[:name]}": salesforce_field_to_json_schema_type(field)
97
+ }
98
+ end.reduce(:merge)
99
+
100
+ json_schema = {
101
+ "$schema": "http://json-schema.org/draft-07/schema#",
102
+ "title": metadata["name"],
103
+ "type": "object",
104
+ "additionalProperties": true,
105
+ "properties": fields_schema
106
+ }
107
+
108
+ required = metadata["fields"].map do |field|
109
+ field["name"] if field["nillable"] == false
110
+ end.compact
111
+ primary_key = metadata["fields"].map do |field|
112
+ field["name"] if field["nillable"] == false && field["unique"] == true
113
+ end.compact
114
+
115
+ {
116
+ "name": metadata["name"],
117
+ "action": "create",
118
+ "json_schema": json_schema,
119
+ "required": required,
120
+ "supported_sync_modes": %w[full_refresh incremental],
121
+ "source_defined_cursor": true,
122
+ "default_cursor_field": ["updated"],
123
+ "source_defined_primary_key": [primary_key]
124
+ }
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end
130
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiwoven-integrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.47
4
+ version: 0.1.48
5
5
  platform: ruby
6
6
  authors:
7
7
  - Subin T P
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-26 00:00:00.000000000 Z
11
+ date: 2024-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -423,6 +423,7 @@ files:
423
423
  - lib/multiwoven/integrations/destination/salesforce_consumer_goods_cloud/config/meta.json
424
424
  - lib/multiwoven/integrations/destination/salesforce_consumer_goods_cloud/config/spec.json
425
425
  - lib/multiwoven/integrations/destination/salesforce_consumer_goods_cloud/icon.svg
426
+ - lib/multiwoven/integrations/destination/salesforce_consumer_goods_cloud/schema_helper.rb
426
427
  - lib/multiwoven/integrations/destination/salesforce_crm/client.rb
427
428
  - lib/multiwoven/integrations/destination/salesforce_crm/config/catalog.json
428
429
  - lib/multiwoven/integrations/destination/salesforce_crm/config/meta.json
@@ -468,6 +469,7 @@ files:
468
469
  - lib/multiwoven/integrations/source/salesforce_consumer_goods_cloud/config/meta.json
469
470
  - lib/multiwoven/integrations/source/salesforce_consumer_goods_cloud/config/spec.json
470
471
  - lib/multiwoven/integrations/source/salesforce_consumer_goods_cloud/icon.svg
472
+ - lib/multiwoven/integrations/source/salesforce_consumer_goods_cloud/schema_helper.rb
471
473
  - lib/multiwoven/integrations/source/snowflake/client.rb
472
474
  - lib/multiwoven/integrations/source/snowflake/config/meta.json
473
475
  - lib/multiwoven/integrations/source/snowflake/config/spec.json