From ed7e6e937962ab4919410a4e9ba9512f6f8f7a15 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Edgar=20Ram=C3=ADrez-Mondrag=C3=B3n?= <edgarrm358@gmail.com>
Date: Thu, 5 Sep 2024 20:17:25 -0600
Subject: [PATCH] Move FS configs to their own module

---
 tap_csv/filesystem_config.py | 87 +++++++++++++++++++++++++++++++++++
 tap_csv/tap.py               | 88 ++----------------------------------
 2 files changed, 92 insertions(+), 83 deletions(-)
 create mode 100644 tap_csv/filesystem_config.py

diff --git a/tap_csv/filesystem_config.py b/tap_csv/filesystem_config.py
new file mode 100644
index 0000000..c522b86
--- /dev/null
+++ b/tap_csv/filesystem_config.py
@@ -0,0 +1,87 @@
+"""JSON Schema for each filesystem configuration."""
+
+from __future__ import annotations
+
+from singer_sdk import typing as th  # JSON schema typing helpers
+
+FTP = th.Property(
+    "ftp",
+    th.ObjectType(
+        th.Property(
+            "host",
+            th.StringType,
+            required=True,
+            description="FTP server host",
+        ),
+        th.Property(
+            "port",
+            th.IntegerType,
+            default=21,
+            description="FTP server port",
+        ),
+        th.Property(
+            "username",
+            th.StringType,
+            description="FTP username",
+        ),
+        th.Property(
+            "password",
+            th.StringType,
+            secret=True,
+            description="FTP password",
+        ),
+        th.Property(
+            "encoding",
+            th.StringType,
+            default="utf-8",
+            description="FTP server encoding",
+        ),
+    ),
+    description="FTP connection settings",
+)
+
+GITHUB = th.Property(
+    "github",
+    th.ObjectType(
+        th.Property(
+            "org",
+            th.StringType,
+            required=True,
+            description=("GitHub organization or user where the repository is located"),
+        ),
+        th.Property(
+            "repo",
+            th.StringType,
+            required=True,
+            description="GitHub repository",
+        ),
+        th.Property(
+            "username",
+            th.StringType,
+            required=False,
+            description="GitHub username",
+        ),
+        th.Property(
+            "token",
+            th.StringType,
+            required=False,
+            secret=True,
+            description="GitHub token",
+        ),
+    ),
+    description="GitHub connection settings",
+)
+
+DROPBOX = th.Property(
+    "dropbox",
+    th.ObjectType(
+        th.Property(
+            "token",
+            th.StringType,
+            secret=True,
+            required=True,
+            description="Dropbox token",
+        ),
+    ),
+    description="Dropbox connection settings",
+)
diff --git a/tap_csv/tap.py b/tap_csv/tap.py
index 8cc70be..43abb44 100644
--- a/tap_csv/tap.py
+++ b/tap_csv/tap.py
@@ -11,7 +11,7 @@
 from singer_sdk.helpers._classproperty import classproperty
 from singer_sdk.helpers.capabilities import TapCapabilities
 
-from tap_csv.client import CSVStream
+from . import client, filesystem_config
 
 
 class TapCSV(Tap):
@@ -53,87 +53,9 @@ class TapCSV(Tap):
                 "dropbox",
             ],
         ),
-        th.Property(
-            "ftp",
-            th.ObjectType(
-                th.Property(
-                    "host",
-                    th.StringType,
-                    required=True,
-                    description="FTP server host",
-                ),
-                th.Property(
-                    "port",
-                    th.IntegerType,
-                    default=21,
-                    description="FTP server port",
-                ),
-                th.Property(
-                    "username",
-                    th.StringType,
-                    description="FTP username",
-                ),
-                th.Property(
-                    "password",
-                    th.StringType,
-                    secret=True,
-                    description="FTP password",
-                ),
-                th.Property(
-                    "encoding",
-                    th.StringType,
-                    default="utf-8",
-                    description="FTP server encoding",
-                ),
-            ),
-            description="FTP connection settings",
-        ),
-        th.Property(
-            "github",
-            th.ObjectType(
-                th.Property(
-                    "org",
-                    th.StringType,
-                    required=True,
-                    description=(
-                        "GitHub organization or user where the repository is located"
-                    ),
-                ),
-                th.Property(
-                    "repo",
-                    th.StringType,
-                    required=True,
-                    description="GitHub repository",
-                ),
-                th.Property(
-                    "username",
-                    th.StringType,
-                    required=False,
-                    description="GitHub username",
-                ),
-                th.Property(
-                    "token",
-                    th.StringType,
-                    required=False,
-                    secret=True,
-                    description="GitHub token",
-                ),
-            ),
-            description="GitHub connection settings",
-        ),
-        th.Property(
-            "dropbox",
-            th.ObjectType(
-                th.Property(
-                    "token",
-                    th.StringType,
-                    secret=True,
-                    required=True,
-                    description="Dropbox token",
-                ),
-            ),
-            description="Dropbox connection settings",
-        ),
+        filesystem_config.FTP,
+        filesystem_config.GITHUB,
+        filesystem_config.DROPBOX,
         th.Property(
             "csv_files_definition",
             th.StringType,
@@ -189,7 +111,7 @@ def discover_streams(self) -> list[Stream]:
             raise ConfigValidationError(msg, errors=errors)
 
         return [
-            CSVStream(
+            client.CSVStream(
                 tap=self,
                 name=file_config.get("entity"),
                 file_config=file_config,