multiwoven-integrations 0.34.15 → 0.34.16

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: b0bc47bb18e9eb776b3e1b72ad711dddba187f2fb5d092deb0f8261dc17c250a
4
- data.tar.gz: a49ddccf93fba66d26359af93f66b4a60f211e759e83f4da32eb9f555e359be7
3
+ metadata.gz: b6b99b3873653f5b2e7e7854a933ad303133548fe02d3c226e6cdb5416b3a2fa
4
+ data.tar.gz: b4e0f73a8cf353a66884917ba79d3f9e1535bb9807acaeddb810ceb50b00fbd3
5
5
  SHA512:
6
- metadata.gz: 4445bb6e997771cdfe4f9113ca2a1fe444ac6825aad43ea013a1a74b86abc853738c851cf86d47dc6d975cb15e0bb96b7be9010bf00f76719e821cc7bcc8b65f
7
- data.tar.gz: bd04c9011ab5eafd34bf9bc2019b03b6948fe6dfc31302b19d05a98dd97f7138e04162a6ca0bd394ee8888a9d8e1f34b61e9f360eadfefe179fbc3ba6cbf6302
6
+ metadata.gz: 66cb050fc40ed6385371b2f4577f77f2902c79f29e36a3fa4a5388314653cacff8b66427eb39deeec3af9773227f5568b5fb45b3cbe2a5c103567c0bee43bcb4
7
+ data.tar.gz: 37a520ae02b487111059022dc1d27b7f177a5b52436df77dba9d3d0adce32355d909d75d0057eb60a2dc9b7428d73befdd3b75bf38c56df32352cc26d3861dad
@@ -13,9 +13,12 @@ module Multiwoven::Integrations::Destination
13
13
  ConnectionStatus.new(status: ConnectionStatusType["failed"], message: e.message).to_multiwoven_message
14
14
  end
15
15
 
16
- def discover(_connection_config = nil)
17
- catalog_json = read_json(CATALOG_SPEC_PATH)
18
- catalog = build_catalog(catalog_json)
16
+ def discover(connection_config)
17
+ connection_config = connection_config.with_indifferent_access
18
+ conn = create_connection(connection_config)
19
+ records = discover_columns_from_s3(conn, connection_config)
20
+ grouped = group_by_table(records, connection_config[:file_name])
21
+ catalog = Catalog.new(streams: create_streams(grouped))
19
22
  catalog.to_multiwoven_message
20
23
  rescue StandardError => e
21
24
  handle_exception(e, {
@@ -94,6 +97,60 @@ module Multiwoven::Integrations::Destination
94
97
  timestamp = Time.now.strftime("%Y%m%d-%H%M%S")
95
98
  "#{connection_config[:file_name]}_#{timestamp}.#{connection_config[:format_type]}"
96
99
  end
100
+
101
+ def build_discover_prefix(connection_config)
102
+ file_path = connection_config[:file_path].to_s.strip
103
+ file_path = "#{file_path}/" if file_path.present? && file_path[-1] != "/"
104
+ format_type = connection_config[:format_type].to_s.downcase
105
+ "#{file_path}#{connection_config[:file_name]}.#{format_type}"
106
+ end
107
+
108
+ def discover_columns_from_s3(s3_client, connection_config)
109
+ bucket = connection_config[:bucket_name]
110
+ prefix = build_discover_prefix(connection_config)
111
+ format_type = connection_config[:format_type].to_s.downcase
112
+
113
+ response = s3_client.list_objects_v2(bucket: bucket, prefix: prefix, max_keys: 100)
114
+ raise StandardError, "No files found in the bucket" if response.contents.empty?
115
+
116
+ key = response.contents&.find { |obj| obj.key.end_with?(".#{format_type}") }&.key
117
+ raise StandardError, "No files found in the bucket" if key.nil?
118
+
119
+ read_csv_headers(s3_client, bucket, key)
120
+ end
121
+
122
+ def read_csv_headers(s3_client, bucket, key)
123
+ obj = s3_client.get_object(bucket: bucket, key: key)
124
+ first_line = obj.body.read.to_s.lines.first
125
+ return [] if first_line.nil? || first_line.strip.empty?
126
+
127
+ CSV.parse_line(first_line.strip)
128
+ end
129
+
130
+ def group_by_table(records, file_name)
131
+ result = {}
132
+ records.each do |entry|
133
+ table_name = file_name
134
+ column_data = {
135
+ column_name: entry,
136
+ type: "string",
137
+ optional: true
138
+ }
139
+ result[table_name] ||= { tablename: table_name, columns: [] }
140
+ result[table_name][:columns] << column_data
141
+ end
142
+ result
143
+ end
144
+
145
+ def create_streams(tables)
146
+ tables.values.map do |r|
147
+ Multiwoven::Integrations::Protocol::Stream.new(
148
+ name: r[:tablename],
149
+ action: StreamAction["create"],
150
+ json_schema: convert_to_json_schema(r[:columns])
151
+ )
152
+ end
153
+ end
97
154
  end
98
155
  end
99
156
  end
@@ -4,7 +4,7 @@
4
4
  "connection_specification": {
5
5
  "$schema": "http://json-schema.org/draft-07/schema#",
6
6
  "title": "AmazonS3",
7
- "required": ["access_key_id", "secret_access_key", "region", "bucket_name", "file_path", "file_name", "format_type" ],
7
+ "required": ["access_key_id", "secret_access_key", "region", "bucket_name", "file_name", "format_type" ],
8
8
  "properties": {
9
9
  "access_key_id": {
10
10
  "description": "The AWS Access Key ID to use for authentication.",
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Multiwoven
4
4
  module Integrations
5
- VERSION = "0.34.15"
5
+ VERSION = "0.34.16"
6
6
 
7
7
  ENABLED_SOURCES = %w[
8
8
  Snowflake
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.34.15
4
+ version: 0.34.16
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: 2026-02-12 00:00:00.000000000 Z
11
+ date: 2026-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -599,7 +599,6 @@ files:
599
599
  - lib/multiwoven/integrations/destination/ais_data_store/config/spec.json
600
600
  - lib/multiwoven/integrations/destination/ais_data_store/icon.svg
601
601
  - lib/multiwoven/integrations/destination/amazon_s3/client.rb
602
- - lib/multiwoven/integrations/destination/amazon_s3/config/catalog.json
603
602
  - lib/multiwoven/integrations/destination/amazon_s3/config/meta.json
604
603
  - lib/multiwoven/integrations/destination/amazon_s3/config/spec.json
605
604
  - lib/multiwoven/integrations/destination/amazon_s3/icon.svg
@@ -1,16 +0,0 @@
1
- {
2
- "request_rate_limit": 600,
3
- "request_rate_limit_unit": "minute",
4
- "request_rate_concurrency": 10,
5
- "schema_mode": "schemaless",
6
- "streams": [
7
- {
8
- "name": "create",
9
- "batch_support": true,
10
- "batch_size": 100000,
11
- "action": "create",
12
- "json_schema": {},
13
- "supported_sync_modes": ["full_refresh","incremental"]
14
- }
15
- ]
16
- }