multiwoven-integrations 0.30.2 → 0.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: 51616b2e7b06336873aceb0c9e5731526dd7e57ba332eab190bc215d99c4ed8d
4
- data.tar.gz: d376ae2826566eea31fd92dbd4e4ddf16034e1ef9085edf08f7b554744424583
3
+ metadata.gz: bd0cbb0f8015d5dca4ae579b0b119c615901e04c4fbed4740d30f6beb7dbd301
4
+ data.tar.gz: eb33686acc75c66167433386773d8a20addcbe585c130acd4ac82c7d9f6c0de1
5
5
  SHA512:
6
- metadata.gz: fc9778e2da0499ed9bec602005b3b69aadd8e038e251d77acc8407bde99dbf213c1ff0d6f937a832c1d4aa660dbae578de8042caf9c0720fca3ddcff2e0d762a
7
- data.tar.gz: a8438815522f82a1bc6db95c6bd29c94a55f182bf459f90c3e01209f54b17e303d939280a63549f6c1eff5da4e57ca1f80e85b98646f6f935995f3a371f7b274
6
+ metadata.gz: 573368e7d20ed38dd568645a3b9e25912856a4aa9a2e844bff348a6ed718a56f5c858ada5f728c6561dc002f63bd469f1cc8ac38ec5fed68497ec51d7fd75bb4
7
+ data.tar.gz: da4e8d247a40d77cbec1859b93f982d8b47b6e414cfe3392275ec0867263271807237830328f81b271d48599784e778b173ca5c08389279939f98f8a3ae21fc9
@@ -73,6 +73,7 @@ module Multiwoven
73
73
  attribute :name, Types::String
74
74
  attribute :type, ConnectorType
75
75
  attribute :connection_specification, Types::Hash
76
+ attribute :connector_instance, Types::Any.optional.default(nil)
76
77
  attribute :query_type, Types::String.default("raw_sql").enum(*ConnectorQueryType.values)
77
78
  end
78
79
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Multiwoven
4
4
  module Integrations
5
- VERSION = "0.30.2"
5
+ VERSION = "0.30.4"
6
6
 
7
7
  ENABLED_SOURCES = %w[
8
8
  Snowflake
@@ -30,7 +30,7 @@ module Multiwoven::Integrations::Source
30
30
  connection_config = sync_config.source.connection_specification
31
31
  connection_config = connection_config.with_indifferent_access
32
32
  url = create_connection(connection_config)
33
- query(url, nil)
33
+ query(url, nil, nil)
34
34
  rescue StandardError => e
35
35
  handle_exception(e, {
36
36
  context: "FIRECRAWL:READ:EXCEPTION",
@@ -58,15 +58,14 @@ module Multiwoven::Integrations::Source
58
58
  FIRECRAWL_CRAWL_URL
59
59
  end
60
60
 
61
- def query(url, query)
62
- has_limit = query.match(/LIMIT\s+(\d+)\s*$/i) if query.present?
63
- if has_limit.present?
61
+ def query(url, _query, limit = 1)
62
+ if limit.present?
64
63
  if @config["includePaths"]&.any?
65
64
  path = @config["includePaths"].first
66
65
  @config["url"] = URI.join(@config["url"], path).to_s
67
66
  end
68
67
  @config.delete("includePaths")
69
- @config[:limit] = has_limit[1].to_i
68
+ @config[:limit] = limit
70
69
  end
71
70
  request = execute_crawl(url)
72
71
  request = JSON.parse(request.body)
@@ -44,6 +44,7 @@ module Multiwoven::Integrations::Source
44
44
  def read(sync_config)
45
45
  connection_config = sync_config.source.connection_specification
46
46
  connection_config = connection_config.with_indifferent_access
47
+ @connector_instance = sync_config&.source&.connector_instance
47
48
  query = sync_config.model.query
48
49
  query = batched_query(query, sync_config.limit, sync_config.offset) unless sync_config.limit.nil? && sync_config.offset.nil?
49
50
  access_token = create_connection(connection_config)
@@ -114,9 +115,8 @@ module Multiwoven::Integrations::Source
114
115
  end
115
116
 
116
117
  def create_connection(connection_config)
117
- cache = defined?(Rails) && Rails.respond_to?(:cache) ? Rails.cache : ActiveSupport::Cache::MemoryStore.new
118
118
  load_connection_config(connection_config)
119
- get_access_token(cache)
119
+ refresh_access_token
120
120
  end
121
121
 
122
122
  def load_connection_config(connection_config)
@@ -124,25 +124,23 @@ module Multiwoven::Integrations::Source
124
124
  @client_secret = connection_config[:client_secret]
125
125
  @realm_id = connection_config[:realm_id]
126
126
  @environment = connection_config[:environment]
127
- @refresh_token = connection_config[:refresh_token]
128
- end
129
-
130
- def get_access_token(cache)
131
- cache_key = "intuit_quickbooks_#{@client_id}_#{@client_secret}_#{@realm_id}}"
132
- cached_token = cache.read(cache_key)
133
- if cached_token
134
- cached_token
135
- else
136
- new_token = refresh_access_token
137
- # max expiration is 3 minutes. No way to make it higher
138
- cache.write(cache_key, new_token, expires_in: 180)
139
- new_token
140
- end
127
+ @refresh_token = if @connector_instance&.configuration
128
+ @connector_instance.configuration["refresh_token"]
129
+ else
130
+ connection_config[:refresh_token]
131
+ end
141
132
  end
142
133
 
143
134
  def refresh_access_token
144
135
  oauth2_client = IntuitOAuth::Client.new(@client_id, @client_secret, QUICKBOOKS_REDIRECT_URL, @environment)
145
- oauth2_client.token.refresh_tokens(@refresh_token).access_token
136
+ response = oauth2_client.token.refresh_tokens(@refresh_token)
137
+ if @connector_instance&.configuration
138
+ config = @connector_instance.configuration
139
+ config = {} unless config.is_a?(Hash)
140
+ new_config = config.merge("refresh_token" => response.refresh_token)
141
+ @connector_instance.update!(configuration: new_config)
142
+ end
143
+ response.access_token
146
144
  end
147
145
 
148
146
  def create_streams(records)
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.30.2
4
+ version: 0.30.4
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: 2025-06-27 00:00:00.000000000 Z
11
+ date: 2025-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport